cancel
Showing results for 
Search instead for 
Did you mean: 

Coding help with Script Editor

ag_
Community Member

Hi everyone,

I need some help to make an automation in the new script editor:

When everyone is away and time is sunset or later, turn light on. Turn light off at midnight.

I need both the home presence and/or the time to be a starter. So that if I am already away and then the sun sets OR the sun has already set and then I go away, in both cases the light will trigger. Both conditions need to be true and both can be a starter. This is what I cannot figure out how to do.

 

Any ideas? much appreciated

 

1 Recommended Answer

ashinzekene
Community Member

You can have something like this. Triggers on any condition and then verify that both conditions are true

  starters:
    - type: home.state.HomePresence
      state: homePresenceMode
      is: AWAY

    - type: time.schedule
      at: sunset+60min
 
  condition:
    type: and
    conditions:
      - type: home.state.HomePresence
        state: homePresenceMode
        is: AWAY
      - type: time.between
        before: sunrise
        after: sunset

 

View Recommended Answer in original post

1 REPLY 1

ashinzekene
Community Member

You can have something like this. Triggers on any condition and then verify that both conditions are true

  starters:
    - type: home.state.HomePresence
      state: homePresenceMode
      is: AWAY

    - type: time.schedule
      at: sunset+60min
 
  condition:
    type: and
    conditions:
      - type: home.state.HomePresence
        state: homePresenceMode
        is: AWAY
      - type: time.between
        before: sunrise
        after: sunset