cancel
Showing results for 
Search instead for 
Did you mean: 

Script editor - run action only after device state is on for x seconds

Spaceman_B
Community Member

I am trying to set up an automation where lights turn on only after media has been paused for 5 seconds. Is that possible? 

Thank you!

2 REPLIES 2

Nes58
Community Member

Probably something like this : 

metadata:
name: Turn on lights when media is paused
description: Turn on lights when media is paused
automations:
- starters:
- type: device.state.MediaState
device: name-media-device
state: isPaused
is: true
for: 5sec
actions:
- type: device.command.OnOff
devices:
- some lights
on: true

Spaceman_B
Community Member

Hey thanks for the help! I had to tweak it a little to make it work:

metadata:
name: Media play
description: Media play for 5 secs

automations:
starters:
- type: device.state.MediaState
state: playbackState
is: PLAYING
device: Chromecast device
for: 5sec

actions:

- type: device.command.OnOff
on: false
devices: Lights