-
Notifications
You must be signed in to change notification settings - Fork 2
/
esp-kyo-alarm.yaml
276 lines (261 loc) · 6.9 KB
/
esp-kyo-alarm.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
substitutions:
name: esp-kyo-alarm-generic
friendly_name: "ESP KYO Alarm Generic"
esphome:
name: ${name}
platform: ESP8266
board: d1_mini
comment: "ESP KYO alarm integration"
includes:
- kyo-alarm/
# Global values
globals:
# Arm home partitions (bitfield, LSB first) as configured in alarm (IDD)
- id: armed_home
type: uint8_t
restore_value: no
initial_value: '0x1'
# Arm night partitions (bitfield, LSB first) as configured in alarm (IID)
- id: armed_night
type: uint8_t
restore_value: no
initial_value: '0x3'
# Arm away partitions (bitfield, LSB first) as configured in alarm (III)
- id: armed_away
type: uint8_t
restore_value: no
initial_value: '0x7'
# Disable UART logging
logger:
baud_rate: 0
level: INFO
# Encrypted native API
api:
encryption:
key: !secret api_encryption_key
# Enable Over-the-Air flash
ota:
password: !secret ota_password
# Enable WiFi, keep captive portal disabled
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Reference time
time:
- platform: homeassistant
id: ha_time
timezone: Europe/Rome
on_time_sync:
then:
lambda: |-
KyoAlarmComponent* k = (KyoAlarmComponent*) kyo;
k->onTimeSync(id(ha_time).now());
# Configure UART link to KYO alarm
uart:
id: uart_bus
tx_pin: GPIO5
rx_pin: GPIO4
baud_rate: 9600
data_bits: 8
parity: EVEN
# Restart buttons
button:
- platform: restart
name: "${friendly_name} Restart"
- platform: safe_mode
name: "${friendly_name} Restart (Safe Mode)"
disabled_by_default: true
# Custom Kyo component
custom_component:
- lambda: |-
auto kyo = new KyoAlarmComponent(id(uart_bus));
App.register_component(kyo);
return {kyo};
components:
- id: kyo
# Text sensors
text_sensor:
# Alarm status
- platform: custom
lambda: |-
KyoAlarmComponent* k = (KyoAlarmComponent*) kyo;
return {k->alarmStatusSensor};
text_sensors:
- id: kyo_alarm_status
name: "Alarm Status"
icon: "mdi:shield"
# Model and firmware version
- platform: custom
lambda: |-
KyoAlarmComponent* k = (KyoAlarmComponent*) kyo;
return {k->modelSensor, k->firmwareSensor};
text_sensors:
- id: kyo_model
name: "Model"
icon: "mdi:shield-home"
entity_category: "diagnostic"
- id: kyo_firmware
name: "Firmware"
icon: "mdi:memory"
entity_category: "diagnostic"
# Generic sensors
sensor:
# Warning and tamper flags (used internally)
- platform: custom
lambda: |-
KyoAlarmComponent* k = (KyoAlarmComponent*) kyo;
return {k->warningSensor, k->tamperSensor};
sensors:
- id: kyo_warning
name: "Warning flags"
internal: true
- id: kyo_tamper
name: "Tamper flags"
internal: true
# Binary sensors
binary_sensor:
# Zones status
- platform: custom
lambda: |-
KyoAlarmComponent* k = (KyoAlarmComponent*) kyo;
return {&k->zoneSensor[0], &k->zoneSensor[1],
&k->zoneSensor[2], &k->zoneSensor[3]};
binary_sensors:
- id: kyo_zone1
name: "Zone 1"
device_class: "motion"
- id: kyo_zone2
name: "Zone 2"
device_class: "window"
- id: kyo_zone3
name: "Zone 3"
device_class: "door"
- id: kyo_zone4
name: "Zone 4"
device_class: "garage_door"
# Warnings
# 00000001 - Mains failure
# 00000010 - Missing BPI
# 00000100 - Fuse warning
# 00001000 - Low battery
# 00010000 - Telephone line
# 00100000 - Default code
# 01000000 - Wireless warning
- platform: template
id: kyo_warn_mains
name: "Mains failure"
device_class: "problem"
lambda: |-
return((static_cast<uint8_t>(id(kyo_warning).state) & 0x01) > 0);
- platform: template
id: kyo_warn_bpi
name: "Missing BPI"
device_class: "problem"
lambda: |-
return((static_cast<uint8_t>(id(kyo_warning).state) & 0x02) > 0);
- platform: template
id: kyo_warn_fuse
name: "Fuse warning"
device_class: "problem"
lambda: |-
return((static_cast<uint8_t>(id(kyo_warning).state) & 0x04) > 0);
- platform: template
id: kyo_warn_batt
name: "Low battery"
device_class: "problem"
lambda: |-
return((static_cast<uint8_t>(id(kyo_warning).state) & 0x08) > 0);
- platform: template
id: kyo_warn_phone
name: "Telephone line"
device_class: "problem"
lambda: |-
return((static_cast<uint8_t>(id(kyo_warning).state) & 0x10) > 0);
- platform: template
id: kyo_warn_code
name: "Default code"
device_class: "problem"
lambda: |-
return((static_cast<uint8_t>(id(kyo_warning).state) & 0x20) > 0);
- platform: template
id: kyo_warn_wireless
name: "Wireless warning"
device_class: "problem"
lambda: |-
return((static_cast<uint8_t>(id(kyo_warning).state) & 0x40) > 0);
# Tampers
# 00000100 - Zone tamper
# 00001000 - False key
# 00010000 - BPI tamper
# 00100000 - System tamper
# 01000000 - Jam
# 10000000 - Wireless tamper
- platform: template
id: kyo_tamp_zone
name: "Zone tamper"
device_class: "tamper"
lambda: |-
return((static_cast<uint8_t>(id(kyo_tamper).state) & 0x04) > 0);
- platform: template
id: kyo_tamp_key
name: "False key"
device_class: "tamper"
lambda: |-
return((static_cast<uint8_t>(id(kyo_tamper).state) & 0x08) > 0);
- platform: template
id: kyo_tamp_bpi
name: "BPI tamper"
device_class: "tamper"
lambda: |-
return((static_cast<uint8_t>(id(kyo_tamper).state) & 0x10) > 0);
- platform: template
id: kyo_tamp_sys
name: "System tamper"
device_class: "tamper"
lambda: |-
return((static_cast<uint8_t>(id(kyo_tamper).state) & 0x20) > 0);
- platform: template
id: kyo_tamp_jam
name: "Jam"
device_class: "tamper"
lambda: |-
return((static_cast<uint8_t>(id(kyo_tamper).state) & 0x40) > 0);
- platform: template
id: kyo_tamp_wireless
name: "Wireless tamper"
device_class: "tamper"
lambda: |-
return((static_cast<uint8_t>(id(kyo_tamper).state) & 0x80) > 0);
# Switches
switch:
# Zones bypass switch
- platform: custom
id: zoneSwitches
lambda: |-
for(int i = 0; i < 32; i++) {
auto s = new KyoZoneSwitch(i);
App.register_component(s);
((KyoAlarmComponent*) kyo)->zoneSwitches.push_back(s);
}
return {((KyoAlarmComponent*) kyo)->zoneSwitches};
switches:
- id: kyo_zone1_sw
name: "Zone 1"
icon: "mdi:motion-sensor"
entity_category: "config"
inverted: true
- id: kyo_zone2_sw
name: "Zone 2"
icon: "mdi:leak"
entity_category: "config"
inverted: true
- id: kyo_zone3_sw
name: "Zone 3"
icon: "mdi:leak"
entity_category: "config"
inverted: true
- id: kyo_zone4_sw
name: "Zone 3"
icon: "mdi:leak"
entity_category: "config"
inverted: true