From ffdce829fd79731ed8530964b0457483e33eecfb Mon Sep 17 00:00:00 2001 From: Pim van den Berg Date: Sun, 15 Nov 2020 14:59:57 +0100 Subject: [PATCH] feat(itho-wpu): implement getserial action --- itho-wpu.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/itho-wpu.py b/itho-wpu.py index 1e6049b..2cedef8 100755 --- a/itho-wpu.py +++ b/itho-wpu.py @@ -177,6 +177,8 @@ def process_response(action, response, args): export_to_influxdb(action, measurements) elif action == "getnodeid": process_nodeid(response) + elif action == "getserial": + process_serial(response) def process_nodeid(response): @@ -199,6 +201,14 @@ def process_nodeid(response): f"ListVersion: {listversion}") +def process_serial(response): + if int(response[1], 0) != 0x90 and int(response[2], 0) != 0xE1: + logger.error(f"Response MessageClass != 0x90 0xE1 (getserial), but {response[1]} {response[2]}") + return + serial = (int(response[5], 0) << 16) + (int(response[6], 0) << 8) + int(response[7], 0) + logger.info(f"Serial: {serial}") + + def process_datalog(response): if int(response[1], 0) != 0xA4 and int(response[2], 0) != 0x01: logger.error(f"Response MessageClass != 0xA4 0x01 (getdatalog), but {response[1]} {response[2]}")