Repository: nutechsoftware/alarmdecoder

Issue:
Communicator failures not handled
Messages such as this lead to failures when updating zones:
```
May 12 10:08:59 [00000001000000000A--],0fc,[f704009f10fc000008020000000000],"COMM. FAILURE                   "
May 12 10:09:03 [00000001000000100A--],0bf,[f704009f10bf000208020000000000],"CHECK 103 LngRngRadio       0000"
```
```
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/site-packages/alarmdecoder/devices/base_device.py", line 148, in run
    self._device.read_line(timeout=self.READ_TIMEOUT)
  File "/usr/local/lib/python3.8/site-packages/alarmdecoder/devices/socket_device.py", line 356, in read_line
    self.on_read(data=ret)
  File "/usr/local/lib/python3.8/site-packages/alarmdecoder/event/event.py", line 84, in fire
    func(self.obj, *args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/alarmdecoder/decoder.py", line 1041, in _on_read
    self._handle_message(data)
  File "/usr/local/lib/python3.8/site-packages/alarmdecoder/decoder.py", line 439, in _handle_message
    msg = self._handle_keypad_message(data)
  File "/usr/local/lib/python3.8/site-packages/alarmdecoder/decoder.py", line 481, in _handle_keypad_message
    self._update_internal_states(msg)
  File "/usr/local/lib/python3.8/site-packages/alarmdecoder/decoder.py", line 632, in _update_internal_states
    self._update_zone_tracker(message)
  File "/usr/local/lib/python3.8/site-packages/alarmdecoder/decoder.py", line 1017, in _update_zone_tracker
    self._zonetracker.update(message)
  File "/usr/local/lib/python3.8/site-packages/alarmdecoder/zonetracking.py", line 209, in update
    self._zones_faulted.sort()
TypeError: '<' not supported between instances of 'str' and 'int'
```

Discussion:

Patch:
diff --git a/alarmdecoder/zonetracking.py b/alarmdecoder/zonetracking.py
index 13be3c3..ae92eb7 100644
--- a/alarmdecoder/zonetracking.py
+++ b/alarmdecoder/zonetracking.py
@@ -189,7 +189,7 @@ class Zonetracker(object):
                     if match is None:
                         return
 
-                    zone = match.group(1)
+                    zone = int(match.group(1))
 
                 # Add new zones and clear expired ones.
                 if zone in self._zones_faulted:


Test patch:
diff --git a/test/test_zonetracking.py b/test/test_zonetracking.py
index 6d8f087..0156871 100644
--- a/test/test_zonetracking.py
+++ b/test/test_zonetracking.py
@@ -76,7 +76,7 @@ class TestZonetracking(TestCase):
         msg = Message('[00000000000000100A--],0bf,[f707000600e5800c0c020000],"CHECK 1                         "')
         self._zonetracker.update(msg)
 
-        self.assertEqual(self._zonetracker._zones['1'].status, Zone.CHECK)
+        self.assertEqual(self._zonetracker._zones[1].status, Zone.CHECK)
 
     def test_zone_restore_skip(self):
         panel_messages = [