Got it wired up today and all is working well; current, voltage, relay, input switch, and temperature!
The calibration of the power sensor is way off, showing 700W for what should be a <100W or so load. I’ll be calibrating this with my diy ‘killer watts’ meter, but otherwise consider this a working shelly 1pm config. Regardless, the sensor is responding properly, so calibration is all that is needed here.
I included some small automations to make the existing toggle style wall switch behave like a standard wall switch (up=on, down=off). I also have node red doing some additional automations based on motion, luminance, and switch position, but that’s out of the scope of this post. Hope this helps someone down the line!
# Shelly 1pm Example#############################
substitutions:
name: "garage_lights"
friendly_name: "Garage Lights"
esphome:
name: ${name}
platform: ESP8266
board: esp01_1m
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "${friendly_name} Fallback Hotspot"
password: "oops"
# Enable logging
logger:
api:
password: !secret garage_lights_password
ota:
password: !secret ota_password
switch:
- platform: gpio
name: "${friendly_name} Relay"
icon: "mdi:power-socket-us"
pin: GPIO15
id: relay
sensor:
- platform: wifi_signal
name: "${friendly_name} WiFi Signal"
update_interval: 60s
- 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: "${friendly_name} Power"
unit_of_measurement: W
id: "${name}_power"
icon: mdi:flash-circle
accuracy_decimals: 0
filters:
#Reading -> actual
- calibrate_linear:
- 2.5 -> 0.16
- 747.0 -> 125.0
- 1409.0 -> 237.0
- 2663.0 -> 444.0
- 8600.0 -> 1390.0
- lambda: if (x <= 6.0) return 0; else return (x - 6);
update_interval: 10s
# NTC Temperature
- platform: ntc
sensor: ${name}_resistance_sensor
name: "${friendly_name} Temperature"
unit_of_measurement: "°C"
accuracy_decimals: 1
icon: mdi:thermometer
calibration:
b_constant: 3350
reference_resistance: 10kOhm
reference_temperature: 298.15K
- platform: resistance
id: ${name}_resistance_sensor
sensor: ${name}_source_sensor
configuration: DOWNSTREAM
resistor: 32kOhm
- platform: adc
id: ${name}_source_sensor
pin: A0
update_interval: 10s
binary_sensor:
- platform: status
name: "${friendly_name} Status"
# Binary sensor for the button press
- platform: gpio
name: "${friendly_name} Input"
pin:
number: GPIO4
on_state:
- switch.toggle: relay
#on_press:
# - switch.turn_on: relay
#on_release:
# - switch.turn_off: relay
status_led:
pin: GPIO0
[edit: Got my calibration done… added it to this config. Incidentally, that’s the farthest off from calibration I’ve ever seen a sensor… not that it means anything, but usually output values are within a few 10% before calibrating, not ~800% off as in this case. Either way, a linear calibration does look valid for the sensor (roughly the same 8x factor across the range).]