-
Notifications
You must be signed in to change notification settings - Fork 1
/
mcu-nspanel-office-r.yaml
325 lines (292 loc) · 8.41 KB
/
mcu-nspanel-office-r.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
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
substitutions:
device: nspanel-office-r
name: Office R NSPanel
name_short: Office R
comment: "Office R NSPanel"
panel_recv_topic: "tele/${device}/RESULT"
panel_send_topic: "cmnd/${device}/CustomSend"
tft_url: !secret tft_url
esphome:
name: mcu-${device}
comment: ${comment}
esp32:
board: nodemcu-32s
framework:
type: esp-idf
external_components:
- source:
type: git
url: https://github.com/sairon/esphome-nspanel-lovelace-ui
ref: dev
components: [nspanel_lovelace]
- source: components
packages:
common: !include common/common.yaml
api:
# https://github.com/granadaxronos/120-SONG_NOKIA_RTTTL_RINGTONE_PLAYER_FOR_ARDUINO_UNO/blob/master/RTTTL_PLAYER/songs.h
#
# stupnovane:d=4,o=6,b=180:c,e,g
# help:d=4,o=6,b=100:f,8p,f,8p,f,8p,f,8p,f,8p,f,8p,f,8p,f,8p,f,8p,f
# gate_opening:d=16,o=5,b=160:a, 8p, a
# fireplace_attention:d=16,o=5,b=160:a, 8p, g, 16p, c
services:
- service: play_rtttl
variables:
song: string
then:
- rtttl.play:
rtttl: !lambda 'return song;'
- service: notify
variables:
heading: string
message: string
song: string
then:
- lambda: 'id(nspanel_id).send_custom_command("notify~" + heading + "~" + message);'
- rtttl.play:
rtttl: !lambda 'return song;'
- delay: 10s
- lambda: 'id(nspanel_id).send_custom_command("notify~~");'
- service: update_tft
then:
- lambda: |-
id(nspanel_id).upload_tft("${tft_url}");
- service: upload_tft
variables:
url: string
then:
- lambda: |-
id(nspanel_id).upload_tft(url);
# Service to send a command directly to the display. Useful for testing
- service: send_command
variables:
cmd: string
then:
- lambda: "id(nspanel_id).send_custom_command(cmd.c_str());"
# Service to pusblish to mqtt used for refreshin the panel
- service: publish_to_recv_topic
variables:
cmd: string
then:
- mqtt.publish:
topic: $panel_recv_topic
payload: !lambda "return cmd;"
# Service to send a command wake the screen
- service: wake
then:
- lambda: 'id(nspanel_id).send_custom_command("wake");'
# Service to send a command to show screensaver (some of the values are hardcoded)
- service: show_screensaver
then:
- mqtt.publish:
topic: $panel_recv_topic
payload: '{"CustomRecv":"event,sleepReached,cardGrid"}'
# Service to navigate to screen
- service: navigate_to_page
variables:
page: string
then:
- mqtt.publish_json:
topic: $panel_recv_topic
payload: |-
root["CustomRecv"] = "event,buttonPress2,navigate." + page + ",button";
# Service to send a command disable screensaver
- service: disable_screensaver
then:
- lambda: 'id(nspanel_id).send_custom_command("timeout~0");'
# Service to send a command enabled screensaver
- service: enable_screensaver
then:
- lambda: 'id(nspanel_id).send_custom_command("timeout~20");'
# Service to send a command wake the screen
- service: dim_0_to_100
variables:
intensity: string
then:
- lambda: 'id(nspanel_id).send_custom_command("dimmode~"+intensity+"~100");'
# Service to send a command To show the screen of a specific like
- service: show_entity
variables:
entity: string
title: string
then:
- lambda: 'id(nspanel_id).send_custom_command("pageType~popupLight~" + title + "~" + entity);'
# Service to send a command To show the screen of a specific like
- service: notify_on_screensaver
variables:
line1: string
line2: string
then:
- lambda: 'id(nspanel_id).send_custom_command("notify~" + line1 + "~" + line2);'
- rtttl.play: "short:d=4,o=5,b=100:16e6"
# Service to send a command To show the screen of a specific like
# interaction of the buttons are on implemented yet
- service: notify_fullscreen
variables:
title: string
description: string
button1: string
button2: string
time_secs: string
then:
# show notification screen
- lambda: 'id(nspanel_id).send_custom_command("pageType~popupNotify");'
# set values on notification screen
# color defined as number created in binary and converted to decimal (rrrrggggbbbbaaaa)
- lambda: 'id(nspanel_id).send_custom_command("entityUpdateDetail~id~"+ title + "~65535~" + button1 +"~3840~" + button2 + "~61440~" + description + "~65535~" + time_secs);'
- rtttl.play: "scale_up:d=32,o=5,b=100:c,c#,d#,e,f#,g#,a#,b"
uart:
id: display_uart
tx_pin: 16
rx_pin: 17
baud_rate: 115200
mqtt:
id: mqtt_client
broker: !secret mqtt_ip
username: !secret mqtt_username
password: !secret mqtt_password
discovery: false
nspanel_lovelace:
id: nspanel_id
mqtt_recv_topic: $panel_recv_topic
mqtt_send_topic: $panel_send_topic
time:
- platform: homeassistant
id: ha_time
timezone: Europe/Bratislava
binary_sensor:
# - platform: gpio
# name: ${name} Left Button
# pin:
# number: 14
# inverted: true
# on_click:
# - switch.toggle: relay_1
# - platform: gpio
# name: ${name} Right Button
# pin:
# number: 27
# inverted: true
# # on_click:
# # - switch.toggle: relay_2
# on_click:
# - homeassistant.service:
# service: light.toggle
# data:
# entity_id: light.office_r_desk_strip
- platform: gpio
name: ${name} Left Button
pin:
number: 14
inverted: true
on_click:
- homeassistant.service:
service: light.toggle
data:
entity_id: light.office_r_desk_strip
- mqtt.publish_json:
topic: $panel_recv_topic
payload: |-
root["CustomRecv"] = "event,buttonPress1,navigate.cardGrid_main,button";
# - lambda: 'id(nspanel_id).send_custom_command("event,buttonPress1,navigate.cardGrid_main,button");'
- platform: gpio
name: ${name} Right Button
pin:
number: 27
inverted: true
on_click:
- light.toggle: light_1
- mqtt.publish_json:
topic: $panel_recv_topic
payload: |-
root["CustomRecv"] = "event,buttonPress2,navigate.cardGrid_main,button";
# - lambda: 'id(nspanel_id).send_custom_command("event,buttonPress2,navigate.cardGrid_main,button");'
output:
- platform: ledc
id: buzzer_out
pin:
number: 21
- id: relay_1
platform: gpio
pin:
number: 22
# - id: relay_2
# platform: gpio
# pin:
# number: 19
light:
- platform: esp32_rmt_led_strip
name: "${name_short} Presence Light"
id: neo
rgb_order: GRB
pin: 23
num_leds: 3
rmt_channel: 0
chipset: SK6812
effects:
- pulse:
- pulse:
name: "Fast Pulse"
transition_length: 1s
update_interval: 1s
- pulse:
name: "Slow Pulse"
transition_length: 2s # defaults to 1s
update_interval: 2s
- platform: binary
name: ${name_short} Light
id: light_1
output: relay_1
# # - platform: binary
# # name: ${name_full} Relay 2
# # output: relay_2
switch:
# - platform: gpio
# name: ${name_short} Light
# id: relay_1
# pin:
# number: 22
- platform: gpio
# name: ${name_full} Relay 2
id: relay_2
pin:
number: 19
- platform: gpio
name: ${name} Screen Power
id: screen_power
entity_category: config
pin:
number: 4
inverted: true
restore_mode: ALWAYS_ON
rtttl:
id: buzzer
output: buzzer_out
sensor:
- platform: adc
id: ntc_source
pin: 38
update_interval: 5min
attenuation: 12db
- platform: resistance
id: resistance_sensor
sensor: ntc_source
configuration: DOWNSTREAM
resistor: 11.2kOhm
- platform: ntc
id: temperature
sensor: resistance_sensor
calibration:
b_constant: 3950
reference_temperature: 22°C
reference_resistance: 10kOhm
name: "${name_short} Temperature"
- platform: template
id: room_temperature_id
# esp32_ble_tracker:
# text_sensor:
# - platform: ble_scanner
# name: "${name_short} BLE Scanner"
# esp32_ble_beacon:
# type: iBeacon
# uuid: '6d68252f-2e6f-b5b9-965f-43c0a3713880'