From d1b1be32caf69cd87e64d8bd3aded45502fdb3f8 Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Thu, 2 May 2013 23:56:03 +0200 Subject: [PATCH] Make read_battery use set_battery_info This allows battery readouts to generate warnings and debug logs for a given status and level. --- lib/logitech/unifying_receiver/status.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/logitech/unifying_receiver/status.py b/lib/logitech/unifying_receiver/status.py index df5c5c64..35176c31 100644 --- a/lib/logitech/unifying_receiver/status.py +++ b/lib/logitech/unifying_receiver/status.py @@ -125,7 +125,7 @@ class DeviceStatus(dict): return bool(self._active) __nonzero__ = __bool__ - def set_battery_info(self, level, status): + def set_battery_info(self, level, status, timestamp=None): self[BATTERY_LEVEL] = level self[BATTERY_STATUS] = status error = None @@ -141,7 +141,7 @@ class DeviceStatus(dict): if error is not None: # TODO: show visual warning/notif to user self[ERROR] = error - self._changed(alert=alert, reason=error) + self._changed(alert=alert, reason=error, timestamp=timestamp) def read_battery(self, timestamp=None): d = self._device @@ -157,8 +157,8 @@ class DeviceStatus(dict): # return if battery: - self[BATTERY_LEVEL], self[BATTERY_STATUS] = battery - self._changed(timestamp=timestamp) + level, status = battery + self.set_battery_info(level, status, timestamp=timestamp) elif BATTERY_STATUS in self: self[BATTERY_STATUS] = None self._changed(timestamp=timestamp)