Problem getting History Stats "on" time working

Hi,

I previously followed the History Stats man page instructions and was able to get the “on” time (for each day) of my receiver working well. Over the past 6 or so months though, the automation stopped working and I’m unable to figure out the problem.

Here’s what I have in my configuration:

  - platform: history_stats
    name: Projector On Time
    entity_id: media_player.tsr_7850_074e93
    state: 'on'
    type: count
    start: '{{ now().replace(hour=0, minute=0, second=0) }}'
#    start: '{{ 0 }}'
    end: '{{ now() }}'

I’ve tried different versions of start as above, and changed the type value from ‘time’ to ‘count’ as I saw in this post: https://community.home-assistant.io/t/count-on-time-of-a-binary-sensor/375233

Still doesn’t work.

Here’s my card on my Dashboard that used to work:

type: vertical-stack
cards:
  - type: entity
    name: TV / Projector
    state_color: true
    entity: media_player.tsr_7850_074e93
  - type: gauge
    entity: sensor.projector_on_time
    min: 0
    max: 3
    severity:
      green: 0
      yellow: 1
      red: 2

But the card never budges from 0 time, and reviewing the history likewise never budges past 0. See the screenshot of the receiver being on but still no history stats accruing:

image

Open to ideas, and thanks in advance for any help!

The state appears to be playing not on. Also you mentioned you wanted the time, not a count. So:

  - platform: history_stats
    name: Projector On Time
    entity_id: media_player.tsr_7850_074e93
    state: 'playing'
    type: time # not count
    start: '{{ today_at() }}' # same as today at 0:00:00
    end: '{{ now() }}'

But check in Developer Tools → States to be sure.

Wow, that was it! I guess the receiver entity probably changed and I didn’t notice. Thanks so much!