Hello and looking for some guidance on my first attempt at scripting a few actions on my system. It was working as anticipated for a few days but has stopped unexpectedly. What I am attempting to do is have a button on my dashboard that when selected it will perform the following actions:
shut off any light that is in the “on” state on my first floor
lower the TV volume to a level of “4”
Turn “off” TV
Turn on another light so I can “find” my way upstairs
turn off the same light from step 4 after 30secs has passed
I have detailed my process below for reference and let me also say I am relatively new so sure there is a more efficient way of accomplishing this.
I created a scene with all the entities that I wanted to have controlled with their desired states (off, volume 4, and TV off)
created a script to turn on the light from step 4 above
alias: Bedtime script
sequence:
- action: scene.turn_on
metadata: {}
target:
entity_id: scene.bedtime
- action: light.turn_on
metadata: {}
data: {}
target:
entity_id: light.kitchen_island_lights
description: >-
full script that will run bedtime scene plus turn on island lights for
30seconds
Created an automation to turn the light off after 30 seconds:
shut off any light that is in the “on” state on my first floor
lower the TV volume to a level of “4”
Turn “off” TV
Turn on another light so I can “find” my way upstairs
turn off the same light from step 4 after 30secs has passed
Since you seems not very comfortable with the yaml config, you should probably use the GUI editor to create your sequence (and maybe check out the result in YAML after you completed what you want with the GUI if you’re interested in it)
But I didn’t tested it my self.
What you should do is to call several actions :
light.turn_off / switch.turn_off targeting the entity you want to turn off
another action would be light.turn_on → turning on the stairs
then wait action for 30 seconds
then light.turn_off → turning off the stairs.
I don’t have enough informations on your devices to write down the whole script for you so the best I can do is giving some directions.
And I guess your goal here is to understand how to achieve this yourself instead of c/c something on the internet.
I hope this help, and I’d be glad to help you more on this if needed
Cheers.
I agree with @nok… from what you have posted there doesn’t seem to be a reason to split off the part in the automation.
However, if you decide to use it anyway, you should edit the trigger. Your post describes it as:
… but that is not exactly what your trigger is doing. As constructed, the trigger will fire when the state object is stable for 30 seconds. While this will most often be when the script’s state changes from “on” to “off” and stays that way, you may get other, seemingly random, triggers from other changes. I would make the trigger specific to the on-off transition event.
triggers:
- trigger: state
entity_id:
- script.bedtime_script
to: "off"
from: "on"
for:
hours: 0
minutes: 0
seconds: 30
thank you for the guidance @Didgeridrew and @nok! I will attempt to put into a single script and see how I do. You are correct still learning so appreciate the “bread crumbs” !! better to teach to fish…
Thank you again and success!!! Here is the final script and yes much easier to have just one file. Really appreciate all your help @Didgeridrew and @nok !