Added handler for error messages from bot in VacBot class

This commit is contained in:
Torbjörn Axelsson
2017-12-05 10:16:25 -08:00
parent 9ee1012334
commit e1208e2dfe
2 changed files with 13 additions and 0 deletions
+2
View File
@@ -0,0 +1,2 @@
__pycache__
Pipfile.lock
+11
View File
@@ -142,6 +142,8 @@ class VacBot(ClientXMPP):
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 @@ class VacBot(ClientXMPP):
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 @@ class VacBot(ClientXMPP):
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()