I’m using the builtin Shelly integration. I wanted to add up channel A and channel B to get a total for Watts used, but when I try to add a statistics graph card, I don’t see Power Total as an option to select. This is what I have for my template:
@flyingmoose, one thing which needs to be fixed is the “device_class”. It should be “power” (instead of “energy”). The “last_reset” attribute is not needed, since this is not a cumulative sensor. The rest looks fine.
Please note that you should give it an hour before adding the new card, since the statistics engine does it magic only once per hour (in the12th minute of the hour).
Here is our configuration for “power total” and “power factor total”, along with the new statistics graph cards:
Thank you! I made the change you suggested yesterday afternoon and waited overnight for statistics to populate, and it is working as expected now. Thank you again for your help!
However I am having problems due to (apparently) occasional unavailability of the EM3 causing the float filter to produce a 0 value which the Utility Meter then interprets as a reset causing spikes and big steps in the values of the daily/monthly totals. See below:
@pfrock42, you can find software workarounds, like keeping the old value if one of the phases is zero. However, you should probably fix the Wi-Fi coverage around the Shelly 3EM so you get a stable connection and reliable sensors.
Thanks. Good point about finding the root cause of the unavailability of the Shelly… I don’t think it’s the WiFi (I’ve put a lot of work into ensuring good Wifi around the house) but I’ll definitely double check!
I can confirm that this works! Although the Shelly has been more stable over the last 48h there have been 3 unavailability events that were correctly filtered out by this so thank you again.
I’m still looking into the root cause of the unavailability events… the WiFi signal at the Shelly is -65 dBm so, not great, but then neither is it streaming 4k video… Currently it is <10m from the access point but admittedly behind a heavy fire proof door (for building regs) so I’ll install another AP within the room and see if it improves.
Hi,
I’m using Shelly 3EM together with Solar PV and 3-phase system. I noticed that the “current_consumption” entities show negative values when my solar panels are working (makes sense).
However, I cannot figure out how to get real “consumption” of power in my house - that is the actual Power in W being used in the house (without solar). I tried to use the “total_returned” entity available but that shows only the accumulated energy (not power). Unfortunately - I don’t have a separate meter on my solar panels
Is it possible for me to see current Power usage (without taking into account the solar panels)?
Yes, that’s possible by calculation OR by placing the Shelly Clamps on the “right spots”.
How to calculate real consumption in a PV setup depends on how the PV has been integrated. There are multiple ways to do so…
Hybrid inverters (those with battery and power out support) are creating a virtually second neutral which could produce errors in measurement.
Measurement:
With Hybrid inverters one has to measure at least three points (Inverter-Grid, Grid-House, Inverter-House)
With Non Hybrid Inverters one has to measure at least two points (Inverter-Grid, Grid-House)
Do you have a hybrid inverter (with batteries)? Those
how exactly did you connect the phases of the shelly?
I’m quite sure that you can not just add the energy from the 3 phases. You have to divide the result with SQRT(3) to get the actual amount that the electrical company registers (note that this is a good thing, less energy spent!).
Here’s my calculation:
consumed_energy:
friendly_name: "Total Consumption"
device_class: energy
unit_of_measurement: 'kWh'
value_template: "{{ ((states('sensor.em_channel_a_energy')|float + states('sensor.em_channel_b_energy')|float + states('sensor.em_channel_c_energy')|float)/sqrt(3))|round(2) }}"
availability_template: "{{ not ( is_state('sensor.em_channel_a_energy', 'unavailable') or is_state('sensor.em_channel_b_energy', 'unavailable') or is_state('sensor.em_channel_c_energy', 'unavailable') ) }}"
does anyone have this working with the MQTT based setup (mqtt shelly discovery script)? I’m trying to backport your findings to it, but it isn’t exactly straight forward i found
i use this:
- sensor:
- name: "House Energy kWh"
unit_of_measurement: "kWh"
state_class: measurement
device_class: energy
state: >
{{ [ states('sensor.shelly_3em_meter_total_0'),
states('sensor.shelly_3em_meter_total_1'),
states('sensor.shelly_3em_meter_total_2') ]
| map('float') | sum }}
attributes:
last_reset: '1970-01-01T00:00:00+00:00'
availability: >
{{ not 'unavailable' in
[ states('sensor.shelly_3em_meter_total_0'),
states('sensor.shelly_3em_meter_total_1'),
states('sensor.shelly_3em_meter_total_2') ] }}
but i get those zero values after HA is reloaded anyhow