fix too close status
This commit is contained in:
@ -9,13 +9,16 @@ Temperature, 2
|
|||||||
Status, 1
|
Status, 1
|
||||||
|
|
||||||
|
|
||||||
|
import base64
|
||||||
|
import struct
|
||||||
|
|
||||||
payload = 'DQYCjAAAAAE='
|
payload = 'DQYCjAAAAAE='
|
||||||
frame = base64.b64decode(payload)
|
frame = base64.b64decode(payload)
|
||||||
|
|
||||||
battery = struct.unpack('<H', frame[0:2])[0]
|
battery = struct.unpack('>H', frame[0:2])[0]
|
||||||
distance = struct.unpack('<H', frame[2:4])[0]
|
distance = struct.unpack('>H', frame[2:4])[0]
|
||||||
interrupt: frame[4:5]
|
status = struct.unpack('?', frame[7:8])[0]
|
||||||
temperature: frame[5:7]
|
|
||||||
status: struct.unpack('<H', frame[7:8])[0]
|
|
||||||
|
|
||||||
|
print(f"{battery=}, {distance=}, {status=}")
|
||||||
|
|
||||||
|
payload = 'DRgAAAAAAAE='
|
||||||
|
@ -107,7 +107,7 @@ def mqttOnMessageCallback(client, userdata, message):
|
|||||||
statusText = 'Ok'
|
statusText = 'Ok'
|
||||||
if not status:
|
if not status:
|
||||||
statusText = 'No sensor'
|
statusText = 'No sensor'
|
||||||
elif distance == 20:
|
elif distance < 280:
|
||||||
statusText = 'Too close'
|
statusText = 'Too close'
|
||||||
|
|
||||||
measurement = {
|
measurement = {
|
||||||
|
Reference in New Issue
Block a user