Lights do not turn off after no motion

Hi,

I have an automation that turns the lights on in a room on movement and lights go on perfectly. After 2 minutes of no motion they should be turned off but nothing happens and have no idea why. I have another automation that does the same for an other room and have no problems. The only diffirence is that the working automation has 1 entity and the other has 2 entities.

Not working:

alias: 'Dressing licht aan bij beweging '
description: ''
trigger:
  - type: motion
    platform: device
    device_id: 19ce812e978a6bbed7dfaa2601697397
    entity_id: binary_sensor.tradfri_motion_sensor
    domain: binary_sensor
condition: []
action:
  - service: light.turn_on
    data: {}
    entity_id:
      - light.dimmable_light_2
      - light.dimmable_light_3
  - type: is_no_motion
    condition: device
    device_id: 19ce812e978a6bbed7dfaa2601697397
    entity_id: binary_sensor.tradfri_motion_sensor
    domain: binary_sensor
    for:
      hours: 0
      minutes: 2
      seconds: 0
  - service: light.turn_off
    data: {}
    entity_id:
      - light.dimmable_light_2
      - light.dimmable_light_3
mode: single

Working one:

description: ''
trigger:
  - type: motion
    platform: device
    device_id: c4c80007da66442c298b7865979e9b00
    entity_id: binary_sensor.wcboven_motion
    domain: binary_sensor
condition: []
action:
  - service: switch.turn_on
    data: {}
    entity_id: switch.sonoff_wcboven
  - type: is_no_motion
    condition: device
    device_id: c4c80007da66442c298b7865979e9b00
    entity_id: binary_sensor.wcboven_motion
    domain: binary_sensor
    for:
      hours: 0
      minutes: 3
      seconds: 0
  - service: switch.turn_off
    data: {}
    entity_id: switch.sonoff_wcboven
mode: single

Any ideas?

Keep it simple …

alias: 'Dressing licht aan/uit bij beweging'
description: ''
trigger:
  - platform: state
    entity_id: binary_sensor.wcboven_motion
    from: 'on'
    to: 'off'
    for: '00:03:00'
  - platform: state
    entity_id: binary_sensor.wcboven_motion
    from: 'off'
    to: 'on'
condition: []
action:
  - service: switch.turn_{{ trigger.to_state.state }}
    entity_id: switch.sonoff_wcboven
mode: single
1 Like

Dud you create that fully thru the ui editor including the two entities or did you have to manually edit the yaml to get those two entities in there like that?

I had to manually edit the yaml to get the two entities in there.

Then I would guess that the syntax is not supported with the UI editor?

But it seems strange that the turn_on works but the turn_off doesn’t.

try splitting them up into two separate actions to see if that works.

Or if that doesn’t work as well then I guess there could be a problem with the condition.

I followed your simple way and it works! Thanx!

alias: Dressing licht aan/uit bij beweging
description: ''
trigger:
  - platform: state
    entity_id: binary_sensor.tradfri_motion_sensor
    from: 'on'
    to: 'off'
    for: '00:02:00'
  - platform: state
    entity_id: binary_sensor.tradfri_motion_sensor
    from: 'off'
    to: 'on'
condition: []
action:
  - service: 'light.turn_{{ trigger.to_state.state }}'
    entity_id:
      - light.dimmable_light_2
      - light.dimmable_light_3
mode: single
1 Like