Integration Solar inverter huawei 2000L

@trevee Remember to use a new templates format when creating those sensors, the one I posted was in the old format, just convert those to the new format.

I think we should update the sensors to new templates

My HA server is quite far from the inverter (25m). After I read details of the integration, I’m curious that can it use ESP32 with RS-485 module (using MODBUS component of ESPHome) instead of using RS-485 to USB and using long wire to HA server or not?

if that is possible, that will be the cheapest and most reliable method.

You can certainly create a ModbusRTU to ModbusTCP bridge with an ESP32+RS485 module. However, ESPHome does not support such a thing. My 2 minutes of Googling showed the following interesting option: https://github.com/zivillian/esp32-modbus-gateway .

If you still need to buy the hardware, I would suggest an M5Stack ATOM RS485, which I already have lying around myself. It packages an ESP8266 + RS485-to-tll module together in a nice package.

Everything I say here is untested, so try at your own risk :sweat_smile:

Anyone facing this error in HA logs

Logger: homeassistant.components.sensor.recorder
Source: components/sensor/recorder.py:396
Integration: Sensor (documentation, issues)
First occurred: 10:30:10 PM (2 occurrences)
Last logged: 10:30:10 PM

sensor.grid_reactive_power has unit var which is unsupported for device_class power
sensor.grid_reactive_power_2 has unit kVarh which is unsupported for device_class energy

Hi guyz, new here at Huawei 2000L, please can somebody point me to right direction?
Using githubs custom component from https://github.com/Emilv2/huawei_solar
And i am confused as what to put where at energy tab.
This is my screenshots and with cloud graphs also.





Hi. I have a solar inverter huawey without “dongle wifi”(i use directly wifi interface of inverter to connect it into my router).
My inverter provider updated my inverter firmware from V200R001C00SPC109 to SPC123
 but with version firmware tcp modbus port doesn’t work
 My provider inverter haven’t a backup of SPC109 firmware and from huawey I can’t download scp109(it is removed).

What is the last firmware version that support tcp modbus port by wifi without dongle???
Somebody can send me the zip package of that firmware??

Hi, I quote last reply and I would ask to be sure:
If I have SD Dongle as well and upgrade inverter to latest firmware (App propose to install SPC141, currently I have SPC135) the 502 (or 6607) will still be open? With SPC135 it is but I saw some discordant messages in the post and I want to be sure that my integration will not be disconnected if I upgrade

THANKS !!

1 Like

This is mine, but I am now using @wlcrs integration, which is easier to setup

https://github.com/wlcrs/huawei_solar

Did you change the setting using the installer account for modbus?

Thank you very much for a reply, but it’s giving me errors, will try with different settings
or report to github

Logger: homeassistant.config_entries
Source: custom_components/huawei_solar/number.py:33
Integration: Huawei Solar
First occurred: 8:02:35 PM (1 occurrences)
Last logged: 8:02:35 PM

Error setting up entry SUN2000-10KTL-M1SUN2000-12 for number
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 313, in async_setup
    result = await component.async_setup_entry(hass, self)  # type: ignore
  File "/usr/src/homeassistant/homeassistant/components/number/__init__.py", line 81, in async_setup_entry
    return await component.async_setup_entry(entry)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 147, in async_setup_entry
    platform = await async_prepare_setup_platform(
  File "/usr/src/homeassistant/homeassistant/setup.py", line 309, in async_prepare_setup_platform
    platform = integration.get_platform(domain)
  File "/usr/src/homeassistant/homeassistant/loader.py", line 530, in get_platform
    cache[full_name] = self._import_platform(platform_name)
  File "/usr/src/homeassistant/homeassistant/loader.py", line 535, in _import_platform
    return importlib.import_module(f"{self.pkg_path}.{platform_name}")
  File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/config/custom_components/huawei_solar/number.py", line 33, in <module>
    HuaweiSolarNumberEntityDescription(
TypeError: __init__() got an unexpected keyword argument 'native_min_value'
Unable to prepare setup for platform huawei_solar.sensor: Platform not found (cannot import name 'POWER_VOLT_AMPERE_REACTIVE' from 'homeassistant.const' (/usr/src/homeassistant/homeassistant/const.py)).

Thank you very much, now no error, waiting for few hours to feed the data :slight_smile: Connection is active :slight_smile:
I had old HAOS, updated


Hopefully, it is working fine now.

I have updated the instructions according to the new features introduced by wlcrs

Summary

So to summarize, I did this. Note Huawei inverter is on another subnet that is 192.168.200.0.
image

  1. Flash Openwrt on the router
  2. Setup your router as a dumb AP. [OpenWrt Wiki] Wireless Access Point / Dumb Access Point
  3. Connect it to your ISP router via ethernet. This will change the IP to something in the router’s subnet range. e.g if your ISP’s router Ip is 192.168.1.1 then your OpenWrt’s router IP will be 192.168.1.24 (anything in between 192.168.1.2 to 192.168.1.100)
  4. Connect to your Huwaei Sun2000 inverter’s wifi as a client via 2.4Ghz radio.
  • Network – Wireless

  • click scan
    image

  • connect to SUN2000-HVxxxxxxxx

  • Use password “Changeme”

  • Wireless security WPA2-PSK
    image
    Check the connection between OpenWrt and router by ping 192.168.200.1 (in most cases but in some cases it will be 192.168.199.1)

  • Network – Diagnostics
    image


Step 2
This step is unique for each user, depending on your ISP modem/ router.
Set up a static route in ISP router/modem/
e.g
On F@st 5366

  1. Open 192.168.1.1 (again depending on your Isp router Ip address)
  2. follow these instructions to open the static route page. Route - SAGEMCOM Swan F5366s User Manual [Page 19] | ManualsLib
  3. enter the following setting
  4. IP address 192.168.200.0 (in your case 192.168.199.0)
  5. Gateway IP address 192.168.1.2 (whatever your OpenWRT router Ip address is)
  6. Interface IP_BR_LAN (in my case it was br0)
  7. Subnet mask 255.255.255.0 (if there is a field for subnet mask)
  8. Save and reboot both your ISP modem/router and OpenWrt router.
    This will complete step 2.

Step 3

  1. Download and install the latest Winscp from WinSCP:: Official Site:: Download
  2. Run WinScp
  3. select Scp as protocol.
  • login with your OpenWrt’s ssh credentials e.g
    image
  • accept the terms etc etc
  1. You will be presented with these windows with OpenWRT folders.double click on three dots icons
    image
    you will be presented with
    image
  2. Navigate to the first file by double-clicking etc and then config. Here you will find all the three files “network” “wireless” and “firewall”
    image
  3. double click on the “network” and copy-paste the following code at the end of the files. remember to set defaultroute '0" as mentioned in the GitHub wiki.
config interface 'wlan'
        option proto 'dhcp'
        option defaultroute '0'

image
7. repeat the process with “wireless” files by adding the following code to the end of the wireless file. changing according to your inverter’s AP’s Name and BSSID

config wifi-iface 'wifinet0'
        option key 'Changeme'
        option ssid 'SUN2000-HV0123456789'
        option device 'radio0'
        option mode 'sta'
        option bssid '94:25:33:12:34:56'
        option encryption 'psk2'
        option network 'wlan'
  1. Add the following code to the “firewall” file.
config zone
        option input 'ACCEPT'
        option name 'sun'
        option output 'ACCEPT'
        option forward 'ACCEPT'
        option masq '1'
        option network 'wlan'

config forwarding
        option dest 'sun'
        option src 'lan'

config forwarding
        option dest 'lan'
        option src 'sun'
  1. save everything and restart your OpenWrt router.

Step 4
Firewall rules for the port forwarding

  1. Network – Firewall – Port forwarding
  2. Setup first rules as follows
  • Name: Preroute
  • Protocol: TCP
  • Source zone: Lan
  • External port: 6607
  • Destination zone : sun(wlan)
  • Internal IP: Select from dropdown: 192.168.200.1
    image
  1. Uncheck NAT loopback from advanced setting tab
    image

  2. Add second rule as following

  • Name : Post route
  • Protocol TCP
  • Outbound zone Sun(wlan)
  • Destination address select from dropdown 192.168.200.1
  • Destination port: 6607
  • Action: SNAT (there is some debate on this issue but you can use this)
  • Rewrite IP address: select from dropdown 192.168.200.2 (OpenWrt router IP in Huwai inverter subnet)

image

Step five

  1. Verify connectivity, Before continuing with the setup of the integration, you should test whether you can ping the inverter on 192.168.200.1. You can use one of the SSH/Terminal add-ons of HA, or use a terminal in the VSCode add-on.
  2. successful connection will look like this
    image

Install Wlcrs integration.

  1. Connect Home Assistant to the WiFi Access Point of your Huawei inverter.
  2. Install this integration with HACS, or copy the contents of this repository into the custom_components/huawei_solar directory
  3. Restart HA
  4. Start the configuration flow:
  • Start Config Flow
  • Or: Go to Configuration → Integrations and click the + Add Integration. Select Huawei Solar from the list
  1. Choose whether you want to connect via serial or network connection. In this case we will choose network
    image

  2. Enter the IP address of your inverter (192.168.200.1). The slave id is typically 0. You should only check the Advanced: elevate permissions checkbox if you intend to dynamically change your battery settings.

  3. When using the elevate permissions feature, you might be asked to enter the credentials to the installer account in the next step. These are the credentials used to connect to the inverter in the “Device Commissioning” section of the FusionSolar App. The default password is 00000a


Hi! I have an apexcharts-card where I have the produced electricity, sold electricity and total produced electricity from my solar panels. Now i need sensor.grid_import_solar_daily_energy + sensor.daily_yield - sensor.grid_export_solar_daily_energy = To get the total consumption in the house - the exported electricity. So total i need 4 slices of the pie chart

Here is the card i use:

type: custom:apexcharts-card
chart_type: pie
header:
show: true
show_states: true
colorize_states: true
title: SÄld, Köpt & Producerad El
apex_config:
chart:
height: 300px
legend:
show: true
dataLabels:
enabled: true
formatter: |
EVAL:function(value) {
return value.toFixed(0) + “%”;
}
series:

  • entity: sensor.grid_export_solar_daily_energy
    name: SĂ„ld El
    color: green
    float_precision: 2
  • entity: sensor.grid_import_solar_daily_energy
    name: Köpt El
    color: red
    float_precision: 2
  • entity: sensor.daily_yield
    name: Totalt Producerad El
    color: magenta
    float_precision: 2
  • entity: HERE?
    name: Consumption
    color: magenta
    float_precision: 2

Can somebody explain how can i make actual data, not comulative daily in Home Assistant.
I have this in energy:
Screenshot_289

But i want this for example in lovelace dash shows actual usage etc
:
Screenshot_290

I think i managed to create state actual usage

       solar_spotreba_vypocet_sit_aktualni:
         value_template: >
             {% set temp = (states('sensor.power_meter_phase_c_active_power') | float + states('sensor.power_meter_phase_a_active_power') | float + states('sensor.power_meter_phase_b_active_power') | float) | multiply(0.001) | round(3) %}
             {% if temp %}
               {{ temp }}
             {% else %}
               {{ 0 }}
             {% endif %}
         unit_of_measurement: 'kW'

       solar_vyroba_aktualni:
         value_template: >
             {% set temp = states('sensor.inverter_active_power') | float | multiply(0.001) | round(3)  %}
             {% if temp %}
               {{ temp }}
             {% else %}
               {{ 0 }}
             {% endif %}
         unit_of_measurement: 'kW' 

       solar_spotreba_ze_site_aktualni:
         value_template: >
             {% set temp = (states('sensor.power_meter_phase_c_active_power') | float + states('sensor.power_meter_phase_a_active_power') | float + states('sensor.power_meter_phase_b_active_power') | float) | multiply(0.001) | round(3) %}
             {% if temp < 0.000 %}
               {{ temp | abs }}
             {% else %}
               {{ 0 }}
             {% endif %}
         unit_of_measurement: 'kW'    

       solar_dodej_do_site_aktualni:
         value_template: >
             {% set temp = (states('sensor.power_meter_phase_c_active_power') | float + states('sensor.power_meter_phase_a_active_power') | float + states('sensor.power_meter_phase_b_active_power') | float) | multiply(0.001) | round(3) %}
             {% if temp > 0.000 %}
               {{ temp | abs }}
             {% else %}
               {{ 0 }}
             {% endif %}
         unit_of_measurement: 'kW' 

       solar_dum_spotreba_aktualni:
         value_template: >
             {% set temp = (states('sensor.solar_vyroba_aktualni') | float | round (3) + states('sensor.solar_spotreba_ze_site_aktualni') | float | round (3) - states('sensor.solar_dodej_do_site_aktualni') | float | round (3)) %}
             {% if temp %}
               {{ temp }}
             {% else %}
               {{ 0 }}
             {% endif %}
         unit_of_measurement: 'kW' 

Will see if it work when sun is down :-E

any of you use off-grid mode inverter integration?
when the system enters off grid mode without the grid operator’s power grid, power supply is supplied by battery via the backup line of the Backup Box-B0. in this condition the integration does not work and shows “config entry ‘SUN2000-6KTL-L1’ for huawei_solar integration not ready yet: Could not update (serial number my inverter ) values”.
when the grid voltage is switched on again by the operator., the inverter re-assign on grid mode and integration work perfect.
be possible to make integration work with inveter off grid status (island mode)

1 Like

Idea to extend the battery live:
I would like to know your opinion about the possibility to implement following idea in home assistant to extend the battery live (in my case could be a 20-30% more live). It applies only for the case your system injects the rest of electricity, not used in your home, in the grid and you revive compensation for it. The idea is, when there is no solar production, to prioritize the consumption of the compensation instead to use the battery, it means to prioritize the consumption from the grid during a time instead the battery. To track the compensation in Home Assistant should not be complicate (you know the grid consumption and probably the sale price, in may case it is easy).And It is possible to create a template sensor to track the grid consumption in front of the compensated buffered amount. The key is to know if it would be possible to modify dynamically the operation mode of the battery through the integration (in my case a Luna2000 battery), or if it is possible to shutdown and star-up the battery with the integration. Other possibility maybe is to connect a smart switch to the battery and control it out of the Huawei integration, but in this case I don’t know if this way to proceed could damage the batteries or system. Summarize the idea is to prioritize the use of the grid compensation instead the battery, so we can reduce the amount of cycles of our batteries and extend their lives. For example during the sommer my system injects monthly too much energy into the grid more than required to compensate the grid consupmtion monthly invoice.
@wlcrs : I appreciate specially your opinion about it if you see possible to proceed in some way with the integration. Thanks.