Fronius inverter integration

@nilrog Thanks for sharing. I have rewritten most of my sensors now and are staring to get somewhere.

I know you are usiing some sensor that are not in HACS but still I am curious how you use:

smartmeter: true (in the fronius integration)

And this sensor that were in some lovelace cards. (sensor.fronius_smartmeter)

I will write something about my setup when I am done on my blog. Would it be ok to use and share some of your cards and sensors?

Thanks! :slight_smile:
You are welcome to use my stuff on your site as you see fit. I once had an idea of cleaning up my package file and posting it somewhere for others to look at. But I do not have time to publish anything myself apart from the activity here. So go ahead…and I will see what I can borrow from you when it’s published on your site :stuck_out_tongue:

This just enables the creation of 10 new sensors that are read from the “meter” API in the inverter.

smartmeter: true

And when that is done I just use them in lovelace right now. It’s just so I can see them. I haven’t yet thought about if/how to use them in a better way.

The smartmeter stuff has been merged to master. But it is still not in a release. I think @safepay wants some positive feedback before making a release. So if you want to try it out you can do a manual clone from github, replace your version from HACS, and try it out. And if it works for you you can post back here or in the pull-request that it works fine.

When you configure the smartmeter you may need to specify also the smartmeter_device_id depending on your setup. I think it will always be 0 in a fresh setup with only one meter. But I have no proof as I have only looked at my own setup.

But try first with only the first line. If your new sensors show up with valid values you are all set. If not then you can use this URL and check with device id your smartmeter has.

http://ip_address/solar_api/v1/GetMeterRealtimeData.cgi?Scope=System

And then add this second line to your config with the number it has in your system.

smartmeter: true
smartmeter_device_id: <your smartmeter id>

@nilrog Cool. Works perfect.

1 Like

Nice! :slight_smile:

I realized after the patch was merged that two of the sensors are redundant and could be removed.
The “Energy AC Absolute Plus/Minus” returns the same as “Energy AC Consumed/Sold” and “Consumed/Sold” is more user friendly. So I think I will push an update to remove them before @safepay makes a new release.

Too bad that Fronius cannot document the true meaning of all the values that the API returns. Some are obvious, but some are hard to understand or doesn’t mank much sense.

1 Like

I’ve manually updated sensor.py from @safepay’s github and added the following lines under my fronius integration but the smartmeter sensor is not appearing. Any idea?
smartmeter: True
smartmeter_device_id: 0

Did you restart HASS after replacing the sensor.py and updating the configuration?

If you did restart HASS can you open this URL in your browser (replace “ip_address” with the IP of your Fronius Inverter) and post the response you got?
It could be that the smartmeter_device_id is not 0.

I got it to show up now. For some reason I had to add the sensors to
monitored_conditions:
- smartmeter_current_ac_phase_one
- smartmeter_current_ac_phase_two
- smartmeter_current_ac_phase_three
- smartmeter_voltage_ac_phase_one
- smartmeter_voltage_ac_phase_two
- smartmeter_voltage_ac_phase_three
- smartmeter_energy_ac_absolute_plus
- smartmeter_energy_ac_absolute_minus
- smartmeter_energy_ac_consumed
- smartmeter_energy_ac_sold

1 Like

image

Any idea why my bought and sold energy figures are in thousands?

Are you using these two sensors?

smartmeter_energy_ac_consumed
smartmeter_energy_ac_sold

They show the total amount of energy consumed/sold since the smartmeter was installed into your house. If you want it to display what is consumed/sold today then you need custom sensors. Take a look at the package file I posted a link to recently. There you can see how I have created sensors for that.

Thanks. I got it working now. But i think your package file for monthly and yearly usage is incorrect/inaccurate?

For some reason the figures are wrong again

image

i am using sensor.grid_consumed_energy_day and sensor.grid_sold_energy_day

Looks like you have your energy unit set to “Wh” and not “kWh” so the input to those two sensors are 1000 times too high. If you do not use the same units as I have in my package file for the fronius integration then you need to adjust your other sensors accordingly.

Are you referring to the sensors under utility_meter or the configuration for fronius?

This is what i have under my configuration. I’ve units: kWh.

- platform: fronius_inverter
  ip_address: !secret fronius_host
  smartmeter: True
  smartmeter_device_id: 0
  powerflow: True
  power_units: W
  units: kWh

I’ve added unit_of_measurement: kWh to all the sensors under utility_meter. Is that right? See below for eg.

utility_meter:
  ### daily data ###
  # calculate daily energy used
  house_energy_day:
    unit_of_measurement: kWh
    source: sensor.energy_used_hour
    cycle: daily

Afaik the utility meter doesn’t support “unit_of_measurment”, at least it’s not documented. It uses the source sensor unit. If you want the same result as I have then compare your file with mine and look for what is different. Something is not like I have it because my bought and sold sensors works as expected. But yours are 1000 times too big.

Are you using the latest version of the integration? If not then there is a problem that it doesn’t convert the units correctly.

I dumped all my codes and used yours but they are still showing big figures.

Yes, i am using the latest integration and Hassio. Not sure what i am doing wrong.

Where is the conversion for Energy bought and sold done? I couldn’t find it anywhere in your codes.

The energy_used_hour originates from fronius_house_load. The fronius_house_load sensor will be in W if it is setup as in my package. It is then fed into the current_consumed_positive template sensor that just converts it into a positive value since house load is negative. The current_consumed_positive is fed into the integration sensor energy_used_hour that converts it into energy in kWh.

  # convert house power consumption to energy
  - platform: integration
    source: sensor.current_consumed_positive
    name: energy_used_hour
    unit_prefix: k
    unit_time: h
    round: 2
    method: left

power_units: ‘W’ <- This determines the fronius_house_load sensor to be in W right?
I’ve used all the codes in your package but not sure why the figures are incorrect.

I checked the sensor state and they are already set to kWh.

Yes, based on what you have shown here it should be ok. Yet it looks like your consumed/sold from the smartmeter is 1000 times too high.

It could also be something with the utility meter. Have you looked at the history graph for the two sensors grid_sold_energy_day and grid_consumed_energy_day and checked if they are reset to zero every night?

When I upgraded HA from 0.103.* to 0.106.* the utility meter “broke” some of my utility sensor at every restart of HA. It applied the current state on top of the current state so I got totally wrong values. That said, it has been stable for me since I updated HA to the latest 0.106.* version.

Could you check what your smartmeter actually reports?
Open this URL, replace ip_address with your inverters IP. You should see those values there and you can compare them with what you see in HA.

http://ip_address/solar_api/v1/GetMeterRealtimeData.cgi?Scope=System

I realised the values are showing up correctly during the start of the day.
image

However, when it reaches a certain value (i’ve not establish what value yet), it started to reported values in thousands.

image

Below is the value i extract from my inverter.
{
“Body” : {
“Data” : {
“0” : {
“Current_AC_Phase_1” : 13.548,
“Current_AC_Sum” : 13.548,
“Details” : {
“Manufacturer” : “Fronius”,
“Model” : “Smart Meter 63A-1”,
“Serial” : “xxxxx”
},
“Enable” : 1,
“EnergyReactive_VArAC_Phase_1_Consumed” : 145800,
“EnergyReactive_VArAC_Phase_1_Produced” : 3648710,
“EnergyReactive_VArAC_Sum_Consumed” : 145800,
“EnergyReactive_VArAC_Sum_Produced” : 3648710,
“EnergyReal_WAC_Minus_Absolute” : 1229902,
“EnergyReal_WAC_Phase_1_Consumed” : 640743,
“EnergyReal_WAC_Phase_1_Produced” : 1229902,
“EnergyReal_WAC_Plus_Absolute” : 640743,
“EnergyReal_WAC_Sum_Consumed” : 640743,
“EnergyReal_WAC_Sum_Produced” : 1229902,
“Frequency_Phase_Average” : 50.100000000000001,
“Meter_Location_Current” : 0,
“PowerApparent_S_Phase_1” : 3340.9299999999998,
“PowerApparent_S_Sum” : 3340.9299999999998,
“PowerFactor_Phase_1” : -0.97999999999999998,
“PowerFactor_Sum” : -0.97999999999999998,
“PowerReactive_Q_Phase_1” : -308.88,
“PowerReactive_Q_Sum” : -308.88,
“PowerReal_P_Phase_1” : -3295.5500000000002,
“PowerReal_P_Sum” : -3295.5500000000002,
“TimeStamp” : 1585535950,
“Visible” : 1,
“Voltage_AC_Phase_1” : 246.59999999999999
}
}
},
“Head” : {
“RequestArguments” : {
“DeviceClass” : “Meter”,
“Scope” : “System”
},
“Status” : {
“Code” : 0,
“Reason” : “”,
“UserMessage” : “”
},
“Timestamp” : “2020-03-30T13:39:11+11:00”
}
}

Hmm, so something weird is happening with the utility sensors for consumed/sold then :frowning:
That sensor is supposed to add the difference between each reading to the sensor. And apart from the glitches I had during a couple of upgrades they have been working flawlessly for me.

It could be that there are some bad readings that trips the sensor off. Do you keep your inverter in logging mode 24/7 or does it shut off during night?

Could you also post your utility sensor configs?