02-13-2024 04:43 PM
Hi, Basically I’m after a google home automation script that turns lights on (if they are off) and off (if they are on).
When I run the following script it turns the lights on, then off 😐, and on other occasions it seems to do 2 or 3 actions… eg on off on, off on, etc. I assume it’s doing the following starters and actions sequentially
ps the reason for this request is to minimise the growing number of automations I have, an if then else command would half the number of automations needed and simplify favourites and automations tabs on google home
regards
jim
metadata:
name: test lights
description: toggle lights, if off turn on, if on turn off
automations:
# if off turn on
- starters:
- type: device.state.OnOff
device: pendant lights - Kitchen
state: on
is: false
actions:
- type: device.command.OnOff
devices: pendant lights - Kitchen
on: true
# if on turn off
- starters:
- type: device.state.OnOff
device: pendant lights - Kitchen
state: on
is: true
actions:
- type: device.command.OnOff
devices: pendant lights - Kitchen
on: false
02-28-2024 05:45 PM
First glance you would want a condition for each that separates so they dont randomly trigger each other. Could also probably do it with FOR or supressFOR in your starter.
03-03-2024 02:26 PM
hi, thanks for the info (i'm just back from hols), i'll google FOR and see what it can do
03-05-2024 02:56 PM
I couldn’t find anything to help, I also looked at conditions
i guess “if then else” is not supported which seems rather odd as it’s a basic element of all programming languages I’ve used for the last 50 years…
06-02-2024 06:39 AM
#
06-02-2024 06:42 AM
#
06-02-2024 07:00 AM
This was solved, here