03-24-2025 05:09 PM
I've been trying to write a script for my light to turn on when I say "Command word" if the light is off, and to turn off when I say "command word" if the light is on. The script AI cannot create it, and I've been trying to use conditions to no avail. All I need is "if light on --> turn off --- else -->turn on" but in script editor language. Please help!
Answered! Go to the Recommended Answer.
03-27-2025 10:20 AM - edited 03-27-2025 10:22 AM
You can do this by using the same starter twice (make sure you use the hyphen in front of the starters as indicated in the following example:
metadata:
name: Light on/off with same command
description: Light on/off same command
automations:
- starters:
- type: assistant.event.OkGoogle
eventData: query
is: Toggle light
condition:
type: device.state.OnOff
device: Light - Living room
state: on
is: false
actions:
- type: device.command.OnOff
devices: Light - Living room
on: true
- starters:
- type: assistant.event.OkGoogle
eventData: query
is: Toggle light
condition:
type: device.state.OnOff
device: Light - Living room
state: on
is: true
actions:
- type: device.command.OnOff
devices: Light - Living room
on: false
03-25-2025 12:34 AM - edited 03-25-2025 12:58 AM
No script required. Just a simple Routine. Even though I say "Hey Google, Air conditioner" you can also use any word.
This is my YouTube video from my channel...
03-27-2025 10:20 AM - edited 03-27-2025 10:22 AM
You can do this by using the same starter twice (make sure you use the hyphen in front of the starters as indicated in the following example:
metadata:
name: Light on/off with same command
description: Light on/off same command
automations:
- starters:
- type: assistant.event.OkGoogle
eventData: query
is: Toggle light
condition:
type: device.state.OnOff
device: Light - Living room
state: on
is: false
actions:
- type: device.command.OnOff
devices: Light - Living room
on: true
- starters:
- type: assistant.event.OkGoogle
eventData: query
is: Toggle light
condition:
type: device.state.OnOff
device: Light - Living room
state: on
is: true
actions:
- type: device.command.OnOff
devices: Light - Living room
on: false