Blink to turn on a switch if motion is detected only when system is armed

I am new to the home assistant. I am trying to create an automation to turn the light on using a sonoff switch when the motion is detected but only when the blink is armed. If the switch turns on then turn it off after 10 minutes. I am not able to find how to check the state of the system.

- id: '1588172004740'
  alias: Front Door Light Turns On When Motion Detected
  description: Front Camera Motion Detected Front Door Light Turn on
  trigger:
  - entity_id: binary_sensor.blink_front_motion_detected
    from: 'off'
    platform: state
    to: 'on'
  condition:
  - condition: state
    entity_id: binary_sensor.blink_front_camera_armed
    state: 'on'
  action:
  - data: {}
    entity_id: switch.sonoff_100057c411
    service: switch.turn_on
  - delay: 00:00:10
  - data: {}
    entity_id: switch.sonoff_100057c411
    service: switch.turn_off

Can an experience person tell me where i am wrong.

The motion detected variable can only be set if blink is armed, so there’s no need to have a condition based on that. You only have to look for the motion detection state change, nothing else.

BTW, the motion detection logic has a bug in pre-0.109 versions so what you’re trying to do won’t work well until then (currently motion detection gets stuck “high” and never resets)

1 Like

Thank you for your reply. I did update to 0.109 and issue seems to have been resolved. As per your advice i took away the condition. Automation is working now.

Thank you very much for help.