I got bad data from your script so I took a look
https://github.com/JsBergbau/MiTemperature2/blob/a680630e211faf26fea80a0922155191f3636c99/LYWSD03MMC.py#L695-L714
It seems that you are not considering the case that the preamble is not in the data_str. In this case, packetStart is -1 and you try to parse garbage data.
If any of the if cases then happen to detect a correct length and correct data identifier (which can just happen randomly), garbage data will be returned.
This also applies to the other decode functions.
You should likely return nothing if packetStart is -1 before you do anything else.
I got bad data from your script so I took a look https://github.com/JsBergbau/MiTemperature2/blob/a680630e211faf26fea80a0922155191f3636c99/LYWSD03MMC.py#L695-L714 It seems that you are not considering the case that the preamble is not in the
data_str
. In this case,packetStart
is -1 and you try to parse garbage data.If any of the
if
cases then happen to detect a correct length and correct data identifier (which can just happen randomly), garbage data will be returned.This also applies to the other decode functions.
You should likely return nothing if packetStart is -1 before you do anything else.