openshwprojects / OpenBK7231T_App

Open source firmware (Tasmota/Esphome replacement) for BK7231T, BK7231N, BL2028N, T34, XR809, W800/W801, W600/W601, BL602 and LN882H
https://openbekeniot.github.io/webapp/devicesList.html
1.43k stars 253 forks source link

HA MQTT discovery topic is not sending daily energy stats #805

Open fokcuk opened 1 year ago

fokcuk commented 1 year ago

As per the header - HA MQTT discovery topic is not sending daily energy stats I can see that its sending MQTT data for daily, hourly etc in the main device topics, but there is no configuration to show what is actually getting sent to the Homeassistant discovery. When I checked MQTT data, OpenBK is sending hourly stats, but not daily stats. So HA never discovers it Is there a way to check/change what is getting to sent via HA discovery?

openshwprojects commented 1 year ago

Thanks. Json format was wrong. It should be ok now. Can you retest?

stefan064 commented 8 months ago

I've noticed this also. When NTP is enabled then energycounter_yesterday, energycounter_todayand energycounter_clear_date are all published on MQTT as expected and also show up on the web UI. However none of these are discovered in home assistant, which is because command scheduleHADiscovery doesn't include them in the MQTT homeassistant/sensor topic.

I tried manually publishing one of the missing discovery messages to homeassistant/sensor and that fixed it: i.e. after some ~half-hour home assistant discovered the sensor and started showing its value.

Possible cause: In hass.c -> hass_init_power_sensor_device_info() it looks like OBK_CONSUMPTION_YESTERDAY, OBK_CONSUMPTION_TODAY, OBK_CONSUMPTION_CLEAR_DATE are never included and therefore left out. Perhaps these are meant to be conditionally included when NTP is enabled or similar?

stefan064 commented 7 months ago

Here's my attempt at improving this: https://github.com/stefan064/OpenBK7231T_App

image