Hey team. First off, thank you so much to everyone who answers questions here and helps others. It is a wealth of knowledge with nothing in return so “thank you”.
I have created my own blueprint, as I’m learning HA, for motion activated lights. I did borrow a lot of the code from this forum from different places. But I wanted to create my own to learn, rather than just using one out there, even though I know it’s almost identical.
Here’s what I’m experiencing. The lights turn on as expected, but seem to turn off right at the “motion delay”. So for example, they turn on when it’s dark and motion is seen, but then if the “no motion turn off” is set to say 15 minutes, they almost always turn off right at that 15 minute mark, and then turn on again seconds later, ostensibly because the motion sensor sees motion.
This happens even when the motion sensor is seeing continuous motion.
I was under the impression the mode of “restart” would address this, hence my question here. Did I do something wrong here?
One day, when they turned off, I quickly opened the HA app just to see that in fact the motion sensor had seen motion 8 minutes prior. So that tells me certainly something is wrong in the code if they’re turning off after only 8 minutes of no motion.
I hope this makes sense and thank you so much again.
Matt
blueprint:
name: Mesa Interior Motion-Activated Light
description: Turn a light on based on detected motion, only if it's dark
domain: automation
input:
motion_sensor:
name: Motion Sensor
description: This sensor will be synchronized with the light
selector:
entity:
domain: binary_sensor
device_class: motion
target_light:
name: Lights
description: The lights to turn on
selector:
target:
entity:
domain: light
illuminance_sensor:
name: Illuminance Sensor
description: The sensor to read the brightness from
selector:
entity:
domain: sensor
device_class: illuminance
lux:
name: Lux
description: The light will turn on only if the lux in the room is less than this value
default: 15
selector:
number:
min: 1
max: 1000
brightness:
name: Brightness
description: The brightness to set the lights to
default: 20
selector:
number:
min: 1
max: 100
no_motion_wait:
name: Wait time
description: Time in minutes to leave the light on after last motion is detected
default: 900
selector:
number:
min: 0
max: 3600
unit_of_measurement: seconds
blocker_entity:
name: (OPTIONAL) Blocking entity
description: If this entity's state is on, it will prevent the automation from running. E.g. sleepmode or away mode.
default:
selector:
entity:
mode: restart
max_exceeded: silent
variables:
blocker_entity_var: !input blocker_entity
trigger:
- platform: state
entity_id: !input motion_sensor
from: "off"
to: "on"
- platform: numeric_state
entity_id: !input illuminance_sensor
below: !input lux
condition:
- condition: numeric_state
entity_id: !input illuminance_sensor
below: !input lux
- condition: state
entity_id: !input motion_sensor
state: "on"
- condition: state
entity_id: group.family
state: "home"
- condition: template
value_template: "{{ (blocker_entity_var == none) or (states(blocker_entity_var) == 'off') }}"
action:
- service: light.turn_on
target:
entity_id: !input target_light
data:
brightness_pct: !input brightness
- wait_for_trigger:
- platform: state
entity_id: !input motion_sensor
from: "on"
to: "off"
- delay: !input no_motion_wait
- service: light.turn_off
target:
entity_id: !input target_light
- id: kitchen_island_automatic_lighting
alias: "[Lights] Kitchen Island Automatic Lighting"
use_blueprint:
path: /config/blueprints/automation/mesa/mesa_interior_motion_light.yaml
input:
motion_sensor: binary_sensor.hue_motion_sensor_1_motion
target_light: light.kitchen_island_lights
brightness: "{{ states('input_number.dynamic_brightness') | float }}"
illuminance_sensor: sensor.hue_motion_sensor_1_illuminance