Integration Solar inverter huawei 2000L

Yes my template sensors are created in a configuration yaml file.

I also use Utility Meter Integration for Daily Import / Export sensors

grid_import_solar_daily_energy:
  source: sensor.grid_consumption
  cycle: daily
grid_export_solar_daily_energy:
  source: sensor.grid_exported
  cycle: daily
2 Likes

can you post all code in single post. e.g

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

resulted in this error

duplicated mapping key at line 163, column 7:
          friendly_name: "Grid 2 House"
          ^

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 …

Any know issues?

finally

Why do you still use this outdated version of the integration? You should be using this one:

It can be installed via HACS → integrations

1 Like

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).

1 Like

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

hmm Just use it as i set it up a year ago and it was great since, no issues, thank you for the link will give it a go next time it gets broken :slight_smile:

just out of curiosity , if both work why switch? is there any improvements ?

Yes. There are a lot of improvements.

That it is not working in 2022.4 would be enough of a break, don’t you think? :wink:

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 :grin:

1 Like

Ciao Carlo

I ask you for a kindness …

You could post your .Yaml code in full (obviously only for the sensors part) and related card code …

  • The data you use are those of EmilV2
  • your card uses lovelace.

I’m trying to make it work but I’m sure the conversion of the data is wrong given the absurd values it proposes to me …

A thousand thanks.

1 Like

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

and for lovelace card

type: custom:tesla-style-solar-power-card
name: 'Power Flow '
threshold_in_k: 4
hide_inactive_lines: 0
show_gap: true
change_house_bubble_color_with_flow: 1
grid_to_house_entity: sensor.template_grid_consumption
generation_to_grid_entity: sensor.template_grid_feed_in
generation_to_house_entity: sensor.template_curent_solar_consumption
house_entity: sensor.house_consumption_daily
generation_entity: sensor.daily_yield
grid_entity: sensor.grid_import_solar_daily_energy
house_extra_entity: sensor.grid_import_solar_daily_energy
generation_extra_entity: sensor.daily_yield
grid_extra_entity: sensor.grid_export_solar_daily_energy

it will produce this graph
image

Thank you so much yousaf465

now I try it, I wanted to ask you missing the part for the battery ? I don’t seem to see it in the script

Many thanks again …

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.

## Adjusting long-term statistics

3 Likes

Have the same error. What did you do to get rid of this error?

duplicated mapping key at line 34, column 7:
friendly_name: “Grid 2 House”

Which code you copied?
Copy the last code in this post Integration Solar inverter huawei 2000L - #1620 by yousaf465

That’s indeed the one i’ve copied. So what’s wrong with it?