History_stats entity not reporting data

I am trying to create a mini graph card, using the history stats integration, on my Lovelace dashboard which shows the number of hours that my heating is turned on each day. The binary sensor that I’m using is working fine (binary_sensor.thermostat_2_state) - i.e. switching on/off at various times, but my history_stats entity is not capturing any data - i.e. it always reports 0.0.
This is my sensor definition:

sensor:
  - platform: history_stats
    name: "Living Room Heating Hours Today"
    entity_id: binary_sensor.thermostat_2_state
    state: "On"
    type: time
    start: "{{ now().replace(hour=0, minute=0, second=0) }}"
    end: "{{ now() }}"

Any idea what I’m doing wrong?

“On” isn’t the same as “on”… a binary sensor’s state will never be “On”.