forked from mjoshd/esphome_moes-ss01-3way-light-switch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
moes_ss01_3way_light_switch.yaml
133 lines (110 loc) · 2.87 KB
/
moes_ss01_3way_light_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
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
# ##################################
# MOES SS01 3-Way Light Switch
# ##################################
# D2 GPIO04: white led (inverted)
# D1 GPIO05: red led (inverted)
# D6 GPIO12: relay
# D7 GPIO13: button (inverted)
# D5 GPIO14: power/usage sensor (inverted)
# ##################################
substitutions:
# https://esphome.io/guides/configuration-types.html#substitutions
device_name: basement_stair_lights
friendly_name: Basement Stair Lights
ip_address: !secret basement_stair_lights_ip
icon: "mdi:lightbulb"
esphome:
# https://esphome.io/components/esphome
name: ${device_name}
platform: ESP8266
board: esp01_1m
wifi:
# https://esphome.io/components/wifi
ssid: !secret wifi_ssid
password: !secret wifi_password
manual_ip:
static_ip: ${ip_address}
gateway: !secret wifi_gateway
subnet: !secret wifi_subnet
dns1: !secret wifi_dns1
# web_server:
# port: 80
# https://esphome.io/components/web_server.html
logger:
# https://esphome.io/components/logger
api:
password: !secret esphome_api_password
# https://esphome.io/components/api
ota:
password: !secret esphome_ota_password
# https://esphome.io/components/ota
status_led:
# https://esphome.io/components/status_led
pin:
number: GPIO5 # Red LED
inverted: True
binary_sensor:
- platform: gpio
# https://esphome.io/components/binary_sensor/gpio.html
pin:
number: GPIO14
inverted: True
id: sensor
name: ${friendly_name} Sensor
filters:
- delayed_off: 50ms
on_press:
- switch.turn_off: white_led
on_release:
- switch.turn_on: white_led
internal: True
- platform: gpio
# https://esphome.io/components/binary_sensor/gpio.html
pin:
number: GPIO13
inverted: True
id: button
name: ${friendly_name} Button
on_press:
- switch.toggle: relay
internal: True
switch:
- platform: gpio
# https://esphome.io/components/switch/gpio
id: white_led
name: ${friendly_name} White LED
pin:
number: GPIO4
inverted: True
restore_mode: RESTORE_DEFAULT_ON
internal: True
- platform: gpio
pin: GPIO12
id: relay
name: ${friendly_name} Relay
internal: True
# present the state of the switch in HA based on the sensor
- platform: template
# https://esphome.io/components/switch/template.html
name: ${friendly_name}
id: ${device_name}
icon: ${icon}
lambda: |-
if (id(sensor).state) {
return true;
} else {
return false;
}
# https://esphome.io/guides/automations.html#if-action
turn_on_action:
- if:
condition:
binary_sensor.is_off: sensor
then:
- switch.toggle: relay
turn_off_action:
- if:
condition:
binary_sensor.is_on: sensor
then:
- switch.toggle: relay