-
Notifications
You must be signed in to change notification settings - Fork 0
/
esp_rf_bridge.yaml
229 lines (211 loc) · 5.41 KB
/
esp_rf_bridge.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
substitutions:
devicename: esp_rf_bridge
display_devicename: ESP RF Bridge
esphome:
name: ${devicename}
platform: ESP8266
board: esp8285
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
fast_connect: on
reboot_timeout: 0s
power_save_mode: none
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "${devicename} Fallback Hotspot"
password: !secret fallback_password
captive_portal:
# Enable web server
web_server:
port: 80
auth:
username: !secret web_server_user
password: !secret web_server_password
# Enable logging
logger:
baud_rate: 0
uart:
tx_pin: GPIO01
rx_pin: GPIO03
baud_rate: 19200
ota:
platform: esphome
password: !secret ota_password
api:
encryption:
key: !secret hass_key
services:
- service: send_code
variables:
sync: int
low: int
high: int
code: int
then:
- rf_bridge.send_code:
sync: !lambda "return sync;"
low: !lambda "return low;"
high: !lambda "return high;"
code: !lambda "return code;"
- service: learn
then:
- rf_bridge.learn
- service: start_advanced_sniff
then:
- rf_bridge.start_advanced_sniffing
- service: stop_advanced_sniff
then:
- rf_bridge.stop_advanced_sniffing
- service: bucket_learn_on
then:
- rf_bridge.start_bucket_sniffing
# light:
# - platform: binary
# name: "${display_devicename} WiFi LED"
# id: wifi_led
# output: output_wifi_led
# internal: True
sensor:
- platform: uptime
name: "${display_devicename} Uptime"
id: uptime_seconds
- platform: wifi_signal
name: "${display_devicename} WiFi Signal"
update_interval: 300s
switch:
- platform: restart
name: "${display_devicename} Restart"
remote_receiver:
pin: 4
dump: raw
filter: 5us
tolerance: 50%
idle: 3ms
remote_transmitter:
pin: 5
carrier_duty_percent: 100%
status_led:
pin:
number: GPIO13
inverted: True
rf_bridge:
on_code_received:
- homeassistant.event:
event: esphome.rf_code_received
data:
sync: !lambda "return format_hex(data.sync);"
low: !lambda "return format_hex(data.low);"
high: !lambda "return format_hex(data.high);"
code: !lambda "return format_hex(data.code);"
- text_sensor.template.publish:
id: rf_code
state: !lambda "return format_hex(data.code);"
- if: # front door closed
condition:
lambda: |-
return data.code == 0x0094c00a;
then:
- binary_sensor.template.publish:
id: front_safety_door
state: ON
- if: # front door open
condition:
lambda: |-
return data.code == 0x94C00E;
then:
- binary_sensor.template.publish:
id: front_safety_door
state: OFF
- if: # garage closed
condition:
lambda: |-
return data.code == 0x92440A;
then:
- binary_sensor.template.publish:
id: garage_door
state: ON
- if: # garage open
condition:
lambda: |-
return data.code == 0x92440E;
then:
- binary_sensor.template.publish:
id: garage_door
state: OFF
- if: # back door closed
condition:
lambda: |-
return data.code == 0x92E60A;
then:
- binary_sensor.template.publish:
id: back_safety_door
state: ON
- if: # back door open
condition:
lambda: |-
return data.code == 0x92E60E;
then:
- binary_sensor.template.publish:
id: back_safety_door
state: OFF
on_advanced_code_received:
- homeassistant.event:
event: esphome.rf_advanced_code_received
data:
length: !lambda "return data.length;"
protocol: !lambda "return data.protocol;"
code: !lambda "return data.code;"
binary_sensor:
# - platform: status
# name: "${display_devicename} Status"
# on_state:
# then:
# - light.toggle: wifi_led
- platform: gpio
pin: GPIO00
name: "${display_devicename} Pairing Button"
- platform: template
name: "Door State: Front"
device_class: door
id: front_safety_door
- platform: template
name: "Door State: Garage"
device_class: garage_door
id: garage_door
- platform: template
name: "Door State: Back"
device_class: door
id: back_safety_door
text_sensor:
- platform: version
name: "${display_devicename} Version"
- platform: wifi_info
ip_address:
name: "${display_devicename} IP Address"
- platform: template
name: "${display_devicename} Uptime"
lambda: |-
uint32_t dur = id(uptime_seconds).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, %02u:%02u:%02u", dys, hrs, mnts, dur);
return {buffer};
icon: mdi:clock-start
- platform: template
name: "${display_devicename} Latest Code"
id: rf_code