davidrapan / ha-solarman

⚡ Solarman Stick Logger integration for 🏠 Home Assistant
MIT License
115 stars 25 forks source link

Second inverter not working across WAN's #22

Closed ks0002544 closed 2 months ago

ks0002544 commented 4 months ago

I need to control several inverters. But it does not work. Only one inverter works. But Solarman integration can work with three inverters.

davidrapan commented 4 months ago

Hi, what does it do then? Can you maybe provide some logs with debugging enabled?

ks0002544 commented 4 months ago

can you check your code: I use connection to inverter via port transfering (from WAN to another WAN). Not inside local net. real Solarman supports it.

ks0002544 commented 4 months ago

here is log home-assistant_solarman_2024-07-18T19-44-23.015Z.log

davidrapan commented 4 months ago

can you check your code: I use connection to inverter via port transfering (from WAN to another WAN). Not inside local net. real Solarman supports it.

That should not be a problem,

here is log home-assistant_solarman_2024-07-18T19-44-23.015Z.log

I need you to also enable debug here: solarman_enable_debug

But V5FrameError: V5 frame contains incorrect data logger serial number looks quite suspicious...

Cheers!

ks0002544 commented 4 months ago

it is very strange I have 2 servers Deb 12 with HA installed both the same FW These servers are located in other WAN One server can connect to three inverters using your integration Second one can not

davidrapan commented 4 months ago

That's strange indeed...

My first best guess is that there is slight difference between configuration of the connection between the servers and inverters (maybe firewall rules, or even port forwarding or something like that).

But I want to help you debug your issue so to better understand your "setup" I have few questions.

Did you try to remove the inverters and re-add them again? So we can rule out some configuration fopa cause the log showed some problem with the serial number. Maybe you mismatched and used wrong combination of IP and Serial Numbers of the inverters.

Are both mentioned servers behind the same WAN? Inverters are also both together behind but other WAN? So you are connecting between two WAN's like this WAN <-> WAN? And then using port forwarding on the routers? Or you are using tunneled connections?

If it's the former I have to express some concerns due to security reasons. Exposing Solarman ports on the WAN is really not great Idea as the protocol don't understand what security is. So I hope you have at least some firewall rules in place which limits access to those exposed ports only from your other WAN where the servers sits.

ks0002544 commented 4 months ago

Yes I use port transfering on my routers. I have Wan1 - 2 x 3 phase inverters Wan2 - server1 Wan3 - server2 and 1x 1 phase inverter

davidrapan commented 4 months ago

And which way it works and which one do not? Which server has mentioned issues?

ks0002544 commented 4 months ago

Server1 can connect to all three inverters Server2 can connect only to 1 phase inverter locally but no connection to 2x3 phase inverters

ks0002544 commented 4 months ago

But with real solarman integration it works

davidrapan commented 4 months ago

Okay I have to say that at least this makes some sense...

Now we can say that the issue is probably with Wan1 configuration meaning maybe the router is blocking connection from Wan3 (server2). Could be some firewall rules which are allowing only IP from Wan2 and not from Wan3.

davidrapan commented 4 months ago

But with real solarman integration it works

What do you mean by real solarman integration? You mean the app or?

ks0002544 commented 4 months ago

I mean integration from Stephan

davidrapan commented 4 months ago

Server1 can connect to all three inverters Server2 can connect only to 1 phase inverter locally but no connection to 2x3 phase inverters

I mean integration from Stephan

Please try to enable debug logging as I showed you on the picture before on server2. Best will be to also restart HA after you enable it and then let it run for few minutes and post the log here.

davidrapan commented 4 months ago

Yes I use port transfering on my routers. I have Wan1 - 2 x 3 phase inverters Wan2 - server1 Wan3 - server2 and 1x 1 phase inverter

Please also tell me your IP and S/N combination you are using in your setting in both servers (S/N only first few digits for example as 211XXXXXXX). So I can rule out some misconfiguration.

davidrapan commented 4 months ago

@ks0002544 I prob did found the issue!

I tried to fix it in: fix: DIsabled discovery was ignored at runtime

Please don't forget that you have to disable device discovery as this feature is probably the culprit.

ks0002544 commented 4 months ago

so Wan1 - 2 x 3 phase inverters 192.168.1.95/274XXXXX and 192.168.1.91/279XXXXX Wan2 - server1 Wan3 - server2 and 1x 1 phase inverter 192.168.1.24/290XXXXXX

Disabled discovery did not fix it

ks0002544 commented 4 months ago

this is the log home-assistant_solarman_2024-07-19_1.log

ks0002544 commented 4 months ago

I found on git https://github.com/StephanJoubert/home_assistant_solarman/issues/419#issuecomment-1773924534

https://github.com/StephanJoubert/home_assistant_solarman/issues/539#issuecomment-2035314517

davidrapan commented 4 months ago

this is the log home-assistant_solarman_2024-07-19_1.log

It is still log without debug enabled...

Please first click on this button at the bottom...

can you check your code: I use connection to inverter via port transfering (from WAN to another WAN). Not inside local net. real Solarman supports it.

That should not be a problem,

here is log home-assistant_solarman_2024-07-18T19-44-23.015Z.log

I need you to also enable debug here: solarman_enable_debug

But V5FrameError: V5 frame contains incorrect data logger serial number looks quite suspicious...

Cheers!

ks0002544 commented 4 months ago

log file home-assistant_solarman_2024-07-19T18-53-43.199Z.log

davidrapan commented 4 months ago

Great!

And I guess the IP you obfuscated (xxx.xxx.xxx.xxx) at first line with timestamp: 2024-07-19 21:39:32.364 is your WAN IP where the remote inverter sits right? Just to be clear.

So from the log it looks like it for some reason ignores the set IP and just connects to the local inverter even with discovery disabled so that is probably the issue. I'm gonna try to find out why it happens and I'll let you know!

Thanks for your cooperation!

ks0002544 commented 4 months ago

yes it is WAN where inverters are installed

davidrapan commented 4 months ago

When did you updated the integration last time? And how did you do the update? Did you used HACS to do it or manually replaced the code? (Just making sure that we are both running the same code)

ks0002544 commented 4 months ago

I used both methods. But last time several times manually copied integration into folder solarman

davidrapan commented 4 months ago

Yes manual copy is the proper way during "hot-fixing" like this cause HACS would download older version.

Could you try one more thing for me? The same thing as you did before, adding the device again (while having the debug enabled) but purposefully with wrong IP (some random local one for example)? And do it once with discovery enabled and once with discovery disabled.

Thanks again for your excessive help with this issue!

ks0002544 commented 4 months ago

Edit: Deleted logs as they exposed serial numbers!

davidrapan commented 4 months ago

So I just committed feat: Disable discovery for non private IPs which should disable discovery for non private IPs by default. So update the code manually again and let me know if it worked.

And if won't I just get rid of it all together cause it already caused way more troubles than it was useful...

Cheers!

ks0002544 commented 4 months ago

Edit: Deleted log as it exposed serial numbers!

ks0002544 commented 4 months ago

so, I noticed the following: I can connect to the 2 inverters from Wan2 to Wan1 because Wan2 has no any local inverter connected/discovered otherwise no connection from Wan3 to Wan1 because solarman integration discovered one local inverter

Wan1 - 2 x 3 phase inverters 192.168.1.95/274XXXXX and 192.168.1.91/279XXXXX Wan2 - server1 Wan3 - server2 and 1x 1 phase local inverter 192.168.1.24/290XXXXXX

davidrapan commented 4 months ago

Ou sorry, I broke it:

2024-07-20 09:04:01.223 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Inverter for solarman
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 586, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/solarman/__init__.py", line 61, in async_setup_entry
    inverter = Inverter(inverter_host, inverter_serial, inverter_port, inverter_mb_slave_id, name, inverter_mac, lookup_path, lookup_file)
                                                                                                   ^^^^^^^^^^^^
UnboundLocalError: cannot access local variable 'inverter_mac' where it is not associated with a value

But it looks like it will work after I fix this. Gimme a sec! :)

davidrapan commented 4 months ago

It should be all good now! Fixed in: 1889332

ks0002544 commented 3 months ago

So, 3 inverters are not working in one intergation but if I do separate integration for each inverter - it is works

davidrapan commented 3 months ago

What do you mean by that? And always provide debug logs please.

github-actions[bot] commented 2 months ago

This issue is stale because it has been open for 30 days with no activity.

davidrapan commented 2 months ago

Closing because that shouldn't be an issue anymore.