Created
September 20, 2024 06:11
-
-
Save httpoz/aa65379544cae60eaa19535423c591fb to your computer and use it in GitHub Desktop.
Light automation with Motion sensors and Lux input
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
blueprint: | |
name: Motion and lux activated Light | |
description: Turn on a light when motion is detected and it is dark enough (based on lux sensor). | |
domain: automation | |
source_url: https://github.com/home-assistant/core/blob/dev/homeassistant/components/automation/blueprints/motion_light.yaml | |
author: httpoz | |
input: | |
motion_entity: | |
name: Motion Sensor | |
selector: | |
entity: | |
filter: | |
device_class: motion | |
domain: binary_sensor | |
light_entity: | |
name: Light | |
selector: | |
entity: | |
domain: light | |
lux_sensor: | |
name: Lux Sensor | |
description: Select a sensor that measures the ambient light level (lux). | |
selector: | |
entity: | |
domain: sensor | |
device_class: illuminance | |
lux_threshold: | |
name: Lux Threshold | |
description: The light level (in lux) below which the light will turn on. | |
default: 10 | |
selector: | |
number: | |
min: 0 | |
max: 100 | |
unit_of_measurement: lux | |
no_motion_wait: | |
name: Wait time | |
description: Time to leave the light on after the last motion is detected. | |
default: 120 | |
selector: | |
number: | |
min: 0 | |
max: 3600 | |
unit_of_measurement: seconds | |
# If motion is detected within the delay, we restart the script. | |
mode: restart | |
max_exceeded: silent | |
trigger: | |
platform: state | |
entity_id: !input motion_entity | |
from: "off" | |
to: "on" | |
condition: | |
# Check if it's dark enough (lux level below threshold) | |
- condition: numeric_state | |
entity_id: !input lux_sensor | |
below: !input lux_threshold | |
action: | |
- choose: | |
- conditions: | |
- condition: state | |
entity_id: !input light_entity | |
state: "off" | |
- condition: numeric_state | |
entity_id: !input lux_sensor | |
below: !input lux_threshold | |
sequence: | |
- alias: "Turn on the light(s)" | |
service: light.turn_on | |
entity_id: !input light_entity | |
- alias: "Wait until there is no motion from device" | |
wait_for_trigger: | |
platform: state | |
entity_id: !input motion_entity | |
from: "on" | |
to: "off" | |
- alias: "Wait the number of seconds that has been set" | |
delay: !input no_motion_wait | |
- alias: "Turn off the light" | |
service: light.turn_off | |
entity_id: !input light_entity |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment