-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsmart-time.yaml
296 lines (289 loc) · 7.32 KB
/
smart-time.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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
esphome:
name: smart-time
friendly_name: Умные часы
# Тип контроллера и тип платы
esp8266:
board: d1_mini
# Отключаем вывод лога на физический порт uart
logger:
baud_rate: 0
# Включаем обновление прошивки по сети
ota:
password: "02c4d1987f2c6f6c85ec92a060569dd1"
# Прописываем сеть wifi
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# При невозможности подключить сеть wifi создаем точку доступа
ap:
ssid: "Smart-Time Fallback Hotspot"
password: "12345678"
# выводим страницу настройки контроллера
captive_portal:
# Указываем путь для стороннего компонента dynamic_on_time https://github.com/hostcc/esphome-component-dynamic-on-time
external_components:
source: github://hostcc/esphome-component-dynamic-on-time
components: [ dynamic_on_time ]
# Создаем интерфейс для подключения датчиков (i2c)
i2c:
sda: D2
scl: D1
# Создаем интерфейс для управления dfplayer (uart)
uart:
tx_pin: 3
rx_pin: 1
baud_rate: 9600
id: df
# Указываем использование библиотеки bsec для датчика bme680 и указываем его адрес
bme680_bsec:
address: 0x77
# Прописываем сенсоры датчика bme680
sensor:
- platform: bme680_bsec
temperature:
name: "BME680 Temperature"
id: temp
pressure:
name: "BME680 Pressure"
id: pres
filters:
- multiply: 0.75
unit_of_measurement: mmHg
humidity:
name: "BME680 Humidity"
id: vlaga
iaq:
name: "BME680 IAQ"
id: iaq
co2_equivalent:
name: "BME680 CO2 Equivalent"
id: co2
breath_voc_equivalent:
name: "BME680 Breath VOC Equivalent"
# Прописываем кнопку отключения проигрывания мелодии
binary_sensor:
- platform: tm1637
name: alarm off
tm1637_id: tm1637_co2
key: 0
on_press:
- dfplayer.stop
# Прописываем dfplayer
dfplayer:
uart_id: df
on_finished_playback:
then:
logger.log: 'Somebody press play!'
# Создаем выключатели дней недели для будильника и выключатель сигнала будильника
switch:
- platform: template
id: mon
name: "Alarm Mon"
optimistic: true
restore_mode: RESTORE_DEFAULT_OFF
entity_category: config
- platform: template
id: tue
name: "Alarm Tue"
optimistic: true
restore_mode: RESTORE_DEFAULT_OFF
entity_category: config
- platform: template
id: wed
name: "Alarm Wed"
optimistic: true
restore_mode: RESTORE_DEFAULT_OFF
entity_category: config
- platform: template
id: thu
name: "Alarm Thu"
optimistic: true
restore_mode: RESTORE_DEFAULT_OFF
entity_category: config
- platform: template
id: fri
name: "Alarm Fri"
optimistic: true
restore_mode: RESTORE_DEFAULT_OFF
entity_category: config
- platform: template
id: sat
name: "Alarm Sat"
optimistic: true
restore_mode: RESTORE_DEFAULT_OFF
entity_category: config
- platform: template
id: sun
name: "Alarm Sun"
optimistic: true
restore_mode: RESTORE_DEFAULT_OFF
entity_category: config
- platform: template
id: disabled
name: "Alarm Disable"
optimistic: true
restore_mode: RESTORE_DEFAULT_OFF
entity_category: config
# Создаем числовой ввод часов, минут, уровень громкости, выбор мелодии.
number:
- platform: template
id: hour
name: "Alarm Hour"
entity_category: config
optimistic: true
restore_value: true
initial_value: 0
min_value: 0
max_value: 23
step: 1
mode: box
- platform: template
name: "Alarm Minute"
id: minute
entity_category: config
optimistic: true
restore_value: true
initial_value: 0
min_value: 0
max_value: 59
step: 1
mode: box
- platform: template
name: "Alarm melody"
id: melody
entity_category: config
optimistic: true
restore_value: true
initial_value: 1
min_value: 1
max_value: 9
step: 1
mode: box
- platform: template
name: "Alarm volume"
id: volume
entity_category: config
optimistic: true
restore_value: true
initial_value: 20
min_value: 1
max_value: 30
step: 1
mode: box
on_value:
- dfplayer.set_volume:
!lambda |-
return id(volume).state;
# Создаем быдильник на стороннем компоненте dynamic_on_time
dynamic_on_time:
- id: alarm_clock
rtc: sntp_time
hour: hour
minute: minute
mon: mon
tue: tue
wed: wed
thu: thu
fri: fri
sat: sat
sun: sun
disabled: disabled
on_time:
- logger.log:
format: 'Alarm clock'
level: 'INFO'
- dfplayer.play_mp3:
file:
!lambda |-
return id(melody).state;
# Создаем кнопки включения выключения мелодии для WEB интерфейса
button:
- platform: template
name: "play"
on_press:
- dfplayer.play_mp3:
file:
!lambda |-
return id(melody).state;
- platform: template
name: "stop"
on_press:
- dfplayer.stop
# Прописваем дисплеи и распределяем на них показания
display:
- platform: tm1637
id: tm1637_time
clk_pin:
number: D5
allow_other_uses: true
dio_pin: D4
update_interval: 1s
length: 6
lambda: |-
static int i = 0;
i++;
if ((i % 2) == 0)
it.strftime("%H.%M", id(sntp_time).now());
else
it.strftime("%H%M", id(sntp_time).now());
if ((i % 8) == 0)
it.print(5, "C.");
else
it.printf(4, "%.0f", id(temp).state);
- platform: tm1637
id: tm1637_date
clk_pin:
number: D5
allow_other_uses: true
dio_pin: D6
length: 6
update_interval: 2s
lambda: |-
it.strftime("%d.%m", id(sntp_time).now());
static int h = 0;
h++;
if ((h % 4) == 0)
it.print(5, "H");
else
it.printf(4, "%.0f", id(vlaga).state);
- platform: tm1637
id: tm1637_pres
clk_pin:
number: D5
allow_other_uses: true
dio_pin: D7
update_interval: 2s
lambda: |-
static int p = 0;
p++;
if ((p % 4) == 0)
it.print(0, "PAe5");
else
it.printf(0, "%.0f", id(pres).state);
- platform: tm1637
id: tm1637_co2
clk_pin:
number: D5
allow_other_uses: true
dio_pin: D0
update_interval: 2s
lambda: |-
static int q = 0;
q++;
if ((q % 4) == 0)
it.print(0, "CO2");
else
it.printf(0, "%.0f", id(co2).state);
# Создаем клиента sntp для получения точного времени
time:
- platform: sntp
id: sntp_time
timezone: Europe/Moscow
servers:
- 0.pool.ntp.org
- 1.pool.ntp.org
- 2.pool.ntp.org
# Создаем WEB интерфейс
web_server:
port: 80
version: 3