forked from fixtse/blueprints
-
Notifications
You must be signed in to change notification settings - Fork 0
/
light_brightness_sensor_automation.yaml
executable file
·102 lines (97 loc) · 2.78 KB
/
light_brightness_sensor_automation.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
blueprint:
name: Luz controlada por sensor de Luminosidad
description: Enciende una luz y ajusta el brillo de acuerdo a la luminosidad.
source_url: https://github.com/fixtse/blueprints/blob/main/light_brightness_sensor_automation.yaml
domain: automation
input:
illuminance_sensor:
name: Sensor de Luminosidad
selector:
entity:
domain: sensor
device_class: illuminance
target_light:
name: Foco
selector:
entity:
domain: light
max_brightness:
name: Brillo Máximo
description: Limita el máximo nivel de brillo del foco
default: 100
selector:
number:
min: 0
max: 100
unit_of_measurement: "%"
brightness_trigger_light_off:
name: Límite de iluminación para encender la luz
description: Cuando la luminosidad se encuentre bajo este nivel, la luz se encenderá
default: 30
selector:
number:
min: 0
max: 1000
unit_of_measurement: lx
brightness_trigger_light_on:
name: Límite de iluminación apagar la luz
description: Cuando la luminosidad se encuentre sobre este nivel, la luz se apagará
default: 80
selector:
number:
min: 0
max: 1000
unit_of_measurement: lx
transition_time:
name: Tiempo de Transición
description: Tiempo que tardará la luz en cambiar de brillo.
default: 4
selector:
number:
min: 0
max: 10
unit_of_measurement: seg
control_light:
name: Control
description: Ayudante para activar y desactivar la automatización de forma sencilla.
selector:
entity:
domain: input_boolean
mode: restart
max_exceeded: silent
trigger:
- platform: state
entity_id: !input illuminance_sensor
- platform: state
entity_id: !input control_light
condition:
- condition: state
entity_id: !input control_light
state: "off"
variables:
lux_sensor: !input illuminance_sensor
lux: "{{ states(lux_sensor) |int }}"
brg_tg_on: !input brightness_trigger_light_on
max_brg: !input max_brightness
brg_tg_off: !input brightness_trigger_light_off
light: !input target_light
brightness: >-
{%- if is_state(light.entity_id, 'off') -%}
{% if lux >= brg_tg_off %}
0
{% else%}
{{ (150 - lux) / (150 / 100) | float }}
{% endif %}
{%- else -%}
{% if lux >= brg_tg_on %}
0
{% else%}
{{ (150 - lux) / (150 / 100) | float }}
{% endif %}
{%- endif -%}
action:
- service: light.turn_on
target: !input target_light
data:
brightness_pct: "{{ ((max_brg * brightness) / 100) | int }}"
transition: !input transition_time