-
Notifications
You must be signed in to change notification settings - Fork 0
/
shelly1-detached-switch.yaml
90 lines (76 loc) · 2.07 KB
/
shelly1-detached-switch.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
substitutions:
device_name: "switch-light"
device_verbose_name: "Switch Light Detached"
esphome:
name: shelly1-detached
platform: ESP8266
board: modwifi
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
safe_mode: true
id: my_ota
password: !secret ota_password
wifi:
ssid: !secret wifi_ssid_not
password: !secret wifi_key_not
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: ${device_name}
password: !secret fallback_hotspot_password
captive_portal:
# Enable Web server (optional).
web_server:
port: 80
# Text sensors with general information.
text_sensor:
- platform: wifi_info
ip_address:
name: ${device_verbose_name} IP
# Sensors with general information.
sensor:
# Uptime sensor.
- platform: uptime
name: ${device_verbose_name} Uptime
# WiFi Signal sensor.
- platform: wifi_signal
name: ${device_verbose_name} WiFi Signal
update_interval: 60s
# Shelly 1 detached switch config with fallback in case of wifi or api fail
switch:
- platform: gpio
name: ${device_verbose_name}
pin: GPIO4
id: shelly_relay
# after reboot, keep the relay off. this prevents light turning on after a power outage
restore_mode: ALWAYS_OFF
binary_sensor:
- platform: gpio
name: ${device_verbose_name} Input
internal: true
pin:
number: GPIO5
# small delay to prevent debouncing
filters:
- delayed_on_off: 50ms
# config for state change of input button
on_press:
then:
- if:
condition:
and:
- wifi.connected:
- api.connected:
- switch.is_on: shelly_relay
# toggle smart light if wifi and api are connected and relay is on
then:
- homeassistant.service:
service: input_boolean.toggle
data:
entity_id: input_boolean.house_alarm_clock
# else, toggle relay
else:
- switch.toggle: shelly_relay
id: button