UI not clear or documentation issue? History stats "state"

I have a binary sensor configured to have “Running” and “Not Running” states.


It’s a template sensor, here the other part of the configuration:

Now, when I tried to configure a History Stat tracking this binary sensor, to make it work I had to set as state “on”, instead of “running”.

At that point I was basically trying everything, but I think this is wrong!

  - platform: history_stats
    name: PompaUnoTempo
    entity_id: binary_sensor.pompauno
    state: "on" # <--- I was setting here "running"
    type: time
    duration:
      days: 3
    end: "{{ now() }}"

Running and not running are only translations on screen . Binary sensors are always on or off. So you should test for that. Always check the developer tools what the state is, that shows the real, untranslated value.

Binary sensor states are always “off” or “on”. This can be “translated” to other words by the frontend depending on the device_class.