blueprints/automation/motion-light.yaml gelöscht

This commit is contained in:
2025-08-29 19:55:31 +00:00
parent 06d7a4cd09
commit 93a202e6f8

View File

@@ -1,148 +0,0 @@
blueprint:
name: Motion-activated Light/Switch with Optional Lux
description: Turn on a light or switch when motion is detected, optionally only if lux is below a threshold.
domain: automation
author: ChatGPT
input:
motion_entity:
name: Motion Sensor
selector:
entity:
filter:
- device_class: occupancy
domain: binary_sensor
- device_class: motion
domain: binary_sensor
target_entity:
name: Light or Switch
selector:
entity:
domain:
- light
- switch
lux_entity:
name: Lux Sensor (optional)
default: null
selector:
entity:
domain: sensor
device_class: illuminance
lux_threshold:
name: Lux Threshold
default: 50
selector:
number:
min: 0
max: 1000
unit_of_measurement: lx
no_motion_wait:
name: Wait time
default: 120
selector:
number:
min: 0
max: 3600
unit_of_measurement: seconds
mode: restart
max_exceeded: silent
trigger:
- platform: state
entity_id: !input motion_entity
from: "off"
to: "on"
variables:
lux_entity_var: !input lux_entity
lux_threshold_var: !input lux_threshold
target_entity_id: !input target_entity
target_domain: "{{ target_entity_id.split('.')[0] }}"
condition:
- alias: "Optional lux check"
condition: template
value_template: >
{% if lux_entity_var and states(lux_entity_var) not in ['unknown','unavailable','none',''] %}
{{ states(lux_entity_var) | float(0) < lux_threshold_var | float(0) }}
{% else %}
true
{% endif %}
action:
- alias: "Set dynamic brightness"
variables:
max_brightness: 255
sun_elevation: "{{ state_attr('sun.sun','elevation') | float(0) }}"
current_lux: >
{% if lux_entity_var %}
{{ states(lux_entity_var) | float(0) }}
{% else %}
0
{% endif %}
brightness: >-
{% set base = 50 %}
{% if sun_elevation > 10 %}
{% set base = 100 %}
{% elif sun_elevation > 0 %}
{% set base = 150 %}
{% else %}
{% set base = 200 %}
{% endif %}
{% if current_lux > 50 %}
{% set base = base - ((current_lux / 500) * base) | int %}
{% endif %}
{{ [base, max_brightness] | min }}
- alias: "Turn on device (with brightness if supported)"
choose:
- conditions:
- condition: template
value_template: >
{{ target_domain == 'light' and 'brightness' in state_attr(target_entity_id, 'supported_color_modes') | default([]) }}
sequence:
- service: light.turn_on
target:
entity_id: "{{ target_entity_id }}"
data:
brightness: "{{ brightness }}"
- conditions:
- condition: template
value_template: "{{ target_domain == 'light' }}"
sequence:
- service: light.turn_on
target:
entity_id: "{{ target_entity_id }}"
- conditions:
- condition: template
value_template: "{{ target_domain == 'switch' }}"
sequence:
- service: switch.turn_on
target:
entity_id: "{{ target_entity_id }}"
- alias: "Wait until motion stops"
wait_for_trigger:
- platform: state
entity_id: !input motion_entity
from: "on"
to: "off"
- delay: !input no_motion_wait
- alias: "Turn off device"
choose:
- conditions:
- condition: template
value_template: "{{ target_domain == 'light' }}"
sequence:
- service: light.turn_off
target:
entity_id: "{{ target_entity_id }}"
- conditions:
- condition: template
value_template: "{{ target_domain == 'switch' }}"
sequence:
- service: switch.turn_off
target:
entity_id: "{{ target_entity_id }}"