Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't read data from prana recuperator due to connection failing after 5 attempts #3

Open
MislavMandaric opened this issue May 6, 2021 · 4 comments

Comments

@MislavMandaric
Copy link

MislavMandaric commented May 6, 2021

Hi.

First of all, thank you for the great work on this integration. I never thought I'd see my recuperator integrated with HA and I really appreciate the work you've done, both on the integration and the awesome prana_rc library.

I set up this integration and prana_rc server on my RPi (both running on the same HA OS) and when I first start the prana_rc docker container, everything works well.

But after some time, I always get the error from the title after which my recuperator disconnects from HA and becomes unavailable.

This is my setup:

  • HA OS running on RPi4, version 5.12; HA Core version is core-2021.4.6; Supervisor version is supervisor-2021.04.3
  • Prana RC server running on the same machine, deployed using Portainer (config from the prana_rc repository is used -- /run/dbus/system_bus_socket, hassio network, restart unless stopped policy, with default 8881 port mapping), version corvis/prana-rc:0.4.4 of the image
  • Integration installed using HACS as custom repository
  • RPi is ~6m away from the recuperator, in the same room

I can ping the prana_rc server from my laptop terminal, which means the server itself is running and it does show proper connection to the recuperator:

curl -X POST -H "Accept: application/json" http://homeassistant.local:8881/ -d '{ "jsonrpc": "2.0", "id": 1, "method": "prana.healthcheck" }'
{"result": {"version": "0.4.4", "timestamp": "2021-05-06T19:21:15.699394", "current_connections": ["XX:XX:XX:XX:XX:XX"]}, "id": 1, "jsonrpc": "2.0"}

But this is the log from HA, showing connection errors. I enabled the debug log and there is nothing in addition to these error snippets, which occur 3-4 times in the log.

2021-05-06 21:22:46 WARNING (MainThread) [custom_components.prana.fan] Can't read data from prana recuperator Prana (prana_XX_XX_XX_XX_XX_XX): RPC Invocation error -32000: Server error. Cause: RuntimeError: Connection to device XX:XX:XX:XX:XX:XX failed after 5 attempts
2021-05-06 21:22:46 ERROR (MainThread) [custom_components.prana.fan] Unexpected error fetching prana_XX_XX_XX_XX_XX_XX data: RPC Invocation error -32000: Server error. Cause: RuntimeError: Connection to device XX:XX:XX:XX:XX:XX failed after 5 attempts
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 173, in _async_refresh
self.data = await self._async_update_data()
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 143, in _async_update_data
return await self.update_method()
File "/config/custom_components/prana/fan.py", line 67, in async_get_state
raise e
File "/config/custom_components/prana/fan.py", line 62, in async_get_state
return await prana_client.get_state(
File "/usr/local/lib/python3.8/site-packages/prana_rc/contrib/client/common.py", line 45, in get_state
await self.async_invoke(
File "/usr/local/lib/python3.8/site-packages/sizzlews/client/common.py", line 179, in async_invoke
return await self._invoke_request(rq, expected_response_type)
File "/usr/local/lib/python3.8/site-packages/sizzlews/client/aiohttp.py", line 47, in _invoke_request
return self._parse_rpc_response(await response.json(), expected_response_type)
File "/usr/local/lib/python3.8/site-packages/sizzlews/client/common.py", line 119, in _parse_rpc_response
raise RPCInvocationError.from_rpc_dict(response[RESPONSE_FIELD_EROR])
sizzlews.client.common.RPCInvocationError: RPC Invocation error -32000: Server error. Cause: RuntimeError: Connection to device XX:XX:XX:XX:XX:XX failed after 5 attempts
2021-05-06 21:22:46 DEBUG (MainThread) [custom_components.prana.fan] Finished fetching prana_XX_XX_XX_XX_XX_XX data in 2.729 seconds

This is the screenshot of how it looks like from the UI (all entities are disabled and unavailable).
image

If there is anything I can do more to help out in in resolving this issue, I'll gladly contribute.

@corvis
Copy link
Owner

corvis commented May 7, 2021 via email

@MislavMandaric
Copy link
Author

MislavMandaric commented Jul 10, 2021

Hey @corvis. Do you have any updates on this one?

I still have this same behavior -- once I set up my integration, it works for some time (~hours) and after that it stops working.

Now I checked out the usage by curling the API some more and apparently it doesn't work even from the terminal. Same as before, I can get a proper health check response (same as I already wrote), but when I do a curl for get_state method, it returns an error:

curl -X POST -H "Accept: application/json" http://homeassistant.local:8881/ -d '{ "jsonrpc": "2.0", "id": 1, "method": "prana.get_state", "params": {"address": "XX:XX:XX:XX:XX:XX"} }' 
{"error": {"code": -32000, "message": "Server error", "data": {"type": "RuntimeError", "args": ["Connection to device XX:XX:XX:XX:XX:XX failed after 10 attempts"], "message": "Connection to device XX:XX:XX:XX:XX:XX failed after 10 attempts"}}, "id": 1, "jsonrpc": "2.0"}

So it might not be connected to the integration, rather to the prana_rc server.

I'm looking at the logs in Portainer for my prana_rc container and there aren't any. Is there a way to run the prana_rc server with some verbose logging, so I can provide more details on the issue?

Also, would you rather to open another PR in prana_rc repository since the issue is most likely somewhere in the server, not in the integration.

EDIT: Stopping and starting the container again makes it work from the CLI, but from Home Assistant it is still showing as unavailable.

@aurelian17
Copy link

aurelian17 commented Oct 15, 2022

I have a similar problem. On HA 2022.10 is impossible to connect to the Prana recuperator.
If makes any sense, in the past 2 releases, HA added support natively for BT BLE. Also, a new feature called BT Proxy might help connect to the recuperators that are far from the server running the prana_rc.

@yuriilemberg
Copy link

I have same issue, sometimes it works sometimes it gives me this error

code: -32000, message: 'Server error', data: { type: 'RuntimeError', args: [Array], message: 'Connection to device xx:94:xx:F5:xx:xx failed after 10 attempts'

btw, discover works all the time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants