Skip to content

Commit

Permalink
Added handler for error messages from bot in VacBot class
Browse files Browse the repository at this point in the history
  • Loading branch information
Zenconomy committed Dec 5, 2017
1 parent 9ee1012 commit e1208e2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
__pycache__
Pipfile.lock
11 changes: 11 additions & 0 deletions sucks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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')
Expand All @@ -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()
Expand Down

0 comments on commit e1208e2

Please sign in to comment.