-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathzb-bt.yaml
278 lines (241 loc) · 5.64 KB
/
zb-bt.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
# 1. SUBSTITUTIONS (Names to be used in sensor IDs)
substitutions:
name: "slzb-06-zigbee_bluetooth"
# 2. GENERAL ESPHOME CONFIGURATION SETTINGS
## Project information
esphome:
name: "${name}"
name_add_mac_suffix: true
project:
name: SMLIGHT.SLZB-06*
version: "1.31"
on_boot:
priority: 600
then:
- switch.turn_on: zRST_gpio
- delay: 15ms
- switch.turn_off: zRST_gpio
## Board information
esp32:
board: esp32dev
flash_size: 16MB
framework:
type: arduino
## Connection to Home Assistant through API is enabled
api:
## Logger is enabled
#logger:
## OTA firmware updates are available
#ota:
## Accessible portal with control buttons is available
#web_server:
# port: 80
# local: True
## WiFi settings
#wifi:
# ssid: !secret wifi_ssid
# password: !secret wifi_password
#
# # Enable fallback hotspot (captive portal) in case wifi connection fails
# ap:
# ssid: "slzb-06 Hotspot"
# password: "slzb06"
## Enabling captive portal
# captive_portal:
# 3. EXTERNAL COMPONENTS USED
external_components:
- source: github://tube0013/esphome-stream-server-v2
dashboard_import:
package_import_url: github://smlight-tech/testesphome/zb-bt.yaml
# 4. COMMUNICATION SETTINGS
## Ethernet Connection
ethernet:
type: LAN8720
mdc_pin: GPIO23
mdio_pin: GPIO18
clk_mode: GPIO0_IN
phy_addr: 1
power_pin: GPIO16
## UART Settings
uart:
id: uart_bus
rx_pin: GPIO5
tx_pin: GPIO17
baud_rate: 115200
## Stream Server
stream_server:
uart_id: uart_bus
id: streamServer
port: 6638
## MDNS service settings
mdns:
services:
- service: "_slzb-06"
protocol: "_tcp"
port: 6638
txt:
version: 1.0
name: SMLIGHT SLZB-06
radio_type: znp
baud_rate: 115200
data_flow_control: software
# 5. BLLUETOOTH PROXY COMPONENTS
esp32_ble_tracker:
scan_parameters:
interval: 1100ms
window: 1100ms
active: true
bluetooth_proxy:
active: true
#button:
#- platform: safe_mode
# name: Safe Mode Boot
# entity_category: diagnostic
# 6. SENSORS
## Upteime information as sensor
text_sensor:
- platform: template
name: "SLZB-06 Uptime"
lambda: |-
uint32_t dur = id(uptime_s).state;
int dys = 0;
int hrs = 0;
int mnts = 0;
if (dur > 86399) {
dys = trunc(dur / 86400);
dur = dur - (dys * 86400);
}
if (dur > 3599) {
hrs = trunc(dur / 3600);
dur = dur - (hrs * 3600);
}
if (dur > 59) {
mnts = trunc(dur / 60);
dur = dur - (mnts * 60);
}
char buffer[17];
sprintf(buffer, "%ud %02uh %02um %02us", dys, hrs, mnts, dur);
return {buffer};
icon: mdi:clock-start
update_interval: 60s
## Uptime generic sensor
sensor:
- platform: uptime
id: uptime_s
update_interval: 60s
## Status of physical button - sensor
binary_sensor:
- platform: gpio
name: "Physical button status"
icon: mdi:toggle-switch
id: gpio35btn1
pin:
number: GPIO35
mode:
input: true
inverted: yes
on_press:
then:
- switch.toggle: modeSwitchTemplate
- platform: stream_server
stream_server: streamServer
name: "SLZB-06* Serial Connected"
# 7. SWITCHES
## ESP32 Restart
switch:
- platform: restart
id: coreRestart
name: "Core only restart"
## Zigbee Restart
- platform: gpio
pin: 33
id: zRST_gpio
inverted: yes
restore_mode: ALWAYS_OFF
- platform: template
name: "Zigbee Restart"
icon: mdi:toggle-switch
id: zRST
turn_on_action:
- switch.turn_on: zRST_gpio
- delay: 15ms
- switch.turn_off: zRST_gpio
## Full Restart
- platform: template
name: "Full (Core+Zigbee) Restart"
icon: mdi:toggle-switch
id: fullRST
turn_on_action:
- switch.turn_on: zRST_gpio
- delay: 15ms
- switch.turn_off: zRST_gpio
- delay: 15ms
- switch.turn_on: coreRestart
## Zigbee to flash mode switch
- platform: gpio
pin: 32
name: "Zigbee flash Mode internal"
icon: mdi:toggle-switch
id: zBSL
inverted: yes
restore_mode: ALWAYS_OFF
internal: true
- platform: template
name: "Zigbee flash Mode"
icon: mdi:cellphone-arrow-down
turn_on_action:
- script.execute: fw_update_mode
turn_off_action:
- switch.toggle: zRST
## Mode LAN/USB switch
- platform: template
name: "DEVICE MODE SWITCH (LAN|OFF / USB|ON)"
id: modeSwitchTemplate
turn_on_action:
- switch.turn_on: gpio12LED1
- switch.turn_on: gpio4Select
- switch.template.publish:
id: modeSwitchTemplate
state: ON
turn_off_action:
- switch.turn_off: gpio12LED1
- switch.turn_off: gpio4Select
- switch.template.publish:
id: modeSwitchTemplate
state: OFF
- platform: gpio
name: "DEVICE MODE SWITCH (LAN|OFF / USB|ON)"
restore_mode: ALWAYS_OFF
icon: mdi:toggle-switch
internal: true
id: gpio4Select
pin:
number: GPIO4
### LEDs swithces
- platform: gpio
name: "LED - device mode (Blue)"
restore_mode: ALWAYS_OFF
icon: mdi:toggle-switch
id: gpio12LED1
pin:
number: GPIO12
- platform: gpio
name: "LED - power (Yellow)"
restore_mode: ALWAYS_ON
icon: mdi:toggle-switch
id: gpio14LED2
pin:
number: GPIO14
# 8. SCRIPTS
script:
- id: fw_update_mode
then:
- switch.turn_on: zBSL
- delay: 1s
- switch.turn_on: zRST_gpio
- delay: 1s
- switch.turn_off: zRST_gpio
- logger.log: "Wait 1 seconds for Zigbee chip to be ready"
- delay: 1s
- switch.turn_off: zBSL
- logger.log: "Update Zigbee with your Z-Stack firmware now!"