jason0x43 / hacs-hubitat

A Hubitat integration for Home Assistant
MIT License
203 stars 47 forks source link

Post-migration to Home Assistant OS, "Unexpected error occured" #301

Open jeffbeale opened 1 day ago

jeffbeale commented 1 day ago

I migrated from TrueNAS scale into Proxmox and had to recreate and restore my Home Assistant setup from a backup. After the restoration, Hubitat completely broke and now I have no doors, buttons, or switches.

A part of this migration was migrating away from the janky setup I had on TrueNAS where I was using the x86 baremetal image as the base for a virtual machine -I am now using the Home Assistant OS as installed from here: https://community-scripts.github.io/ProxmoxVE/scripts?id=haos-vm

When adding, the error on the integration page reads "Unexpected error occured" and it happens immediately.

To reliably reproduce this in my environment, do the following: 1) Migrate from a janky half baked TrueNAS VM to a Proxmox VM using the Home Assistant OS image 2) Restore from backup 3) Configure network settings so that the new instance matches the same IP that the old instance had 4) Hubitat breaks 5) After deleting the app and integration, downloading a fresh install, and attempting to add it back the logs show this error: image

Error text: This error originated from a custom integration.

Logger: custom_components.hubitat.config_flow Source: custom_components/hubitat/config_flow.py:100 integration: Hubitat (documentation, issues) First occurred: 6:22:10 AM (1 occurrences) Last logged: 6:22:10 AM

Unexpected exception Traceback (most recent call last): File "/config/custom_components/hubitat/hubitatmaker/hub.py", line 167, in check_config await self._check_api() File "/config/custom_components/hubitat/hubitatmaker/hub.py", line 307, in _check_api await self._api_request("devices") File "/config/custom_components/hubitat/hubitatmaker/hub.py", line 467, in _api_request raise e File "/config/custom_components/hubitat/hubitatmaker/hub.py", line 414, in _api_request async with aiohttp.request( File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 1391, in aenter self._resp = await self._coro ^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 690, in _request await resp.start(conn) File "/usr/local/lib/python3.12/site-packages/aiohttp/client_reqrep.py", line 1059, in start message, payload = await protocol.read() # type: ignore[union-attr] ^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/aiohttp/streams.py", line 644, in read await self._waiter aiohttp.client_exceptions.ServerDisconnectedError: Server disconnected

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/config/custom_components/hubitat/config_flow.py", line 100, in async_step_user info = await _validate_input(user_input) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/hubitat/config_flow.py", line 474, in _validate_input await hub.check_config() File "/config/custom_components/hubitat/hubitatmaker/hub.py", line 169, in check_config raise ConnectionError(str(e)) ConnectionError: Server disconnected

Environment

jeffbeale commented 12 hours ago

Multiple forum posts indicate this is definitely not an integration issue. This is likely an issue with the networking on my local environment, most likely a firewall issue within Proxmox (this is odd as I do not have the firewall enabled at any layer). Once I find the resolution, I will post a detailed writeup here and on the community forums

jason0x43 commented 9 hours ago

The main network considerations are

HA must be able to send HTTP messages to "Hub address", and Hubitat must be able to send HTTP messages to "Event server URL" (and the event server must be able to receive things sent to the event server URL).

Screenshot 2024-12-01 at 17 44 15

If HA is behind a proxy, the proxy should forward things received at "event server URL" to the event server's port, so "event server port" and the port in "event server URL" could be different. If HA is not behind a proxy, and Hubitat is able to access it directly, then "event server port" and the port in "event server URL" should be the same.