wlcrs / huawei_solar

Home Assistant integration for Huawei Solar inverters via Modbus
GNU Affero General Public License v3.0
503 stars 80 forks source link

[Feature Request]: add table comparing connection methods #586

Closed torwag closed 4 months ago

torwag commented 6 months ago

Describe your feature request

Just a feature request for the documentation.

As there are several ways to connect the inverters to HA, I was wondering if a ranking among them in terms of stability, features, support, might help to make the decision which way to follow.

Furthermore a table which includes which method requires which hardware and impose which constrains would be very helpful.

Right now, there is only the remark that a wired connection via the dongle seems unreliable.

Proper usage

torwag commented 6 months ago

Sorry I messed up to add a title... Can't change it. If a good soul of the repro owners can create one... Positiv karma will flow.

wlcrs commented 6 months ago

It's pretty hard to synthesize the differences between the connection methods into a table, as there are many possible configurations that can influence the outcome: Is there a battery present? Do you multiple inverters that are setup in a cascade? Do you want to stay connected to the FusionSolar cloud?

I'm only intimately familiar with my own setup. I'm hesitant to give advice for setups where I don't have any experience with. For instance I do not know if you can query a cascaded inverter when connecting to the WiFi of main inverter. Hence that is why I don't document how it should be done. I'm also unable to test the use of the serial connection because I seem to have damaged the serial connector of my inverter: it's not responding to any device I connect with it anymore 😢. I thus cannot evaluate whether an USB-dongle or a Modbus RTU-to-TCP bridge is the best option.

All connection methods are functionally identical. Only difference I can think of: when connected via serial you have elevated permissions to start with, when connecting via the WiFi, we need to do some magic to perform a login to gain elevated permissions.

The best advice that I can give, and that will apply to probably 90% of the installations: try to use the WiFi-option first, as in many cases it does not require extra hardware. If that doesn't work or is unstable, you can buy a serial connection device instead. However, when you are using an SDongle, using the serial pins is not an option as it will conflict: you either remove your SDongle (and lose the connection to the FusionSolar cloud), or you make do with the sometimes unstable TCP connection via the SDongle.

Please feel free to improve on the documentation if you are able to test and evaluate different scenarios: you can edit the Wiki pages or submit a PR which adapts the README.

torwag commented 6 months ago

Thanks for the detailed reply. Indeed I'm in the middle of installing three converters cascaded, each connected to a battery. I will add a pair of wires and a tcp cable to the installation, just to be prepared. That should allow me to go all options. I will happily report how this is going. Wondering why the network connection via the sdongle seems unstable. Nevertheless, I happily would like to avoid using the cloud, if I can get all data locally.

Is there anything known already which seems to be available via cloud but not locally?

Guess I'm ready in a few weeks and most likely will have many more questions 😉

MajoV commented 6 months ago

Hello, I don't know if this is the right place to post my experience with connecting the inverter, but I'll do it, maybe it will help someone. I have a similar setup as @torwag , three cascaded inverters, each with its own battery and DTSU666.

My first connection to HA was made using an S-Dongle. Yes it was unstable with frequent crashes. In addition, the initial initialization of this connection took a very long time and did not always end with a successful result.

Another connection I tried was via the serial connector, of course with the S-Dongle removed. The initial initialization was very fast, the connection was amazing without any dropouts. The only problem in this connection without the S-Dongle was that the system did not work properly, because the batteries did not know when to charge or discharge, because the entire system is controlled by the S-Dongle.

The last thing I tried, and it has been working without problems and outages for two months, was connecting to the wifi of each inverter. For this, I used three pieces of USB WiFi adapter, in my case D-Link DWA-121, each piece connected to an extension USB cable and placed each by its converter to prevent WiFi interference. The only thing you have to change in the inverter is the IP address of the internal WiFi, it should be unique for each inverter. In this case, I had to initialize the Huawei Solar for each network interface. The USB WiFi adapters are connected to an Odroid C4 running Home Assistant. I publish the telemetry of the entire Huawei system via MQTT to my master Home Assistant.

EDIT: attaching a picture

IMG_8467

torwag commented 6 months ago

Thanks @MajoV for your (for me) very useful response. That will indeed help me to save days of fiddling, testing and head scratching. Thanks for the picture as well. Looks very nice and clean. I am just in the middle of doing all the wiring. It is indeed a crazy amount of wires getting all connected. The box seems a tidy bit oversized for an Odroid, but that might be just the perspective of the image ;)

Is there a reason that you choose to use three WIFI-adapters instead of one, besides of interferences? I like the idea of running a client-HA just for the PV and make sure it runs independent of what happens to the rest of the house automation, particular as a charger unit for electric vehicles will be added to the mix and I might come up with stuff like PV and weather prediction as well as real weather data.

When you said, connection via the SDongle you mean the wired connection? I still wonder why that is so unstable, after all the purpose of that dongle should be to establish that connection.

When you said, you connected via serial, you mean via modbus, right? That was my preferred method until I read you had troubles with it. Do you have any details why the batteries couldn't be set to charge or discharge via modbus?

Well all my questions might high-jack the purpose of a bug/feature-tracker. If there is any other way to communicate (discord, signal, etc.), please let me know. I am from Germany, if this helps.

AlfaCube commented 6 months ago

After two weeks of running without any problems my HA decided to play games with me.

I run HA on a Intel NUC and Huawei Solar with ModBus active after two weeks has this error: here is the error: ogger: pymodbus.logging Source: custom_components/huawei_solar/init.py:92 Integration: Huawei Solar (documentation, issues) First occurred: 12:34:58 AM (11 occurrences) Last logged: 12:46:10 AMFailed to connect [Errno 111] Connect call failed

Reboot the wifi- no change, reboot the inverters- no change, unplug the Sdongle- no change. Delete the Huawei Solar integration- only the inverter visible on Huawei Solar, no power meter. Go back to an older HA backup- no change.

Today: Huawei Solar shoes only the SUN2000-4KTL-L1, no Power Meter..

I am not an expert in HA or ITbut I managed to see this two errors:

**_This error originated from a custom integration.

Logger: custom_components.huawei_solar Source: helpers/update_coordinator.py:306 Integration: Huawei Solar (documentation, issues) First occurred: 6:49:08 PM (2 occurrences) Last logged: 6:50:39 PM

Timeout fetching TA2240030061_data_updatecoordinator data**

and this one:

_**Logger: huawei_solar.huawei_solar Source: /usr/local/lib/python3.11/site-packages/huawei_solar/huawei_solar.py:348 First occurred: 6:50:36 PM (2 occurrences) Last logged: 6:50:38 PM

Modbus client is not connected to the inverter. NoneType: None**_

Can you guys please guide me what to do next?

After a week of testing some automations involving solar pannels and electric heater I finally managed to make them run with no problems but now I got this problem.

Can you guys help me with this errors?

ogger: huawei_solar.huawei_solar Source: /usr/local/lib/python3.11/site-packages/huawei_solar/huawei_solar.py:184 First occurred: 2:53:56 PM (6 occurrences) Last logged: 3:01:13 PM

Aborting client creation due to error. Traceback (most recent call last): File "/usr/local/lib/python3.11/asyncio/tasks.py", line 500, in wait_for return fut.result() ^^^^^^^^^^^^ File "/usr/local/lib/python3.11/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.11/site-packages/huawei_solar/huawei_solar.py", line 178, in create await huawei_solar._initialize() File "/usr/local/lib/python3.11/site-packages/huawei_solar/huawei_solar.py", line 107, in _initialize self.time_zone = (await self.get(rn.TIME_ZONE)).value ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/huawei_solar/huawei_solar.py", line 241, in get return (await self.get_multiple([name], slave))[0] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/huawei_solar/huawei_solar.py", line 276, in get_multiple response = await self._read_registers(registers[0].register, total_length, slave) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/huawei_solar/huawei_solar.py", line 396, in _read_registers async with self._communication_lock(): File "/usr/local/lib/python3.11/contextlib.py", line 204, in aenter return await anext(self.gen) ^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/huawei_solar/huawei_solar.py", line 145, in _communication_lock raise err File "/usr/local/lib/python3.11/site-packages/huawei_solar/huawei_solar.py", line 141, in _communication_lock await asyncio.wait_for(self._client.connected_event.wait(), WAIT_FOR_CONNECTION_TIMEOUT) File "/usr/local/lib/python3.11/asyncio/tasks.py", line 502, in wait_for raise exceptions.TimeoutError() from exc TimeoutError

Logger: huawei_solar.huawei_solar Source: /usr/local/lib/python3.11/site-packages/huawei_solar/huawei_solar.py:143 First occurred: 2:53:56 PM (6 occurrences) Last logged: 3:01:13 PM

Timeout while waiting for connection. Reconnecting... Traceback (most recent call last): File "/usr/local/lib/python3.11/asyncio/tasks.py", line 500, in wait_for return fut.result() ^^^^^^^^^^^^ File "/usr/local/lib/python3.11/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.11/site-packages/huawei_solar/huawei_solar.py", line 141, in _communication_lock await asyncio.wait_for(self._client.connected_event.wait(), WAIT_FOR_CONNECTION_TIMEOUT) File "/usr/local/lib/python3.11/asyncio/tasks.py", line 502, in wait_for raise exceptions.TimeoutError() from exc TimeoutError

This error originated from a custom integration.

Logger: pymodbus.logging Source: custom_components/huawei_solar/init.py:89 Integration: Huawei Solar (documentation, issues) First occurred: 2:53:47 PM (6 occurrences) Last logged: 3:01:08 PM

Failed to connect [Errno 113] Connect call failed ('192.168.68.104', 502) Failed to connect [Errno 111] Connect call failed

MajoV commented 6 months ago

Hello @torwag, here are the short answers to your questions:

The box seems a tidy bit oversized for an Odroid, but that might be just the perspective of the image ;)

Odroid is placed together with other circuit breakers and protections in the PV AC Box on a DIN rail in such a box IMG_8495

Is there a reason that you choose to use three WIFI-adapters instead of one, besides of interferences?

Inverter works as a WiFi access point, it is not possible to connect one WiFi USB in the role of a station to several access points

I like the idea of running a client-HA just for the PV

client-HA also calculates the produced solar energy

When you said, connection via the SDongle you mean the wired connection? I still wonder why that is so unstable, after all the purpose of that dongle should be to establish that connection.

It doesn't matter if it is connected to WiFi or cable. Among other things, the S-Dongle also connects to the Fusion Solar cloud, which causes outages

When you said, you connected via serial, you mean via modbus, right?

Right

That was my preferred method until I read you had troubles with it. Do you have any details why the batteries couldn't be set to charge or discharge via modbus?

I think it is sufficiently explained here https://github.com/wlcrs/huawei_solar/discussions/595

Well all my questions might high-jack the purpose of a bug/feature-tracker. If there is any other way to communicate (discord, signal, etc.), please let me know. I am from Germany, if this helps.

If you want to solve something private, don't hesitate to send an email, I'm ready to help

Strakomania commented 5 months ago

Hey @MajoV, I just want to try connecting my huawei inverter the same way as you did. My question is how did you connect the USB wifi sticks? Is it just Plug and Play or need to install an accesspoint addon? And wich wifi stick you can recommend? I just bought the D-Link DWA-131 but im not sure if it will work.

Maybe you can help me.


My Setup: Homeassistant generic x64 on a IntelNuc.

torwag commented 5 months ago

@Strakomania I am not @MajoV but the APs come from the inverters. The reason you need a single stick (interface) for each inverter is the fact, that each converter creates its own wifi network. The sticks itself only need to run in client-Mode, which basically is the standard mode. As all this runs under Linux, you need sticks supported under Linux (which are the majority by now). I would not think to much about it, try a usb stick and if it works get a couple more. The network config is a bit more delicated as usual (with a single interface) as you have to setup three networks. I did not do it by myself yet, but when it comes to it, I am curious to see if I can adjust the wifi channel on the inverters to make sure they do not interfere.

Hope that helps.

Strakomania commented 5 months ago

Thanks for your answer.

Ok i will try a few sticks. The Amazon description from the stick says that it will work under linux but my HASS wont find it.

I am from Germany as well, if you want we could connect on discord.

github-actions[bot] commented 4 months ago

This issue has been automatically marked as stale because it has been open 30 days with no activity. Remove stale label or comment or this issue will be closed in 10 days

github-actions[bot] commented 4 months ago

This issue was automatically closed because of stale in 10 days