[Request] KMC Energy Monitor Plug

I’m looking for help creating a yaml config for this plug. I have one already that I’ve flashed using Tuya Convert and put tasmota on it. It seems to report the power correctly – however I want to consolidate all my devices on ESPHome instead of Tasmota.

The specific part I need clarification on is the power monitoring aspect

KMC Energy Monitor Plug
Amazon Link

Tasmota Config:

Thanks for pointing me in the right direction @nickrout!

Here’s my initial take:

esphome:
  name: kmc01
  platform: ESP8266
  board: esp01_1m

wifi:
  ssid: "name"
  password: "password"

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "KMC01 Fallback Hotspot"
    password: "password"

captive_portal:

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:

web_server:
  port: 80

sensor:
  - platform: hlw8012
    sel_pin: GPIO12
    cf_pin: GPIO4
    cf1_pin: GPIO5
    current:
      name: "KMC01 Current"
    voltage:
      name: "KMC01 Voltage"
    power:
      name: "KMC01 Power"
    update_interval: 60s
    
  - platform: wifi_signal
    name: "KMC01 WiFi signal"
    update_interval: 60s

  - platform: uptime
    name: "KMC01 Uptime"

text_sensor:
  - platform: version
    name: "KMC01 ESPHome Version"  


## not sure if the switches need to be inverted or not yet. 
switch:
  - platform: gpio
    name: "KMC01 relay 1"
    pin: GPIO15
    # inverted: yes
    id: relay1
  - platform: gpio
    name: "KMC01 relay 2"
    pin: GPIO13
    # inverted: yes
    id: relay2
  - platform: gpio
    name: "KMC01 relay 3"
    pin: GPIO14
    # inverted: yes
    id: relay3

binary_sensor:
  - platform: gpio
    pin:
      number: GPIO16
      mode: INPUT_PULLUP
      inverted: False
    name: "KMC01 button"
    on_press:
      - switch.toggle: relay1
      - switch.toggle: relay2
      - switch.toggle: relay3
    on_double_click:
      min_length: 50ms
      max_length: 350ms
      then:
      - switch.turn_off: relay1
      - switch.turn_off: relay2
      - switch.turn_off: relay3

  - platform: status
    name: "KMC01 Status"


status_led:
  pin:
    number: GPIO1
    inverted: yes

If anyone is brave enough to try it, please let me know if it works for you!

If not, I’ll do it this weekend and report back.

When you get it working please post the details here

EDIT the original site has changed to esp-devices.com.

esphome-configs.io should NOT be visited, it is one of those hackfests.

1 Like

I just tried it and it seems to mostly work. Relays 1, 2, and 3 all turn on and off as expected. Relays 1 and 2 show a status (OFF, ON) but relay 3 shows nothing. Nothing showing for button, status, or esphome version. Haven’t tested a load that shows anything with current or power yet. Only a lamp with an LED bulb.

I stripped the config down a bit and it seems to be working. I removed the actions on the button as well as removing the version, wifi, and uptime sensors.

Screen Shot 2020-03-19 at 1.33.50 PM

1 Like

thanks for being brave! I’m still waiting for my second one to arrive so I don’t mess with the one in “production” lol

so you’re saying the energy sensor, web interface, and relays all work now? Are you going to try and add in the actions on the button or leave as is?

Honestly, I don’t have any purpose for the button. This is for my washing machine. I needed a multi-outlet so I could also plug in another ESP8266 sensor for the dryer.

The energy sensor, web interface, and all relays work. I’ve got a few automations set in hass to notify laundry cycles.

It’s all good – I’d be very interested in seeing that automation setup so I can use it for my dishwasher!

I followed Phil Hawthorne’s guide. I haven’t tested yet since we don’t have any laundry ready.

I tried that code. Looks like it is working but it shows way to high voltage - in my case 134.7 V
Any idea how to fix that?

Thanks for trying it out! I realized the same thing.

We need to add a sensor filter in esphome to calibrate the energy monitor sensor. Unfortunately, I don’t have a kill-a-watt or other power meter and shipping times have been slow here.

Check the detailed process here:

Thank you - I will check.
Button does not work properly I think.

Do note that the web server uses quite a lot of resources and can cause problems. And in any case, it is of little value apart from testing. Web Server Component — ESPHome

The web_server component creates a simple web server on the node that can be accessed through any browser and a simple REST API. Please note that enabling this component will take up a lot of memory and can lead to problems, especially on the ESP8266.

Anyone have final code? did everything work?

I saw this plug is on slickdeals 2 for $10 with the coupon code if you’re trying to pick up more

Hey Jerry,

The code I originally posted works fine on my plugs, I haven’t calibrated the energy consumption part but mostly use the plugs just for toggling on/off the relays with Home Assistant and don’t really care about accurate energy consumption. You can still use it to tell when something is on/off - like my desktop computer which was plugged into it and relays to turn on/off dual monitors.

After testing, I did comment out the webserver component as Nick suggested.

LMK if you end up getting it working or making any improvements!

Does anyone have a working ESPHome Template for this plug?

KMC should be able to help you.

I set up two of these for my houseplant lighting. It all works with some small adjustments.

First:
The mode of GPIO16 for esp01 (generic), does not permit INPUT_PULLUP. Mode should simply be INPUT.

Second:
Inverted: should be set to TRUE. As it originally was, the button action occurred when the button was released instead of when it is pushed.

Third: The current and Voltage measurements are way off. Voltage measured 130V for an actual 117V, and the current measurement was way high. The power reported does not appear to be taking into account the power factor and consequently also gives very high readings. I freaked out when it reported that my 200W power supply was delivering 335W. I’m not sure that it is worth the effort to

I see some flickering of the button light when first powered up. After operation, that stops. This may be worth investigating.

   pin:
      number: GPIO16
      mode: INPUT
      inverted: TRUE
   name: "KMC01 button"

Thanks for the head start on this. It proved to be quite useful.

1 Like