asantaga / lightwaverf_HA_EnergySensor

Home Assistant Sensor for the LightwaveRF energy monitor
MIT License
5 stars 3 forks source link

Update for new energy dashboard & timeouts #9

Open anthonywalker75 opened 2 years ago

anthonywalker75 commented 2 years ago

Add necessary attributes to allow home assistant's new energy dashboard to use lightwaverf energy monitor sensor data

Also seem to experience excessive timeouts events. see below:

Logger: homeassistant.helpers.entity Source: helpers/entity.py:657 First occurred: 4:02:20 (559 occurrences) Last logged: 21:36:12

Update of sensor.electricity_current_usage_w is taking over 10 seconds Update of sensor.electricity_energy_today_usage_kwh is taking over 10 seconds

asantaga commented 2 years ago

The timeouts occur because I only wait for 10s before releasing back to HA. This is so we're not blocking unnecessarily. I could rewrite the component using async but "time poor".

I'll look into the attributes for the new energy dashboard, this is a good idea

proffalken commented 2 years ago

FWIW, https://developers.home-assistant.io/docs/core/entity/sensor/#long-term-statistics is the link to the new stats setup, if I find time I'll try and take a stab at this, but not sure when that might be at the moment...

proffalken commented 2 years ago

OK, I've had a couple of attempts at this without any luck this morning, the documentation seems to be... lacking... so I've asked for help on the forum

dsymons commented 2 years ago

As a temporary 'fix' I create an integration sensor using the following YAML:

You then need to customise the entity (Configuration -> Customisations) and set the device class to energy (you can't seem to fo that directly in the YAML)

That allowed me to get the usage into the Energy tab.

Ideally the parameters should be set on the today usage measurement. The key I think is the last reset and making sure all the clocks agree but I haven't had time to look at that.

To get rid of the timeout errors and drop out in communications I edited the code to give a longer timeout to receive the data, bad I know but all working atm!

David

asantaga commented 2 years ago

Hey , nice workaround

I'll get this done asap, I was on a 2 week vacation in Tenerife with the kids. I did look at the spec and it looks really easy to tweak so I'll get this out of the door quite quickly..

thanks for pursuing! and using the integration. This one is simple enough that I may make it into a full blown HA component (not a fan of the process though)

anthonywalker75 commented 2 years ago

I was using the workaround and found that since the upgrade to 2021.9.1 the energy dashboard was complaining that the kwh integration was not using the correct state class.

I made a change to the customize.yaml file and this appeared to fix it.

configuration.yaml: - platform: integration source: sensor.electricity_current_usage_w name: energy_spent unit_prefix: k round: 2

customize.yaml: sensor.energy_spent: device_class: energy state_class: total_increasing ** was set to measurement prior to upgrade ** last_reset: '1970-01-01T00:00:00+00:00'

Hope this helps

Anthony

asantaga commented 2 years ago

started working on this, but got issues with my server. will debug tomorrow damm docker @anthonywalker75 , so you've set the electricity_current_usage_w to total_increasing?? I thought this would be a measure..