krbaker / hass-sunpower

Home Assistant SunPower Integration using the local installer ethernet interface.
Apache License 2.0
63 stars 23 forks source link

Can't connect to raspberry interface #87

Open chenzetian opened 3 months ago

chenzetian commented 3 months ago

Hello,

I've already set up the Raspberry Pi on the PSV system and can get the device list on 10.0.0.174. However, on HA, it says it cannot connect. When I run ifconfig on HA system. I can see the eth0 is at 172.30.33.1, which is weird. The HA is on 10.0.0.3. In the HA system, It says the network interface it's using is End0. However, I can't see that on ifconfig.

I can confirm that they are on the same lan.

krbaker commented 3 months ago

If you can explain your networks in a little more detail that might be helpful.

You have probably 4 systems at minimum: 1) Your Router / DHCP server (just guessing 10.0.0.1) for your home network and looks like that network is 10.0.0.0/24 (or maybe bigger netmask, but roughly that) 2) Your HA box 10.0.0.3 (is it running the full HA-OS + Supervisor or is it some other container management system?). This is the system you are seeing eth0 is 172.30.33.1? (that sounds like it might be a docker virtual device if I'm not mistaken..). If this is just the docker network on an HA-OS box it should bridge just fine.. if its some other container management system you might well need to allow access. 3) Your Raspberry Pi which it sounds like is living on both the PVS and your home network? On your home network the RPI has an address of 10.0.0.174 (and presumably a 172 address from the PVS). When you say you can get the device list endpoint 'on 10.0.0.174' are you running the command from the Raspberry Pi? It might well have a firewall on the RPI or not be setup to listed on the 10.0.0.174 interfaces. Given the way you say 'from 10.0.0.172' I'm assuming you are curling from a command line on the Raspberry Pi to http://10.0.0.174/ which means its at least opening the right TCP port on the right interface (so I'd check for a firewall). Have you tried curling from a different host on the 10.0.0.0/24 network? does that work properly? 4) Last of all the PVS, I'm assuming its management interface is not 'on the same lan' because it always has DHCP running and that would conflict with the DHCP you are presumably running on your home network. I assume there is a two device network of RPI & PVS and then another 'home network' (10.0.0.0/24 ish)

The first spot of debugging would be to curl the device list endpoint from another machine on the 10.0.0.0/24 network. If that doesn't work its probably a firewall on the RPI. If that does work I'd look at the machine running HA-OS.. I'd TCPdump on the host itself (the very base system, not within a container). See if any connections to 10.0.0.174 are leaving the system, investigate from there.

jgrant216 commented 2 months ago

I also have a Raspberry PI (RPI 5 to be exact) and am having the same symptoms, unable to get it to recognize the IP. Since OP is 6 weeks out and hasn't responded, here are my details.

My RPI is wired with IP 192.168.6.41. The PSV6 is wireless with IP 192.168.4.30. Network is Eero 6e.

From RPI Terminal (add-on to HA), I am able to ping 192.168.4.30. Running curl -v http://192.168.4.30/cgi-bin/dl_cgi?Command=DeviceList, it just spins. Is the URL wrong?

From my laptop, also wireless, I can ping 192.168.4.30 and the curl command continues to time out.

Pinging 192.168.4.30 with 32 bytes of data:
Reply from 192.168.4.30: bytes=32 time=172ms TTL=64

curl -v --max-time 180 --connect-timeout 180 http://192.168.4.30/cgi-bin/dl_cgi?Command=DeviceList
*   Trying 192.168.4.30:80...
* connect to 192.168.4.30 port 80 from 0.0.0.0 port 55838 failed: Timed out
* Failed to connect to 192.168.4.30 port 80 after 21035 ms: Couldn't connect to server
* Closing connection
curl: (28) Failed to connect to 192.168.4.30 port 80 after 21035 ms: Couldn't connect to server

Is there any more information In can provide?

jgrant216 commented 2 months ago

@krbaker , from more searching online, I think the issue is that the PVS6 doesn't provide an API over the home connected wifi. Instead, people have connected an RPI to the PVS6's ethernet and used HA Proxy to forward the LAN connection across their wifi.

Please confirm that we cannot use the PVS6 for API calls over it's wifi connection to the home network.

koleson commented 2 months ago

Please confirm that we cannot use the PVS6 for API calls over its wifi connection to the home network.

This is correct. You cannot access the local API over the PVS6's connection to the home Wi-Fi if so-configured.

You can access the local API over the PVS6's built-in access point (SSID SunPower######) when available.

heyhewmike commented 2 months ago

from more searching online, I think the issue is that the PVS6 doesn't provide an API over the home connected wifi. Instead, people have connected an RPI to the PVS6's ethernet and used HA Proxy to forward the LAN connection across their wifi.

Correct. Based on the IPs you shared it looks like you either have subnets or a 192.168.0.0 255.255.0.0 setup.

My PVS6 is currently showing it is handing out an address in the 172.27.153.0 range on it's local network.

The issue that is happening when trying to access via the home connected wifi is that the firmware is running a firewall on the wifi and wan ethernet/usb port.

Using the RPi to the Lan port, where a SunVault would connect for it's Internet connection, and using software like Nginx (HA Proxy) to forward requests from their home network through the RPi's WiFi and out the RPi's Ethernet to reach the LAN, SunVault Ethernet plug, allows the requsts to be answered. This bypasses the firewall.

Inside the SunVault is a communication device for the inverter that requires an internet connection that the PVS would provide through itself, in addition to any other communication methods being used for management of the inverter.

jgrant216 commented 1 month ago

@koleson , I am getting a 403 on the API so I think that means I am out of luck to use this service. Please confirm.

Edit - Including URL http://172.27.153.1/#/summary This was my misunderstanding as the summary URL is expected to return a 403. See my later comment for more information.

koleson commented 1 month ago

@jgrant216 can you be a bit more specific about which URL you're trying to hit when you get a 403?

jgrant216 commented 1 month ago

@koleson , I was getting a 403 against http://172.27.153.1/#/summary.

Now I see the integration uses http://172.27.153.1/cgi-bin/dl_cgi?Command=DeviceList which does indeed return my device list after about 8 seconds.

Sorry for the red herring as I think I'm OK to proceed. My next step is to sort out my mini-router mapping but at least, from the router WIFI, I can connect to the dl_cgi URL.