The is_number approach to availability is pretty neat!
And thanks for others as well in this topic. I was quite stuck with the false readings and couldn’t find out what was the problem with my calculated sensor.
Anyways, my code is as follows now:
- platform: template
sensors:
total_main_energy:
friendly_name: 'Total Main Energy'
device_class: energy
unit_of_measurement: "kWh"
entity_id:
- sensor.phase_1_energy
- sensor.phase_2_energy
- sensor.phase_3_energy
value_template: "{{ (states('sensor.phase_1_energy')|float +
states('sensor.phase_2_energy')|float +
states('sensor.phase_3_energy')|float )|round(3) }}"
availability_template: >-
{{
is_number(states('sensor.phase_1_energy')) and
is_number(states('sensor.phase_2_energy')) and
is_number(states('sensor.phase_2_energy'))
}}
- platform: template
sensors:
total_main_energy_returned:
friendly_name: 'Total Main Energy Returned'
device_class: energy
unit_of_measurement: "kWh"
entity_id:
- sensor.phase_1_energy_returned
- sensor.phase_2_energy_returned
- sensor.phase_3_energy_returned
value_template: "{{ (states('sensor.phase_1_energy_returned')|float +
states('sensor.phase_2_energy_returned')|float +
states('sensor.phase_3_energy_returned')|float)|round(3) }}"
availability_template: >-
{{
is_number(states('sensor.phase_1_energy_returned')) and
is_number(states('sensor.phase_2_energy_returned')) and
is_number(states('sensor.phase_2_energy_returned'))
}}
But now I have a question, how to correct the data on my energy dashboard?
Thanks for the is_number recommendation!
I’ve updated the original post at the top of this thread to include it.
Here is how the sensor looks now (IMHO, quite clean):
Hi,
One quick doubt : If the Shelly 3EM allows to monitor 3 lines, I could buy and install 2 Shelly 3EM to monitor 6, and so on, right ?
I have the main line and 6 sub-lines I’d like to be able to monitor independently, that would mean 14 CTs to install, I’m not sure this module would be the best / most affordable way… But I am a newby in electricity monitoring so…
Yes, you are correct.
I have currently 3 Shelly 3EM. They measure one heat pump, a two log houses independently. To measure the property’s total grid/import/export I use modbus via the my SolarEdge inverter and a meter connected that way.
Ok so I guess I’d also need 3x 3EM for 9 circuits all in all (I have 1 phase at home). Main circuit from public network and 8 sub-circuits in house.
I would not know how to use the modbus but I guess I wouldn’t have to anyway as I would only be monitoring the circuits the simple way (one CT for each, 3 circuits on each 3EM, all of that going to HA and configuring HA to make sense of all the data).
Are there good tutorials on how to connect everything ? I’m no electrician but it does not seem so complicated (apart from knowing where to connect each cable on N, VA, VB, VC, I and O)
@ianadd, the wiring is probably wrong. My bet is that VA, VB, and VC are not synchronized with A, B, and C.
I’ve asked a question about 3EM wiring, and you can find in the comments the relevant explanation (here).
A small amount of returned energy can be leaked, if you have (like me) a heat pump or something with an inverter connected to the Shelly 3EM. That’s inevitable. But in your case try to just turn the clamps the other way…?
If the clamps were the wrong way round then surely the reading would always be negative. But I can get negative and positive power values on the same channel depending on what I am using. Current and volts always show positive. The shelly app shows the same problem. The issue is not in HA.
Anyone have installation of 3EM with 4th clamp? I have installed one on neutral to detect possible leakage, but I do not see it anywhere in HA or even not in Shelly web interface. Any special process to ‘activate’ this feature?
OK, the alignment of the power feeds to the clamps sorted the negative numbers.
Still got energy returned sensors showing data. Can’t see that info in shelly app tho’.
Any ideas?
I am in an apartment block and each unit has a separate meter. So I will go read our meter a couple of times next week and see how well it agrees with shelly.