bgbraga / homeassistant-apsystems

An APsystems Sensor for Home Assistant
Apache License 2.0
22 stars 13 forks source link

Energy dashboard #4

Open sgouw-hacs opened 3 years ago

sgouw-hacs commented 3 years ago

I want to use this for the new Energy dashboard. Is it possible to add this? https://developers.home-assistant.io/docs/core/entity/sensor#long-term-statistics

synack666 commented 3 years ago

You could help yourself, add state class, device class and last reset to the sensor via customize.yaml. Did the update of counts work for you? See issue 3.

sgouw-hacs commented 3 years ago

Thanks for this. I am pretty new to HA so I didn't that I could add it myself. The update of counts doesn't seem to work, I only get new values when I restart.

overas commented 3 years ago

@synack666 I added the state class, device class and last reset to the "sensor.apsystems_energy_day" using customize_glob. https://www.home-assistant.io/docs/configuration/customizing-devices/. It has been nice if this could be done from the plugin.

In the configuration.yaml I put in this:


homeassistant:  
  customize_glob:
    sensor.apsystems_energy_day:
      last_reset: '1970-01-01T00:00:00+00:00'
      device_class: energy
      state_class: measurement
synack666 commented 3 years ago

should work if the counter updatet, hope this will be fixed soon.

andrebbruno commented 3 years ago

Hello @bgbraga - any plans on adding this within your integration?

thanks!

andrebbruno commented 3 years ago

should work if the counter updatet, hope this will be fixed soon.

I was able to add this to the energy tab with the code you provided , hope this works now :)

And hope mr Braga can have that updated in the integration itself.

thank you guys!

andrebbruno commented 3 years ago

should work if the counter updatet, hope this will be fixed soon.

I was able to add this to the energy tab with the code you provided , hope this works now :)

And hope mr Braga can have that updated in the integration itself.

thank you guys!

Edit: Issue fixed by removing "last reset and changing state class to total_increasing

thanks!


Guys,

Any idea why the counter went negative in the beggining of the day? 17,68 is what was produced yesterday.

This is what happened when I added the code @synack666 suggested.

thanks!

image

skelgaard commented 2 years ago

i have the same problem... did you find any solution for the negative start value ?

andrebbruno commented 2 years ago

Issue fixed by removing "last reset and changing state class to total_increasing

Issue fixed by removing "last reset and changing state class to total_increasing

skelgaard commented 2 years ago

Issue fixed by removing "last reset and changing state class to total_increasing

Issue fixed by removing "last reset and changing state class to total_increasing

how do you do this ?

andrebbruno commented 2 years ago

Issue fixed by removing "last reset and changing state class to total_increasing

Issue fixed by removing "last reset and changing state class to total_increasing

how do you do this ?

This is what I have in my config.yaml

image

skelgaard commented 2 years ago

thanx, i will test that right away :)

skelgaard commented 2 years ago

thanx @andrebbruno that fixed it for me.... now i only need to figure out if there is some way to make it update every hour, as it seems to only update every 3 hours which makes bad graphs in the energy overview

andrebbruno commented 2 years ago

thanx @andrebbruno that fixed it for me.... now i only need to figure out if there is some way to make it update every hour, as it seems to only update every 3 hours which makes bad graphs in the energy overview

cool! 3 Hours update is new to me ... mine updates every hour in the energy tab.

skelgaard commented 2 years ago

billede

skelgaard commented 2 years ago

well i found out why it doesn't update that often.... still looking into why

Logger: homeassistant.helpers.entity
Source: custom_components/apsystems/sensor.py:156
Integration: apsystems (documentation)
First occurred: 09:07:33 (34 occurrences)
Last logged: 11:52:28
Update for sensor.apsystems_energy_latest fails

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 487, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 691, in async_device_update
    raise exc
  File "/config/custom_components/apsystems/sensor.py", line 156, in async_update
    value = value[-1]
IndexError: list index out of range
andrebbruno commented 2 years ago

well i found out why it doesn't update that often.... still looking into why

Logger: homeassistant.helpers.entity
Source: custom_components/apsystems/sensor.py:156
Integration: apsystems (documentation)
First occurred: 09:07:33 (34 occurrences)
Last logged: 11:52:28
Update for sensor.apsystems_energy_latest fails

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 487, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 691, in async_device_update
    raise exc
  File "/config/custom_components/apsystems/sensor.py", line 156, in async_update
    value = value[-1]
IndexError: list index out of range

yeah unfortunately we´re a bit out of luck, the developer seems DoA on his own integration

skelgaard commented 2 years ago

i'm working on fixing it, and if he doesn't come back, i will do a fork and fix it in that.

synack666 commented 2 years ago

This sounds great and I thank you already!!!

skelgaard commented 2 years ago

looks like i got it fixed, i will post tomorrow if works there too..... image

skelgaard commented 2 years ago

i have made a fix and put it on my own page https://github.com/skelgaard/homeassistant-apsystems please post there, if any other problems

synack666 commented 2 years ago

Cant see how to post there, button "Issues" dont exist. I installed today and from sunrise to now it works perfect.

andrebbruno commented 2 years ago

i have made a fix and put it on my own page https://github.com/skelgaard/homeassistant-apsystems please post there, if any other problems

should I remove the current integration in HACS and add yours?

synack666 commented 2 years ago

thats the way i do it, leave the config untouched, works

synack666 commented 2 years ago

@skelgaard How could we report issues, there is no issues button in your fork. (only for interest, no problems found)

skelgaard commented 2 years ago

missing a checkmark... done now for both issues and discussions :)

synack666 commented 2 years ago

pefrect