jbouwh / omnikdatalogger

Datalogger for Omnik solar power inverters with DSMR integration and output to Home Assistant, PVOUTPUT, InfluxDB and MQTT
https://jbsoft.nl/site/omnik-datalogger/
GNU General Public License v3.0
11 stars 3 forks source link

MQTT Warnings in home assistant core log #15

Closed jbouwh closed 3 years ago

jbouwh commented 3 years ago

Background

When the sun is down, omnik inverters stop providing data. Omnikdatalogger caches the last total_energy and today_enery. Other attributes are omitted. This causes warning in the log wen using the MQTT auto discovery in Home Assistant.

2021-10-07 06:35:08 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'operation_hours' when rendering '{{(value_json.operation_hours)}}'
2021-10-07 06:35:08 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'current_power_pv' when rendering '{{(value_json.current_power_pv)}}'
2021-10-07 06:40:08 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'current_power' when rendering '{{(value_json.current_power)}}'
2021-10-07 06:40:08 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'power_ac1' when rendering '{{(value_json.power_ac1)}}'
2021-10-07 06:40:08 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'power_pv1' when rendering '{{(value_json.power_pv1)}}'
2021-10-07 06:40:08 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'power_pv2' when rendering '{{(value_json.power_pv2)}}'

Cause

Omnikdatalogger publishes al inverter states over one shared state topic, but all entities listening to this state topic will be triggered. When certain attributes are omitted (the ones shown in the log), Home Assistant cannot update the state, which it should not, but it still causes a warning.

Possible solutions:

Possible solutions are:

Using a state per attribute will give much more payload, and will break usecases for MQTT-users not using Home Assistant. Adding this missing attributes will take away the warnings. A disadvantage is that updates need to be processed, even when there is no update. For users that do not want to retain MQTT messages this will be good, since the state will recover automatically for these attributes.

P.S. The warnings do not impact presenting the correct values over MQTT.

jbouwh commented 3 years ago

Fixed with release v1.7.5