Conditions codes from script editor stoped working

Ran_Shemesh
Community Member

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!

10 REPLIES 10

webnibbler
Community Member

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?

This is how it was and worked.

So if I want to have time and divce state, what should be the conditions?

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

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..

Try adding an ACTION at the end

actions:
      type: device.command.OnOff
      on: true
      devices: curved lamp - Living Room

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.

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

Asterix1
Community Member

Was this resolved? It suddenly stopped working today for me.

No:(
I can't find a way to fix it.
I tried many variations, even asking ChatGPT, but nothing worked

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.