08-01-2024 12:00 PM
Hey everyone,
I'm having trouble with conditions in the Script editor. I used to have 3 automations that worked perfectly based on time of day and device status, but they suddenly stopped without any error message.
Here is an example for the triggers
- starters:
- type: time.schedule
# Required. Time to schedule automation. Accepts either clock time (10:00:00 AM, with seconds optional, or in a 24 hour format), or 'sunrise' or 'sunset', with an optional offset ('sunrise+10m', for instance)
at: 21:30 # HH:MM (24 hours format). Adjust time as needed
# Optional. Days of the week to run automation on.
weekdays:
- MON
- TUE
- WED
- THU
- FRI
- SAT
- SUN
condition:
type: and
# "AND" together two or more conditionals
conditions:
- type: device.state.OnOff # The basic on and off functionality for any device that has binary on and off, including plugs and switches as well as many future devices.
state: on
# Whether a device with an on/off switch is on or off. <code>true</code> if the device is on, <code>false</code> if the device is off. [available operators: is, isNot]
is: true
device: curved lamp - Living Room
Has anyone else encountered this issue? Any suggestions on how to fix it?
Thanks in advance!
08-04-2024 05:00 AM
Just from the YAML provided in your post there appears to be only one condition for your AND where there should at least two. Was this just missed in the copy and paste?
08-04-2024 06:07 AM
This is how it was and worked.
So if I want to have time and divce state, what should be the conditions?
08-05-2024 09:26 PM
Except you have one condition listed along with an AND statement.
That might be the confusion as the AND statement covers the CONDITIONS and not a CONDITION and STARTER
08-06-2024 12:54 AM
I tried this:
starters:
- type: time.schedule
at: 21:31
weekdays:
- MON
- TUE
- WED
- THU
- FRI
- SAT
- SUN
condition:
type: and
conditions:
- type: time.between
before: sunrise+60min
after: 21:30
weekdays:
- MON
- TUE
- WED
- THU
- FRI
- SAT
- SUN
- type: device.state.OnOff
state: on
is: true
device: curved lamp - Living Room
But this is still not working..
08-06-2024 08:48 AM
Try adding an ACTION at the end
actions:
type: device.command.OnOff
on: true
devices: curved lamp - Living Room
08-11-2024 08:07 AM
There is actions after the triggers, but the triggers are not working.
I want that my actions will start once it’s a time of the day and a specific light is on. And for some reason I can’t manage to get that.
08-13-2024 04:16 AM
I tried this but it's not working as well:(
starters:
- type: device.state.OnOff
device: curved lamp - Living Room
state: on
is: true
condition:
type: and
conditions:
- type: device.state.OnOff
state: on
is: true
device: Ceiling light - Living Room
- type: time.between
after: 21:30
actions:
- type: device.command.OnOff
on: true
devices: Table lamp - Living Room
03-31-2025 06:39 AM
Was this resolved? It suddenly stopped working today for me.
04-01-2025 12:31 AM
No:(
I can't find a way to fix it.
I tried many variations, even asking ChatGPT, but nothing worked
04-01-2025 08:06 PM
I managed to resolve my issue. It was due to my tuya virtual switch (i use it to set away mode to stop the automations) not communicating properly with google home (or the other way around).
I recreated the virtual switch using google home playground and ithe conditions are working again.