I have configured a history stat senor to track the lifespan of a UV water sanitation bulb. I have an input_button configured that I can press when I have replaced the buld and the sensor should fall back to 0:
Start:
{% set start = states('input_button.uv_lamp_reset_reset') %}
{{ iif(start in ['unknown','unavailable'],now(),start|as_datetime) }}
End:
{{ now() }}
The sensor is set up to track the state “On” of a shelly switch:
This is the state of the input button:
The sensor just remains at 0 no matter how long the bulb switch is in “On” state.
Weird thing is that I have the exactly same configuration for another maintenance tracker (burntime of a wood heating system) and that one is working perfectly fine! ojnly difference is, only difference I can think of ist taht in the case of the UV Buld tracker HA somehow added the new sensor to the Shelly device it depends on, while the heating tracker was treated as an independent senor because it relies on a state generated by a template sensor. (Even if I try skipping the dialog box where HA asks me about adding the sensor to a device, it will still do it no matter what…)
Searched around the interwebs for answers but to no avail. Tried to ask ChatGPT about it, but that was useless as expected.
Why is this not working / what am I doning wrong?
Thanks in advance for your inputs!