Integration of a Fronius Symo Gen 24 plus Inverter via Modbus TCP

Glad to find this topic! I was able to configure Modbus in confuguration.yaml and get data from my GEN24 and Smartmeter Modbus. I allready can see the data in developer section and use sensors in my own cards. But can please anybody tell me, how to use the data as entity option for energy dashboard? I’m new with Home Assistant but it seems available options for this page has to be configured somewhere else?

Second Question: Is there some dokumentation of modbus sensor adresses for GEN24? I’m searching for the total PV production value.

Do i have to do this in configuration like this?

 # Adding Sensor for "reading_energy_main_meter"      
   template:
 - sensor:
     - name: "Modbus Energy Main Meter"
       unit_of_measurement: "W"
       state: {{ states('sensor.reading_energy_main_meter') }}

Because in developer area of HA i’m allready getting correct values.
But I am not able to to set this in Energy Dashboard Grid Consumption. Because this entity is missing there inside option dropdown. Ho to add this there? Any suggestions?

i think you need the RiemanSum Integral
so you change Power in Energy (for Energy Dashboard)

in my case see here: (configuration.yaml)

######## Energy Dashboard Anfang (RiemanSum Integral)


  - platform: integration
    source: sensor.derived_energy_pv_output_total
    name: energy_sonne
    unit_prefix: k
    round: 2

  - platform: integration 
    source: sensor.derived_energy_from_grid
    name: energy_verbrauch_Haus
    unit_prefix: k
    round: 2

  - platform: integration 
    source: sensor.derived_energy_to_grid
    name: energy_return_grid
    unit_prefix: k
    round: 0

  - platform: integration 
    source: sensor.derived_energy_tobattery
    name: energy_battery_Ladung
    unit_prefix: k
    round: 2

  - platform: integration 
    source: sensor.derived_energy_frombattery
    name: energy_battery_Entladung
    unit_prefix: k
    round: 2
    
  - platform: integration 
    source: sensor.energy_real_ac_consumed_fronius_ohmpilot_0_http_10_0_0_245
    name: energy_Ohmpilot_total
    unit_prefix: k
    round: 2
  
  - platform: integration 
    source: sensor.pv_leistung_total
    name: energy_gesamt_sonne
    unit_prefix: k
    round: 2
  
    
######## Energy Dashboard Ende (RiemanSum Integral)

and this one in customize.yaml:

sensor.fronius_total_energy:
  state_class: measurement
  last_reset: '1970-01-01T00:00:00+00:00'
  device_class: energy
sensor.fronius_smartmeter_energy_ac_consumed:
  state_class: measurement
  last_reset: "homeassistant.util.dt.utc_from_timestamp(0)"
sensor.fronius_smartmeter_energy_ac_sold:
  state_class: measurement
  last_reset: "homeassistant.util.dt.utc_from_timestamp(0)"
sensor.derived_energy_pv_output_total:
  state_class: total_increasing 
  last_reset: '1970-01-01T00:00:00+00:00'
  device_class: energy
sensor.derived_energy_from_grid:
  state_class: total_increasing 
  last_reset: '1970-01-01T00:00:00+00:00'
  device_class: energy
sensor.derived_energy_to_grid:
  state_class: total_increasing 
  last_reset: '1970-01-01T00:00:00+00:00'
  device_class: energy
sensor.derived_energy_tobattery:
  state_class: total_increasing 
  last_reset: '1970-01-01T00:00:00+00:00'
  device_class: energy
sensor.derived_energy_frombattery:
  state_class: total_increasing 
  last_reset: '1970-01-01T00:00:00+00:00'
  device_class: energy
sensor.energy_gesamt_sonne:
  state_class: total_increasing 
  last_reset: '1970-01-01T00:00:00+00:00'
  device_class: energy

good luck!

for your total PV production value:

in my case (Fronius GEN24)…configuration.yaml:

- platform: rest 
    resource: http://10.0.0.245/solar_api/v1/GetPowerFlowRealtimeData.fcgi
    method: GET
    name: "Energie_total_api"
    value_template: "{{ ( value_json['Body']['Data']['Inverters']['1']['E_Total'] |float/ 1000000 )| round(2) }}"
    unit_of_measurement: 'MWh'
    scan_interval: 90
    force_update: true 

change the IP Adress for your Case

Hey guys,

My goal is to set the minimum soc on gen24 to ‚100‘ to ensure that the byd battery is not used during electric vehicle charging. After it is charged I want to set the minimum soc back to ‚5‘. This won’t work via json api but I guess it should work with modbus tcp. But to be honest: never did something with modbus and I am absolutely unsure if it should generally work and if so how.

Any help (or other idea) is heavily appreciated.

Best
Dirk

My solution is described here: Fronius Symo Gen 24 plus Batteries - #15 by dm82m

1 Like

Hello All,
just a quick heads-up: I installed this morning Core 2023.8.3 and it broke the Fronius Modbus integration for me. As I did not have time to analyze the issue I restored to 2023.8.2. A look into the change log of 2023.8.3 showed some chagnes to the modbus integration, that may effect this configuration here.

Just as a heads-up to at least create a backup when moving to 2023.8.3 in case you run into the some issue.

Best
Stephan

Should be fixed with 2023.8.4: `structure` illegal with `slave_count` / `slave` @ data['modbus'] · Issue #98643 · home-assistant/core · GitHub

2 Likes

Hi all,
I have been using Home Assistant for +7 years now, and got a Gen24 inverter half a year ago.
Everything is perfectly integrated, I can change everything from either NodeRED Modbus-Flex-Write nodes or Home Assistant modbus service calls and perfectly read out everything. One thing that continues to nag me, is whenever I set the “StorCtl_Mod” setting (40347, the one that enables or disable the use of the In/OutWRte settings - and address is tripple checked). Whenever I change the value to “3” to active both limits, it keeps the setting for a few seconds, and afterwards resets it to 0, so no limits is enabled.

It doesn’t matter if I have Battery Management enabled in Fronius administrative interface or have disabled / removed all the settings for time-dependent battery control. It is the only setting that gets overwritten, and kinda annoys me as I wan’t to control charge/discharge to perfection during the day, if theres cheap energy and no sun - but still wan’t to keep zero export with grid.

Anyone knowing what is going on and can help me out on this? :slight_smile:

I’ve found lots of “samples” that does work for other people, so seems to be a setting in the inverter that I’ve missed. First time I’ve ever given up

Best regards
Steffan

Sounds like “InOutWRte_RvrtTms” is not set to 0.

1 Like

Hi Stephan,

You were 100% correct on you assumption. Got total control on the battery charge/discharge now - thank you so much! Really appreciate your help. Never saw or found the connection and dependability anywhere else.

Best regards
Steffan

1 Like

Hi,
Thanks a lot, but how can i use the Derived Template Sensors?

Copying into the configuration.yaml does not work.

Thanks

Hi Stephan, Could you show your work. I am new in Node-Red. And want to control my Gen24. and BYD

Answering my own questions. My mistakes where:

  1. All Modbus SunSpec registers over address 40000 is apparently holding registers not input ones, even if they are read-only.
  2. As Oscar Knapp has pointed out on several occasions, you need to decrease the Modbus register address by “1” for correct results.

Adhering to the above two rules and “everything” now works as expected.

/Jörgen

Hi Per,

Just got confused - you replied to my post and wrote the name of the helper to my post :slight_smile:
Are you interested in my work? Your name indicates you could be a dane? (as I am).
I don’t think the entire work, combined in NodeRED and Home Assistant fit in a short post in here. Maybe we could chat and show work on mail etc? Can try and show some pictures here:




image

It’s tons of pictures with lots of code and thoughts put into it :slight_smile:

Best regards
Steffan

2 Likes

Just installed 2023.10. Breaks @soly3141 's Modbus Fronius integration. Extract of the Error messsages:

*Invalid config for [modbus]: reading_battery_soc_scaled: `count: 1` cannot be combined with `data_type: uint16` @ data['modbus'][0]['sensors'][6]. Got {'name': 'reading_battery_soc_scaled', 'slave': 1, 'count': 1, 'data_type': 'uint16', 'address': 40361, 'scan_interval': 1}*
*reading_battery_storage_control: `count: 1` cannot be combined with `data_type: uint16` @ data['modbus'][0]['sensors'][7]. Got {'name': 'reading_battery_storage_control', 'slave': 1, 'count': 1, 'data_type': 'uint16', 'address': 40358, 'scan_interval': 1}* ...

Rather annoyed by Modbus in Home Assistant now. Considering moving everything to node-red, as all my battery management is broken … now, that I am on my fourth day with Tibber … :frowning:

@steffanlm, would you probably share your flows? Data gathering looks like a heck of work you put into this.

OK, this was an announced breaking change. Removing the count-line für float32, uint16, etc. will do the job and the integrations works again.

Did not have the patience to look into this yesterday …

3 Likes

Hey Steffan,
that looks like a ton of great work. I’m still struggling to get battery control right with Node and HA. Really interested in your flows. Could you share them?

Surely I can share my code/nodes :slight_smile: Hopefully you can get something out of it.

All the data gathering is in this flow.

Data gathering flow

Whenever I have calculated values to send as InWRte, OutWRte, StorCtl_Mod or ChaGriSet then I send the values throug this function:

InWRte, OutWRte, StorCtl_Mod or ChaGriSet

Before sending into the “Modbus execute” group:

Modbus execute group

Likewise I use the function node to send WMaxLim_Ena and WMaxLimPct in the same Modbus command, - also to the Modbus execute group.

WMaxLim_Ena and WMaxLimPct

Lots of the other nodes has been refactored and are primarily used as very specific calculations for our house, and most can only be used coherent with my other flows and specific data from Home Assistant.

Hope the above gives you some ideas - and if you find anything not working out, please write so I can change it :slight_smile:

2 Likes

Wow! Great thread, I’m happy I found it - and thanks to everyone posting!

I’m in a situation were I want to charge the battery on low prices, and use it during peak hours… Same as many of you here. I’ve just setup the Sunspec integration, but question is - does it provide the same functions as a manual YAML file? I haven’t yet found the settings to control the battery…

Any advice would be greatful! I don’t want to dig deep in the wrong direction. :slight_smile:

Hi and welcome to this thread :slight_smile:
The Sunspec integrations, as far as I’m concerned, does only support reading registers and not writing.
Which means you’ll have to either use NodeRED with the Modbus TCP palettes or use Modbus TCP inside Home Assistant to write to the registers.

Keep in mind, that theres some restraints in some of the writeable registers, especialy the battery power commands and storage mode (InWRte, OutWRte and StorCtl_Mod), from the inverter register map, it states:

Blockquote
Please be aware that setting an invalid power window will result in a modbus exception 3 (ILLEGAL DATA VALUE).
Invalid power windows are all windows where condition:
((StorCtl_Mod == 3) AND ((-1) * InWRtg > OutWRtg))
evaluates to true.
This can happen for example if two negative values are written into InWRtg and OutWRtg and both limits are activated by StorCtl_Mod = 3.
Blockquote

Hope this helps you on your way :slight_smile:

1 Like

Ok, so basically the Sunspec integration is useless as I could use the SolarAPI (and the official Fronius app) for the same thing (reading)?