Reoccuring time trigger with multiple conditions does not work

Hi all,

I am trying to switch off all living room lights when we go to bed i.e. the couch motion sensor does not detect motion for 30 minutes. Lights shell be turned off only if they are on (fernseh is part of the group). The automation does not trigger, triggering manually turns off the light (seems to ignore the motion sensor condition).

- alias: turn light off unused
  trigger:
    platform: time
    minutes: '/15'
    seconds: 00
  condition:
    condition: and
    conditions:
      - condition: state
        entity_id: binary_sensor.couch_motion
        state: 'off'
        for:
          minutes: 30
      - condition: state
        entity_id: light.fernseh
        state: 'on'
      - condition: sun
        after: sunset
        before: sunrise
  action:
    service: light.turn_off
    data:
      entity_id: group.living_room

- alias: turn light off on sunrise
  trigger:
    platform: sun
    event: sunrise
    offset: "+00:30:00"
  action:
    service: light.turn_off
    data:
      entity_id: group.living_room

turn light off unused does not work while turn light off on sunrise switches off the light every morning.

I have no idea whats wrong but my girlfriend starts to get annoyed that the light is on the whole night, so I really do need help :wink:

I don’t think you need the condition that the lights are on, because if it’s off then turning it off again is still off.

I don’t think you can have after sunset and before sunrise in the same day, so that condition is probably always false. Also, whether it’s dark or not shouldn’t affect whether you want this automation to run I don’t think.

Looking at your requirements I see it more like this (unless you specifically want the lights on during the day and for them to be left on regardless of occupancy)…

- alias: turn light off unused
  trigger:
    platform: state
    entity_id: binary_sensor.couch_motion
    state: 'off'
    for:
      minutes: 30
  action:
    service: light.turn_off
    data:
      entity_id: group.living_room

… Which should replace both automations you currently have and still do everything you want.