Automation won't work with different time conditions

Hi there,

Upstairs I have a motion sensor which will turn on my lights in the hallway. I would like to have different brightnesses for different times. I something like, between sunset en 23:00 turn on the lights when movement is detected with brightness 200, an after 23:00 en before sunrise turn on the lights when movement is detected with brightness 5. But I can’t get it to work.

# Zet lamp hal boven aan bij beweging
- id: lights_on_motion_hall_upstairs_early
  alias: Turn on the ligts when motion is detected in hall upstairs early
  initial_state: True
  hide_entity: False
  trigger:
    platform: state
    entity_id: binary_sensor.bewegingssensor_hal_boven
    from: 'off'
    to: 'on'
  condition:
    - condition: time
      before: '19:00:00'
    - condition: sun
      after: sunset
  action:
    - service: light.turn_on
      data:
        entity_id: light.hal_boven
        brightness: 200

- id: lights_on_motion_hall_upstairs_late
  alias: Turn on the ligts when motion is detected in hall upstairs late
  initial_state: True
  hide_entity: False
  trigger:
    platform: state
    entity_id: binary_sensor.bewegingssensor_hal_boven
    from: 'off'
    to: 'on'
  condition:
    - condition: sun
      before: sunrise
    - condition: time
      after: '19:00:00'
  action:
    - service: light.turn_on
      data:
        entity_id: light.hal_boven
        brightness: 5

sunrise/set is day based. So there us no time that is before sunrise AND after 1900.

That’s true for the 2nd automation, so the condition need to be shown with an ‘OR’ rather the default ‘AND’ when nothing is defined.

It should work for the 1st automation, though - unless there is an issue with the timezone set in HA.
Does the 1st automation work without the condition at all?

You are correct, the first automation was working.
Thanks for your help (and nickrout’s), it is working perfectly now.

Would you mind marking it ‘solved’ so that other people know that they can either find a solution here or don’t need to look any more because no more help is required.

1 Like

Ofcourse, i’m sorry. Forgot is. It is done!