def _handle_battery_info(self, iq): try: self.battery_status = float(iq['power']) / 100 except ValueError: _LOGGER.warning("couldn't parse battery status " + ET.tostring(iq)) else: self.batteryEvents.notify(self.battery_status) _LOGGER.debug("*** battery_status = {:.0%}".format(self.battery_status))
def _wrap_command(self, cmd, recipient): #Remove the td from ctl xml for RestAPI payloadxml = cmd.to_xml() payloadxml.attrib.pop("td") return { 'auth': { 'realm': EcoVacsAPI.REALM, 'resource': self.resource, 'token': self.secret, 'userid': self.user, 'with': 'users', }, "cmdName": cmd.name, "payload": ET.tostring(payloadxml).decode(), "payloadType": "x", "td": "q", "toId": recipient, "toRes": self.vacuum['resource'], "toType": self.vacuum['class'] }