Integration Solar inverter huawei 2000L

I tried adding this block of code after the normal ‘sensor: -platform:huawei_solar host:192.168.200.1’ in configuration.yaml but got “expected , but found ‘’” for the code starting with ‘-platform: template’

help! this looks perfect because I have a smart meter and want to read the energy consumption etc as well as the generation, and also put it in the energy for HA

Read some of my posts further up, you need to create template sensors from the attributes of the main entity

ok I got all that working, wahoo!

last thing I want is the actual power im using which isnt an attribute by default for some reason? can anyone tell me whats wrong with this syntax:

value_template: "{{ state_attr('sensor.sun2000', 'power_meter_active_power') | float) - ( states('sensor.sun2000') | float) }}"
{{ state_attr('sensor.sun2000', 'power_meter_active_power') | float(0) - states('sensor.sun2000') | float(0) }}

for some reason this broke everything :confused:
allowd me to restart as valid config but broke all the attribute values…

Invalid config for [template]: invalid slug power_meter_Load (try power_meter_load) for dictionary value @ data['sensors']. Got OrderedDict([('pv_01_voltage', OrderedDict([('friendly_name', 'pv_string_01_voltage'), ('unit_of_measurement', 'V'), ('icon_template', 'mdi:flash-alert-outline'), ('value_template', "{{ state_attr('sensor.sun2000_5ktl_l1_hv2150011134', 'pv_string_01_voltage') }}")])), ('pv_02_voltage', OrderedDict([('friendly_name', 'pv_string_02_voltage'), ('unit_of_measurement', 'V'), ('icon_template', 'mdi:flash-alert-outline'), ('value_template', "{{ state_attr('sensor.sun2000_5ktl_l1_hv2150011134', 'pv_s.... (See /config/configuration.yaml, line 23).

As I don’t see you config I can’t help you, but earlier you used

states('sensor.sun2000')

Now in your template I see

state_attr('sensor.sun2000_5ktl_l1_hv2150011134'

I can share my current template config, maybe it will help somebody.
In configuration.yaml I have:

template: !include template.yaml

In template.yaml

  sensor:
    - name: "String 1 napięcie"
      unique_id: pv_01_voltage
      unit_of_measurement: 'V'
      icon: mdi:flash-alert-outline
      state: "{{ state_attr('sensor.sun2000_8ktl_m0', 'pv_string_01_voltage') | float(0) }}"

    - name: "String 2 napięcie"
      unique_id: pv_02_voltage
      unit_of_measurement: 'V'
      icon: mdi:flash-alert-outline
      state: "{{ state_attr('sensor.sun2000_8ktl_m0', 'pv_string_02_voltage') | float(0) }}"

    - name: "String 1 natężenie"
      unique_id: pv_01_current
      unit_of_measurement: 'A'
      icon: mdi:current-dc
      state: "{{ state_attr('sensor.sun2000_8ktl_m0', 'pv_string_01_current') | float(0) }}"

    - name: "String 2 natężenie"
      unique_id: pv_02_current
      unit_of_measurement: 'A'
      icon: mdi:current-dc
      state: "{{ state_attr('sensor.sun2000_8ktl_m0', 'pv_string_02_current') | float(0) }}"

    - name: "Faza 1 V (f)"
      unique_id: phase_a_voltage
      unit_of_measurement: 'V'
      icon: mdi:flash-alert-outline
      state: >
        {% if state_attr('sensor.sun2000_8ktl_m0', 'phase_A_voltage') | float(0) > 180 and state_attr('sensor.sun2000_8ktl_m0', 'phase_A_voltage')|float(0) < 264 %}
          {{ state_attr('sensor.sun2000_8ktl_m0', 'phase_A_voltage') }}
        {% else %}
          {{ state_attr('sensor.sun2000_8ktl_m0', 'grid_A_voltage') }}
        {% endif %}

    - name: "Faza 2 V (f)"
      unique_id: phase_b_voltage
      unit_of_measurement: 'V'
      icon: mdi:flash-alert-outline
      state: >
        {% if state_attr('sensor.sun2000_8ktl_m0', 'phase_B_voltage') | float(0) > 180 and state_attr('sensor.sun2000_8ktl_m0', 'phase_B_voltage')|float(0) < 264 %}
          {{ state_attr('sensor.sun2000_8ktl_m0', 'phase_B_voltage') }}
        {% else %}
          {{ state_attr('sensor.sun2000_8ktl_m0', 'grid_B_voltage') }}
        {% endif %}

    - name: "Faza 3 V (f)"
      unique_id: phase_c_voltage
      unit_of_measurement: 'V'
      icon: mdi:flash-alert-outline
      state: >
        {% if state_attr('sensor.sun2000_8ktl_m0', 'phase_C_voltage') | float(0) > 180 and state_attr('sensor.sun2000_8ktl_m0', 'phase_C_voltage')|float(0) < 264 %}
          {{ state_attr('sensor.sun2000_8ktl_m0', 'phase_C_voltage') }}
        {% else %}
          {{ state_attr('sensor.sun2000_8ktl_m0', 'grid_C_voltage') }}
        {% endif %}

    - name: "Faza 1 V (m)"
      unique_id: m_grid_a_voltage
      unit_of_measurement: 'V'
      icon: mdi:flash-alert-outline
      state: "{{ state_attr('sensor.sun2000_8ktl_m0', 'grid_A_voltage') | float(0) }}"

    - name: "Faza 2 V (m)"
      unique_id: m_grid_b_voltage
      unit_of_measurement: 'V'
      icon: mdi:flash-alert-outline
      state: "{{ state_attr('sensor.sun2000_8ktl_m0', 'grid_B_voltage') | float(0) }}"

    - name: "Faza 3 V (m)"
      unique_id: m_grid_c_voltage
      unit_of_measurement: 'V'
      icon: mdi:flash-alert-outline
      state: "{{ state_attr('sensor.sun2000_8ktl_m0', 'grid_C_voltage') | float(0) }}" 

    - name: "Faza 1 A (f)"
      unique_id: phase_a_current
      unit_of_measurement: 'A'
      icon: mdi:current-ac
      state: "{{ state_attr('sensor.sun2000_8ktl_m0', 'phase_A_current') | float(0) }}"

    - name: "Faza 2 A (f)"
      unique_id: phase_b_current
      unit_of_measurement: 'A'
      icon: mdi:current-ac
      state: "{{ state_attr('sensor.sun2000_8ktl_m0', 'phase_B_current') | float(0) }}"

    - name: "Faza 3 A (f)"
      unique_id: phase_c_current
      unit_of_measurement: 'A'
      icon: mdi:current-ac
      state: "{{ state_attr('sensor.sun2000_8ktl_m0', 'phase_C_current') | float(0) }}"

    - name: "Produkcja DC"
      unique_id: pv_input_power
      unit_of_measurement: 'W'
      icon: mdi:solar-power
      state: "{{ state_attr('sensor.sun2000_8ktl_m0', 'input_power') | float(0) }}"

    - name: "Zużycie prądu"
      unique_id: power_meter_active_power
      unit_of_measurement: 'W'
      icon: mdi:transmission-tower
      state: "{{ state_attr('sensor.sun2000_8ktl_m0', 'power_meter_active_power') | float(0) }}"
 
    - name: "Zużycie A"
      unique_id: active_grid_a_power
      unit_of_measurement: 'W'
      icon: mdi:transmission-tower
      state: "{{ state_attr('sensor.sun2000_8ktl_m0', 'active_grid_A_power') | float(0) }}"
 
    - name: "Zużycie B"
      unique_id: active_grid_b_power
      unit_of_measurement: 'W'
      icon: mdi:transmission-tower
      state: "{{ state_attr('sensor.sun2000_8ktl_m0', 'active_grid_B_power') | float(0) }}"
 
    - name: "Zużycie C"
      unique_id: active_grid_c_power
      unit_of_measurement: 'W'
      icon: mdi:transmission-tower
      state: "{{ state_attr('sensor.sun2000_8ktl_m0', 'active_grid_C_power') | float(0) }}"
 
    - name: "Prąd oddany do sieci"
      unique_id: m_grid_exporterd_energy
      unit_of_measurement: 'kWh'
      icon: mdi:transmission-tower
      state: >
        {% if state_attr('sensor.sun2000_8ktl_m0','grid_exported_energy') | float(0) > 0  %}
        {{ state_attr('sensor.sun2000_8ktl_m0','grid_exported_energy') | float(0) }}
        {% endif %}                    
      device_class: energy
      state_class: total_increasing
      
    - name: "Prąd pobrany z sieci"
      unique_id: m_grid_accumulated_energy
      unit_of_measurement: 'kWh'
      icon: mdi:transmission-tower
      state: >
        {% if state_attr('sensor.sun2000_8ktl_m0','grid_accumulated_energy') | float(0) > 0  %}
        {{ state_attr('sensor.sun2000_8ktl_m0', 'grid_accumulated_energy') | float(0) }}
        {% endif %}                    
      device_class: energy
      state_class: total_increasing

    - name: "Temperatura falownika"
      unique_id: pv_temperatura
      unit_of_measurement: '°C'
      state: "{{ state_attr('sensor.sun2000_8ktl_m0', 'internal_temperature') | float(0) }}"   

    - name: "Efetywność Falownika"
      unique_id: pv_efficiency
      unit_of_measurement: '%'
      state: >
        {% if state_attr('sensor.sun2000_8ktl_m0', 'efficiency') | float(0) < 100 %}
          {{ state_attr('sensor.sun2000_8ktl_m0', 'efficiency') }}
        {% else %}
          0
        {% endif %}

    - name: "Zużycie prądu dom"
      unique_id: energy_used
      unit_of_measurement: 'kWh'
      state: >
        {% if states('sensor.total_yield') | float(0) > 0 and state_attr('sensor.sun2000_8ktl_m0','grid_exported_energy') | float(0) > 0 and state_attr('sensor.sun2000_8ktl_m0','grid_accumulated_energy') | float(0) > 0 %}
        {{ '%0.2f' | format(states('sensor.total_yield') | float(0) - 
                            state_attr('sensor.sun2000_8ktl_m0','grid_exported_energy') | float(0) + 
                            state_attr('sensor.sun2000_8ktl_m0','grid_accumulated_energy') | float(0)) }}
        {% endif %}                    
      device_class: energy
      state_class: total_increasing
      

yes I have already stolen this from you !! :slight_smile: works good.

but what I want is the amount of power im using which I can work out by subtracting
“{{ state_attr(‘sensor.sun2000_8ktl_m0’, ‘power_meter_active_power’) | float(0) }}”’

from how much power is being generated which I thought would be
“{{ states(‘sensor.sun2000_8ktl_m0’) | float(0) }}”’

so I thought it would be:
“{{ state_attr(‘sensor.sun2000_8ktl_m0’, ‘power_meter_active_power’) | float(0) - states(‘sensor.sun2000_8ktl_m0’) | float(0)}}”’

but when I do this it breaks all my atttributes…

and also - for the one that does work “{{ state_attr(‘sensor.sun2000_8ktl_m0’, ‘power_meter_active_power’)}}" - how do I add this value to the energy dashboard for the ‘return to grid’ value - doesnt have anything except daily_yield and total_yield

In HA you have developer tools → template and you can check if it’s working. It could be mistake in yaml file (to many spaces or something similar).

Return to grid that mean energy sent to grid in kWh so you need

grid_exported_energy

edit:
I read again your post and

and I think correctly will be adding not subtracting, because energy used from grid is negative and energy generated from inverter is positive so if you are using eg: 1000 W and generating 3000W you should count it : -1000 + 3000 = 2000
English is not my primary language and I hope you will understand what I have on mind.

ok ill try and show you what it says.

I know about the grid.exported attribute that I templated using your code. but how do I make it show up in the energy dashboard to be able to select from the dropdown for return to grid?

{{ state_attr(‘sensor.SUN2000-5KTL-L1_HV2150011134’, ‘power_meter_active_power’) | float(0) - states(‘sensor.SUN2000-5KTL-L1_HV2150011134’) | float(0) }}

Answer:

Result type: number
0
This template listens for the following state changed events:

Entity: sensor.SUN2000-5KTL-L1_HV2150011134

should not be zero…?

It was written in this topic that if you want to see entity in energy tab it must have some attributes:

oh ok, where do I put those? in the individual template sensors: ??

I’m using it in this way and it’s working for me, but you can also change it in entity customize.

So, seems like my odyssey is still far away to be solved. Today I found my Dongle updated to version 124 and this blocked communication with HA integration. I checked port 502 and it appears closed and I don’t have any option in FusionSolar to open it.

Good afternoon

I am configuring my Huawei SUN2000-5KTL-L1 inverter with the Modbus module integrated in Home Assisant. So far so good, although I am putting more records from the datasheet.

I have a question about the registration with address 32066 with title Power grid voltage / Line voltage between phases A and B. It tells me that "When the output mode is L / N, L1 / L2 / N, or L1 / L2, Power grid voltage is used ". The question is, that in my case, would the first option be (Power grid voltage) instead of the second (Line voltage between phases A and B) since I BELIEVE my inverter is single phase so my mode is L / N?

Also, would the Line voltage between phases B and C and Line voltage between phases C and B registers not be valid?

In the same way, since my measurement equipment is single phase (single phase ddsu666-h). Therefore, the signals A, B, C phase voltage and A, B, C phase current and A-B line voltage, B-C line
voltage, AC line voltage and A, B, C phase active power, won’t they serve me either?

Thank you

I have found using the developer tools for template that state_attr(‘sensor.SUN2000-5KTL-L1_HV2150011134’, ‘power_meter_active_power’)|float = 0

which it should be -1400w. So I think thats why its breaking, not sure why it isnt working because it does on the dashboards…

Perfect, thanks!

Hi guys,
Today I upgraded my FE-Dongle from V100R001C00SPC122 to new firmware V100R001C00SPC124.
After the upgrade the TCP ModBus port (502) was CLOSED.

PORT    STATE  SERVICE
502/tcp closed mbap

It was not working at all - disabled, connection refused !!!
Note: I am using LAN cable (not wifi)

I had to downgrade to V100R001C00SPC123 and now it is working back again!
So - be careful with this.
Why huawei had disabled this feature ?!

Is was already written about it in this topic. It is only disabled connection in spc124. You can enable it in setting if you also have newest firmware in inverter.