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