home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
72.39k stars 30.29k forks source link

Cannot install Risco integration using local option with panel RP512 panel #87008

Closed papeon closed 1 year ago

papeon commented 1 year ago

The problem

I'm trying to add the integration Risco to manage my panel in HA. The cloud communication is disabled because I prefer the local one for many reason. I'm not able to finish the wizard and problem is very similar (if not the same) to discussed at issue: 82209.

My panel is: image and my ethernet card is: image

During the installation I use the right IP:port and also the right Access Code. After some seconds I get this error without any other log. image

I'm quite sure of the code and IP:port because I'm able to connect with Configuration Software (see pics). The panel is Risco ProSYS Plus (RP512). May it be that this panel is not supported?

I would like to help if I can with some more information.

Thanks.

What version of Home Assistant Core has the issue?

core-2023.1.7

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Risco

Link to integration documentation on our website

https://www.home-assistant.io/integrations/risco

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

My HA istance is running on a Raspberry Pi 3 (32-bit)

home-assistant[bot] commented 1 year ago

Hey there @onfreund, mind taking a look at this issue as it has been labeled with an integration (risco) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `risco` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Change the title of the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign risco` Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


risco documentation risco source (message by IssueLinks)

OnFreund commented 1 year ago

RP512 should be supported. Can you turn on debug logs for the Risco integration?

papeon commented 1 year ago

Could you explain me how to do this? I've added logger: logs: homeassistant.components.risco: debug in my configuration.yaml. Is this correct? Where I found the logs?

OnFreund commented 1 year ago
logger:
  default: warn
  logs:
    homeassistant.components.risco: debug

And then restart HA.

papeon commented 1 year ago

Ok, I've found where to look. Here's the result after the last test to setup:

2023-01-31 11:39:17.513 DEBUG (MainThread) [homeassistant.components.risco.config_flow] Cannot connect
Traceback (most recent call last):
File "/usr/local/lib/python3.10/asyncio/tasks.py", line 456, in wait_for
return fut.result()
asyncio.exceptions.CancelledError
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/pyrisco/local/risco_socket.py", line 105, in send_command
return await asyncio.wait_for(future, 1)
File "/usr/local/lib/python3.10/asyncio/tasks.py", line 458, in wait_for
raise exceptions.TimeoutError() from exc
asyncio.exceptions.TimeoutError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/pyrisco/local/risco_socket.py", line 36, in connect
panel_id = int(await self.send_result_command('RID'), 16)
File "/usr/local/lib/python3.10/site-packages/pyrisco/local/risco_socket.py", line 95, in send_result_command
command = await self.send_command(command)
File "/usr/local/lib/python3.10/site-packages/pyrisco/local/risco_socket.py", line 107, in send_command
raise OperationError(f'Timeout in command: {command}')
pyrisco.common.OperationError: Timeout in command: RID
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/risco/config_flow.py", line 159, in async_step_local
info = await validate_local_input(self.hass, user_input)
File "/usr/src/homeassistant/homeassistant/components/risco/config_flow.py", line 87, in validate_local_input
await risco.connect()
File "/usr/local/lib/python3.10/site-packages/pyrisco/local/risco_local.py", line 26, in connect
await self._rs.connect()
File "/usr/local/lib/python3.10/site-packages/pyrisco/local/risco_socket.py", line 47, in connect
raise CannotConnectError from exc
pyrisco.common.CannotConnectError
OnFreund commented 1 year ago

Looks like your panel is reject the connection. Most likely you either have the wrong hostname, or no available connections. Do you have anything else communicating locally with the panel? You might have to disable cloud (not having an active subscription is not enough)

papeon commented 1 year ago

Yes, I have disabled the cloud communications as the first thing. No other communications active that my CS. image

On previuous log CS was active (but not in the many others test). Sorry, here's the new log with no CS closed and no other communication with the panel:

2023-01-31 12:08:39.479 DEBUG (MainThread) [homeassistant.components.risco.config_flow] Cannot connect
Traceback (most recent call last):
File "/usr/local/lib/python3.10/asyncio/tasks.py", line 456, in wait_for
return fut.result()
asyncio.exceptions.CancelledError
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/pyrisco/local/risco_socket.py", line 105, in send_command
return await asyncio.wait_for(future, 1)
File "/usr/local/lib/python3.10/asyncio/tasks.py", line 458, in wait_for
raise exceptions.TimeoutError() from exc
asyncio.exceptions.TimeoutError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/pyrisco/local/risco_socket.py", line 36, in connect
panel_id = int(await self.send_result_command('RID'), 16)
File "/usr/local/lib/python3.10/site-packages/pyrisco/local/risco_socket.py", line 95, in send_result_command
command = await self.send_command(command)
File "/usr/local/lib/python3.10/site-packages/pyrisco/local/risco_socket.py", line 107, in send_command
raise OperationError(f'Timeout in command: {command}')
pyrisco.common.OperationError: Timeout in command: RID
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/risco/config_flow.py", line 159, in async_step_local
info = await validate_local_input(self.hass, user_input)
File "/usr/src/homeassistant/homeassistant/components/risco/config_flow.py", line 87, in validate_local_input
await risco.connect()
File "/usr/local/lib/python3.10/site-packages/pyrisco/local/risco_local.py", line 26, in connect
await self._rs.connect()
File "/usr/local/lib/python3.10/site-packages/pyrisco/local/risco_socket.py", line 47, in connect
raise CannotConnectError from exc
pyrisco.common.CannotConnectError
OnFreund commented 1 year ago

It's still timing out in RID, which is the first command being sent. That means it's not able to establish a connection. Are you sure that the panel is accessible from HA?

papeon commented 1 year ago

Yes, from the terminal i can ping the panel's IP. Just to avoid mistake I've done a test with only 3 devices: rpi, mypc, panel (hardwired with a tplink unmanaged switch). The test have produced the same result.

OnFreund commented 1 year ago

Well, you're on Home Assistant OS, so it's not exactly 3 devices (you have multiple containers), but most problems I know with OS are DNS related, and sounds like you're using the IP address.

Can you try using pyrisco directly in a Python repl?

papeon commented 1 year ago

I'm not so really expert, sorry. Other tips? Is it any other way but using ip address? in my panel's configuration I haven't found any "hostname". DNS of eth0 in HAOS is the same of Risco and is related to my router (TP-Link Deco).

OnFreund commented 1 year ago

Sorry, can't really remotely debug what seems to be a network issue. If you're able to run a Python console with pyrisco we can try to investigate a bit further.

papeon commented 1 year ago

I've installed python and pyrisco. I'm in the console.

OnFreund commented 1 year ago

OK, install the pyrisco package and the https://pypi.org/project/aioconsole/ package, and then run apython to start a shell (this will make it easier to run async code). Then trying running the sample code from the Local section of the readme (replace with the relevant host, etc..), and let's see where you get to

papeon commented 1 year ago

ok, other step ahead. installed aioconsole package and run it on a terminal window. In a new one opened python and dropped the code with my 3 parameters. I'm wrong with:

>>> await r.connect()
  File "<stdin>", line 1
SyntaxError: 'await' outside function

what am I missing? thanks for your patience.

OnFreund commented 1 year ago

As I mentioned above, you need to run apython to open an async shell.

papeon commented 1 year ago

I feel so stupid.... forgive me.

I've done the test on the pc where I have CS installed (and working fine) Here opart of the log:

>>> await r.connect()
Traceback (most recent call last):
  File "C:\Users\paolo\AppData\Local\Programs\Python\Python311\Lib\asyncio\tasks.py", line 490, in wait_for
    return fut.result()
           ^^^^^^^^^^^^
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\paolo\AppData\Local\Programs\Python\Python311\Lib\site-packages\pyrisco\local\risco_socket.py", line 105, in send_command
    return await asyncio.wait_for(future, 1)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\paolo\AppData\Local\Programs\Python\Python311\Lib\asyncio\tasks.py", line 492, in wait_for
    raise exceptions.TimeoutError() from exc
TimeoutError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\paolo\AppData\Local\Programs\Python\Python311\Lib\site-packages\pyrisco\local\risco_socket.py", line 36, in connect
    panel_id = int(await self.send_result_command('RID'), 16)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\paolo\AppData\Local\Programs\Python\Python311\Lib\site-packages\pyrisco\local\risco_socket.py", line 95, in send_result_command
    command = await self.send_command(command)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\paolo\AppData\Local\Programs\Python\Python311\Lib\site-packages\pyrisco\local\risco_socket.py", line 107, in send_command
    raise OperationError(f'Timeout in command: {command}')
pyrisco.common.OperationError: Timeout in command: RID

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\paolo\AppData\Local\Programs\Python\Python311\Lib\site-packages\aioconsole\execute.py", line 145, in aexec
    result, new_local = await coro
                        ^^^^^^^^^^
  File "<console>", line 2, in __corofn
  File "C:\Users\paolo\AppData\Local\Programs\Python\Python311\Lib\site-packages\pyrisco\local\risco_local.py", line 26, in connect
    await self._rs.connect()
  File "C:\Users\paolo\AppData\Local\Programs\Python\Python311\Lib\site-packages\pyrisco\local\risco_socket.py", line 47, in connect
    raise CannotConnectError from exc
pyrisco.common.CannotConnectError
OnFreund commented 1 year ago

Wait, CS is connected to the panel? You need to close it and wait 5 minutes for the connection to close (ideally shut that computer down and try from a different one)

papeon commented 1 year ago

no, cs closed, but it's the same machine

OnFreund commented 1 year ago

I'm not familiar with CS, but it's possible it has some background service that's keeping the connection open. I really don't see anything other than the panel not responding to the first command being sent, which is why I'm suggesting shutting the computer with CS down, waiting 5 minutes, and then trying to connect from a different device (you can try the integration), no need to install another python environment.

papeon commented 1 year ago

No good news... Tried to: powered off the panel and on after 30 minutes, powered off the machine with CS, using other machine "without CS" tried to setup the integration > failed using the same new machine installed all the enviroment, python, apython, pyrisco launched the test with my parameters > failed

also new machine can reach (ping) the panel

I don't paste the log because is always the same.

I'm very frustrated and confused. I'm quite sure it isn't a network issue but more likely panel compatibility or other hidden setting that I don't know. The only good news of the day is that now I'm a little bit familiar with Python.

OnFreund commented 1 year ago

Panel compatibility would have most likely manifested later in the connection process. This is a timeout in the very first command sent to the panel. Are you absolutely sure you have the right port?

papeon commented 1 year ago

Yes, I'm 100% sure. I think that if is not an issue of the software, and not on network can be some settings on the panel. Anyway, if in the end this can hint something... connecting with CS it takes about 30 seconds. Maybe changing the code (not integration yet) for a try is the last things to do I believe.

OnFreund commented 1 year ago

Sorry, I'm out of ideas...

papeon commented 1 year ago

Tried with Hercules. TCP connection is done. IP&port is fine. I don't know which command to send so after 30s connection are closed remotely from remote host.

OnFreund commented 1 year ago

The first command to send is "RID", but if you have to encode it. This is the place to start: https://github.com/OnFreund/pyrisco/blob/master/pyrisco/local/risco_crypt.py (don't worry about encryption - the RID command doesn't have to be encrypted - just encoding)

issue-triage-workflows[bot] commented 1 year ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.