devices.esphome.io

Teckin SP20

Teckin SP20

Device Type: plug
Electrical Standard: us
Board: esp8266

Amazon Link

GPIO Pinout

PinFunction
GPIO0Status LED - Red
GPIO12sel_pin hlw8012
GPIO5cf_pin hlw8012
GPIO14cf1_pin hlw8012
GPIO2Status LED - Blue
GPIO13Button
GPIO4Relay

Alternate GPIO Pinout

Unit from 2018/April (Amazon) had a diffent pinout. Visually, the QR code was on the "Live" plug side, and programming pins were slighlty different layout.

Worth a try if standard pin out isn't working properly (relay will constantly click due sel_pin difference)

PinFunction
GPIO0Status LED - Red
GPIO3sel_pin hlw8012
GPIO5cf_pin hlw8012
GPIO14cf1_pin hlw8012
GPIO15Status LED - Blue
GPIO13Button
GPIO12Relay

Basic configuration below assumes standard pinout, update accordingly if using alternate pinout.

Basic Configuration

# Basic Config
substitutions:
device_name: sp20
friendly_name: SP20
ip_address: <assigned static ip address for this device>
esphome:
name: ${device_name}
ESP8266:
board: esp01_1m
restore_from_flash: true
# OTA flashing
ota:
- platform: esphome
wifi: # Your Wifi network details
# Enable fallback hotspot in case wifi connection fails
ap:
# Enabling the logging component
logger:
# Enable Home Assistant API
api:
# Enable the captive portal
captive_portal:
time:
- platform: homeassistant
id: homeassistant_time
sensor:
- platform: hlw8012
sel_pin:
number: GPIO12
inverted: True
cf_pin: GPIO5
cf1_pin: GPIO14
current:
name: ${friendly_name} Current
power:
name: ${friendly_name} Power
id: power_monitor_value
filters:
- lambda: return (x / 2.2);
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
- platform: total_daily_energy
# https://esphome.io/components/sensor/total_daily_energy.html
name: ${friendly_name} Total Daily Energy
power_id: power_monitor_value
filters:
- multiply: 0.001 # convert Wh to kWh
unit_of_measurement: kWh
- platform: uptime
name: ${friendly_name} Uptime
status_led:
pin:
number: GPIO0 # Red LED
inverted: True
output:
- platform: esp8266_pwm
id: blue_led_output
pin:
number: GPIO2
inverted: True
light:
- platform: monochromatic
name: ${friendly_name} Blue LED
output: blue_led_output
id: blue_led
default_transition_length: 1ms # default 1s
internal: True
binary_sensor:
- platform: gpio
pin:
number: GPIO13
id: button
name: ${friendly_name} Button
on_press:
- switch.toggle: relay_template
internal: True
switch:
- platform: gpio
pin: GPIO4
id: relay
- platform: template
# https://esphome.io/components/switch/template.html
name: ${friendly_name}
id: relay_template
lambda: |-
if (id(relay).state) {
return true;
} else {
return false;
}
turn_on_action:
- light.turn_on: blue_led
- switch.turn_on: relay
turn_off_action:
- light.turn_off: blue_led
- switch.turn_off: relay
Edit this page on GitHub