template_grid_feed_in:
friendly_name: "Solar 2 Grid"
unit_of_measurement: 'W'
device_class: power
value_template: >
{% if states('sensor.grid_active_power') | int > 0 %}
{{ states('sensor.grid_active_power') }}
{% else -%}
0
{% endif %}
# sensor used to show power flow from Panels to Grid and doesn't allow it to show a negative number only positive numbers
template_grid_consumption:
friendly_name: "Grid 2 House"
unit_of_measurement: 'W'
device_class: power
value_template: >
{% if states('sensor.grid_active_power') | int > 0 %}
0
{% else -%}
{{ (states('sensor.grid_active_power') | int) | abs }}
{% endif %}
# shows the solar power being fed to the house and doesn't allow it to show a negative number only positive numbers
template_curent_solar_consumption:
friendly_name: 'Solar 2 House'
unit_of_measurement: 'W'
device_class: power
value_template: >-
{% if states('sensor.template_grid_consumption') | float > 0 %}
{{ states('sensor.active_power') }}
{% else -%}
{{ (states('sensor.active_power')| float - states('sensor.template_grid_feed_in')| float) }}
{% endif %}
#import and export
grid_import_solar_daily_energy:
source: sensor.grid_consumption
cycle: daily
grid_export_solar_daily_energy:
source: sensor.grid_exported
cycle: daily
try this now -
Had the formatting slightly wrong before
sensor:
- platform: template
sensors:
# sensor used to show power flow from Panels to Grid, but shows a negative at night
template_grid_feed_in:
friendly_name: "Solar 2 Grid"
unit_of_measurement: "W"
device_class: power
value_template: >
{% if states('sensor.grid_active_power') | int > 0 %}
{{ states('sensor.grid_active_power') }}
{% else -%}
0
{% endif %}
# sensor used to show power flow from Panels to Grid and doesn't allow it to show a negative number only positive numbers
template_grid_consumption:
friendly_name: "Grid 2 House"
unit_of_measurement: "W"
device_class: power
value_template: >
{% if states('sensor.grid_active_power') | int > 0 %}
0
{% else -%}
{{ (states('sensor.grid_active_power') | int) | abs }}
{% endif %}
# shows the solar power being fed to the house and doesn't allow it to show a negative number only positive numbers
template_curent_solar_consumption:
friendly_name: "Solar 2 House"
unit_of_measurement: "W"
device_class: power
value_template: >-
{% if states('sensor.template_grid_consumption') | float > 0 %}
{{ states('sensor.active_power') }}
{% else -%}
{{ (states('sensor.active_power')| float - states('sensor.template_grid_feed_in')| float) }}
{% endif %}
utility_meter:
grid_import_solar_daily_energy:
source: sensor.grid_consumption
cycle: daily
grid_export_solar_daily_energy:
source: sensor.grid_exported
cycle: daily
looks like the Emilv2 / huawei_solar stopped working with 2022.4.3 so I had to roll back to 2022.3.8 to bring it back to life.
It worked flawlessly for nearly a year hope there will be a fix soon …
A quick sidenote here: Since the last Fusionsolar update (last weekend) the daily yield in Fusionsolar now perfectly matches the one calculated by:
Input Yield = Daily Yield - Battery Day Discharge + Battery Day Charge
So when using this for the energy dashboard, then the numbers there will exactly match die Fusionsolar numbers (also for energy consumption). The fact that the numbers are decreasing in the morning just reflects the fact that the battery consumes energy and has never been a problem with my energy dashboard (the enery dashboard expects a solar yield figure which is “total increasing”, but it has no problems dealing with the decreases in the morning).
all good updated to the latest one he has on his gitub and apparently sensor name includes serial so updated attribute gathering and all great ! work like a charm
yeah though so, but turns out the thing was due to serial number included in the sensor name. updated the name , so now it works with 2022.4.3.
not sure what kind of improvements needed as you get just reading from import export consumption production and like, as long as it is stable it does the job for me , long term stats are also valuable so dont want to have new sensor names
I will see if I can try the one you suggested. need some time to reconfigure all that … in good case scenario if the sensors names are identical if not will be a pain to reconfigure all the automation scripts and dashboards … so I try to avoid messing with it hehe
As @dd77 mentioned here is his code to be pasted in configuration.yaml
template:
- sensors:
template_grid_feed_in:
friendly_name: "Solar 2 Grid"
unit_of_measurement: 'W'
device_class: power
value_template: >
{% if states('sensor.grid_active_power') | int > 0 %}
{{ states('sensor.grid_active_power') }}
{% else -%}
0
{% endif %}
# sensor used to show power flow from Panels to Grid and doesn't allow it to show a negative number only positive numbers
template_grid_consumption:
friendly_name: "Grid 2 House"
unit_of_measurement: 'W'
device_class: power
value_template: >
{% if states('sensor.grid_active_power') | int > 0 %}
0
{% else -%}
{{ (states('sensor.grid_active_power') | int) | abs }}
{% endif %}
# shows the solar power being fed to the house and doesn't allow it to show a negative number only positive numbers
template_curent_solar_consumption:
friendly_name: 'Solar 2 House'
unit_of_measurement: 'W'
device_class: power
value_template: >-
{% if states('sensor.template_grid_consumption') | float > 0 %}
{{ states('sensor.active_power') }}
{% else -%}
{{ (states('sensor.active_power')| float - states('sensor.template_grid_feed_in')| float) }}
{% endif %}
utility_meter:
grid_import_solar_daily_energy:
source: sensor.grid_consumption
cycle: daily
grid_export_solar_daily_energy:
source: sensor.grid_exported
cycle: daily
Hi!
Fyi.
The latest home assistant update finally includes a simple tool to adjust or correct data stored under “Statistic”. In our case for example it helps and make easier to adjust this exporadic issue related to spurius error measured data by grid sensor when a home grid outage/shutdown has taken place.