History stats sensor is not tracking - same configuration in other sensor works

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!

The state of any switch entity would be on not On, it is case sensitive.

You can check the exact states in developer-tools/state.

Thank you for your input!

I’ll never get the concept of case sensitivity in programming. Even worse that while indeed the state displayed in developer tools is “on”, in the frontend the state is shown as “On”. These kind of inconsistencies just really make the learning curve in HA unnecessarily steep!

All that said however: Even after changing the tracked state from “On” to “on” the sensor has remained at 0 for hours now…

Looking at the image above now has me wondering why the entity does not have any logbook events! Might this a problem for the history stats?