Hello all,
Since two weeks I have my home assistant up and running at my house (Running HA container v2021.12.10.) My current project is to measure our solar production, energy consumption and our return to grid.
I have a three-phase electrical installation with an older, analog, meter.
In order to measure energy usage and production I am using a Shelly EM and Shelly 3EM.
The EM is used to measure the solar production and the 3EM measures the three separate phases.
I have used the following energy setup.
For grid consumption I use two standard entities from the shelly 3EM (Meter channel A energy and Meter channel B energy). For the third phase Iām using a custom sensor (since this is the phase where solar power is added and the standard Shelly value only delivers data per phase) For the return to grid, Iām also using a custom sensor.
For the solar production Iām using the standard energy returned entity from the Shelly EM.
The three custom sensors are constructed the following way:
-
Actual power phase C
- In order to get the actual watts that are consumed on the phase where the solar energy is being added.
-
Actual consumption phase C
- A corrected kWh sensor that cancels out the solar return to get the actual consumption on the phase where solar energy is being added.|
-
Actual return to grid
- A sensor where I tried to record the actual return to grid.
I used an If-statement to evaluate if we are in a return to grid scenario (solar power exceeds the power consumption of all power drawn by the three phases.
If yes, then the states should record this excess.
Else = 0.0
- A sensor where I tried to record the actual return to grid.
template:
- sensor:
- name: Actual power phase c
state: >
{{ (states ('sensor.meter_channel_c_power')|float(0) - states ('sensor.2_zonnemeter_channel_1_power')|float(0))|round(3) }}
unit_of_measurement: "W"
- sensor:
- name: Actual consumption phase c
state: >
{{ (states ('sensor.meter_channel_c_energy')|float(0) - states ('sensor.2_zonnemeter_channel_1_energy')|float(0))|round(3) }}
unit_of_measurement: "kWh"
state_class: total
device_class: energy
- sensor:
- name: Actual return to grid
state: >
{% if states("sensor.2_zonnemeter_channel_1_energy_returned")|float(0) + states("sensor.meter_channel_a_energy")|float(0) + states("sensor.meter_channel_b_energy")|float(0) + states("sensor.actual_power_phase_c")|float(0) < 0 %}
{{(states ('sensor.2_zonnemeter_channel_1_energy_returned")|float(0) + states("sensor.meter_channel_a_energy")|float(0) + states("sensor.meter_channel_b_energy")|float(0) + states("sensor.actual_power_phase_c')|float(0))|round(3)}}
{% else %}
{{(states ('0.0')|float(0))|round(3) }}
{% endif %}
unit_of_measurement: "kWh"
state_class: total
device_class: energy
The code does not trigger a configuration error, however Iām not getting any values in the āActual return to gridā. Yesterday we had sunny conditions and the Shelly app did mention some actual return to grid (phase a and b practically not consuming and phase c providing energy). However, it did not show up in the energy overview.
Does anyone see anything wrong in the sensor-code that was used?
(I did receive quite a few āāfloatā got invalid input āunknownā when rendering templateā- errors that I think got fixed by adding the ā(0)ā-argument.
Thank you in advance,
Kind regards