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
71.03k stars 29.68k forks source link

Roomba initial failed connection logging #117358

Open bobrippling opened 3 months ago

bobrippling commented 3 months ago

The problem

Problem

When I start home-assistant, if my roomba isn't turned on I find my HA logs end up filled with connection errors (see below). This makes it hard to see if there are any other issues due to the volume of these logs.

Cause

I believe this is the roomba module attempting to initialise.

Proposed solutions

I'd like to reduce the logs I see from this - is it possible for me to use any parts of the roomba integration to write an automation that will (for example) turn on the plug powering the roomba until the module has initialised, then turn the roomba back off? (Once the module has initialised, the logs settle down)

Or alternatively, log once and then silence future logs, if their error is the same?

What version of Home Assistant Core has the issue?

core-2024.5.3

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Core

Integration causing the issue

Roomba

Link to integration documentation on our website

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

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

File ".../lib/python3.12/socket.py", line 837, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused
YYYY-MM-DD HH:MM:SS ERROR (roombapy) [roombapy.remote_client] Can't connect to <ip>
Traceback (most recent call last):
  File ".../lib/python3.12/site-packages/roombapy/remote_client.py", line 93, in connect
    self._open_mqtt_connection()
  File ".../lib/python3.12/site-packages/roombapy/remote_client.py", line 121, in _open_mqtt_connection
    self.mqtt_client.reconnect()
  File ".../lib/python3.12/site-packages/paho/mqtt/client.py", line 1044, in reconnect
    sock = self._create_socket_connection()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../lib/python3.12/site-packages/paho/mqtt/client.py", line 3685, in _create_socket_connection
    return socket.create_connection(addr, timeout=self._connect_timeout, source_address=source)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../lib/python3.12/socket.py", line 852, in create_connection
    raise exceptions[0]
  File ".../lib/python3.12/socket.py", line 837, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused
YYYY-MM-DD HH:MM:SS ERROR (roombapy) [roombapy.remote_client] Can't connect to <ip>
Traceback (most recent call last):
  File ".../lib/python3.12/site-packages/roombapy/remote_client.py", line 93, in connect
    self._open_mqtt_connection()
  File ".../lib/python3.12/site-packages/roombapy/remote_client.py", line 121, in _open_mqtt_connection
    self.mqtt_client.reconnect()
  File ".../lib/python3.12/site-packages/paho/mqtt/client.py", line 1044, in reconnect
    sock = self._create_socket_connection()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../lib/python3.12/site-packages/paho/mqtt/client.py", line 3685, in _create_socket_connection
    return socket.create_connection(addr, timeout=self._connect_timeout, source_address=source)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../lib/python3.12/socket.py", line 852, in create_connection
    raise exceptions[0]
  File ".../lib/python3.12/socket.py", line 837, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused
YYYY-MM-DD HH:MM:SS ERROR (roombapy) [roombapy.remote_client] Unable to connect to <ip>
YYYY-MM-DD HH:MM:SS WARNING (roombapy) [roombapy.roomba] Unexpectedly disconnected from Roomba <ip>, code The connection was lost
YYYY-MM-DD HH:MM:SS WARNING (roombapy) [roombapy.roomba] Periodic connection lost due to Unable to connect to Roomba at <ip>

Additional information

No response

home-assistant[bot] commented 3 months ago

Hey there @pschmitt, @cyr-ius, @shenxn, @xitee1, @orhideous, mind taking a look at this issue as it has been labeled with an integration (roomba) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `roomba` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign roomba` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


roomba documentation roomba source (message by IssueLinks)

Tamqs commented 1 month ago

I use Home Assistant

Core 2024.7.2 Frontend 20240710.0

I have the same error: Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/roombapy/remote_client.py", line 93, in connect self._open_mqtt_connection() File "/usr/local/lib/python3.12/site-packages/roombapy/remote_client.py", line 117, in _open_mqtt_connection self.mqtt_client.connect(self.address, self.port) File "/usr/local/lib/python3.12/site-packages/paho/mqtt/client.py", line 914, in connect return self.reconnect() ^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/paho/mqtt/client.py", line 1044, in reconnect sock = self._create_socket_connection() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/paho/mqtt/client.py", line 3685, in _create_socket_connection return socket.create_connection(addr, timeout=self._connect_timeout, source_address=source) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/socket.py", line 853, in create_connection raise exceptions[0] File "/usr/local/lib/python3.12/socket.py", line 838, in create_connection sock.connect(sa) ConnectionRefusedError: [Errno 111] Connection refused

lush commented 1 month ago

Hi,

I have the same issue with the latest docker image of homeassistant (2024.7.2) when trying to configure the integration for my irobot roomba 980.

I was able to retrieve BLID and PASS via dorita980 within the docker-images. A manual roombapy connect from inside the docker-image using the hostname also worked.

roombapy connect roomba -b <BLID> -p "<PASS>" | jq
{
  "state": {
    "reported": {
      "netinfo": {
        "dhcp": true,

But in 3 of 4 cases when I'm using the ip address instead of the hostname I've got the following error from roombapy

roombapy connect <IP_ADDRESS> -b <BLID> -p "<PASS>"
Traceback (most recent call last):
  File "/usr/local/bin/roombapy", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/usr/local/lib/python3.12/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/roombapy/cli.py", line 141, in connect
    if obtained_password := RoombaPassword(bot.ip).get_password():
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/roombapy/getpassword.py", line 39, in get_password
    self._connect()
  File "/usr/local/lib/python3.12/site-packages/roombapy/getpassword.py", line 49, in _connect
    self.server_socket.connect((self.roomba_ip, self.roomba_port))
  File "/usr/local/lib/python3.12/ssl.py", line 1353, in connect
    self._real_connect(addr, False)
  File "/usr/local/lib/python3.12/ssl.py", line 1344, in _real_connect
    self.do_handshake()
  File "/usr/local/lib/python3.12/ssl.py", line 1320, in do_handshake
    self._sslobj.do_handshake()
TimeoutError: _ssl.c:983: The handshake operation timed out

Currently it's apparently not possible to use the hostname instead of the ip address in the roomba homeassistant integration.

homeassistant.log

2024-07-18 16:21:14.722 ERROR (roombapy) [roombapy.remote_client] Can't connect to <IP_ADDRESS>
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/roombapy/remote_client.py", line 93, in connect
    self._open_mqtt_connection()
  File "/usr/local/lib/python3.12/site-packages/roombapy/remote_client.py", line 121, in _open_mqtt_connection
    self.mqtt_client.reconnect()
  File "/usr/local/lib/python3.12/site-packages/paho/mqtt/client.py", line 1044, in reconnect
    sock = self._create_socket_connection()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/paho/mqtt/client.py", line 3685, in _create_socket_connection
    return socket.create_connection(addr, timeout=self._connect_timeout, source_address=source)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/socket.py", line 853, in create_connection
    raise exceptions[0]
  File "/usr/local/lib/python3.12/socket.py", line 838, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

I have currently no clue - at the end I was trying to configure vacuum via platform: roomba in configuration.yaml, but this is not supported according the the homeassistant.log output.

not working configuration

# configuration.yaml (not working)
vacuum:
  - platform: roomba
    host: roomba
    username: <BLID>
    password: <PASS>
yentelmanero commented 1 month ago

Hi,

I have the same issue with the latest docker image of homeassistant (2024.7.2) when trying to configure the integration for my irobot roomba 980.

I was able to retrieve BLID and PASS via dorita980 within the docker-images. A manual roombapy connect from inside the docker-image using the hostname also worked.

roombapy connect roomba -b <BLID> -p "<PASS>" | jq
{
  "state": {
    "reported": {
      "netinfo": {
        "dhcp": true,

But in 3 of 4 cases when I'm using the ip address instead of the hostname I've got the following error from roombapy

roombapy connect <IP_ADDRESS> -b <BLID> -p "<PASS>"
Traceback (most recent call last):
  File "/usr/local/bin/roombapy", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/usr/local/lib/python3.12/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/roombapy/cli.py", line 141, in connect
    if obtained_password := RoombaPassword(bot.ip).get_password():
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/roombapy/getpassword.py", line 39, in get_password
    self._connect()
  File "/usr/local/lib/python3.12/site-packages/roombapy/getpassword.py", line 49, in _connect
    self.server_socket.connect((self.roomba_ip, self.roomba_port))
  File "/usr/local/lib/python3.12/ssl.py", line 1353, in connect
    self._real_connect(addr, False)
  File "/usr/local/lib/python3.12/ssl.py", line 1344, in _real_connect
    self.do_handshake()
  File "/usr/local/lib/python3.12/ssl.py", line 1320, in do_handshake
    self._sslobj.do_handshake()
TimeoutError: _ssl.c:983: The handshake operation timed out

Currently it's apparently not possible to use the hostname instead of the ip address in the roomba homeassistant integration.

homeassistant.log

2024-07-18 16:21:14.722 ERROR (roombapy) [roombapy.remote_client] Can't connect to <IP_ADDRESS>
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/roombapy/remote_client.py", line 93, in connect
    self._open_mqtt_connection()
  File "/usr/local/lib/python3.12/site-packages/roombapy/remote_client.py", line 121, in _open_mqtt_connection
    self.mqtt_client.reconnect()
  File "/usr/local/lib/python3.12/site-packages/paho/mqtt/client.py", line 1044, in reconnect
    sock = self._create_socket_connection()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/paho/mqtt/client.py", line 3685, in _create_socket_connection
    return socket.create_connection(addr, timeout=self._connect_timeout, source_address=source)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/socket.py", line 853, in create_connection
    raise exceptions[0]
  File "/usr/local/lib/python3.12/socket.py", line 838, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

I have currently no clue - at the end I was trying to configure vacuum via platform: roomba in configuration.yaml, but this is not supported according the the homeassistant.log output.

not working configuration

# configuration.yaml (not working)
vacuum:
  - platform: roomba
    host: roomba
    username: <BLID>
    password: <PASS>

I am having the exact same issue described here, but I did not run roombapy, since I'm not sure in which scope I would even be able to do that (I am running HAOS)

Has anyone found a solution or the actual cause of the issue yet?

Tamqs commented 1 month ago

I managed to add my roomba to HA with this instructions: https://github.com/home-assistant/core/issues/117039#issuecomment-2184242302

lush commented 1 month ago

I am having the exact same issue described here, but I did not run roombapy, since I'm not sure in which scope I would even be able to do that (I am running HAOS)

Has anyone found a solution or the actual cause of the issue yet?

Hi,

I have successfully added my roomba 980 with set continuous=True in config_flow.py line:58. The workaround was described in a different issue [roomba] fails to set up] here: https://github.com/home-assistant/core/issues/117071#issuecomment-2211249126

Cheers

bobrippling commented 1 month ago

For the original issue, I have no problem connecting my roomba - it's just that I don't want to have to turn it on each time HA starts to establish an initial connection. But if I don't turn the roomba on for the initial connection, my logs get full of connection errors, which I'd prefer to have only once.