fix EMT7110
This commit is contained in:
parent
bae3ef816a
commit
889ba1a8f3
2 changed files with 9 additions and 8 deletions
|
@ -48,7 +48,7 @@ baudChanger.daemon = True
|
||||||
baudChanger.start()
|
baudChanger.start()
|
||||||
|
|
||||||
while 1:
|
while 1:
|
||||||
data = rfm.receive(5)
|
data = rfm.receive(12)
|
||||||
if data == None:
|
if data == None:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ class lacross(rawsensor):
|
||||||
self._data['AFC'] = data[2]
|
self._data['AFC'] = data[2]
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
res = 'La crosse ' + str(self._data) # + ' ' + rawsensor.__str__(self);
|
res = 'La crosse ' + str(self._data)
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -75,17 +75,18 @@ class lacross(rawsensor):
|
||||||
class emt7110(rawsensor):
|
class emt7110(rawsensor):
|
||||||
def __init__(self, data):
|
def __init__(self, data):
|
||||||
rawsensor.__init__(self, data)
|
rawsensor.__init__(self, data)
|
||||||
id = data[0] << 24 | data[1] << 16 | data[2] << 8 | data[3]
|
_data = data[0]
|
||||||
|
id = _data[0] << 24 | _data[1] << 16 | _data[2] << 8 | _data[3]
|
||||||
self._data['ID'] = hex(id)[2:]
|
self._data['ID'] = hex(id)[2:]
|
||||||
self._data['P'] = (((data[4] << 8 | data[5]) & 0x3FFF) / 2.0, 'W')
|
self._data['P'] = (((_data[4] << 8 | _data[5]) & 0x3FFF) / 2.0, 'W')
|
||||||
self._data['U'] = (data[8] / 2.0 + 128, 'V')
|
self._data['U'] = (_data[8] / 2.0 + 128, 'V')
|
||||||
self._data['I'] = (data[6] << 8 | data[7], 'mA')
|
self._data['I'] = (_data[6] << 8 | _data[7], 'mA')
|
||||||
self._data['W'] = (((data[9] << 8 | data[10]) & 0x3FFF) / 100, 'kWh')
|
self._data['W'] = (((_data[9] << 8 | _data[10]) & 0x3FFF) / 100, 'kWh')
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return 'emt7110 ' + str(self._data)
|
return 'emt7110 ' + str(self._data)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def Create(data):
|
def Create(data):
|
||||||
if len(data) >= 12 and len(data) <= 20 and csum(data) == 0:
|
if len(data[0]) >= 12 and len(data[0]) <= 20 and csum(data[0]) == 0:
|
||||||
return emt7110(data)
|
return emt7110(data)
|
||||||
|
|
Loading…
Reference in a new issue