Why si the light still on after 22:00?

This should be fairly straight forward, but still the light does not turn off at 22:00 as wanted…

What am I missing here?

- alias: LYS - Utelys i gesims PÅ
  trigger:
    platform: numeric_state
    entity_id: sun.sun
    value_template: '{{ state.attributes.elevation }}'
    below: '-3.0'
  condition: 
    - condition: time
      before: '22:00:00'
      after: '06:45:00'
  action:
    - service: switch.turn_on
      entity_id: 
        - switch.utelys_gesims
    - service: notify.ios_pals_iphone
      data:
        title: "Utelys - Gesims på kl. {{ states.sensor.time.state }}"
        message: "Gesimslys er slått på"

First I would try;
switch.turn_off instead of switch.turn_on

:wink:

But It will only turn off the light if sun it at -3 before 22:00 otherwise it wll stay on.

Are you expecting this automation to turn the light on when the sun is 3° below the horizon and turn off at 22:00?

It wont. That’s not how this works.

The automation triggers only when the sun is 3° below the horizon. That is the only time it runs. That’s your trigger.

If it is between 06:45 and 22:00 when this happens the light turns on. That’s a condition that is evaluated after and only after the automation is triggered. It is not evaluated at any other time.

If you want the light to turn off at 22:00 you will have to write another automation to trigger at that time.

Thank you @tom_l

Yes, I want the light to be ON after sunset, and OFF between 22:00 and 05:45.
If there is no other way, I would have to write an other automation.

I would think, however that condition Is what actually controls under what conditions this work. So I was mistaken :slight_smile:

Can I list multiple entities like this?

  action:
    - service: switch.turn_on
      entity_id: 
        - switch.utelys_inngang_terrasse
        - switch.utelys_gesims

Yes you can

1 Like