Interpreting media player sensors first turn on each day

Hi,

I want to see when my children first turn the games consoles on each day and the data source I have is a media_player playing sensor. Does anyone have any suggestions on how I can determine via an automation or something else when the TV was first turned on each day?

At the moment I have a history graph on my UI and I have to hover over the bar to see when the status changes to on.

Thanks

I have a Twilight lighting automation running as follows:


  trigger:

    - platform: state
      entity_id: binary_sensor.daylight
      from: 'on'
      to: 'off'

  condition:
  - |-
    {%- set last = state_attr(this.entity_id, 'last_triggered') %}
    {{ last is not none and now().date() != last.date() }}

  action:

  - …

The automation will only be triggered once a day.

Additionally, a history_stats sensor could be interesting for you :wink:

1 Like

Great thanks, will see if it runs tonight. I’ve created a time of day helper instead of the daylight sensor to be active between 3am and 11am

I must add that a brand new created automation (obviously) has no last_triggered value so the first time the automation runs the condition will fail.

1 Like