blueprints/automation/motion-light.yaml aktualisiert
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
blueprint:
|
||||
name: Smart Motion Light with Optional Lux and Time-Based Dimming
|
||||
description: Turns on a light when motion is detected or when lux falls below a threshold (optional), and dims based on time of day. Turns off when no motion is detected.
|
||||
name: Smart Motion Light with Optional Lux Trigger and Time-Based Dimming
|
||||
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.
|
||||
domain: automation
|
||||
input:
|
||||
motion_entity:
|
||||
@@ -27,7 +27,6 @@ blueprint:
|
||||
device_class: illuminance
|
||||
lux_threshold:
|
||||
name: Lux Threshold
|
||||
description: Only turn on the light if lux is below this value (if sensor is defined).
|
||||
default: 50
|
||||
selector:
|
||||
number:
|
||||
@@ -47,27 +46,25 @@ mode: restart
|
||||
max_exceeded: silent
|
||||
|
||||
trigger:
|
||||
# Motion trigger
|
||||
- platform: state
|
||||
entity_id: !input motion_entity
|
||||
from: "off"
|
||||
to: "on"
|
||||
- platform: numeric_state
|
||||
entity_id: !input lux_entity
|
||||
below: !input lux_threshold
|
||||
|
||||
condition:
|
||||
- alias: "Optional lux check and recent motion"
|
||||
condition: template
|
||||
# Optional lux trigger
|
||||
- platform: template
|
||||
value_template: >
|
||||
{% set last_motion = states(!input.motion_entity) %}
|
||||
{% set recent_motion = (last_motion == 'on') or (as_timestamp(now()) - as_timestamp(last_motion)) < 300 %}
|
||||
{% if lux_entity %}
|
||||
{% set lux_value = states(lux_entity) | float(0) %}
|
||||
{{ recent_motion and lux_value < lux_threshold }}
|
||||
{{ states(lux_entity) | float(0) < lux_threshold and
|
||||
(states(motion_entity) == 'on' or
|
||||
(as_timestamp(now()) - as_timestamp(states(motion_entity))) < 300) }}
|
||||
{% else %}
|
||||
{{ recent_motion }}
|
||||
false
|
||||
{% endif %}
|
||||
|
||||
condition: []
|
||||
|
||||
action:
|
||||
- alias: "Turn on the light with calculated brightness"
|
||||
service: light.turn_on
|
||||
|
||||
Reference in New Issue
Block a user