Integration Solar inverter huawei 2000L

I’m also getting this error while starting HA, but integration works correctly.

2020-11-09 22:27:32 WARNING (MainThread) [homeassistant.components.sensor] Setup of sensor platform huawei_solar is taking over 10 seconds.
2020-11-09 22:27:34 ERROR (MainThread) [homeassistant.components.yeelight] Failed to get capabilities from 192.168.5.31
2020-11-09 22:27:34 WARNING (MainThread) [homeassistant.config_entries] Config entry for yeelight not ready yet. Retrying in 10 seconds
2020-11-09 22:27:34 ERROR (SyncWorker_6) [huawei_solar.huawei_solar] could not read register value, is an other device already connected?

I set the mode from info to debug again and now (and I find this very strange!) it says it has added entities. And yes, it has added the entity!! Wow!!

So happy! :wink: Thank you so much for you time @ligeza Rafal! I owe you!

Can you provide details on how you created that dashboard? i am very new to grafana

This not home-assistant platform, this monitoring system i wrote a lot years ago in PHP and Mysql for my home and for my friend projects.

I updated inverter visualization, and now looks a bit better :slight_smile:

2 Likes

First of all, I would like to give a big thank you to @Emilv2 for your custom component. I had my new solar PV installed a few days ago, and going through this thread, I was able to add my Huawei SUN2000-5KTL-L1 inverter into Home Assistant. You work has indeed benefitted us who use it. Now I can track the PV power generation within Home Assistant, and not having to rely onthe Huawei FusionSolar app only.

Many thanks to @ligeza Rafal. Your contribution to this thread is immensely helpful. I went was only able to get this working after following your work and how you tested it within Python, enabling me to positively test the connectivity within my LAN network with the inveter.

Special mention to @Frans1 for your guide on getting additional information using the REST API. I was able to use this with the Huawei tenant for Asia Pac (rather than eu5.fusionsolar.huawei.com, I simply change the subdomain name of the endpoint from eu5 to sg5, ie. https://sg5.fusionsolar.huawei.com/ ).

A big kudos to all you good folks. Well done to all!!!

1 Like

Hi @Emilv2,
Once again, thank you so much for sharing this custom component. You have done a wonderful work here and I am grateful for you sharing with us in the community.

Can I just share a little back, there is a typo in your sensor.py code. The ‘Grid exported energy’ should read “exported” and not “exporterd” I think:

line 47: ATTR_GRID_EXPORTED_ENERGY = "grid_exporterd_energy"
line:157: ATTR_GRID_EXPORTED_ENERGY: self._grid_exporterd_energy,
line:212:  self._grid_exporterd_energy = self._inverter.get("grid_exporterd_energy").value

Cheers,

I installed the integration and after some trouble due to my low skill, all is ok.
Thank you so much for your work, it is really FANTASTIC!

This inverter series is natively ready to connect a battery LG RESU-7H or 10H and I installed one.
It seems that the related data are not handled at all.
Is it possible to add the management of the battery data (IN/OUT power and current, voltage, SOC, SOH and so on)?

Hee Guys,

I was looking for a way to forecast the PV production.

I found a interesting site that makes a forecast (today/tomorrow) based on you location and situation:

Below you can found the configuration.yaml code to make it work.

Make sure you change the URL (see website below)
http://doc.forecast.solar/doku.php?id=api:estimate

Let me know what you think about it, maybe there is a better provider.

Frans

sensor:
#http://doc.forecast.solar/doku.php?id=api:estimate
  - platform: rest
    name: pv_forecast
    resource: https://api.forecast.solar/estimate/watthours/day/52.09/5.10/35/44/3.520
    method: GET
    force_update: true
    scan_interval: 600
    json_attributes:
      - result
      - message
    headers:
      Content-Type: application/json
    value_template: ok

  - platform: template
    sensors:
      pv_forecast_today:
        value_template: "{{ states.sensor.pv_forecast.attributes['result'][now().strftime('%Y-%m-%d')] | float() / 1000  }}"
        unit_of_measurement: "kWh"
        device_class: power
        icon_template: 'mdi:solar-panel'
      pv_forecast_tomorrow:
        value_template: "{{ states.sensor.pv_forecast.attributes['result'][(now()+timedelta(1)).strftime('%Y-%m-%d')]  | float() / 1000 }}"
        unit_of_measurement: "kWh"
        device_class: power
        icon_template: 'mdi:solar-panel'
3 Likes

Hi Guys,

New here, also fairly new to home assistant, I’m trying to get the custom intergration working but i keep getting the bellow error

Logger: pymodbus.client.asynchronous
Source: /usr/local/lib/python3.8/site-packages/pymodbus/client/asynchronous/init.py:43
First occurred: 7:26:22 (1 occurrences)
Last logged: 7:26:22

Not Importing deprecated clients. Dependency Twisted is not Installed

I have tried to follow the steps from when I can last see someone having this issue but no luck so far any help would be greatly appreciated.

Sabax01

You can ignore that warning, your problem probably lies somewhere else.

Can you reach the device from python command line? Which inverter model do you have? Some (older) models need a separate client connection to be able to connect to the modbus server, you will need an extra raspberry pi or a openwrt router or something similar to get it to work.

Good catch, I’ll fix it.

1 Like

Hello everyone and happy christmas!

First and foremost: congratulations for the outstanding work @Emilv2 ! really great component and library: easy to read and comprehensive; thank you so much!!

As you might imagine, I’m the owner of yet another SUN2000-5TKL L1 (the SUN2000L I believe!) and have been trying stuff on how to integrate it to my domestic Home Assistant. So far I’ve reached similar conclusions to the different described by jaslo in post 136 (sorry I can only refer two users and two links in a post). I would point out, though, that there is yet another way to gather information, by using the upload functionality of the inverter to huawei’s cloud.

I’ve been having problems trying to have the integrated wlan (not the internal, but the “external” one, that connects to my home wifi) together with the ethernet dongle, as a way to have other means to access the TCP Modbus. It seems so far not to be compatible; for some reason, when we get both to work, the RS485 connection to the power meter (gavazzi E112) stops working all together… go figure.

Roaming the internet for that and other issues, I came up with some interesting links:

The second link led me to believe that, what the inverter is doing on connecting to the fusionsolar.huawei.com Management System server, is opening a TCP channel for a Modbus TCP connection. It is a “reversed” scheme from the regular: in which the Master acts as a TCP server (instead of the usual TCP client) to which the different Slaves connect to as clients (instead of acting as TCP servers). This is not the first time I see one of this schemes, is pretty common whenever you have to deal with ECG-NAT for SIM based connections.

This could lead us to have yet another alternative way of tapping into the TCP modbus stream, even perhaps keeping the original connection with Huawei’s Management System by proxying those requests, or creating a modbus map replica locally, so that Huawei can read from.

For now, I’m using socat to proxy the connection between my inverter and huawei, and check that the assumption is right, even check what and how is being read from the inverter by huawei.

In other order of business, looking at Emil’s code, I can see that the different parameters form the inverter, are read as individual calls. I think some work could be done to improve latency and throughput, by reading large chunks of information all at once, keeping those chunks stored locally and then splitting those into individual parameters upon request. If there is interest in that regard, I could provide some help in doing it :slight_smile:.

And I think that’s all for now!

Best regards and happy christmas!

I thought about doing that, but never did it because IMO it’s too much effort for barely any gains. Most of the latency comes from the modbus server being slow to start up, after that it’s plenty fast. A welcome addition that would improve latency would be making it a async sensor. Most of the code is there already but when I last tried it just refused to work :confused:. HA got stuck in a loop somewhere.

Of course, any improvement is welcome and if you want to implement reading multiple registers at once I’m happy to accept your code.

1 Like

How did you connect to the port 502

my network is 172.16.0.60 (using usb dongle) and the inverter internal ip is 192.168.8.1.
When i connect to the 172.16.0.60 i can’t get huawei_solar work.

if i need to use 192.168.8.1, then i need to brigde a network with a router (wifi to wifi?)

You need to connect to 192.168.8.1
If you are using raspberry for HA then you can connect wifi to the inverter and lan to home network.

You can also use a router with AP client to bridge to home network. I’m using old tp-link router (dd-wrt firmware) with blocked DHCP traffic Integration Solar inverter huawei 2000L

It should also work with a router using static routing.

1 Like

I used a raspberry pi Zero W as a bridge between the inverter and my LAN.
There are numerous guides that you can follow, example: https://www.raspberrypi.org/forums/viewtopic.php?t=132674

*Connect the pi to the inverter WiFi network
*Connect the Pi LAN interface to your regular LAN (same network as your HA server) and give the Pi a static IP.
*Follow the guide above to set up your Pi as a bridge.
*Enter a static route in your home router that routes all traffic to the Inverter to the LAN IP of your Pi.

It seems like the issue with async is found and being worked on: https://github.com/riptideio/pymodbus/pull/558

Once this lands in a release version of pymodbus (and it fixes the issue in HA) I’ll update the sensor to use async and try to get in officially in HA.

5 Likes

Hello everyone.

I thank you for this tutorial. I followed it, and now I can access all the information on my inverter.

However, I am trying to create more sensors, but you are giving me this error. I don’t have much knowledge of homeassistant. Can someone help me to solve the problem?

entity_id: was removed from template. I think the problem is also text formatting.
My working config:

sensor:
  - platform: huawei_solar   
    host: 192.168.8.1
  
  - platform: template
    sensors:
      pv_01_voltage:
        friendly_name: "String 1 napięcie"
        unit_of_measurement: 'V'
        icon_template: mdi:flash-alert-outline
        value_template: "{{ state_attr('sensor.sun2000_8ktl_m0', 'pv_string_01_voltage') }}"

Thank you very much! Now its working!