Skip to content

Commit

Permalink
Merge pull request #1263 from jbjornstedt/xm126
Browse files Browse the repository at this point in the history
Add support for Acconeer XM126
  • Loading branch information
Ernst79 authored Dec 5, 2023
2 parents c002ae9 + d1ae1c7 commit a1dac35
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
4 changes: 3 additions & 1 deletion custom_components/ble_monitor/ble_parser/acconeer.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
_LOGGER = logging.getLogger(__name__)

ACCONEER_SENSOR_IDS = {
0x80: "Acconeer XM122"
0x80: "Acconeer XM122",
0x91: "Acconeer XM126",
}

MEASUREMENTS = {
0x80: ["presence", "temperature"],
0x91: ["presence", "temperature"],
}


Expand Down
2 changes: 2 additions & 0 deletions custom_components/ble_monitor/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -1682,6 +1682,7 @@ class BLEMonitorBinarySensorEntityDescription(
'Meter TH plus' : [["temperature", "humidity", "battery", "rssi"], [], []],
'Laica Smart Scale' : [["weight", "impedance", "rssi"], [], []],
"Acconeer XM122" : [["temperature", "battery", "rssi"], [], ["motion"]],
"Acconeer XM126" : [["temperature", "battery", "rssi"], [], ["motion"]],
'K6 Sensor Beacon' : [["temperature", "humidity", "acceleration", "voltage", "battery", "rssi"], [], []],
'DSL-C08' : [["battery", "rssi", "voltage"], [], ["lock", "childlock"]],
'SmartDry cloth dryer' : [["temperature", "humidity", "voltage", "battery", "shake", "rssi"], [], ["switch"]],
Expand Down Expand Up @@ -1816,6 +1817,7 @@ class BLEMonitorBinarySensorEntityDescription(
'Meter TH plus' : 'Switchbot',
'Laica Smart Scale' : 'Laica',
'Acconeer XM122' : 'Acconeer',
'Acconeer XM126' : 'Acconeer',
'K6 Sensor Beacon' : 'KKM',
'SmartDry cloth dryer' : 'SmartDry',
}
Expand Down
21 changes: 21 additions & 0 deletions custom_components/ble_monitor/test/test_acconeer_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,24 @@ def test_acconeer_xm122(self):
assert sensor_msg["temperature"] == 22
assert sensor_msg["motion"] == 1
assert sensor_msg["rssi"] == -62


def test_acconeer_xm126(self):
"""Test acconeer parser for Acconeer XM126."""
data_string = "043e22020103013412b69009e01602010612ffc0ac916400160001000000000000000000c2"

data = bytes(bytearray.fromhex(data_string))

# pylint: disable=unused-variable
ble_parser = BleParser()
sensor_msg, tracker_msg = ble_parser.parse_raw_data(data)

assert sensor_msg["firmware"] == "Acconeer"
assert sensor_msg["type"] == "Acconeer XM126"
assert sensor_msg["mac"] == "E00990B61234"
assert sensor_msg["packet"] == "6400160001000000000000000000"
assert sensor_msg["data"]
assert sensor_msg["battery"] == 100
assert sensor_msg["temperature"] == 22
assert sensor_msg["motion"] == 1
assert sensor_msg["rssi"] == -62

0 comments on commit a1dac35

Please sign in to comment.