Skip to content

Commit

Permalink
Restored parsing of lockStatus field (i.e. FFF3 characteristic)
Browse files Browse the repository at this point in the history
  • Loading branch information
rospogrigio committed Dec 22, 2021
1 parent ccb4210 commit 18f376b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions custom_components/airbnk_mqtt/custom_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ def parse_operation_message(self, msg):
if msg_sign == self.cmd["sign"]:
self.cmdSent = True

self.parse_new_lockStatus(payload["lockStatus"])

for callback_func in self._callbacks:
callback_func()

Expand All @@ -260,6 +262,18 @@ def send_mqtt_command(self):
json.dumps(self.cmd),
)

def parse_new_lockStatus(self, lockStatus):
_LOGGER.debug("Parsing new lockStatus: %s", lockStatus)
bArr = bytearray.fromhex(lockStatus)
if bArr[0] != 0xAA or bArr[3] != 0x02 or bArr[4] != 0x04:
_LOGGER.error("Wrong lockStatus msg: %s", lockStatus)
return

lockEvents = (bArr[10] << 24) | (bArr[11] << 16) | (bArr[12] << 8) | bArr[13]
self.lockEvents = lockEvents
self.voltage = ((float)((bArr[14] << 8) | bArr[15])) * 0.01
self.curr_state = (bArr[16] >> 4) & 3

def parse_MQTT_advert(self, mqtt_advert):
_LOGGER.debug("Parsing advert msg: %s", mqtt_advert)
bArr = bytearray.fromhex(mqtt_advert)
Expand Down

0 comments on commit 18f376b

Please sign in to comment.