unfoldedcircle / feature-and-bug-tracker

Feature and bug tracker repository for Unfolded Circle products
22 stars 0 forks source link

Home Assistant integration not installing properly #263

Closed glc650 closed 5 months ago

glc650 commented 6 months ago

Is there an existing issue for this?

Description

Installing the integration results in "Internal server error, please try later": Untitled

After that the integration always just shows "connecting": Screenshot 2024-01-03 at 11 28 48 AM

It still seems to work but only in one direction - Remote Two > HA. The remote in HA is updated (sensors like charging status, etc., although they can take 20-30 seconds to refresh) and I can select an activity in HA and have it start but I cannot share anything in HA with the remote.

How to Reproduce

Just (attempt) to install the HA integration.

Expected behavior

Two-way functionality with the integration being fully connected and reflecting as such in the webif/on the remote.

System version

1.5.2

What part of the system affected by the problem?

Integration

Additional context

No response

zehnm commented 6 months ago

What do you mean exactly with:

It still seems to work but only in one direction - Remote Two > HA. The remote in HA is updated (sensors like charging status, etc., although they can take 20-30 seconds to refresh)

We do not provide an integration in Home Assistant for Remote Two, only the other way around. Remote Two can access and control most Home Assistant entities.

Please provide the Home Assistant integration log from Remote Two so I can investigate the "internal server error". The logs can be downloaded in the web-configurator from:

image

A few more questions:

glc650 commented 6 months ago

Remote Two can access and control most Home Assistant entities.

I don't have that ability: Screenshot 2024-01-03 at 1 45 25 PM If I try to do anything on that page I get the "internal server error" error.

Please provide the Home Assistant integration log from Remote Two

UCR2_logs_2024-01-03.txt

Do you use the default ws://homeassistant.local:8123/api/websocket connection address or a custom one?

I used IP: ws://10.1.0.8:8123/api/websocket

Home Assistant version

Core 2023.12.4 Supervisor 2023.12.0 Operating System 11.2 Frontend 20231208.2

Is your Home Assistant server on the same network as Remote Two, or do you have a router, reverse proxy, etc in between?

Everything is on the same subnet (/24) - Home Assistant (10.1.0.8), Remote Two (10.1.0.98), the macbook (10.1.0.31) used to access the Remote Two webif.

clayboyx commented 6 months ago

Running into similar issue as above... i was able to connect after trying all day but connection error occurred and i am right back to the above

zehnm commented 6 months ago

Thanks for the additional information and logs. I'm running the same HA server version, so that's ok.

From the log file I see that there was never a successful WebSocket connection to the API endpoint of the Home Assistant server. It's immediately disconnected after each connection attempt (Could not connect to ws://10.1.0.8:8123/api/websocket: SendRequest(Connect(Disconnected))). The next release will fix the hard coded reconnection limit and will keep on trying to connect. Related log entry: Max reconnect attempts reached (100). Giving up!. If a WebSocket connection could have been established, the following log message would be printed: Connected to: $url.

Without being able to connect to the Home Assistant server, no available entities will be shown. I'll add an improvement task for the web-configurator to disable all non-available functionality while the integration is not connected or in error state. That's currently causing the "internal server error".

Please double check your Home Assistant URL (ws://10.1.0.8:8123/api/websocket) and your router or access point, that there are no VLAN settings or other restrictions (like client device isolation) which prevent WiFi devices accessing your network.

Do you have connection issues with the dock as well?

If your network settings don't prevent access to the Home Assistant server, then I can only think of a HA setup issue right now. For example that ws:// access is disabled or prevented with a reverse proxy, or that the API port is not mapped if HA is running in a container image.

zehnm commented 6 months ago

@clayboyx please provide log information and a description about your Home Assistant setup.

clayboyx commented 6 months ago

Please provide the Home Assistant integration log from Remote Two

UCR2_logs_2024-01-04 (3).txt

Do you use the default ws://homeassistant.local:8123/api/websocket connection address or a custom one?

I used IP: ws://192.168.1.98:8123/api/websocket

Home Assistant version

Core 2023.12.4 Supervisor 2023.12.0 Operating System 11.2 Frontend 20231208.2

Is your Home Assistant server on the same network as Remote Two, or do you have a router, reverse proxy, etc in between?

Everything is on the same subnet (/24) - Home Assistant :192.168.1.98 Remote Two : 192.168.1.78 dekstop [192.168.1.220] used to access the Remote Two webconf.

hopefully, this helps ... as I said I was able to connect after hours of trying but then the connection began to error while I was running an activity with an entity (avr) power one function guess the remote made a call but timedout . Now just getting internal server error.

zehnm commented 6 months ago

@clayboyx the remote cannot connect to your HA server API endpoint: Could not connect to ws://192.168.1.98:8123/api/websocket: SendRequest(Connect(Io(Os { code: 111, kind: ConnectionRefused, message: "Connection refused" })))

Please check your setup that port 8123 is open, that ws:// connections are allowed and no reverse proxy is installed. A default HA installation has ws:// and port 8123 open. If you installed any dynamic DNS, remote access etc addons in HA, then this might have disabled it.

glc650 commented 6 months ago

Please double check your Home Assistant URL (ws://10.1.0.8:8123/api/websocket)

I'm not sure I follow. 10.1.0.8:8123 is definitely what I use to access Home Assistant except I have to use https (if I use http instead the page fails to load). I'm not sure about ws: and the /api/websocket part. That was already there so I just replaced the hostname with the IP that I always use to access HA. Should I try with https instead or something else?

and your router or access point, that there are no VLAN settings or other restrictions (like client device isolation) which prevent WiFi devices accessing your network.

There's nothing like that blocking access. I probably have some 20+ WiFi devices (light switches, AC outlets, Harmony Hubs, Shelly relays, etc.) all connected throughout my home that I use with HA without any issues and about 10 of those devices are connected to the same AP as the Remote Two.

Do you have connection issues with the dock as well?

In what way? The Dock is wired but as far as I can tell it doesn't even try to connect to HA? I can ping it no problem and access its web page at http://10.1.0.94. Plus the Remote's webif shows it as connected.

For example that ws:// access is disabled or prevented with a reverse proxy, or that the API port is not mapped if HA is running in a container image.

How do I check that? I don't see any settings in HA regarding ws:// access. As I mentioned above the IP:port is correct and what I use to access HA so I know that is working. None of the devices on my network are using proxies.

clayboyx commented 6 months ago

Looks like I had the wrong IP... I switched to the correct one and it is working again but not sure how it got changed cannot remember had 192.168.1.98 correct was 192.168.1.93 man I need sleep losing my mind.

glc650 commented 6 months ago

If you installed any dynamic DNS, remote access etc addons in HA, then this might have disabled it.

I have the Duck DNS (with Let's Encrypt support) add-on installed. Could this be my issue? I need it for Alexa to work with HA (there might be something else I use that needs it too I can't remember).

zehnm commented 6 months ago

I have the Duck DNS (with Let's Encrypt support) add-on installed. Could this be my issue?

Very likely. I haven't used those HA addons (I use VPN to access my internal services) but I suspect your HA server is now configured for https only.

If you use Let's Encrypt in Home Assistant then I assume you do it to access it from the internet? Did you also add a port forwarding in your router to port 8123 on your HA server?

Then that's the issue: 8123 no longer accepts http / ws!

glc650 commented 6 months ago

So what's the solution here? Can't wss be used instead?

zehnm commented 6 months ago

10.1.0.8:8123 is definitely what I use to access Home Assistant except I have to use https (if I use http instead the page fails to load)

Sorry I missed the previous message that you have to use https. This confirms that the default port was changed from http to https, which also changes the WebSocket API protocol from ws to wss. The API URL ws://10.1.0.8:8123/api/websocket doesn't work anymore with this change and requires wss:// instead.

If it works with the IP address depends on how your certificate is generated. Accessing it with the public dynamic DNS depends if your router supports NAT hairpinning.

If a wss:// URL is used in the integration, the certificate needs to be a valid public certificate. The certificate check cannot be disabled with the included HA integration on the remote.

glc650 commented 6 months ago

It appears to be working with wss and the Duck DNS name in the URL. When I first changed to wss it gave the same internal server error but when I went back to the Integrations & docks page HA showed up as Active and entities from HA have been discovered (and the error appears to have stopped popping up).

If a wss:// URL is used in the integration, the certificate needs to be a valid public certificate.

The Duck DNS add-on uses Let's Encrypt so the cert is definitely valid (not self-signed). That must be why using wss with the DNS name works for me.

zehnm commented 5 months ago

Glad to hear it's working, I'm closing this issue.