Skip to content

Commit

Permalink
Fix mibeacon 4109 message parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexxIT committed Mar 25, 2024
1 parent 4209fce commit 029338b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ class BLETempHumi(BaseConv):
def decode(self, device: "XDevice", payload: dict, data: str):
data = bytes.fromhex(data)
payload["temperature"] = int.from_bytes(data[:2], "little", signed=True) / 10.0
payload["humidity"] = (int.from_bytes(data[2:], "little") / 10.0,)
payload["humidity"] = int.from_bytes(data[2:], "little") / 10.0


class BLEToothbrush(BaseConv):
Expand Down
6 changes: 6 additions & 0 deletions tests/test_conv_ble.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ def test_kettle():
assert p == {"power": True, "state": "heat", "temperature": 84}


def test_839():
device = XDevice(839)
p = device.decode({"eid": 4109, "edata": "EC003901"})
assert p == {"humidity": 31.3, "temperature": 23.6}


def test_2443():
device = XDevice(2443)
assert device.market_name == "Xiaomi Door/Window Sensor 2"
Expand Down

0 comments on commit 029338b

Please sign in to comment.