esphome:
  name: '<NODE_NAME>'
  platform: ESP8266
  board: esp01_1m

wifi:
  ssid: '<WIFI_SSID>'
  password: '<WIFI_PASSWORD>'

logger:
  # Disable UART logging (pins GPIO1/3 are used for button/led)
  baud_rate: 0

# Enable Home Assistant API
api:

ota:

binary_sensor:
  - platform: gpio
    name: "Teckin Button"
    pin:
      number: GPIO1
      mode:
        input: true
        pullup: true
      inverted: true
    on_press:
      - switch.toggle: relay

switch:
- platform: gpio
  id: blue_led
  pin:
    number: GPIO13
    inverted: true
- platform: gpio
  name: "Teckin Relay"
  pin: GPIO14
  id: relay
  on_turn_on:
  - switch.turn_on: blue_led
  on_turn_off:
  - switch.turn_off: blue_led

# Use red LED for connectivity status indicator
status_led:
  pin:
    number: GPIO3
    inverted: true

sensor:
  - platform: hlw8012
    sel_pin:
      number: GPIO12
      inverted: true
    cf_pin: GPIO04
    cf1_pin: GPIO05
    # Higher value gives lower watt readout
    current_resistor: 0.00221
    # Lower value gives lower voltage readout
    voltage_divider: 871
    current:
      name: "Teckin Current"
      accuracy_decimals: 2
    voltage:
      name: "Teckin Voltage"
    power:
      name: "Teckin Power"
    update_interval: 15s
