blueprints/automation/motion-light.yaml aktualisiert
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
blueprint:
|
blueprint:
|
||||||
name: Smart Motion Light with Optional Lux Trigger and Time-Based Dimming
|
name: Smart Motion Light with Optional Lux and Global No-Motion Timer
|
||||||
description: Turns on a light when motion is detected or when lux drops below a threshold (if sensor is defined), dims based on time, and turns off when no motion.
|
description: Turns on a light when motion is detected, optionally based on lux sensor, dims based on time of day, and turns off using a global no-motion timer.
|
||||||
domain: automation
|
domain: automation
|
||||||
input:
|
input:
|
||||||
motion_entity:
|
motion_entity:
|
||||||
@@ -33,52 +33,47 @@ blueprint:
|
|||||||
min: 0
|
min: 0
|
||||||
max: 1000
|
max: 1000
|
||||||
unit_of_measurement: lx
|
unit_of_measurement: lx
|
||||||
no_motion_wait:
|
no_motion_timer:
|
||||||
name: Wait Time After Motion Stops
|
name: Global No-Motion Timer
|
||||||
default: 120
|
description: An input_number entity representing the delay in seconds after motion stops before turning off the light.
|
||||||
selector:
|
selector:
|
||||||
number:
|
entity:
|
||||||
min: 0
|
domain: input_number
|
||||||
max: 3600
|
|
||||||
unit_of_measurement: seconds
|
|
||||||
|
|
||||||
mode: restart
|
mode: restart
|
||||||
max_exceeded: silent
|
max_exceeded: silent
|
||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
# Motion trigger
|
|
||||||
- platform: state
|
- platform: state
|
||||||
entity_id: !input motion_entity
|
entity_id: !input.motion_entity
|
||||||
from: "off"
|
from: "off"
|
||||||
to: "on"
|
to: "on"
|
||||||
|
|
||||||
# Optional lux trigger
|
|
||||||
- platform: template
|
|
||||||
value_template: >
|
|
||||||
{% if lux_entity %}
|
|
||||||
{{ states(lux_entity) | float(0) < lux_threshold and
|
|
||||||
(states(motion_entity) == 'on' or
|
|
||||||
(as_timestamp(now()) - as_timestamp(states(motion_entity))) < 300) }}
|
|
||||||
{% else %}
|
|
||||||
false
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
condition: []
|
condition: []
|
||||||
|
|
||||||
action:
|
action:
|
||||||
- alias: "Turn on the light with calculated brightness"
|
- alias: "Check lux (if defined) before turning on"
|
||||||
service: light.turn_on
|
choose:
|
||||||
target: !input.light_target
|
- conditions:
|
||||||
data:
|
- condition: template
|
||||||
brightness: "{{ brightness }}"
|
value_template: >
|
||||||
- alias: "Wait until motion stops"
|
{% if lux_entity %}
|
||||||
wait_for_trigger:
|
{{ states(lux_entity) | float(0) < lux_threshold }}
|
||||||
- platform: state
|
{% else %}
|
||||||
entity_id: !input.motion_entity
|
true
|
||||||
from: "on"
|
{% endif %}
|
||||||
to: "off"
|
sequence:
|
||||||
- alias: "Wait the configured delay"
|
- service: light.turn_on
|
||||||
delay: !input.no_motion_wait
|
target: !input.light_target
|
||||||
- alias: "Turn off the light"
|
data:
|
||||||
service: light.turn_off
|
brightness: "{{ brightness }}"
|
||||||
target: !input.light_target
|
- alias: "Wait until motion stops"
|
||||||
|
wait_for_trigger:
|
||||||
|
- platform: state
|
||||||
|
entity_id: !input.motion_entity
|
||||||
|
from: "on"
|
||||||
|
to: "off"
|
||||||
|
- delay:
|
||||||
|
seconds: "{{ states('!input.no_motion_timer') | int }}"
|
||||||
|
- service: light.turn_off
|
||||||
|
target: !input.light_target
|
||||||
|
|||||||
Reference in New Issue
Block a user