python 3 fixes for #29
This commit is contained in:
parent
e5a28ac64e
commit
04db6d3838
|
@ -17,7 +17,7 @@ class NamedInt(int):
|
|||
def __new__(cls, value, name):
|
||||
assert isinstance(name, str) or isinstance(name, unicode)
|
||||
obj = int.__new__(cls, value)
|
||||
obj.name = unicode(name)
|
||||
obj.name = str(name)
|
||||
return obj
|
||||
|
||||
def bytes(self, count=2):
|
||||
|
|
|
@ -214,7 +214,7 @@ class Receiver(object):
|
|||
serial_reply = self.request(0x83B5, 0x03)
|
||||
assert serial_reply
|
||||
self._serial = _strhex(serial_reply[1:5])
|
||||
self.max_devices = ord(serial_reply[6:7][0])
|
||||
self.max_devices = ord(serial_reply[6:7][0:1])
|
||||
|
||||
if self.max_devices == 1:
|
||||
self.name = 'Nano Receiver'
|
||||
|
|
|
@ -283,11 +283,11 @@ class DeviceStatus(dict):
|
|||
alert = ALERT.NONE
|
||||
reason = self[ERROR] = None
|
||||
if _log.isEnabledFor(_DEBUG):
|
||||
_log.debug("%s: battery %d% charged, %s", self._device, discharge, self[BATTERY_STATUS])
|
||||
_log.debug("%s: battery %d%% charged, %s", self._device, discharge, self[BATTERY_STATUS])
|
||||
else:
|
||||
alert = ALERT.ALL
|
||||
reason = self[ERROR] = self[BATTERY_STATUS]
|
||||
_log.warn("%s: battery %d% charged, ALERT %s", self._device, discharge, reason)
|
||||
_log.warn("%s: battery %d%% charged, ALERT %s", self._device, discharge, reason)
|
||||
self._changed(alert=alert, reason=reason)
|
||||
else:
|
||||
_log.info("%s: unknown BATTERY %s", self._device, n)
|
||||
|
|
Loading…
Reference in New Issue