Roomba980-Python icon indicating copy to clipboard operation
Roomba980-Python copied to clipboard

Unhandled state "chargingerror" (charging dock disconnected from power)

Open xdanik opened this issue 3 years ago • 3 comments

Hello everybody, We just bought a our first Roomba and I am trying to integrate it into our OpenHab setup.

I noticed, that the app stopped responding after moving the charging base from one room to another. After further testing and analyzing the communication from the Roomba, I seems like Roomba reports "chargingerror" state inside the cleanMissionStatus_phase when the base station is unplugged from power. This state is unhandled and thus causing unhandled exception that kills the mqtt thread. App does not recover from this state and requires a restart.

The hacky fix would be to add a early return before the array key access if the new state is unknown at https://github.com/NickWaterton/Roomba980-Python/blob/master/roomba/roomba.py#L829, but there must be a better solution.

I am running:

  • Roomba i7, fw: 3.2.9
  • App 1.2.9 on python 3.7.3
  • Raspberry Pi 4 2GB + latest stable Raspbian
Dec 25 20:14:04: [I 2020-12-25 20:14:04,287] *******************
Dec 25 20:14:04: [I 2020-12-25 20:14:04,287] * Program Started *
Dec 25 20:14:04: [I 2020-12-25 20:14:04,287] *******************
Dec 25 20:14:04: [I 2020-12-25 20:14:04,288] Roomba.py Version: 1.2.9
Dec 25 20:14:04: [I 2020-12-25 20:14:04,289] Python Version: 3.7.3 (default, Jul 25 2020, 13:03:44) [GCC 8.3.0]
Dec 25 20:14:04: [I 2020-12-25 20:14:04,289] Paho MQTT Version: 1.5.1
Dec 25 20:14:04: [I 2020-12-25 20:14:04,289] PIL Version: 8.0.1
Dec 25 20:14:04: [I 2020-12-25 20:14:04,289] <CNTRL C> to Exit
Dec 25 20:14:04: [I 2020-12-25 20:14:04,290] Roomba 980 MQTT data Interface
Dec 25 20:14:04: [I 2020-12-25 20:14:04,290] connecting to broker
Dec 25 20:14:04: [I 2020-12-25 20:14:04,296] Creating Roomba object 192.168.25.108
Dec 25 20:14:04: [I 2020-12-25 20:14:04,296] CONTINUOUS connection
Dec 25 20:14:04: [I 2020-12-25 20:14:04,296] connecting Roomba 192.168.25.108
Dec 25 20:14:04: [I 2020-12-25 20:14:04,297] Posting DECODED data
Dec 25 20:14:04: [I 2020-12-25 20:14:04,297] Connecting robi
Dec 25 20:14:04: [I 2020-12-25 20:14:04,298] Setting TLS
Dec 25 20:14:04: [I 2020-12-25 20:14:04,321] Setting TLS - OK
Dec 25 20:14:04: [I 2020-12-25 20:14:04,751] Roomba Connected robi
Dec 25 20:14:04: [I 2020-12-25 20:14:04,971] Received Roomba Data robi: $aws/things/E59A****************************/shadow/update, b'{"state":{"reported":{"batPct": 94, "batteryType": "F12432832R", "bbchg": {"nChatters": 0, "nKnockoffs": 3, "nLithF": 0, "nChgOk": 5, Dec 25 20:14:05: [W 2020-12-25 20:14:05,021] Error looking up Roomba error message 104
Dec 25 20:14:10: Exception in thread Thread-1:
Dec 25 20:14:10: Traceback (most recent call last):
Dec 25 20:14:10:   File "/usr/lib/python3.7/threading.py", line 917, in _bootstrap_inner
Dec 25 20:14:10:     self.run()
Dec 25 20:14:10:   File "/usr/lib/python3.7/threading.py", line 865, in run
Dec 25 20:14:10:     self._target(*self._args, **self._kwargs)
Dec 25 20:14:10:   File "/usr/local/lib/python3.7/dist-packages/paho/mqtt/client.py", line 3452, in _thread_main
Dec 25 20:14:10:     self.loop_forever(retry_first_connection=True)
Dec 25 20:14:10:   File "/usr/local/lib/python3.7/dist-packages/paho/mqtt/client.py", line 1779, in loop_forever
Dec 25 20:14:10:     rc = self.loop(timeout, max_packets)
Dec 25 20:14:10:   File "/usr/local/lib/python3.7/dist-packages/paho/mqtt/client.py", line 1181, in loop
Dec 25 20:14:10:     rc = self.loop_read(max_packets)
Dec 25 20:14:10:   File "/usr/local/lib/python3.7/dist-packages/paho/mqtt/client.py", line 1572, in loop_read
Dec 25 20:14:10:     rc = self._packet_read()
Dec 25 20:14:10:   File "/usr/local/lib/python3.7/dist-packages/paho/mqtt/client.py", line 2310, in _packet_read
Dec 25 20:14:10:     rc = self._packet_handle()
Dec 25 20:14:10:   File "/usr/local/lib/python3.7/dist-packages/paho/mqtt/client.py", line 2936, in _packet_handle
Dec 25 20:14:10:     return self._handle_publish()
Dec 25 20:14:10:   File "/usr/local/lib/python3.7/dist-packages/paho/mqtt/client.py", line 3216, in _handle_publish
Dec 25 20:14:10:     self._handle_on_message(message)
Dec 25 20:14:10:   File "/usr/local/lib/python3.7/dist-packages/paho/mqtt/client.py", line 3444, in _handle_on_message
Dec 25 20:14:10:     self.on_message(self, self._userdata, message)
Dec 25 20:14:10:   File "/usr/local/lib/python3.7/dist-packages/roomba/roomba.py", line 460, in on_message
Dec 25 20:14:10:     self.decode_topics(json_data)
Dec 25 20:14:10:   File "/usr/local/lib/python3.7/dist-packages/roomba/roomba.py", line 722, in decode_topics
Dec 25 20:14:10:     self.update_state_machine()
Dec 25 20:14:10:   File "/usr/local/lib/python3.7/dist-packages/roomba/roomba.py", line 829, in update_state_machine
Dec 25 20:14:10:     self.current_state = self.states[self.cleanMissionStatus_phase]
Dec 25 20:14:10: KeyError: 'chargingerror'

The robot reported this: $aws/things/E59A****************************/shadow/update:

{
  "state": {
    "reported": {
      "cleanMissionStatus": {
        "cycle": "none",
        "phase": "chargingerror",
        "expireM": 0,
        "rechrgM": 0,
        "error": 104,
        "notReady": 0,
        "mssnM": 0,
        "sqft": 0,
        "initiator": "manual",
        "nMssn": 9
      }
    }
  }
}

Could please someone take a look at this?

xdanik avatar Dec 25 '20 22:12 xdanik

Thanks for the report, I’m currently re-writing the library for my new s9 and Braava jet m6.

I have it working, and will post the new version after a few more days testing.

NickWaterton avatar Dec 29 '20 03:12 NickWaterton

Update: the new version is a little delayed, as my new S9 has the “error 31” problem, and I’m waiting for a replacement.

Maps are still a little buggy, but I’ll push it as soon as I feel it’s at beta stage.

NickWaterton avatar Jan 09 '21 03:01 NickWaterton

Thanks for the update and good luck with the replacement.

xdanik avatar Jan 09 '21 08:01 xdanik