comparison epro.py @ 14:60ead9b5fc1b

Mark temperature as invalid when <-20C as per spec. Shows up as -25C on the unit I have when the sensor is not connected.
author Daniel O'Connor <darius@dons.net.au>
date Mon, 06 Dec 2021 11:26:20 +1030
parents 4450cf739263
children 3090d8bf4242
comparison
equal deleted inserted replaced
13:4450cf739263 14:60ead9b5fc1b
140 def __init__(self, dstadr, srcadr, devid, msgtype, data): 140 def __init__(self, dstadr, srcadr, devid, msgtype, data):
141 super(BatteryTemperature, self).__init__(dstadr, srcadr, devid, msgtype, data) 141 super(BatteryTemperature, self).__init__(dstadr, srcadr, devid, msgtype, data)
142 self.temp = (data[2] & 0x7f | (data[1] & 0x7f) << 7 | (data[0] & 0x3f) << 14) / 10.0 142 self.temp = (data[2] & 0x7f | (data[1] & 0x7f) << 7 | (data[0] & 0x3f) << 14) / 10.0
143 if data[2] & 0x40: 143 if data[2] & 0x40:
144 self.temp *= -1 144 self.temp *= -1
145 if self.temp == -20: 145 if self.temp < -20:
146 self.temp = None 146 self.temp = None
147 147
148 def __repr__(self): 148 def __repr__(self):
149 s = super(BatteryTemperature, self).__repr__() 149 s = super(BatteryTemperature, self).__repr__()
150 if self.temp == None: 150 if self.temp == None: