mchwalisz / home-assistant-senec

SENEC Battery integration for Home Assistant
Apache License 2.0
46 stars 23 forks source link

Update const.py for compatibility to HA core-2021.8.0 #8

Closed Dntouch closed 3 years ago

Dntouch commented 3 years ago

https://github.com/mchwalisz/home-assistant-senec/issues/7

Exceptionfault commented 3 years ago

.. or remove the import of this const completely as it is not used in the script.

But anyways.. 👍

Dntouch commented 3 years ago

You are absolutely right. Removing it would be better and would not cause problems on previous HA versions.

klaus1956 commented 3 years ago

This update is the onyl thing standing between me and HA 2021.8! So an update is highly appreciated

klaus1956 commented 3 years ago

Is there any way to change this myself as Mikolaj seems not to be active at the moment?

Dntouch commented 3 years ago

Hi Klaus, you can install the Visual Studio Code Add-in and edit the const.py yourself.

After installation open the visual studio code editor and navigate to CONFIG -> custom_components -> senec -> const.py

edit line 4 to contain:

from homeassistant.const import ENERGY_KILO_WATT_HOUR, PERCENTAGE, POWER_WATT

klaus1956 commented 3 years ago

Great - Thank You - this description was even working for me and 2021.8 is running now :)

klaus1956 commented 3 years ago

For integration in the new 2021.8-Energy appliction it seems that the entity types need to be updated ro "measuerment" .. but may be I am wrong

Exceptionfault commented 3 years ago

For integration in the new 2021.8-Energy appliction it seems that the entity types need to be updated ro "measuerment" .. but may be I am wrong

Hi @klaus1956 ,

to problem is, that the sensors created by this plugin like for example the sensor.senec_solar_generated_power are of type "power in Watt". But the new energy feature of HA requires them to be of type "energy in kWh"

I've created 3 new sensors, using the Riemann sum integral plugin in the configuration.yaml

sensor:
  - platform: integration
    source: sensor.senec_solar_generated_power
    name: solar_generated_energy
    unit_prefix: k
    unit_time: h
    unit: kWh
    round: 2
  - platform: integration
    source: sensor.senec_grid_imported_power
    name: solar_imported_energy
    unit_prefix: k
    unit_time: h
    unit: kWh
    round: 2
  - platform: integration
    source: sensor.senec_grid_exported_power
    name: solar_exported_energy
    unit_prefix: k
    unit_time: h
    unit: kWh
    round: 2

To work with the new energy feature of HA, an entity must have the attributes (as far as I've understood):

state_class: measurement
device_class: energy

So if you still can't find the new sensors fom the rieman plugin, those attributes can be set in the customize.yaml if necessary:

sensor.solar_exported_energy:
  device_class: energy
loeffelpan commented 3 years ago

Any way to fork this integration an modify it for usage with energy app from HA 2021.8? Workaround is fine, but a proper solution will be much better. But I do not have any skills in python to do this.

klaus1956 commented 3 years ago

As we are discussing: I use data from this application to control a Wallbox PV- charging process. Is there a possibility for controlled entity update frequency ( e.g. all 30 sec). I am nit sure which update frequency the IP interface provides.

flyingrabbi commented 3 years ago

Hey guys, i've just installed a v3 at home w/ battery. I also know next to nothing about github, linux and homeassistant haha.

Will be following this with interest, because as it stands, I'm like a little kid in the dark with a torch!

mchwalisz commented 3 years ago

Thanks for looking into that.