Connect to Huwaei SUN2000 inverter using fiber modem

adding these rules from ssh(I had to break the No command-line rules) partially fixed the issue. Even though I made a mistake in the first rule, my router IP wasn't correct.

iptables -I PREROUTING -t nat -p tcp -d 192.168.1.24 --dport 6607 -j DNAT --to-destination 192.168.200.1:6607
iptables -I POSTROUTING -t nat -d 192.168.200.1 -p tcp --dport 6607 -j MASQUERADE

Now, wlcrs integration is working fine, there are no dropouts as of in the last one hour
image
but I can't ping the inverter from HA, which I think is due to wrong first iptable?

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

  1. Flash Openwrt on the router
  2. Setup your router as a dumb AP. https://openwrt.org/docs/guide-user/network/wifi/dumbap
  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.

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

    you will be presented with
  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”
  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'


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
  1. Uncheck NAT loopback from advanced setting tab

  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)

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

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

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

1 Like

@eduperez @trendy @slh @frollic @pavelgl Sorry for bothering you all. :slightly_smiling_face:
Is this the correct configuration correct? It is working fine but does it fulfil proper networking criteria? Or do you suggest any changes?

At least one user reported this as working even with v22.03.0-rc4.

You are masquerading on the sun zone, so no need for the SNAT rule.

1 Like

Updated according to new feature and connection type being added, i.e serial connection.

Opening this after one year, on 23.05rc2/snapshot I am facing this strange issue. Can't access the internet with the above config.

logs

Sat Jul  8 17:27:07 2023 daemon.notice netifd: wlan (2329): udhcpc: broadcasting select for 192.168.200.2, server 192.168.200.1
Sat Jul  8 17:30:01 2023 daemon.err uhttpd[1454]: [info] luci: accepted login on /admin/system/reboot for root from 192.168.18.126

reset, start from scratch ...

ahh... backups mean nothing it seems :exploding_head:

reconfigure again. let me try that.