substitutions:
device_name: gosund-sp1
friendly_name: Gosund SP1
device_description: Gosund SP01 Smart Plug
sp1_current_resistor: "0.00221"
sp1_voltage_divider: "871"
red_led_pin: GPIO13
blue_led_pin: GPIO1
esphome:
name: ${device_name}
comment: ${device_description}
platform: ESP8266
board: esp8285
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
ap:
captive_portal:
logger:
api:
encryption:
key: !secret encryption_key
ota:
password: !secret ota_password
web_server:
port: 80
time:
- platform: homeassistant
id: homeassistant_time
text_sensor:
- platform: version
name: ${friendly_name} Version
- platform: wifi_info
ip_address:
name: ${friendly_name} IP Address
sensor:
- platform: uptime
name: ${friendly_name} Uptime
- platform: wifi_signal
name: ${friendly_name} Wifi Signal
update_interval: 60s
- platform: hlw8012
sel_pin:
number: GPIO12
inverted: true
cf_pin: GPIO04
cf1_pin: GPIO05
current_resistor: ${sp1_current_resistor}
voltage_divider: ${sp1_voltage_divider}
change_mode_every: 8
update_interval: 10s
current:
name: ${friendly_name} Energy Current
unit_of_measurement: A
accuracy_decimals: 2
voltage:
name: ${friendly_name} Energy Voltage
unit_of_measurement: V
accuracy_decimals: 1
power:
id: power
name: ${friendly_name} Energy Power
unit_of_measurement: W
accuracy_decimals: 0
- platform: total_daily_energy
name: ${friendly_name} Daily Energy Usage
power_id: power
filters:
- multiply: 0.001
unit_of_measurement: kWh
binary_sensor:
- platform: gpio
name: ${friendly_name} Power Button
id: button
pin:
number: GPIO3
inverted: true
on_press:
- switch.toggle: relay
switch:
- platform: restart
name: ${friendly_name} Restart Switch
- platform: gpio
id: relay
name: ${friendly_name} Power Switch
pin: GPIO14
restore_mode: RESTORE_DEFAULT_OFF
on_turn_on:
- light.turn_on: led
on_turn_off:
- light.turn_off: led
output:
- platform: esp8266_pwm
id: state_led
pin:
number: ${blue_led_pin}
inverted: true
light:
- platform: monochromatic
output: state_led
id: led
status_led:
pin:
number: ${red_led_pin}
inverted: true