-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathteckin_sp20.yaml
140 lines (114 loc) · 3.23 KB
/
teckin_sp20.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
# ##################################
# Teckin SP20 Plug w/ power monitoring
# ##################################
# D3 GPIO0 Red LED (inverted)
# D4 GPIO2 Blue LED (inverted)
# D2 GPIO4 Relay
# D1 GPIO5 HLW8012 CF Pin
# D6 GPIO12 HLW8012 SEL Pin (inverted)
# D7 GPIO13 Button (inverted)
# D5 GPIO14 HLW8012 CF1 Pin
# ##################################
substitutions:
# https://esphome.io/guides/configuration-types.html#substitutions
device_name: teckin_sp20 # used internally.. e.g. living_room_lamp
friendly_name: Teckin SP20 # displayed in HA.. e.g. Living Room Lamp
ip_address: !secret teckin_sp20_ip
switch_icon: "mdi:flash-circle"
sensor_icon: "mdi:eye"
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://esphomelib.com/esphomeyaml/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
sensor:
- platform: hlw8012
# https://esphome.io/components/sensor/hlw8012.html
# current, power, voltage can all use sensor options https://esphome.io/components/sensor/#config-sensor
sel_pin:
number: GPIO12
inverted: True
cf_pin: GPIO5
cf1_pin: GPIO14
current:
name: ${friendly_name} Current
icon: ${sensor_icon}
power:
name: ${friendly_name} Power
id: ${device_name}_power
icon: ${sensor_icon}
filters:
- multiply: 0.4545
voltage:
name: ${friendly_name} Voltage
icon: ${sensor_icon}
current_resistor: 0.001 # default 0.001
voltage_divider: 910 # default 2351
change_mode_every: 3 # default 8
update_interval: 3s # default 60s
- platform: total_daily_energy
# https://esphome.io/components/sensor/total_daily_energy.html
name: ${friendly_name} Total Daily Energy
power_id: ${device_name}_power
icon: ${sensor_icon}
filters:
- multiply: 0.001 # convert Wh to kWh
unit_of_measurement: kWh
time:
- platform: homeassistant
# https://esphome.io/components/time
id: homeassistant_time
status_led:
# https://esphome.io/components/status_led
pin:
number: GPIO0 # Red LED
inverted: True
binary_sensor:
- 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: blue_led
pin:
number: GPIO2
inverted: True
- platform: gpio
# https://esphome.io/components/switch/gpio
pin: GPIO4
name: ${friendly_name}
icon: ${switch_icon}
id: relay
# Tie Blue LED to relay
on_turn_on:
- switch.turn_on: blue_led
on_turn_off:
- switch.turn_off: blue_led