forked from konnected-io/konnected-esphome
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalarm-panel-pro-interface-local-alarm.yaml
160 lines (145 loc) · 4.89 KB
/
alarm-panel-pro-interface-local-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
####
##
## Konnected Alarm Panel Pro (ESP32) Interface with Local Alarm
## Firmware configuration for ESPHome
##
## filename: alarm-panel-pro-interface-local-alarm.yaml
## GitHub: https://github.com/konnected-io/konnected-esphome
## Buy Konnected hardware: https://konnected.io
## Help & Support: https://[email protected] (support is provided for verified buyers of Konnected hardware)
##
## This firmware enables the Konnected Alarm Panel Pro plus two Interface Modules to mirror the state of a
## traditional alarm system in Home Assistant. Leveraging ESPHome's new native Alarm Control Panel component,
## the Konnected device itself manages the alarm panel states (armed, disarmed, alarming, etc) and exposes
## individual zones to Home Assistant for use in automatoins and dashboards.
##
## Alarming logic is NOT built-in to this firmware, because we are mirroring the state of the traditional alarm
## system. Using programmable outputs on the traditional alarm panel, the Konnected panel reads the armed/disarmed
## state and alarm state from the old alarm panel, and updates accordingly.
##
## To arm/disarm the alarm, the Konnected panel actuates the relay built-in to the Interface Module to trigger an
## arm/disarm keyswitch on the traditional alarm panel.
##
## ZONE CONFIGURATION EXAMPLE
##
## Zone 1: Input sensor
## Zone 2: Input sensor
## Zone 3: Input sensor
## Zone 4: Input sensor
## Zone 5: Input sensor
## Zone 6: Input sensor
## Zone 7: Alarm state (0=ok; 1=alarm)
## Zone 8: Armed state (0=disarmed; 1=armed)
## Out 1 : Keyswitch relay
substitutions:
name: alarm-panel-pro
friendly_name: Alarm Panel Pro Interface
project_name: konnected.pro-interface-local
project_version: "0.1.0"
ethernet_type: LAN8720
sensor_debounce_time: 200ms
keyswitch_momentary_time: 200ms
blink_on_state: "true"
packages:
remote_package:
url: http://github.com/konnected-io/konnected-esphome
ref: master
refresh: 5min
files:
# Required packages:
- packages/alarm-panel-esp32-base.yaml
- packages/status-led.yaml
# Keep either the wifi.yaml or ethernet.yaml package below (not both)
# - packages/wifi.yaml
- packages/ethernet.yaml
# Default input/output configuration
- packages/alarm-panel/zone1.yaml
- packages/alarm-panel/zone2.yaml
- packages/alarm-panel/zone3.yaml
- packages/alarm-panel/zone4.yaml
- packages/alarm-panel/zone5.yaml
- packages/alarm-panel/zone6.yaml
esphome:
name: ${name}
name_add_mac_suffix: true
alarm_control_panel:
platform: template
name: Alarm Panel
id: acp1
# Trigger the physical alarm panel to toggle armed/disarmed by pressing the keyswitch
# whenever the virtual alarm panel changes to armed or disarmed state, and the traditional
# panel state does not match
on_state:
then:
- if:
condition:
or:
- and:
- lambda: 'return id(acp1)->get_state() == ACP_STATE_DISARMED;'
- binary_sensor.is_on: konnected_armed_state
- and:
- lambda: 'return id(acp1)->get_state() == ACP_STATE_ARMED_AWAY;'
- binary_sensor.is_off: konnected_armed_state
then:
- button.press:
id: alarm_keyswitch
binary_sensor:
# Monitor the alarm triggered / cleared state of the physical panel
# and update the virtual alarm panel accordingly
- id: konnected_alarm_state
pin:
number: $zone7
mode: INPUT_PULLUP
platform: gpio
filters:
- delayed_on_off: $sensor_debounce_time
on_state:
- if:
condition:
binary_sensor.is_on: konnected_alarm_state
then:
lambda: 'id(acp1).publish_state(ACP_STATE_TRIGGERED);'
else:
lambda: 'id(acp1).publish_state(ACP_STATE_DISARMED);'
- if:
condition:
lambda: return id(blink_on_state);
then:
- script.execute: blink_status_led
# Monitor the alarm armed/disaremd state of the physical panel
# and update the virtual alarm panel accordingly
- id: konnected_armed_state
pin:
number: $zone8
mode: INPUT_PULLUP
platform: gpio
filters:
- delayed_on_off: $sensor_debounce_time
on_state:
- if:
condition:
binary_sensor.is_on: konnected_armed_state
then:
lambda: 'id(acp1).publish_state(ACP_STATE_ARMED_AWAY);'
else:
lambda: 'id(acp1).publish_state(ACP_STATE_DISARMED);'
- if:
condition:
lambda: return id(blink_on_state);
then:
- script.execute: blink_status_led
output:
- id: alarm_keyswitch_output
platform: gpio
pin: $out1
button:
- platform: output
id: alarm_keyswitch
output: alarm_keyswitch_output
duration: $keyswitch_momentary_time
internal: true
api:
web_server:
include_internal: true
logger:
ota: