From 53fad263b1a43be6707bb7d32a8f2f57e6125c94 Mon Sep 17 00:00:00 2001 From: Greg Laabs Date: Fri, 8 Dec 2017 15:27:25 -0800 Subject: [PATCH] Save battery status to VacBot Makes battery status available as a public property on VacBot --- sucks/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sucks/__init__.py b/sucks/__init__.py index 8a026f6..ba44995 100644 --- a/sucks/__init__.py +++ b/sucks/__init__.py @@ -141,6 +141,7 @@ def __init__(self, user, domain, resource, secret, vacuum, continent): self.ready_flag = Event() self.clean_status = None self.charge_status = None + self.battery_status = None def wait_until_ready(self): self.ready_flag.wait() @@ -170,8 +171,8 @@ def handle_clean_report(self, iq): def handle_battery_report(self, iq): try: - battery_status = float(iq.find('{com:ctl}query/{com:ctl}ctl/{com:ctl}battery').get('power')) / 100 - logging.debug("*** battery_status = {:.0%}".format(battery_status)) + self.battery_status = float(iq.find('{com:ctl}query/{com:ctl}ctl/{com:ctl}battery').get('power')) / 100 + logging.debug("*** battery_status = {:.0%}".format(self.battery_status)) except ValueError: logging.warning("couldn't parse battery status " + ET.tostring(iq))