generated from esphome/esphome-project-template
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathshelly-uni-doorbell.yaml
211 lines (194 loc) · 4.54 KB
/
shelly-uni-doorbell.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
substitutions:
name: shelly-uni-doorbell
friendly_name: Shelly UNI Doorbell
del: 600ms
del2: 500ms
globals:
- id: chime
type: bool
restore_value: true
initial_value: 'true'
esphome:
name: $name
comment: Shelly Uni Doorbell
name_add_mac_suffix: true
# This will allow for (future) project identification,
# configuration and updates.
project:
name: cpyarger.shelly-uni-doorbell
version: "1.0"
esp8266:
board: esp01_1m
dashboard_import:
package_import_url: github://cpyarger/esphome-templates/shelly-uni-doorbell.yaml@main
# Enable logging
logger:
api:
# Enable Home Assistant API
ota:
wifi:
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "$friendly_name Fallback"
password: "12345678"
captive_portal:
web_server:
port: 80
switch:
- platform: gpio
pin:
number: 15
inverted: false
name: "$friendly_name Relay"
internal: true
id: relay
icon: mdi:alarm-bell
- platform: restart
name: "$friendly_name Restart"
- platform: template
name: "$friendly_name Chime Active"
id: chime_active
restore_state: false
turn_on_action:
- globals.set:
id: chime
value: 'true'
turn_off_action:
- globals.set:
id: chime
value: 'false'
lambda: |-
return id(chime);
- platform: template
name: "Ring Forever"
id: ring_forever
turn_on_action:
lambda: |-
id(some_binary_sensor).publish_state(true);
turn_off_action:
lambda: |-
id(some_binary_sensor).publish_state(false);
lambda: |-
if (id(some_binary_sensor).state) {
return true;
} else {
return false;
}
- platform: gpio
pin:
number: 4
inverted: false
name: "$friendly_name Relay"
internal: true
id: relay_2
icon: mdi:alarm-bell
- platform: restart
name: "$friendly_name Restart"
binary_sensor:
- platform: gpio
pin:
number: 12
inverted: true
name: "$friendly_name Front"
filters:
# Small filter, to debounce the button press.
- delayed_on: 25ms
- delayed_off: 25ms
on_press:
# Only turn on the chime when it is active.
then:
if:
condition:
- switch.is_on: chime_active
then:
- switch.turn_on: relay
- switch.turn_on: relay_2
on_release:
# On release, turn of the chime.
- switch.turn_off: relay
- switch.turn_off: relay_2
- platform: gpio
pin:
number: 13
inverted: true
name: "$friendly_name Side"
filters:
# Small filter, to debounce the button press.
- delayed_on: 25ms
- delayed_off: 25ms
on_press:
# Only turn on the chime when it is active.
then:
if:
condition:
- switch.is_on: chime_active
then:
- switch.turn_on: relay
- switch.turn_on: relay_2
on_release:
# On release, turn of the chime.
- switch.turn_off: relay
- switch.turn_off: relay_2
- platform: template
id: some_binary_sensor
internal: true
on_press:
then:
- script.execute: ding_forever
on_release:
- script.stop: ding_forever
- switch.turn_off: relay
button:
- platform: template
name: "Ding $friendly_name"
icon: mdi:alarm-bell
on_press:
- logger.log: Testing Doorbell
- script.execute: ding
- platform: template
name: "Double Ding $friendly_name"
icon: mdi:alarm-bell
on_press:
- logger.log: Testing Doorbell
- script.execute: double_ding
script:
- id: ding
then:
- switch.turn_on: relay
- delay: ${del}
- switch.turn_off: relay
- id: ding_forever
then:
while:
condition:
lambda: |-
return true;
then:
- switch.turn_on: relay
- switch.turn_on: relay_2
- delay: ${del2}
- switch.turn_off: relay
- switch.turn_off: relay_2
- delay: ${del2}
- id: double_ding
then:
- switch.turn_on: relay
- switch.turn_on: relay_2
- delay: ${del2}
- switch.turn_off: relay
- switch.turn_off: relay_2
- delay: ${del2}
- switch.turn_on: relay
- switch.turn_on: relay_2
- delay: ${del2}
- switch.turn_off: relay
- switch.turn_off: relay_2
sensor:
- platform: adc
pin: GPIO17
name: "$friendly_name ADC"
update_interval: 60s
status_led:
pin:
number: GPIO0
inverted: true