Hi, I seem to get lost - may need some help.
I have D1 mini running tasmota that includes a simple counter that counts revolutions on my gasmeter and adds 0.005 to a variable, that is then reported via MQTT.
It works perfect and sends an MQTT message on every half revolution (equal to 5 liters of gas) with the current counter state.
The D1 sends the following MQTT discovery message:
homeassistant/sensor/D849C_CNT/config
{
"name": "Counter",
"state_topic": "stat/D849C/STATE",
"unique_id": "D849C_CNT",
"value_template": "{{value_json.State.counter}}",
"icon": "mdi:counter",
"unit_of_measurement": "m³",
"state_class": "total_increasing",
"device_class": "gas",
"device": {
"connections": [
[
"mac",
"D849C"
]
]
}
}
and is properly recognized by HA. Status messages are also coming over just fine:
stat/D849C/STATE
{
"State": {
"binary": 0,
"lLimit": 825,
"uLimit": 862,
"counter": 0.06,
"max": 882,
"min": 872
}
}
I can also see the recorder is recording the history. But everytime I restart the D1 mini to see, if the sensor continues to sum up the readings it receives, it resets to 0 and starts all over again.
My expectation would be, that HA would just ignore the reset to 0 and add the new value to the last peak value before the drop with state_class: total_increasing
.
My understanding of the docs and many similar questions in the forum is, that the combination of device_class:energy
, state_class:total_increasing
and unit_of_measurement:m³
should do the trick - but it doesn’t.
I already removed the device, checked for orphaned entities, purged the recorder, even ran Watchman from the HACS integration and then re-started the D1 to get it freshly registered - no improvement.
I’m out of ideas… help appreciated, tom
Screenshot of the history after my last trial-run: system cleaned up, D1 started at around 23:35, count increasing as expected, reset D1 at around 23:27, value falling to 0 and not continuing to rise like expected.