Skip to content

TOPGREENER TGWF115PQM

Charles Powell edited this page Aug 24, 2020 · 3 revisions

Product Details

10A, UL listed, low profile (does not obscure other socket)

Configuration

#Configuration for TGWF115PQM (Small plug)

substitutions:
  plug_name: topgreener_pqm
  # Calibration is done with calibrate_linear sensor filters below
  current_res: "0.001" # Default ESPHome value
  voltage_div: "2351" # Default ESPHome value

esphome:
  name: ${plug_name}
  platform: ESP8266
  board: esp01_1m
  includes:
    - espsense.h
  # Uses the ESPAsyncUDP library
  libraries:
    - "ESPAsyncUDP"
    - "ArduinoJson-esphomelib@5.13.3"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_pass
  fast_connect: on

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "${plug_name} Fallback Hotspot"
    password: !secret ap_pass

ota:
  safe_mode: True
  password: !secret ota_pass

captive_portal:

# Enable logging
logger:
  # level: DEBUG  # Uncomment to get logs via Wifi if connected
  baud_rate: 0 # Disable UART logging, we have no physical connections!

# Enable Home Assistant API
api:

time:
  - platform: homeassistant
    id: homeassistant_time
    
status_led:
  # Use Green LED as ESPHome's built-in status indicator
  pin:
    number: GPIO13
    inverted: False
    
binary_sensor:
  - platform: gpio
    pin:
      number: GPIO3
      inverted: True
    name: "${plug_name} Button"
    on_press:
      then:
        - switch.toggle: "relay"
        # - switch.toggle: "${plug_name}_LED_Blue"

switch:
  - platform: gpio
    name: "${plug_name} Relay"
    id: "relay"
    pin: GPIO14
    restore_mode: ALWAYS_ON
    
  # Used for Status LED above, but could be repurposed!
  # - platform: gpio
  #   name: "${plug_name} Green LED"
  #   id: "led_green"
  #   pin: GPIO13
  #   restore_mode: ALWAYS_ON

sensor:
  - platform: hlw8012
    sel_pin:
      number: GPIO12
      inverted: True
    cf_pin: GPIO04
    cf1_pin: GPIO5
    current_resistor: ${current_res}
    voltage_divider: ${voltage_div}
    current:
      name: "${plug_name} Amperage"
      unit_of_measurement: A
    voltage:
      name: "${plug_name} Voltage"
      unit_of_measurement: V
    power:
      name: "${plug_name} Wattage"
      unit_of_measurement: W
      id: "wattage"
    change_mode_every: 8
    update_interval: 3s
  - platform: total_daily_energy
    name: "${plug_name} Total Daily Energy"
    power_id: "wattage"
    filters:
        # Multiplication factor from W to kW is 0.001
        - multiply: 0.001
    unit_of_measurement: kWh

# Extra sensor to keep track of plug uptime
  - platform: uptime
    name: ${plug_name} Uptime Sensor
    
custom_component:
- lambda: |-
    auto sensor_power = new ESPSense(id(wattage), 120);
    return {sensor_power};
Clone this wiki locally