Hi
I’m trying to add a Shelly device to my energy dashboard. I flashed it with ESPHome and it is working great.
This is my configuration (left out the wifi part):
esphome:
name: wasplaats
platform: ESP8266
board: esp01_1m
captive_portal:
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
switch:
- platform: gpio
name: "wasplaats_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: "wasplaats_power"
unit_of_measurement: W
device_class: "power"
id: "wasplaats_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
I also added two sensors to calculate kWh and store statistics:
- platform: integration
source: sensor.wasplaats_power
name: broodbakmachine_power
unit_prefix: k
round: 2
- platform: statistics
name: broodbakmachine_kwh
entity_id: sensor.broodbakmachine_power
From the information I gathered on this forum, I think an entity needs to be of device_class energy and the integration platform should automatically add this when its source entity is of device_class power. My entity wasplaats_power however does not have a device_class at all:
For reference, another entity from a zigbee smartplug looks like this:
It looks like ESPHome is not adding the device information that is needed further down the chain. I must be doing something wrong, but I can’t see what. I hope the experts here know what to do.
Kind regards,
Merijn