Conditions with "or" and "and"

Hello,

I want to turn on my outdoor lamp before sunrise and after sunset and only if my dummy-switch is “on”.

This is my automation

id: '1583077428563'
  alias: Eingang Licht AN
  description: ''
  trigger:
  - device_id: 18a4c3b0dd7a4745b5ce115410d8f6a2
    domain: binary_sensor
    entity_id: binary_sensor.presence_11
    platform: device
    type: motion
  condition:
  - condition: and
    conditions:
    - condition: state
      entity_id: input_boolean.dummy_switch_eingang
      state: 'on'
    - after: sunset
      condition: sun
  - condition: and
    conditions:
    - condition: state
      entity_id: input_boolean.dummy_switch_eingang
      state: 'on'
    - before: sunrise
      condition: sun
  action:
  - device_id: 8ccf481a9ff24d8bb63644d6edfcd64a
    domain: light
    entity_id: light.licht_eingang
    type: turn_on

This works only in the evening. In the morning, (very early at 6 o’clock, it is always dark) it doesn’t work. What’s the reason?

Thanks,

Jaques-Ludwig

  condition:
    - condition: state
      entity_id: input_boolean.dummy_switch_eingang
      state: 'on'
    - condition: state  # from sunset until sunrise
      entity_id: sun.sun
      state: 'below_horizon'
1 Like

This works, thank you.

1 Like