/
en_light.yaml
191 lines (142 loc) · 6.13 KB
/
en_light.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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
en_light:
homeassistant:
customize:
light.0x00158d0003e74c31:
friendly_name: Прихожая лампочка
icon: phu:bulbs-classic
binary_sensor.0x00158d00013f7894_occupancy:
friendly_name: Прихожая датчик движения
sensor.0x00158d00013f7894_battery:
friendly_name: Прихожая датчик движения
sensor.0x00158d00010b1963_action:
friendly_name: Прихожая кнопка на шкафу
sensor.0x00158d00010b1963_battery:
friendly_name: Прихожая кнопка на шкафу
template:
- binary_sensor:
# Свет без движения в прихожей днем
- name: en_light_day
unique_id: en_light_day
state: >
{{ is_state('light.0x00158d0003e74c31', 'on')
and is_state('binary_sensor.0x00158d00013f7894_occupancy', 'off')
and is_state('binary_sensor.night_time', 'off')
}}
delay_on: 00:03:00
icon: >
{% if is_state("binary_sensor.en_light_day", "on") %}
mdi:timer
{% else %}
mdi:timer-off
{% endif %}
{{ is_state('light.0x00158d0003e74c31', 'on')
and is_state('binary_sensor.0x00158d00013f7894_occupancy', 'off')
and is_state('binary_sensor.night_time', 'off')
}}
# Свет без движения в прихожей ночью
- name: en_light_night
unique_id: en_light_night
state: >
{{ is_state('light.0x00158d0003e74c31', 'on')
and is_state('binary_sensor.0x00158d00013f7894_occupancy', 'off')
and is_state('binary_sensor.night_time', 'on')
}}
delay_on: 00:03:00
icon: >
{% if is_state("binary_sensor.en_light_night", "on") %}
mdi:timer
{% else %}
mdi:timer-off
{% endif %}
# Лампочка выключена менее 3х минут назад
- name: en_light_off_3min
unique_id: en_light_off_3min
state: >
{{ is_state('light.0x00158d0003e74c31', 'on')
}}
delay_off:
minutes: 3
device_class: light
icon: >
{% if is_state("binary_sensor.en_light_off_3min", "on") %}
mdi:lightbulb-on
{% else %}
mdi:lightbulb
{% endif %}
# Открытие двери, лампочка выключена более 3 минут
- name: en_door_open
unique_id: en_door_open
state: >
{{ is_state('binary_sensor.0x00158d000119378d_contact', 'on')
and is_state('binary_sensor.en_light_off_3min', 'off')
}}
device_class: light
icon: >
{% if is_state("binary_sensor.en_door_open", "on") %}
mdi:lightbulb-spot
{% else %}
mdi:lightbulb-spot-off
{% endif %}
automation:
- alias: en_light_control
id: en_light_control
description: Прихожая управление лампочкой
initial_state: true
trigger:
# Выключение света без движения днем
- platform: state
entity_id: binary_sensor.en_light_day
to: 'on'
# Выключение света без движения ночью
- platform: state
entity_id: binary_sensor.en_light_night
to: 'on'
# Включение света при открытии двери
- platform: state
entity_id: binary_sensor.en_door_open
to: 'on'
# Выключатель на стене у входа
- platform: state
entity_id: sensor.0x00158d00057305ac_action
to: 'single_right'
# Круглая кнопка в шкафу
- platform: state
entity_id: sensor.0x00158d0001f3fefe_action
to: 'double'
# 6 клавишник на входе в кухню
- platform: state
entity_id: sensor.0x04cf8cdf3c794209_action
to: 'button_4_single'
# 4 клавишник на комоде
- platform: state
entity_id: sensor.0x04cf8cdf3c7942ca_action
to: 'button_1_single'
## Aqara Opple на столе
- platform: state
entity_id: sensor.0x54ef4410004c1707_action
to: 'button_3_single'
condition:
- condition: state
entity_id: switch.control_mode
state: 'on'
action:
- choose:
- conditions:
- condition: state
entity_id: light.0x00158d0003e74c31
state: 'off'
sequence:
- service: light.turn_on
entity_id:
- light.0x00158d0003e74c31
data_template:
brightness_pct: 100
kelvin: 4000
- conditions:
- condition: state
entity_id: light.0x00158d0003e74c31
state: 'on'
sequence:
- service: light.turn_off
entity_id:
- light.0x00158d0003e74c31