Need guidance on a motion sensor

I have a automation setup to use a P1 motion sensor. It works as expected… although with one issue. So basically I have it set to detect motion up to 10pm at 100% brightness. After 10p until 4am, if motion is detected, it will use 5% brightness.

The problem for example is this… wife wakes up after 11pm, lights turn on at 5% from motion sensor… say she wants to tell Alexa to temp. use 100% brightness to see something… motion sensor re-triggers already re-running the script and forcing the bulbs back to 5%.

Any thoughts?

alias: Motion Sensor
description: ""
trigger:
  - type: motion
    platform: device
    device_id: ffb57ba70f74d6feef9a9930e8ed3c6b
    entity_id: binary_sensor.motion_sensor
    domain: binary_sensor
  - type: no_motion
    platform: device
    device_id: ffb57ba70f74d6feef9a9930e8ed3c6b
    entity_id: binary_sensor.motion_sensor
    domain: binary_sensor
    for:
      hours: 0
      minutes: 5
      seconds: 0
condition: []
action:
  - if:
      - type: is_motion
        condition: device
        device_id: ffb57ba70f74d6feef9a9930e8ed3c6b
        entity_id: binary_sensor.motion_sensor
        domain: binary_sensor
    then:
      - condition: time
        after: "04:00:00"
        before: "22:00:00"
        weekday:
          - mon
          - tue
          - wed
          - thu
          - fri
          - sat
          - sun
      - service: light.turn_on
        data:
          brightness_pct: 100
        target:
          entity_id:
            - light.bathroom_toilet
            - light.bathroom_shower_1
            - light.bathroom_shower_2
            - light.bathroom_light_4
            - light.bathroom_light_5
            - light.bathroom_light_6
            - light.bathroom_light_1
            - light.bathroom_light_3
            - light.bathroom_light_2
  - if:
      - type: is_no_motion
        condition: device
        device_id: ffb57ba70f74d6feef9a9930e8ed3c6b
        entity_id: binary_sensor.motion_sensor
        domain: binary_sensor
        for:
          hours: 0
          minutes: 0
          seconds: 0
    then:
      - service: light.turn_off
        data: {}
        target:
          area_id: bathroom
  - if:
      - type: is_motion
        condition: device
        device_id: ffb57ba70f74d6feef9a9930e8ed3c6b
        entity_id: binary_sensor.motion_sensor
        domain: binary_sensor
    then:
      - condition: time
        after: "22:00:00"
        before: "04:00:00"
        weekday:
          - mon
          - tue
          - wed
          - thu
          - fri
          - sat
          - sun
      - service: light.turn_on
        data:
          brightness_pct: 1
        target:
          entity_id:
            - light.bathroom_toilet
            - light.bathroom_shower_1
            - light.bathroom_shower_2
            - light.bathroom_light_4
            - light.bathroom_light_5
            - light.bathroom_light_6
            - light.bathroom_light_1
            - light.bathroom_light_3
            - light.bathroom_light_2
  - if:
      - type: is_no_motion
        condition: device
        device_id: ffb57ba70f74d6feef9a9930e8ed3c6b
        entity_id: binary_sensor.motion_sensor
        domain: binary_sensor
        for:
          hours: 0
          minutes: 0
          seconds: 0
    then:
      - service: light.turn_off
        data: {}
        target:
          area_id: bathroom
mode: single


For the on action, add a condition of the light being off.

1 Like

ah why didn’t I think of that. I actually used that somewhere else. But in a different scenario. Thank you so much! That should do it.