Skip to content

Commit

Permalink
Change decoding vaqao for battery Level (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
kbeaugrand authored Nov 7, 2021
1 parent b9122be commit 70b6c3b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/modules/WattecoDecoderModule/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,15 +314,15 @@ def VAQAODecoder(devEUI: str, payload: str, fport: int):
def VAQAOPlusDecoder(devEUI: str, payload: str, fport: int):
result = parseFor(3, ['0,1,4,Occupancy', '1,10,7,Temperature', '2,100,6,RelativeHumidity', '3,10,6,CO2', '4,10,6,COV', '5,10,6,LUX', '6,10,6,Pressure'], payload)

if 'CommandID' in result and result['CommandID'] == 'ReportAttributesAlarm'and result['AttributeID'] == 'MeasuredValue':
if 'CommandID' in result and (result['CommandID'] == 'ReportAttributes' or result['CommandID'] == 'ReportAttributesAlarm'):
result = {
result['ClusterID']: result['Data']
}

if 'Temperature' in result:
result['Temperature'] = result['Temperature'] / 100

if 'RelativeHumidity' in result:
result['RelativeHumidity'] = result['RelativeHumidity'] / 100

return result
return result
13 changes: 13 additions & 0 deletions src/modules/WattecoDecoderModule/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,19 @@ def test_vaqaoplus():

assert json == {"Occupancy":1,"Temperature":19.7,"RelativeHumidity":54.0,"CO2":690.0,"COV":50.0,"LUX":10,"Pressure":9790}

response = client.get("/api/vaqaoplus?payload=EQoAUAAGQQUBBAwWBJg=&devEUI=70B3D5E75E009F8F&fport=125")
assert response.status_code == 200
json = response.json()

assert json == {
'Configuration': {
"CurrentPowerMode": "PeriodicallyON",
"AvailablePowerSourceBitField": 4,
"DisposableBatteryVoltage": 3094,
"CurrentPowerSource": "DisposableBattery"
}
}

def test_vaqao():
response = client.get("/api/vaqao?payload=QjOAgKhPAR2g6ADckf2BU2j3QgYOUWgv%2BmYm%2BtaSFn1rSYu%2BmESxRVEUFXFoniAUmxk%3D&devEUI=70B3D5E75E009F8F&fport=125")
assert response.status_code == 200
Expand Down

0 comments on commit 70b6c3b

Please sign in to comment.