-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgosundup111.yaml
223 lines (203 loc) · 5.24 KB
/
gosundup111.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
212
213
214
215
216
217
218
219
220
221
222
223
# Gosund UP111
# Substitutions
substitutions:
# Device Names
device_name: "gosundup111"
friendly_name: "Gosund UP111"
# Icon
main_icon: "power-socket-uk"
# Default Relay State
# Aka: `restore_mode` in documentation
# Options: `RESTORE_DEFAULT_OFF`, `RESTORE_DEFAULT_ON`, `ALWAYS_ON` & `ALWAYS_OFF`
default_state: "RESTORE_DEFAULT_OFF"
# Activity State Threshold
# Threshold (number) that the device will change from `Idle` to `Active` if power is greater than or equal to
activity_threshold: "5"
# Basic Config
esphome:
name: "${device_name}"
platform: ESP8266
board: esp01_1m
name_add_mac_suffix: True
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "${device_name} Hotspot"
password: !secret ap_password
captive_portal:
web_server:
port: 80
logger:
# Enable Home Assistant API
api:
encryption:
key: !secret api_key
ota:
password: !secret ota_password
time:
- platform: sntp
id: sntp_time
# Device Specific Config
binary_sensor:
# Push Button (Toggles Relay When Pressed)
- platform: gpio
pin:
number: GPIO3
mode: INPUT_PULLUP
inverted: true
name: "${friendly_name} Button"
on_press:
- switch.toggle: relay
- platform: status
name: "${friendly_name} Server Status"
switch:
# Relay (As Switch)
- platform: gpio
name: "${friendly_name}"
icon: "mdi:${main_icon}"
pin: GPIO14
id: relay
restore_mode: "${default_state}"
on_turn_on:
- light.turn_on:
id: led
brightness: 100%
transition_length: 0s
on_turn_off:
- light.turn_off:
id: led
transition_length: 0s
sensor:
- platform: uptime
name: Uptime Sensor
id: uptime_sensor
update_interval: 60s
on_raw_value:
then:
- text_sensor.template.publish:
id: uptime_human
state: !lambda |-
int seconds = round(id(uptime_sensor).raw_state);
int days = seconds / (24 * 3600);
seconds = seconds % (24 * 3600);
int hours = seconds / 3600;
seconds = seconds % 3600;
int minutes = seconds / 60;
seconds = seconds % 60;
return (
(days ? to_string(days) + "d " : "") +
(hours ? to_string(hours) + "h " : "") +
(minutes ? to_string(minutes) + "m " : "") +
(to_string(seconds) + "s")
).c_str();
- platform: wifi_signal
name: "$friendly_name WiFi Signal Sensor"
update_interval: 60s
# Power Monitoring
- platform: hlw8012
sel_pin:
number: GPIO12
inverted: true
cf_pin: GPIO4
cf1_pin: GPIO05
change_mode_every: 3
update_interval: 3s
voltage:
name: "${friendly_name} Voltage"
id: voltage
unit_of_measurement: V
accuracy_decimals: 1
filters:
# Map from sensor -> measured value
- calibrate_linear:
- 0.0 -> 0.0
- 602.87506 -> 229.9
- 609.8 -> 232.8
power:
name: "${friendly_name} Power"
id: power
unit_of_measurement: W
accuracy_decimals: 0
filters:
# Map from sensor -> measured value
- calibrate_linear:
- 0.0 -> 1.14
- 62.06167 -> 10.93
- 1503.27161 -> 247.6
- 1599.81213 -> 263.7
- 3923.67700 -> 631.4
- 7109.50928 -> 1148.0
- 7237.0857 -> 1193.0
- 7426.71338 -> 1217.0
current:
name: "${friendly_name} Current"
id: current
unit_of_measurement: A
accuracy_decimals: 3
filters:
# Map from sensor -> measured value
- calibrate_linear:
- 0.0 -> 0.013
- 0.08208 -> 0.071
- 1.34223 -> 1.066
- 5.57170 -> 4.408
- 6.69184 -> 5.259
- 6.97187 -> 5.540
# Total daily energy sensor
- platform: total_daily_energy
name: "${friendly_name} Daily Energy"
power_id: power
filters:
# Multiplication factor from W to kW is 0.001
- multiply: 0.001
unit_of_measurement: kWh
text_sensor:
# Device Activity State
# e.g. shows as active if power reading above a certain threshold
- platform: template
name: "${friendly_name} Activity State"
icon: "mdi:${main_icon}"
lambda: |-
if (id(power).state >= $activity_threshold) {
return {"Active"};
} else {
return {"Idle"};
}
update_interval: 5s
- platform: wifi_info
ip_address:
name: "IP Address"
ssid:
name: "SSID"
bssid:
name: "BSSID"
mac_address:
name: "Mac Address"
- platform: template
name: Uptime Human Readable
id: uptime_human
icon: mdi:clock-start
# Relay State LED
output:
- platform: esp8266_pwm
id: state_led
pin:
number: GPIO1
inverted: true
light:
- platform: monochromatic
output: state_led
id: led
status_led:
pin:
number: GPIO13
inverted: True
button:
- platform: restart
name: "$device_name Restart"
- platform: safe_mode
name: "$device_name Restart (Safe Mode)"
- platform: factory_reset
name: "$device_name Factory Reset"