2022-02-10 23:10:43 +01:00
|
|
|
# Example ESPHome code to emulate stock firmware functionality while maintaining 100%
|
2019-03-06 20:10:43 +01:00
|
|
|
# local control through Home Assistant.
|
|
|
|
|
|
|
|
substitutions:
|
|
|
|
device_name: '<NODE_NAME>' # used internally.. e.g. teckin_sp20
|
|
|
|
friendly_name: '<Node Name>' # displayed in HA.. e.g. Teckin SP20
|
|
|
|
|
|
|
|
esphome:
|
|
|
|
name: ${device_name}
|
2022-02-10 23:10:43 +01:00
|
|
|
|
|
|
|
esp8266:
|
2019-03-06 20:10:43 +01:00
|
|
|
board: esp01_1m
|
|
|
|
|
|
|
|
wifi:
|
2022-02-10 23:10:43 +01:00
|
|
|
ssid: !secret wifi_ssid
|
|
|
|
password: !secret wifi_password
|
2019-03-06 20:10:43 +01:00
|
|
|
|
|
|
|
# Enable Logs from the device
|
|
|
|
logger:
|
|
|
|
|
|
|
|
# Enable Home Assistant API
|
|
|
|
api:
|
|
|
|
|
|
|
|
# Enable Over-The-Air updates
|
|
|
|
ota:
|
|
|
|
|
|
|
|
sensor:
|
|
|
|
# Power measuring sensor
|
|
|
|
- platform: hlw8012
|
|
|
|
sel_pin:
|
|
|
|
number: GPIO12
|
2021-07-28 23:56:11 +02:00
|
|
|
inverted: true
|
2019-03-06 20:10:43 +01:00
|
|
|
cf_pin: GPIO5
|
|
|
|
cf1_pin: GPIO14
|
|
|
|
current:
|
|
|
|
name: ${friendly_name} Current
|
|
|
|
power:
|
|
|
|
name: ${friendly_name} Power
|
|
|
|
id: power
|
|
|
|
filters:
|
|
|
|
# Some calibration
|
|
|
|
- multiply: 0.4545
|
|
|
|
voltage:
|
|
|
|
name: ${friendly_name} Voltage
|
|
|
|
current_resistor: 0.001 # default 0.001
|
|
|
|
voltage_divider: 910 # default 2351
|
|
|
|
change_mode_every: 3 # default 8
|
|
|
|
update_interval: 3s # default 60s
|
|
|
|
|
|
|
|
# Sum power readings over the day
|
|
|
|
- platform: total_daily_energy
|
|
|
|
name: ${friendly_name} Total Daily Energy
|
|
|
|
power_id: power
|
|
|
|
filters:
|
|
|
|
- multiply: 0.001 # convert Wh to kWh
|
|
|
|
unit_of_measurement: kWh
|
|
|
|
|
|
|
|
# Enable getting local time for total daily energy calculation
|
|
|
|
time:
|
|
|
|
- platform: homeassistant
|
|
|
|
id: homeassistant_time
|
|
|
|
|
|
|
|
status_led:
|
|
|
|
pin:
|
|
|
|
number: GPIO0 # Red LED
|
2021-07-28 23:56:11 +02:00
|
|
|
inverted: true
|
2019-03-06 20:10:43 +01:00
|
|
|
|
|
|
|
binary_sensor:
|
|
|
|
- platform: gpio
|
|
|
|
pin: GPIO13
|
|
|
|
id: button
|
|
|
|
name: ${friendly_name} Button
|
|
|
|
on_press:
|
|
|
|
- switch.toggle: relay
|
2021-07-28 23:56:11 +02:00
|
|
|
internal: true
|
2019-03-06 20:10:43 +01:00
|
|
|
|
|
|
|
switch:
|
|
|
|
- platform: gpio
|
|
|
|
id: blue_led
|
|
|
|
pin:
|
|
|
|
number: GPIO2
|
2021-07-28 23:56:11 +02:00
|
|
|
inverted: true
|
2022-02-10 23:10:43 +01:00
|
|
|
|
2019-03-06 20:10:43 +01:00
|
|
|
- platform: gpio
|
|
|
|
pin: GPIO4
|
|
|
|
id: relay
|
|
|
|
name: ${friendly_name}
|
|
|
|
# Tie Blue LED to relay
|
|
|
|
on_turn_on:
|
|
|
|
- switch.turn_on: blue_led
|
|
|
|
on_turn_off:
|
|
|
|
- switch.turn_off: blue_led
|