devices.esphome.io

Calex Holland Smart Power Plug with Energy Monitoring EU16A

Calex Holland Smart Power Plug with Energy Monitoring EU16A

Device Type: plug
Electrical Standard: eu
Board: bk72xx

calexsmartplug Maker: https://www.calex.eu/

Not glued! Very easily opened with 4 shims in the corners, but I just put it in a power strip (not connected) and twisted the two parts apart. It's not great for the tabs but they'll survive one or two openings. Flashing easily done with a CH340 using OpenBeken, from there you can OTA to esphome.

GPIO Pinout

This was generated by OpenBeken. Now I am not sure whether the LED pins are correct because I could only get the WiFi LED to work, but while booting up the button was illuminated much less than when I had it set up. I'm not sure if this is due to some PWM behaviour, ill-defined voltage or some capacitive bleed, but I couldn't detect a second LED on the PCB (I did not look very carefully and don't want to subject the tabs to another breaking event). I was not able to activate the relay LED in HA. As such, I turn on the WiFi LED when toggling the relay and removed mention of the other LED. When the plug is not yet connected to WiFi, it should blink. | Pin | Function | | ------ | ------------------- | | GPIO6 | Relay LED (?) | | GPIO7 | Button | | GPIO8 | Relay | | GPIO10 | WiFi LED (?) | | GPIO11 | BL0937 SEL | | GPIO24 | BL0937 VI | | GPIO26 | BL0937 ELE |

Basic Configuration

Power calculation equation thankfully borrowed from another file on here, Arlec-PC191HA-Plug to be exact, values adjusted based on current resistor value seen and voltage measured with store-bought meter.

substitutions:
device_name: calexsmartplug
friendlyname : smartplug
esphome:
name: ${device_name}
on_boot:
- light.turn_on:
id: light_led
effect: "WiFi Off"
friendly_name: $friendlyname
bk72xx:
board: cb2s
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key:
ota:
- platform: esphome
password:
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Plugcain Fallback Hotspot"
password: !secret ap_password
on_connect:
- light.turn_off:
id: light_led
on_disconnect:
- light.turn_on:
id: light_led
effect: "WiFi Off"
captive_portal:
binary_sensor: # the button
- platform: gpio
pin:
number: P7
mode:
input: true
pullup: true
name: ${device_name} button
id: button
device_class: window
# when button is pressed, toggle the switch on/off
on_release:
then:
- switch.toggle: relay
switch: # the relay
- platform: gpio
pin: P8
name: ${name}
id: relay
restore_mode: always off # default when power is turned on
icon: mdi:power-socket-de
# synchronise the LED with the relay
on_turn_on:
then:
- light.turn_on: light_led
on_turn_off:
then:
- light.turn_off: light_led
output:
- platform: gpio # status led
id: button_led
pin: P10
# restore_mode: always off # default when power is turned on
light:
- platform: status_led
id: light_led
name: "Status LED"
output: button_led
effects:
- strobe:
name: "WiFi Off"
colors:
- state: true
duration: 250ms
- state: false
duration: 250ms
#
# PC191HA sensors - power monitoring and wifi signal
#
sensor:
- platform: wifi_signal # report wi-fi signal strength from this end
name: $name WiFi Signal
id: ${device_name}_wifi_signal
update_interval: 30s # how often to report wifi signal strength
# PC191HA includes a BL0937 chip for measuring power consumption
# and BL0937 is a variation of hlw8012, but using inverted SEL pin functionality
- platform: hlw8012
model: BL0937 # note that the model must be specified to use special calculation parameters
sel_pin: # I believe that cf_pin reports either Voltage or Current depending on this select pin
inverted: true # determine whether true reports Voltage
number: P11
cf_pin: # current or voltage (ele_pin: 7)
inverted: true # the logic of BL0937 is opposite from HLW8012
number: P26
cf1_pin: # Power (vi_pin: 8)
inverted: true # the logic of BL0937 is opposite from HLW8012
number: P24
update_interval: 15s # How often to measure and report values
# PC191HA measures and returns Voltage OR Current according to the value of sel_pin,
# but it can change the value of sel_pin periodically
initial_mode: "VOLTAGE" # reports VOLTAGE or CURRENT
change_mode_every: 4 # how many times to report before swapping between
# reporting Voltage or Current. Note that the first value reported should be ignored as inaccurate
# Adjust according to the actual resistor values on board to calibrate the specific unit
voltage_divider: 768 # LOWER VALUE GIVES LOWER VOLTAGE
current_resistor: 0.001 # HIGHER VALUE GIVES LOWER WATTAGE
#
# how the power monitoring values are returned to ESPHome
#
voltage:
name: $name Voltage
id: ${device_name}_voltage
unit_of_measurement: V
accuracy_decimals: 1
filters:
- skip_initial: 2
power:
name: $name Power
id: ${device_name}_power
unit_of_measurement: W
accuracy_decimals: 2
filters:
- skip_initial: 2
# power should simply be current x voltage -- except that the pc191ha doesn't follow that formula.
# Setting current_resistor to give an accurate Amperage does NOT also give the correct Wattage
# so here I calculate current from power and voltage
- platform: template
name: $name Current
id: ${device_name}_current
unit_of_measurement: A
accuracy_decimals: 2
update_interval: "30s"
lambda: |-
return (id(${device_name}_power).state / id(${device_name}_voltage).state);
filters:
- skip_initial: 2
- platform: uptime
name: $name Uptime
id: ${device_name}_uptime
update_interval: "30s"
export const _frontmatter = {"title":"Calex Holland Smart Power Plug with Energy Monitoring EU16A","date-published":"2025-06-10T00:00:00.000Z","type":"plug","standard":"eu","board":"bk72xx"}
Edit this page on GitHub