Huawei solar integration

hello,
I have just install PV system and a huawei solar inverter.
I have ask the provider to enable tcp-modbus and upgrade the firmware of the dongle.
I have installed the huawai solar integration through HACS. and connect to the dongle on port 502 and get many parameters
I guess the pv production is sensor.inverter_active_power
I guess power to grid is sensor.power_meter_active_power
cannot find household consumption
no idea how to integrate the energy dashbord.
can you help ?

Hey there, if you look at the wiki of the repo, you should find what you are looking for.

What I read from the screenshots is:
Total Yield could be set for Solar Panels.
Total charge/discharge for battery.
Exported and Consuption for the grid.

Huawei Solar Integration
I had a Huawei solar inverter installed along with 21 panels of 450W on my roof, without a battery.I found the offered integrations unpalatable and preferred to create my own simpler version. Myintegration does not include a battery and does not take electricity prices into account My inverter has a dongle that connects to my network. The address is on the router (box for theFrench); I fixed the IP address in the DHCP settings. Confirm with the installer that the TCPModbus value is enabled and that the firmware version matches the documentation(V200R022C10SPC114 for me).
Installation
Through HACS, install Huawei Solar and reboot. In settings, integration, add Huawei Solar. Enter the parameters IP, port 502, slave ID 1, elevate permissions. No need for an installer profile. Set thehidden parameters to enable. It created 7 entities: inverter, meter, and 5 inverters. I also integrated the Zappi car charger from Energi, but that’s another story.It is easy to find the following parameters:
**name sensorname myname **
Production sensor.inverter_active_power prodpv
Power togrid sensor.power_meter_active_power togrid
Additional Parameters
I also need the following additional parameters. I created 3 templates with the availability option. Ittook me a day to figure out how to do it. A simple subtraction did not work.
name sensorname myname Formule
Puissance conso sensor.energie_conso prodpv (prod - togrid)|abs
Puissance togridsold sensor.energie_togridpos togridpos togrid if togrid > 0 else 0
Puissance consomées des PV energie_consopv consopv conso if togrid > 0 else
prodpv
I love Markdown cards and made the following one
markdown card.
-## huawei solar
inverter active power = PV {{ (states(‘sensor.inverter_active_power’) | float) }}
power meter active = togrid {{(states(‘sensor.power_meter_active_power’) | float) }}
difference = homeconso {{ (states(‘sensor.inverter_active_power’) | float) -
(states(‘sensor.power_meter_active_power’) | float) }}
***variable puissance
variable energie_conso {{ (states(‘sensor.energie_conso’))}}
variable energie_prodpv {{ (states(‘sensor.energie_prodpv’))}}
variable energie_togridpos {{ (states(‘sensor.energie_togridpos’))}}
variable energie_consopv {{ (states(‘sensor.energie_consopv’))}}
variable energie_togrid {{ (states(‘sensor.energy_togrid’))}}
****energy
variable conso_energy {{ (states(‘sensor.conso_energy’))}}
variable togridpos_energy {{ (states(‘sensor.togridpos_energy’))}}
variable prodpv_energy {{ (states(‘sensor.prodpv_energy’))}}
Carte Graphique Historique
esy to do example
type: history-graph
entities:

  • entity: sensor.energie_conso
  • entity: sensor.energie_consopv
  • entity: sensor.energie_prodpv
    title: Consommation et prod maison
    hours_to_show: 8
    Template
    -# togrid
  • name: “energie_togrid”
    unit_of_measurement: ‘W’
    state: “{{ (states(‘sensor.power_meter_active_power’) | float(0)) }}”
    -# prodpv plus compréhensibe
  • name: “energie_prodpv”
    unit_of_measurement: ‘W’
    state: “{{ (states(‘sensor.inverter_active_power’) | float(0)) }}”
    -# consommation totale
  • name: “energie_conso”
    unit_of_measurement: ‘W’
    device_class: power
    state_class: measurement
    unique_id: energie_conso
    state: >
    {% set prodpv = states(‘sensor.inverter_active_power’) | float(0) %}
    {% set togrid = states(‘sensor.power_meter_active_power’) | float(0) %}
    {{ (prodpv - togrid)|abs }}
    availability: >
    {{ states(‘sensor.inverter_active_power’) not in [‘unavailable’, ‘unknown’, ‘none’] and states(‘sensor.power_meter_active_power’)
    not in [‘unavailable’, ‘unknown’, ‘none’] }}
    -# energie vendue
  • name: “energie_togridpos”
    unit_of_measurement: ‘W’
    state: >
    {% set togrid = states(‘sensor.power_meter_active_power’) | float(0) %}
    {{ togrid if togrid > 0 else 0 }}
    availability: >
    {{ states(‘sensor.inverter_active_power’) not in [‘unavailable’, ‘unknown’, ‘none’] }}
    device_class: power
    unique_id: energie_togridpos
    state_class: measurement
    -# consopv = pv si togrid negatif
  • name: “energie_consopv”
    unit_of_measurement: ‘W’
    state: >
    {% set prodpv = states(‘sensor.inverter_active_power’) | float(0) %}
    {% set togrid = states(‘sensor.power_meter_active_power’) | float(0) %}
    {% set conso = states(‘sensor.energie_conso’) | float(0) %}
    {{ conso if togrid > 0 else prodpv }}
    availability: >
    {{ states(‘sensor.inverter_active_power’) not in [‘unavailable’, ‘unknown’, ‘none’] and states(‘sensor.power_meter_active_power’)
    not in [‘unavailable’, ‘unknown’, ‘none’] }}
    device_class: power
    unique_id: energie_consopv
    state_class: measurement
    Sensor
    -# Consommation totale
  • platform: integration
    source: sensor.energie_conso
    name: “conso_energy”
    unit_prefix: k
    round: 2
    method: trapezoidal
    -# Energie_vendue
  • platform: integration
    source: sensor.energie_togridpos
    name: “togridpos_energy”
    unit_prefix: k
    round: 2
    unit_time: h
    method: trapezoidal
    -#
  • platform: integration
    source: sensor.energie_prodpv
    name: “Prodpv_energy”
    unit_prefix: k
    round: 2
    unit_time: h
    method: trapezoidal
    unique_id: prodpv_energy
    Energy tab can be easily done.
    Hope ths help
    Cheers

Hello guys, I join the request to understand how to implement the total household consumption per day. I can’t figure out how to configure it.
I’m not a developer, so please explain it in a simple way. :smiley:

It would be helpful if you provided more information where you stand.
Did you set up the energy dashboard? Then you can see the house consumption there and get the graph with energy cards on your dashboard.
If you want a sensor install this prefferably with HACS then include this in your configuration.yaml like this:

homeassistant:
  packages:
    huawei_solar_energy_flow_card: !include huawei-solar-energy-flow-card-package.yaml

Be sure to get the file names right.
To upload or edit code use the addons File Editor or Terminal & SSH

I have done this

But the graph does not correspond related to fusion solar app (I know that there is a delay)

For instance, I have Solar production in my card = 12,15kw, but into fusion solar is 16,15kw

So you use the Cloud intergration with fusion solar?
If you want local control, better data resolution and more sensors use the setup I wrote above.
If you are wondering how to get the home consumption just add Importata and Autopdodatta. Not 100% sure what that means but it seems to add up.
Generally your house consumption is Import + Solar - Battery Input + Battery Output - Export

I’m using Huawei solar via hacs with the information retrived in real time via SDongle huawei.
How i can add " just add Importata and Autopdodatta" ?

Sorry but i’m new :slight_smile:

Thanks

Oh yes sorry forgot to add that.

Under settings, devices, helpers add a template sensor with
Code: {{states('sensor.importata') | float + states('sensor.autopdodatta') | float}}
Unit o.M.: kWh
Device Class: Energy
State Class: total

I’ve created a card to visualiza/manage my Battery but i need an editor to manage TOU Periods
Here my card (i can send the yaml if interested)

Has anyone among you developed this type of editor?

Thanks for your help

Hi everyone,
I wasn’t able to find clear information about how to stop the battery from discharging via automation.

What I’d like to achieve:
:point_right: When my car is charging, I want to prevent the Huawei battery from discharging (so it doesn’t assist the charging load).
After charging, I’d like to return to the default behavior.

I asked ChatGPT, and it suggested this automation using modbus.write_register to block battery discharge:

yaml

CopiaModifica

alias: Block battery discharge when charging Tesla
trigger:
  - platform: state
    entity_id: sensor.teslamate_charging_state
    to: 'Charging'
condition: []
action:
  - service: modbus.write_register
    data:
      hub: huawei_inverter
      unit: 1
      address: 47089
      value: 1  # Charge only
mode: single

And this one to restore normal behavior:

yaml

CopiaModifica

alias: Restore battery after Tesla charging
trigger:
  - platform: state
    entity_id: sensor.teslamate_charging_state
    from: 'Charging'
    to: 'Disconnected'
condition: []
action:
  - service: modbus.write_register
    data:
      hub: huawei_inverter
      unit: 1
      address: 47089
      value: 0  # Automatic mode
mode: single

But before this, I need to add the Modbus connection in configuration.yaml:

yaml

CopiaModifica

modbus:
  - name: huawei_inverter
    type: tcp
    host: 192.168.1.xxx  # IP address of the inverter or dongle
    port: 502
    delay: 1
    timeout: 3
    retries: 10

Does this approach seem correct to you?
Or is there a better/official way to do this with the Huawei inverter?

Thanks!

Till 29-03-2025 my Huawei solar integration worked, bud from dat date it stopped working after an update. I do not know if the home assist update or an update for the dongel or inverter was the problem, but now it is still not working anny more.

Hello,
I’m facing the same issue! Do you found a solution?

Worked again, my ip address changed of the inverter due to network updates. After reconfiguring the device in HomeAssistant and inserted the new IP, it worked again (FYI @Fofuracer )

same issues here, log says:

Timeout while waiting for connection. Reconnecting
Traceback (most recent call last):
File “/usr/local/lib/python3.13/asyncio/tasks.py”, line 507, in wait_for
return await fut
^^^^^^^^^
File “/usr/local/lib/python3.13/asyncio/locks.py”, line 213, in wait
await fut
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “/usr/local/lib/python3.13/site-packages/huawei_solar/huawei_solar.py”, line 141, in _communication_lock
await asyncio.wait_for(

<2 lines>

)
File “/usr/local/lib/python3.13/asyncio/tasks.py”, line 506, in wait_for
async with timeouts.timeout(timeout):
~~~~~~~~~~~~~~~~^^^^^^^^^
File “/usr/local/lib/python3.13/asyncio/timeouts.py”, line 116, in aexit
raise TimeoutError from exc_val
TimeoutError

1 Like