Setting up a motion sensor

I just got a zooz outdoor motion sensor and am trying to set it up. When I go to the “Overview” tab I can see the session detect motion, but it isn’t triggering the automation. Here is how I set it up and I am wondering what I did wrong.

Here is what I see on the Overview tab:

Capture2

It says “Clear” when there is no motion.

Suggestions?

Your trigger requires motion to be detected continuously for 5 minutes.

Try removing the 5 minutes requirement.

Yes, it did work after removing that; however, I want the light to stay on for a given amount of time and then go off. I was starting with 5 minutes.

After removing the five minutes, I set up another automation that turns the light off after five minutes of no motion and that works, but not the way I want it to. If the light is off and it detects motion I want it to go on for five minutes and then go off. If the light is on, I want it to stay on even after detecting motion and then no longer detecting it.

How do I set that up? I was going to trigger the light for five minutes with a condition that the light was off. But with a separate automation that turns it off that condition won’t work because it will be on because of the motion automation.

I then thought maybe I would have the motion automation turn it on to a weird brightness setting, like 23% and have a condition that only turns the light off if it is at 23%. I would be unlikely to manually turn it on to that setting. The problem is that I can’t find brightness level as a condition.

Thoughts?

How about something like this:

description: ""
mode: single
trigger:
  - platform: state
    entity_id:
      - binary_sensor.hall_motion_sensor_on_off
    to: "on"
condition:
  - condition: state
    entity_id: light.hall_table_light_level_on_off
    state: "off"
action:
  - service: light.turn_on
    data: {}
    target:
      device_id: 1750b9e31b2a4cdebd783a664cea5c94
  - delay:
      hours: 0
      minutes: 5
      seconds: 0
      milliseconds: 0
  - service: light.turn_off
    data: {}
    target:
      device_id: 1750b9e31b2a4cdebd783a664cea5c94

That would be better written as:

description: ""
mode: single
trigger:
  - platform: state
    entity_id:
      - binary_sensor.hall_motion_sensor_on_off
    to: "on"
condition:
  - condition: state
    entity_id: light.hall_table_light_level_on_off
    state: "off"
action:
  - service: light.turn_on
    data: {}
    target:
      device_id: 1750b9e31b2a4cdebd783a664cea5c94
  - wait_for_trigger:
      - platform: state
        entity_id: binary_sensor.hall_motion_sensor_on_off
        to: "off"
        for: '00:05:00'
  - service: light.turn_off
    data: {}
    target:
      device_id: 1750b9e31b2a4cdebd783a664cea5c94

Agreed. Thank you.

Thank you the suggestion, this will be great when I figure out how to do it. I have only used the visual editor. I went to the automation, clicked edit and then in the visual editor clicked the three dots in the upper right and selected “Edit in YAML”. I then made edits and clicked save. However, the edits don’t take. It just reverts back to the original stuff. This is what the automation looks like in YAML now:

alias: Motion turn on lights
description: ‘’
trigger:

  • type: motion
    platform: device
    device_id: 5a9da822c712844f78a69c649a53948f
    entity_id: binary_sensor.outdoor_motion_sensor_home_security_motion_detection
    domain: binary_sensor
    for:
    hours: 0
    minutes: 0
    seconds: 0
    condition:
  • condition: sun
    after: sunset
    action:
  • type: turn_on
    device_id: 353079e60daf2e8082548749793c61a8
    entity_id: light.in_wall_600w_dimmer_4
    domain: light
    brightness_pct: 25
    mode: single

I changed it to this and click save, but it won’t “take”, when I go back to the visual editor it is back to what it was before.

alias: Motion turn on lights
description: ‘’
trigger:

  • type: motion
    platform: device
    device_id: 5a9da822c712844f78a69c649a53948f
    entity_id: binary_sensor.outdoor_motion_sensor_home_security_motion_detection
    domain: binary_sensor
    for:
    hours: 0
    minutes: 0
    seconds: 0
    condition:
  • condition: sun
    after: sunset
    action:
  • service: light.turn_on
    data: {}
    target:
    device_id: 353079e60daf2e8082548749793c61a8
  • wait_for_trigger:
    • platform: state
      entity_id: light.in_wall_600w_dimmer_4
      to: “off”
      for: ‘00:05:00’
  • service: light.turn_off
    data: {}
    target:
    device_id: 353079e60daf2e8082548749793c61a8
    mode: single

Please see the sticky post about code markup.

alias: Motion turn on lights
description: ''
trigger:
  - type: motion
    platform: device
    device_id: 5a9da822c712844f78a69c649a53948f
    entity_id: binary_sensor.outdoor_motion_sensor_home_security_motion_detection
    domain: binary_sensor
    for:
      hours: 0
      minutes: 0
      seconds: 0
condition:
  - condition: sun
    after: sunset
action:
 - service: light.turn_on
    data: {}
    target:
      device_id: 353079e60daf2e8082548749793c61a8
  - wait_for_trigger:
      - platform: state
        entity_id: light.in_wall_600w_dimmer_4
        to: "off"
        for: '00:05:00'
  - service: light.turn_off
    data: {}
    target:
      device_id: 353079e60daf2e8082548749793c61a8
  mode: single

That was me testing pasting it correctly. Based on your comment about spacing and such, I redid this and this time copied the line above and below the section I was copying and pasting then deleted those lines. I did this to make sure I was copying and pasting with the correct spacing and such. This time there was progress. The code stayed in there and saved. But, it isn’t working. The light is turning on, but it isn’t turning off.

Here is the code:

alias: Motion turn on lights
description: ''
trigger:
  - type: motion
    platform: device
    device_id: 5a9da822c712844f78a69c649a53948f
    entity_id: binary_sensor.outdoor_motion_sensor_home_security_motion_detection
    domain: binary_sensor
    for:
      hours: 0
      minutes: 0
      seconds: 0
condition:
  - condition: sun
    after: sunset
action:
  - service: light.turn_on
    data: {}
    target:
      device_id: 353079e60daf2e8082548749793c61a8
  - wait_for_trigger:
      - platform: state
        entity_id: light.in_wall_600w_dimmer_4
        to: 'off'
        for: '00:05:00'
  - service: light.turn_off
    data: {}
    target:
      device_id: 353079e60daf2e8082548749793c61a8
mode: single

The wrong entity is in the wait_for_trigger

If you look at what I had I’m using the binary_sensor

Yep, that fixed it! I wanted to do one thing at a time and make sure it worked before adding complications. I got that working (you got that working) and then I added the condition about the light being on and that is working too. It is exactly how I wanted it. Now I will add two more automations that are the same but for different lights. So that motion sensor will be on my porch and motion will trigger three different lights that shut off after five minutes (I may shorten that time, I don’t know). Yet, if I am on my porch reading and the sensor doesn’t see motion, it isn’t going to shut the light off on me.

There is another recent discussion with a very similar use case: Motion Activated Light, but with conditions