From e1208e2dfeeb7f1c325c26eea61c95ea73020b36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torbj=C3=B6rn=20Axelsson?= Date: Tue, 5 Dec 2017 10:16:25 -0800 Subject: [PATCH] Added handler for error messages from bot in VacBot class --- .gitignore | 2 ++ sucks/__init__.py | 11 +++++++++++ 2 files changed, 13 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..62cc354 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +__pycache__ +Pipfile.lock diff --git a/sucks/__init__.py b/sucks/__init__.py index 8e594af..922301e 100644 --- a/sucks/__init__.py +++ b/sucks/__init__.py @@ -142,6 +142,8 @@ def __init__(self, user, domain, resource, secret, vacuum, continent): self.clean_status = None self.charge_status = None self.battery_status = None + self.error = None + self.error_no = None def wait_until_ready(self): self.ready_flag.wait() @@ -160,6 +162,10 @@ def session_start(self, event): self.register_handler(Callback('battery info', MatchXPath('{jabber:client}iq/{com:ctl}query/{com:ctl}ctl[@td="BatteryInfo"]'), self.handle_battery_report)) + self.register_handler(Callback('error', + MatchXPath('{jabber:client}iq/{com:ctl}query/{com:ctl}ctl[@td="error"]'), + self.handle_error)) + def handle_clean_report(self, iq): self.clean_status = iq.find('{com:ctl}query/{com:ctl}ctl/{com:ctl}clean').get('type') @@ -184,6 +190,11 @@ def handle_charge_report(self, iq): logging.warning("Unknown charging status '" + report + "'") logging.debug("*** charge_status =" + self.charge_status) + def handle_error(self, iq): + self.error = iq.find('{com:ctl}query/{com:ctl}ctl').get('error') + self.error_no = iq.find('{com:ctl}query/{com:ctl}ctl').get('errno') + logging.debug("*** error =" + self.error_no + " " + self.error) + def send_command(self, xml): c = self.wrap_command(xml) c.send()