What I want to have is a fairly simple “goodnight” script that I’ll call with Lovelace button when I’m ready to go to bed. I can’t really use a Scene because I want to have conditions on the actions. I was looking at just creating an automation that wouldn’t have a trigger but it looks like that’s not possible. Any suggestions on how I can achieve this? I was thinking of just having a dummy binary sensor with an initial value of “False”. Is that the best way to go?
What’s wrong with it being a script?
I’ve actually never created a script before. Can you put conditions in there like you can an automation?
The action part of an automation and a script both take the exact same things, called script syntax.
You could say that an automation is a script with a trigger, or you could say a script is an automation without one.
A very quick check of the documentation for either component would have explained all of this.
Cool. I’m not sure why I never saw that as I’ve looked at the docs many o times. Will take a look. Thanks!
Ha, I was just coming back to apologise for implying you haven’t looked in the docs properly - seems they’ve recently ‘refurbished’ the docs and it’s nowhere near as straightforward to see how it all comes together as it used to be! Easy to get confused on what goes where now, which explains why so many new starters are struggling.
So yeah, use a script, and sorry for suggesting that you should have found this out yourself, it’s not your fault the documentation isn’t as helpful as it was.
here is my mine - just paste that on your yaml script editor, and change your entities.
alias: 3drt Good Night
sequence:
- type: turn_off
device_id: d8c3039c057e752ff505f58cf13f670d
entity_id: switch.3drt_luzes_armario
domain: switch
- service: light.turn_on
entity_id: light.3drt_luz_rgbw_lado_direito
data:
brightness: 220
rgb_color:
- 255
- 241
- 224
transition: 3
- service: light.turn_on
entity_id: light.3drt_luz_rgbw_lado_direito
data:
brightness: 220
rgb_color:
- 255
- 241
- 224
transition: 3
- type: turn_off
device_id: 3fbea69e0c5e89ed49709db76471407c
entity_id: switch.3drt_luzes_sala_principal
domain: switch
- type: turn_off
device_id: 3fbea69e0c5e89ed49709db76471407c
entity_id: switch.3drt_luzes_sala_secundario
domain: switch
- type: turn_off
device_id: 2776ba549d374f8cf471750d262e2b16
entity_id: switch.3drt_luzes_wc_luzes
domain: switch
- type: turn_off
device_id: 2776ba549d374f8cf471750d262e2b16
entity_id: switch.3drt_luzes_wc_fan
domain: switch
- type: turn_off
device_id: 6a38b06b41e5be9adf400359aaa1fc54
entity_id: switch.3drt_luzes_cozinha_grande
domain: switch
- type: turn_off
device_id: 6a38b06b41e5be9adf400359aaa1fc54
entity_id: switch.3drt_luzes_cozinha_pequena
domain: switch
- type: turn_on
device_id: b0de01058e97a27921357d092bfa78fd
entity_id: switch.3drt_luzes_corredor_principal
domain: switch
mode: single
icon: 'hass:bed'
No offence, but that’s a horrendous amount of code to do this…
alias: 3drt Good Night
sequence:
- service: light.turn_on
data:
entity_id: light.3drt_luz_rgbw_lado_direito
brightness: 220
rgb_color:
- 255
- 241
- 224
transition: 3
- service: switch.turn_off
entity_id:
- switch.3drt_luzes_sala_principal
- switch.3drt_luzes_sala_secundario
- switch.3drt_luzes_wc_luzes
- switch.3drt_luzes_wc_fan
- switch.3drt_luzes_cozinha_grande
- switch.3drt_luzes_cozinha_pequena
- switch.3drt_luzes_armario
- service: switch.turn_on
entity_id: switch.3drt_luzes_corredor_principal
icon: 'hass:bed'
Hello ,
Ah let me try that will this make the script faster ?
I just used the ui instead of yaml
I’m still very fresh in this
It won’t make it faster, but it’s much easier to read and edit now
Also, you can further simplify and modularise the script by incorporating scenes and/or groups.