safepay / sensor.fronius

A Fronius Sensor for Home Assistant
MIT License
82 stars 33 forks source link

WARNING: 2021.9 breaks Energy dashboard derived from this component #62

Closed colwilliamsnz closed 3 years ago

colwilliamsnz commented 3 years ago

The developer docs for 2021.9 suggested that a planned change to energy sensors would be graceful allowing until 2021.11 for developers to make appropriate changes. This is not the case so suggest holding off on 2021.9 until a new release can be tested.

colwilliamsnz commented 3 years ago

Test branch with HA 2021.9 support here: https://github.com/colwilliamsnz/sensor.fronius

@nilrog appreciate your thoughts on this one (and also the breaking changes noted in the readme). Concerned that HA 2021.9 broke the component (despite suggestions there would be some months of compatibility) and so how best to convey this as visibly as possible.

nilrog commented 3 years ago

This is a bug in HA that they are not following their own documentation. It will be impossible for third-party integrations to solve this since not everyone will update to 2021.9.0 immediately. And if we were to release a new version through HACS for 2021.9.0 then people, that may still be on 2021.8.x, will update and we will be broken for them.

nilrog commented 3 years ago

To fix this mess we can do something like this, or just update it and let users on 2021.8 skip the update or fix the mess themselves :P

  1. Update this integration as you have prepared so that it supports HA 2021.9.x
  2. Document in the README how you can use the customize feature in HA to modify attributes for the required sensors so that it can still be used in 2021.8.x for users that does not upgrade immediately, but decides to use the latest version of this integration.

For some reason I could not get the UI config for customizing entities to work, at least not in 2021.9.0. The only available option for state_class was measurement...but doing it the old fashioned yaml-way worked.

Here is what needs to be added to make an updated version compatible with 2021.8.x

configuration.yaml

homeassistant:
  customize: !include customize.yaml

customize.yaml

sensor.fronius_total_energy:
  state_class: measurement
  last_reset: "homeassistant.util.dt.utc_from_timestamp(0)"
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)"

Where "fronius" in the sensor name needs to match the name of the integration. And a note that this needs to be deleted when the user upgrades to 2021.9.x

colwilliamsnz commented 3 years ago

Close. Pull request merged https://github.com/safepay/sensor.fronius/commit/82000435a5cb0d47eb77f9ca189102cbca1319d2