Unfortunately it still doesn’t work. Last night I had zeros in my statistics again.
name: "HM-600 Energie Total"
state_topic: "Hoymiles/HM-600/ch0/YieldTotal"
state_class: total_increasing
value_template: "{{ value if value != 0 else states('sensor.hm_600_energie_total') }}"
unit_of_measurement: 'kWh'
device_class: energy
No that is not valid. The string ‘unknown’ has no state and you can’t round strings.
Try this:
name: "HM-600 Energie Total"
state_topic: "Hoymiles/HM-600/ch0/YieldTotal"
state_class: total_increasing
value_template: "{{ value if value not in [0, 'unknown', 'unavailable', 'none'] else states('sensor.hm_600_energie_total') }}"
unit_of_measurement: 'kWh'
device_class: energy
- platform: mqtt
name: "HM-600 Energie Total"
state_topic: "Hoymiles/HM-600/ch0/YieldTotal"
state_class: total_increasing
value_template: "{{ value if value not in [0, 'unknown', 'unavailable', 'none'] else states('sensor.hm_600_energie_total') }}"
unit_of_measurement: 'kWh'
device_class: energy