This is my code for the plug:
substitutions:
devicename: LSC Plug
esphome:
name: lsc_smartplug
platform: ESP8266
board: esp01_1m
binary_sensor:
- platform: gpio
pin:
number: GPIO14
mode: INPUT_PULLUP
inverted: true
name: "$devicename Power Button"
internal: true
on_press:
- switch.toggle: relay
- platform: status
name: "$devicename Status"
switch:
- platform: gpio
id: led
pin:
number: GPIO4
inverted: true
- platform: gpio
name: "$devicename"
icon: "mdi:power-plug"
pin: GPIO12
id: relay
on_turn_on:
- switch.turn_on: led
on_turn_off:
- switch.turn_off: led
wifi:
ssid: !secret ssid
password: !secret password
# Enable logging
logger:
# Enable Home Assistant API
api:
password: !secret api_ota_pwd
ota:
password: !secret api_ota_pwd