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
73.52k stars 30.71k forks source link

Roomba i7+ issues with paho-mqtt 1.5.1 #43446

Closed geekofweek closed 3 years ago

geekofweek commented 3 years ago

The problem

With the Roomba I7+, and I would assume any Roomba with a Clean Base, there appears to be an issue with the bump to paho-mqtt 1.5.1 causing some KeyErrors. This causes the Roomba Integration to get stuck in a state when it goes to do the Bin Empty (evac) mode. I've also noticed that the i7 will become un-responsive after a number of hours. Example each morning the Roomba controls no longer function with no error messages or logs but a re-load of the integration resolves it. The latter issue is very hard to reproduce. It appears that paho-mqtt is a requirement for the iRobot Roomba Integration that took me a bit to track down. I have validated that downgrading the version of paho-mqtt resolves the issue.

Might be similar to https://github.com/home-assistant/core/issues/41423 but I couldn't figure out the exact details of what caused that issue and might be erroneous in relation to this issue.

Environment

Problem-relevant configuration.yaml

NA

Traceback/Error logs

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/usr/local/lib/python3.8/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.8/site-packages/paho/mqtt/client.py", line 3452, in _thread_main
    self.loop_forever(retry_first_connection=True)
  File "/usr/local/lib/python3.8/site-packages/paho/mqtt/client.py", line 1779, in loop_forever
    rc = self.loop(timeout, max_packets)
  File "/usr/local/lib/python3.8/site-packages/paho/mqtt/client.py", line 1181, in loop
    rc = self.loop_read(max_packets)
  File "/usr/local/lib/python3.8/site-packages/paho/mqtt/client.py", line 1572, in loop_read
    rc = self._packet_read()
  File "/usr/local/lib/python3.8/site-packages/paho/mqtt/client.py", line 2310, in _packet_read
    rc = self._packet_handle()
  File "/usr/local/lib/python3.8/site-packages/paho/mqtt/client.py", line 2936, in _packet_handle
    return self._handle_publish()
  File "/usr/local/lib/python3.8/site-packages/paho/mqtt/client.py", line 3216, in _handle_publish
    self._handle_on_message(message)
  File "/usr/local/lib/python3.8/site-packages/paho/mqtt/client.py", line 3444, in _handle_on_message
    self.on_message(self, self._userdata, message)
  File "/usr/local/lib/python3.8/site-packages/roomba/roomba.py", line 219, in on_message
    self.decode_topics(json_data)
  File "/usr/local/lib/python3.8/site-packages/roomba/roomba.py", line 370, in decode_topics
    self.update_state_machine()
  File "/usr/local/lib/python3.8/site-packages/roomba/roomba.py", line 480, in update_state_machine
    self.current_state = ROOMBA_STATES[self.cleanMissionStatus_phase]
KeyError: 'evac'

Additional information

There was a previous pull request that was put in to add the Evac state (Bin Empty) into Home Assistant but was closed. https://github.com/home-assistant/core/pull/39913

This change alone won't solve the issue. It also requires and upstream change to roombapy

Adding an Evac state to const.py will solve the KeyError:

ROOMBA_STATES = {                        
    "charge": "Charging",
    "new": "New Mission",         
    "run": "Running",                    
    "resume": "Running",         
    "hmMidMsn": "Recharging",       
    "recharge": "Recharging",           
    "stuck": "Stuck",                  
    "hmUsrDock": "User Docking",         
    "dock": "Docking",      
    "dockend": "Docking - End Mission",
    "cancelled": "Cancelled",    
    "stop": "Stopped",             
    "pause": "Paused",
    "hmPostMsn": "End Mission",
    "evac": "Emptying Bin",
    "": None,          

However I am not sure that will resolve the Roomba becoming un-responsive after a time, hence opening an issue instead of a pull request. I think ideally the Roomba Integration should be updated to work with paho-mqtt 1.5.1 but I'm not sure that I've caught all the necessary changes required. Currently this is a breaking bug that will stop any Roomba with a clean base from not getting stuck when it runs the empty bin procedure.

probot-home-assistant[bot] commented 3 years ago

roomba documentation roomba source (message by IssueLinks)

probot-home-assistant[bot] commented 3 years ago

Hey there @pschmitt, @cyr-ius, @shenxn, mind taking a look at this issue as its been labeled with an integration (roomba) you are listed as a codeowner for? Thanks! (message by CodeOwnersMention)

geekofweek commented 3 years ago

Seems to be resolved with the release of 2020.12.0 and the mentioned pull requests. Will monitor but closing for now.