Just wanted to share my esphome file. It’s calibrated by me according to frenck’s guide… It may need some calibration for you. I haven’t tried if the button sensor is working yet and I just remembered that it also got a temperature sensor. I will update with a fix for this later…
# From Tasmota template
# "NAME":"Shelly 1PM","GPIO":[0: Led1i,0,0,0,4: D_SENSOR_SWITCH,5: BL0937 CF,0,0,0,0,0,15: Relay1,0],"FLAG":2,"BASE":18}
substitutions:
plug_name: "shelly1pm"
esphome:
name: ${plug_name}
platform: ESP8266
board: esp01_1m
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
fast_connect: true
domain: !secret domain
manual_ip:
static_ip: 10.222.50.198
gateway: 10.222.50.1
subnet: 255.255.255.0
dns1: 10.222.50.1
# Enable logging
logger:
level: VERBOSE
# Enable Home Assistant API
api:
password: !secret password
ota:
password: !secret password
time:
- platform: homeassistant
id: homeassistant_time
switch:
- platform: gpio
name: "${plug_name}_switch"
icon: "mdi:power-socket-eu"
pin: GPIO15
id: relay
sensor:
- platform: hlw8012
cf_pin: GPIO05
cf1_pin: GPIO13 # not used because it is not available on the 1PM but it is needed to compile
sel_pin: GPIO14 # not used because it is not available on the 1PM but it is needed to compile
power:
name: "${plug_name}_power"
unit_of_measurement: W
id: "${plug_name}_power"
icon: mdi:flash-circle
accuracy_decimals: 0
filters:
# Map from sensor -> measured value
- calibrate_linear:
- 0.0 -> 1.0
- 110.33186 -> 20.62
- 131.01909 -> 24.32
- 341.33920 -> 62.08
- 5561.41553 -> 1000.0
- 2975.51221 -> 535.7
- 9612.66309 -> 1720.0
- 14891.35352 -> 2679.0
# Make everything below 2W appear as just 0W.
# Furthermore it corrects 1.0W for the power usage of the plug.
- lambda: if (x < (2 + 1)) return 0; else return (x - 1);
update_interval: 3s
binary_sensor:
# Binary sensor for the button press
- platform: gpio
name: button
pin:
number: GPIO4
inverted: true
on_press:
- switch.toggle: relay
output:
# Relay state led
- platform: esp8266_pwm
id: state_led
pin:
number: GPIO00
inverted: true