Automation Trigger Help - Time restriction on `template` trigger

I want to write an automation that is triggered when I leave the TV on for more than 10 minutes whilst nothing is playing on chromecast (i.e. i forgot to turn the TV off).
Im having some issues getting the trigger right. The value_template evaluates correctly, however, how do I apply the time restriction? the template trigger platform does not support the commented for config.

- alias:             TV On Notification
  trigger:
    platform:        template
    value_template:  "{{ is_state('media_player.tv', 'playing') == false and is_state('binary_sensor.tv_on','true','on')}}"
    # for:
    #   minutes: 10
  action:
    - service:       notify.pushbullet
      data:
        message:     "You left the TV on."

Any help and ideas would be appreciated. Thanks very much :slight_smile:

2 Likes

did you ever accomplish this?

I suspect not in the way he wanted to do it in the op.

To achieve this, create a template binary sensor that is ‘on’ when the template resolves true, and use the state of the binary sensor as the trigger for the automation with the FOR option.

Hope this helps :+1:

I left the automation commented out and forgot about it. The TV unit socket turns off every night at 11pm which means the need for this automation went away.

It’s an interesting problem to implement though. Would love to hear about any working solutions. @anon43302295’s suggestion should work.