I’ve tried finding other posts that might address this and assume my search skills are deficient because I find it difficult to believe I am alone in dealing with the issue I have going on here. Also, this site says I need to use backticks to quote code which I have done by pasting the code where it says to after using the preformatted code button but it is still telling me I should do that.
Most of my motion activated light automations use a Blueprint (shown below) which generally works very well but on random occasions the state change of a motion detector appears to not get received by the system so the system shows it as remaining in the “Detected” state which then keeps the light(s) on until they are either manually turned off or the motion detector is triggered again (which tells me that the motion detector apparently did cooldown/reset but the system didn’t get the message. I’ve tried to troubleshoot this without any success as it is random, happens to different devices of different manufacturers, and also impacts both those sensors that are line powered and the few which are battery powered.
Currently the “Wait time” gets reset if motion is detected and when this anomaly happens, it apparently is continuously reset so that the light is never turned off until the system sees that the motion detector had changed state to “Clear.”
What I’d like to do, but haven’t had any success in doing is to add a condition to the Blueprint so that the “Wait time” does not get reset unless the system has seen the state of the motion detector change from “Detected” to “Clear” at least once during that particular iteration of the “Wait time.” That way, if the motion detector’s state gets stuck in the “Detected” state, the light still turns off - this assumes that even if there is legitimately motion being detected, the detector will still, at least momentarily, cool down and switch state to “Clear” at least momentarily before legitimately switching state immediately back to “Detected.”
Any assistance would be greatly appreciated.
blueprint:
name: Motion-activated Light with Lux Sensor
description: Turn on a light when motion is detected and illuminance is below a given threshold.
domain: automation
input:
motion_entity:
name: Motion Sensor
selector:
entity:
domain: binary_sensor
device_class: motion
multiple: true
light_target:
name: Light
selector:
entity:
domain:
- light
- switch
multiple: true
override_switch_entity:
name: Manual Override Switch
description: The Manual Override switch disables ALL automations when on. This automation will only run if Manual Override is off.
selector:
entity:
domain:
- input_boolean
- switch
illuminance_entity:
name: Lux Sensor
selector:
entity:
domain: sensor
device_class: illuminance
lux_trigger_value:
name: Required Lux Level
description: Lux level required by the sensor, below which the automation will run.
default: 700
selector:
number:
min: 0
max: 60000
unit_of_measurement: lx
no_motion_wait:
name: Wait time
description: Time to leave the light on after last motion is detected.
default: 120
selector:
number:
min: 0
max: 3600
unit_of_measurement: seconds
trigger:
- platform: state
entity_id: !input motion_entity
from: 'off'
to: 'on'
- platform: state
entity_id: !input motion_entity
to: 'off'
for:
seconds: !input no_motion_wait
condition:
- condition: state
entity_id: !input override_switch_entity
state: 'off'
# - condition: not
# conditions:
# - condition: state
# entity_id: input_select.home_mode
# state: Away
action:
- choose:
- conditions:
- condition: state
entity_id: !input motion_entity
state: 'on'
- condition: numeric_state
entity_id: !input illuminance_entity
below: !input lux_trigger_value
sequence:
- service: homeassistant.turn_on
target:
entity_id: !input light_target
- conditions:
- condition: state
entity_id: !input motion_entity
state: 'off'
sequence:
- service: homeassistant.turn_off
target:
entity_id: !input light_target