Hi I wanted to create a thread about my inaccurate power readings from my Shelly 2.5’s flashed with ESP Home.
I converted over my Shelly 2.5s to ESP Home out of frustration with the MQTT auto-discovery script and the inability to easily create a device in YAML rather than creating single entities not tied together in 1 device (yes I know attributes exist but it’s just not the same as a device).
Anyway after setting the config file to just the way I like I realised the power monitoring is wildly off. Scavenging off forum threads this is the best config I can make.
Does anyone have suggestions on how to make the power monitoring more accurate for Shelly 2.5’s? I’m using linear calibration, I actually had worse results with polynomial 2 and 3 degree’s (I haven’t tried 5 degrees) I’m thinking of just disabling the sensors at this rate as I have whole home power monitoring.
I’m thinking of reading this dreaded document on the ADE7953 Power Sensor to see what the best method will be for calibration but it’s overwhelming for the moment… Also after a quick glance no idea how to go about implementing this…
I’m carrying over findings for the Shelly 2.5 from this thread as it mostly relates to the Shelly 1PM which uses a different chip to the 2.5
substitutions:
friendly_name: Bedroom Ensuite Secondary Light Switches
device_name: bedroom-ens-sec-light-switches
channel_1: Bedroom Ensuite Heat Lamps
channel_2: Bedroom Ensuite Lightstrip
ssid: !secret wifi_ssid
password: !secret wifi_password
max_power: "2000.0"
max_temp: "80.0"
esphome:
name: ${device_name}
platform: ESP8266
board: esp01_1m
wifi:
ssid: ${ssid}
password: ${password}
power_save_mode: HIGH # for ESP8266 LOW/HIGH are mixed up, esphome/issues/issues/1532
ap:
ssid: ${device_name}
captive_portal:
logger:
api:
ota:
web_server:
port: 80
version: 1
time:
- platform: sntp
id: my_time
i2c:
sda: GPIO12
scl: GPIO14
sensor:
- platform: ade7953
irq_pin: GPIO16 # Prevent overheating by setting this
voltage:
name: ${friendly_name} Voltage
# On the Shelly 2.5 channels are mixed ch1=B ch2=A
current_a:
name: ${channel_2} Current
internal: true
current_b:
name: ${channel_1} Current
internal: true
active_power_a:
name: ${channel_2} Power
id: power_channel_2
# active_power_a is normal, so don't multiply by -1
filters:
- calibrate_linear:
- 0.0 -> 0.0
- 70 -> 10
- 4600 -> 600
# 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);
on_value_range:
- above: ${max_power}
then:
- light.turn_off: shelly_light_2
- homeassistant.service:
service: persistent_notification.create
data:
title: Message from ${friendly_name}
data_template:
message: Switch turned off because power exceeded ${max_power}W
active_power_b:
name: ${channel_1} Power
id: power_channel_1
# active_power_b is inverted, so multiply by -1
filters:
- multiply: -1
- calibrate_linear:
- 0.0 -> 0.0
- 70 -> 10
- 4600 -> 600
# 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);
on_value_range:
- above: ${max_power}
then:
- light.turn_off: shelly_light_1
- homeassistant.service:
service: persistent_notification.create
data:
title: Message from ${friendly_name}
data_template:
message: Switch turned off because power exceeded ${max_power}W
update_interval: 5s
- platform: total_daily_energy
name: ${channel_1} Energy
power_id: power_channel_1
filters:
# Multiplication factor from W to kWh is 0.001
- multiply: 0.001
unit_of_measurement: kWh
- platform: total_daily_energy
name: ${channel_2} Energy
power_id: power_channel_2
filters:
# Multiplication factor from W to kWh is 0.001
- multiply: 0.001
unit_of_measurement: kWh
# NTC Temperature
- platform: ntc
sensor: temp_resistance_reading
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
on_value_range:
- above: ${max_temp}
then:
- light.turn_off: shelly_light_1
- light.turn_off: shelly_light_2
- homeassistant.service:
service: persistent_notification.create
data:
title: Message from ${friendly_name}
data_template:
message: Switch turned off because temperature exceeded ${max_temp}°C
- platform: resistance
id: temp_resistance_reading
sensor: temp_analog_reading
configuration: DOWNSTREAM
resistor: 32kOhm
- platform: adc
id: temp_analog_reading
pin: A0
status_led:
pin:
number: GPIO0
inverted: yes
output:
- platform: gpio
pin: GPIO4
id: shelly_relay_1
- platform: gpio
pin: GPIO15
id: shelly_relay_2
light:
- platform: binary
id: shelly_light_1
name: ${channel_1}
output: shelly_relay_1
icon: "mdi:heat-wave"
restore_mode: RESTORE_DEFAULT_ON
- platform: binary
id: shelly_light_2
name: ${channel_2}
output: shelly_relay_2
icon: "mdi:led-strip-variant"
restore_mode: RESTORE_DEFAULT_ON
binary_sensor:
- platform: gpio
pin:
number: GPIO13
name: "${channel_1} Switch Input"
- platform: gpio
pin:
number: GPIO5
name: "${channel_2} Switch Input"