generated from esphome/esphome-project-template
-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
switchman-m5-3c.yaml
282 lines (252 loc) · 7.22 KB
/
switchman-m5-3c.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
# https://templates.blakadder.com/sonoff_SwitchMan_M5-3C.html
# These substitutions allow the end user to override certain values
substitutions:
friendly_name: 'M5-3C'
device_name: 'm5_3c'
node_name: 'm5-3c'
device_description: '3 Gang Switch (ESP32D0-MSW-T5)'
project_base: 'SONOFF'
project_name: 'Switchman M5'
project_version: '3C-80/86'
##########################################################
# Your home specific:
##########################################################
hass_device_1: light.left
hass_device_2: light.middle
hass_device_3: light.right
esphome:
name: $node_name
comment: $device_description
friendly_name: $friendly_name
# Automatically add the mac address to the name
# so you can use a single firmware for all devices
name_add_mac_suffix: true
# This will allow for (future) project identification,
# configuration and updates.
project:
name: ${project_base}.${project_name}
version: ${project_version}
esp32:
board: esp32dev
# To be able to get logs from the device via serial and api.
logger:
# API is a requirement of the dashboard import.
api:
##########################################################
# for managing bluetooth_proxy & esp32_ble_tracker
##########################################################
services:
- service: bluetooth_proxy_set_param
variables:
active: bool
then:
- lambda: |-
id(${device_name}_bluetooth_proxy).set_active(bool(active));
- service: stop_scan
then:
- esp32_ble_tracker.stop_scan
- service: start_scan
then:
- esp32_ble_tracker.start_scan
# OTA is required for Over-the-Air updating
ota:
# This should point to the public location of this yaml file.
dashboard_import:
package_import_url: github://velijv/esphome-configs/switchman-m5-3c.yaml@main
wifi:
# Set up a wifi access point using the device name above
ap:
password: "12345678"
# In combination with the `ap` this allows the user
# to provision wifi credentials to the device.
captive_portal:
##########################################################
# Most projects should not remove anything from above here
# and should just modify the name, project name/version
# and git url for the dashboard_import
##########################################################
# Sets up Bluetooth LE (Only on ESP32) to allow the user
# to provision wifi credentials to the device.
esp32_improv:
authorizer: none
# Sets up the improv via serial client for Wi-Fi provisioning.
# Handy if your device has a usb port for the user to add credentials when they first get it.
improv_serial:
next_url: https://veli.ee/esphome?device_name={{device_name}}&ip_address={{ip_address}}&esphome_version={{esphome_version}}
##########################################################
# SONOFF SWITCHMAN M5 starts here
# Enough room to fit ble_tracker and bluetooth_proxy
##########################################################
esp32_ble_tracker:
id: ${device_name}_esp32_ble_tracker
scan_parameters:
active: true
continuous: true
bluetooth_proxy:
id: ${device_name}_bluetooth_proxy
active: true
##########################################################
# Hardware config starts here
##########################################################
binary_sensor:
- platform: gpio
name: Left
id: ${device_name}_button_left
icon: mdi:format-horizontal-align-left
pin:
number: 4
inverted: true
on_click:
then:
if:
condition:
api.connected:
then:
- homeassistant.service:
service: homeassistant.toggle
data:
entity_id: $hass_device_1
- light.toggle: ${device_name}_led_left
else:
- switch.toggle: ${device_name}_switch_left
- platform: gpio
id: ${device_name}_button_center
icon: mdi:format-horizontal-align-center
name: Center
pin:
number: 0
inverted: true
on_click:
then:
if:
condition:
api.connected:
then:
- homeassistant.service:
service: homeassistant.toggle
data:
entity_id: $hass_device_2
- light.toggle: ${device_name}_led_center
else:
- switch.toggle: ${device_name}_switch_center
- platform: gpio
id: ${device_name}_button_right
icon: mdi:format-horizontal-align-right
name: Right
pin:
number: 15
inverted: true
on_click:
then:
if:
condition:
api.connected:
then:
- homeassistant.service:
service: homeassistant.toggle
data:
entity_id: $hass_device_3
- light.toggle: ${device_name}_led_right
else:
- switch.toggle: ${device_name}_switch_right
switch:
- platform: gpio
name: Left
restore_mode: RESTORE_DEFAULT_ON
id: ${device_name}_switch_left
pin:
number: 23
allow_other_uses: true
- platform: gpio
name: Center
restore_mode: RESTORE_DEFAULT_ON
id: ${device_name}_switch_center
pin:
number: 19
allow_other_uses: true
on_turn_on:
light.turn_on: ${device_name}_led_center
on_turn_off:
light.turn_off: ${device_name}_led_center
- platform: gpio
name: Right
restore_mode: RESTORE_DEFAULT_ON
id: ${device_name}_switch_right
pin:
number: 22
allow_other_uses: true
on_turn_on:
light.turn_on: ${device_name}_led_right
on_turn_off:
light.turn_off: ${device_name}_led_right
output:
- platform: ledc
pin: 18
frequency: 1000 Hz
id: red_output
- platform: ledc
pin:
number: 5
allow_other_uses: true
frequency: 1000 Hz
id: blue_output
- platform: gpio
pin:
number: 23
allow_other_uses: true
id: ${device_name}_output_led_left
- platform: gpio
pin:
number: 19
allow_other_uses: true
id: ${device_name}_output_led_center
- platform: gpio
pin:
number: 22
allow_other_uses: true
id: ${device_name}_output_led_right
light:
# RED LEDs
- platform: monochromatic
output: red_output
id: ${device_name}_led_red
name: LED (all)
default_transition_length: 500ms
restore_mode: RESTORE_DEFAULT_OFF
icon: mdi:led-on
entity_category: config
effects:
- pulse:
- strobe:
# Blue led for status
- platform: status_led
name: LED (blue)
id: ${device_name}_led_status
icon: mdi:led-outline
entity_category: config
pin:
number: 5
inverted: true
allow_other_uses: true
# individual red LEDs
- platform: binary
id: ${device_name}_led_left
name: LED (left)
output: ${device_name}_output_led_left
restore_mode: ALWAYS_OFF
icon: mdi:led-outline
entity_category: config
- platform: binary
id: ${device_name}_led_center
name: LED (center)
output: ${device_name}_output_led_center
restore_mode: ALWAYS_OFF
icon: mdi:led-outline
entity_category: config
- platform: binary
id: ${device_name}_led_right
name: LED (right)
output: ${device_name}_output_led_right
restore_mode: ALWAYS_OFF
icon: mdi:led-outline
entity_category: config