-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathyysonoff_dual_r1.yaml
179 lines (148 loc) · 3.34 KB
/
yysonoff_dual_r1.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
# ------------------------------
# ---- Sonoff Dual R1 ----
# ------------------------------
# NOTE: THIS ONE HAS NO REAL IO!!!
# RELAYS ARE VIA SERIAL TO A CHIP
# Example: https://esphome.io/cookbook/sonoff-dual-light-switch.html
# GND GPIO1 GPIO3 3.3v GPIO0 5v
substitutions:
devicename: sonoff_dual_r1
esphome:
name: ${devicename}
platform: ESP8266
board: esp01_1m
wifi:
#power_save_mode: light # power reduced from ?.?w to ?.?w
#fast_connect: true
networks:
- ssid: !secret wifi_ssid
password: !secret wifi_password
hidden: True
manual_ip:
static_ip: !secret ip_tank_minder
gateway: !secret ip_gateway
subnet: 255.255.255.0
domain: .homelan
ap: # Enable fallback hotspot (captive portal) in case wifi connection fails
ssid: "${devicename} Hotspot"
password: !secret password
captive_portal:
#mqtt:
# broker: !secret mqtt_host
# username: !secret mqtt_username
# password: !secret mqtt_password
# reboot_timeout: 0s # Dont reboot..
# Enable logging
logger:
baud_rate: 0 # So we can use the RX and TX pins
# Enable Home Assistant API
api:
password: !secret password
reboot_timeout: 0s # Dont reboot..
ota:
password: !secret password
web_server:
port: 80
auth:
username: admin
password: !secret password
uart:
tx_pin: GPIO01
rx_pin: GPIO03
baud_rate: 19200
switch:
- platform: template
id: relay_1
turn_on_action:
if:
condition:
switch.is_off: relay_2
then:
- uart.write: [0xA0, 0x04, 0x01, 0xA1]
else:
- uart.write: [0xA0, 0x04, 0x03, 0xA1]
turn_off_action:
if:
condition:
switch.is_off: relay_2
then:
- uart.write: [0xA0, 0x04, 0x00, 0xA1]
else:
- uart.write: [0xA0, 0x04, 0x02, 0xA1]
optimistic: true
- platform: template
id: relay_2
turn_on_action:
if:
condition:
switch.is_off: relay_1
then:
- uart.write: [0xA0, 0x04, 0x02, 0xA1]
else:
- uart.write: [0xA0, 0x04, 0x03, 0xA1]
turn_off_action:
if:
condition:
switch.is_off: relay_1
then:
- uart.write: [0xA0, 0x04, 0x00, 0xA1]
else:
- uart.write: [0xA0, 0x04, 0x01, 0xA1]
optimistic: true
binary_sensor:
- platform: gpio
name: GPIO4
pin:
number: GPIO4
mode: INPUT_PULLUP
inverted: true
# id: button_1
# on_press:
# then:
# - light.toggle: light_1
- platform: gpio
name: GPIO14
pin:
number: GPIO14
mode: INPUT_PULLUP
inverted: true
# id: button_2
# on_press:
# then:
# - light.toggle: light_2
output:
- platform: template
type: binary
id: out_1
write_action:
if:
condition:
light.is_on: light_1
then:
- switch.turn_on: relay_1
else:
- switch.turn_off: relay_1
- platform: template
type: binary
id: out_2
write_action:
if:
condition:
light.is_on: light_2
then:
- switch.turn_on: relay_2
else:
- switch.turn_off: relay_2
light:
- platform: binary
name: "Dual L1"
id: light_1
output: out_1
- platform: binary
name: "Dual L2"
id: light_2
output: out_2
status_led:
pin:
number: GPIO13
inverted: yes