Fronius Modbus TCP automation for charging battery

Hi All,

I have a Fronius Symo GEN24 solar inverter with a BYD HVM 13.8kWh battery box connected.

Modbus over TCP is setup and the new entities are now present in HA.

What I am trying to achieve is an automation which will work as follows:
At 7h00 check battery status. If less than 25% then charge at 2.5kW until it reaches 25% OR time is 8h00. After that stop and set the inverter back to its original state.

With help from ChatGPT it came up with the automation below, the automation triggers and from the ‘trace’ all seems to be setting the inverter but it doesn’t start to charge.

- alias: "Morning battery grid charge"
  description: >
    If battery SOC is below 25% at 07:00, charge from the grid at up to
    2.5 kW until 25% SOC or 08:00, then restore normal operation.
  triggers:
    - trigger: time
      at: "07:00:00"

  conditions:
    - condition: numeric_state
      entity_id: sensor.byd_battery_box_premium_hv_state_of_charge
      below: 25

  actions:
    # 2.5 kW = 25% of the assumed 10 kW maximum charging power.
    - action: number.set_value
      target:
        entity_id: number.gen24_battery_charge_power_limit
      data:
        value: 25

    # Enable the charging power limit.
    - action: switch.turn_on
      target:
        entity_id: switch.gen24_battery_charge_power_limiting

    # Enable charging from the grid.
    - action: switch.turn_on
      target:
        entity_id: switch.gen24_battery_grid_charging

    # Wait until 25% SOC OR 08:00.
    - wait_for_trigger:
        - trigger: numeric_state
          entity_id: sensor.byd_battery_box_premium_hv_state_of_charge
          above: 24.99

        - trigger: time
          at: "08:00:00"

    # Stop grid charging.
    - action: switch.turn_off
      target:
        entity_id: switch.gen24_battery_grid_charging

    # Disable the temporary charging power limit.
    - action: switch.turn_off
      target:
        entity_id: switch.gen24_battery_charge_power_limiting

    # Restore the charge power limit to 100%.
    - action: number.set_value
      target:
        entity_id: number.gen24_battery_charge_power_limit
      data:
        value: 100

  mode: single

The GEN24 Modbus TCP is setup to ‘Allow control’ and ‘Restrict control’ to the IP of the HA instance.

Could anyone help?

Thanks in advance,
John

Doesn’t the switch “switch.gen24_battery_grid_charging” simply tell the inverter he is allowed to charge from the grid? In that case you might have to give it some power value as well?

I dont have a Fronius, but on my inverter I have to set the exact battery power or the target grid power if I want to start charging from te grid.

If it keeps regulating the grid power to zero, it will not start charging, so on my inverter I tell him to start regulating to 1kW or 2kW grid power. This way it will still supply power during consumption peaks.

Yes exactly.

If I see it correctly, the core integration does not have the necessary settings included (yet). That is for sure possible with the HACS integration, I would recommend the the one by callifo.

My recommendation would be to start with manual controlling the entities such that you know it works (setting Mode to „Charge from Grid“ might be sufficient).Then make an automation out of the commands you used manually.

Thanks both for your replies.

I’ve been playing around, sticking with the official Fronius add-on, but still can’t get it to force the charging. I’ll continue and see where it goes.