Skip to content

Commit

Permalink
Add XMPIRO2SXS
Browse files Browse the repository at this point in the history
  • Loading branch information
Ernst79 committed Mar 4, 2024
1 parent a82d31e commit 8b93e95
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 1 deletion.
1 change: 1 addition & 0 deletions custom_components/ble_monitor/ble_parser/xiaomi.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
0x11C2: "SV40",
0x3F0F: "RS1BB",
0x38BB: "PTX",
0x3531: "XMPIRO2SXS",
}

# Structured objects for data conversions
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 @@ -1780,6 +1780,7 @@ class BLEMonitorBinarySensorEntityDescription(
'K9BB-1BTN' : [["battery", "rssi"], ["one btn switch"], []],
'MS1BB(MI)' : [["battery", "rssi"], ["button"], ["opening"]],
'HS1BB(MI)' : [["illuminance", "battery", "rssi"], [], ["motion"]],
'XMPIRO2SXS' : [["illuminance", "battery", "rssi"], [], ["motion"]],
'XMWXKG01YL' : [["rssi"], ["two btn switch left", "two btn switch right"], []],
'XMWXKG01LM' : [["battery", "rssi"], ["one btn switch"], []],
'PTX' : [["battery", "rssi"], ["one btn switch"], []],
Expand Down Expand Up @@ -1894,6 +1895,7 @@ class BLEMonitorBinarySensorEntityDescription(
'XMZNMS04LM' : 'Xiaomi',
'XMZNMS08LM' : 'Xiaomi',
'MJZNZ018H' : 'Xiaomi',
'XMPIRO2SXS' : 'Xiaomi',
'ZX1' : '8H Sleep',
'CGC1' : 'Qingping',
'CGD1' : 'Qingping',
Expand Down
2 changes: 1 addition & 1 deletion custom_components/ble_monitor/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
"btsocket>=0.2.0",
"pyric>=0.1.6.3"
],
"version": "12.10.0"
"version": "12.10.1"
}
28 changes: 28 additions & 0 deletions custom_components/ble_monitor/test/test_xiaomi_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1064,3 +1064,31 @@ def test_Xiaomi_PTX(self):
assert sensor_msg["one btn switch"] == "toggle"
assert sensor_msg["button switch"] == "single press"
assert sensor_msg["rssi"] == -52

def test_Xiaomi_XMPIRO2SXS(self):
"""Test Xiaomi parser for XMPIRO2SXS."""
self.aeskeys = {}
data_string = "043E260201000043ea2d958edc1a020106161695fe485931350b64799117331ef4020000c5d2f6acCC"
data = bytes(bytearray.fromhex(data_string))

aeskey = "685d647dc5e7bc9bcfcf5a1357bd2114"

is_ext_packet = True if data[3] == 0x0D else False
mac = (data[8 if is_ext_packet else 7:14 if is_ext_packet else 13])[::-1]
mac_address = mac.hex()
p_mac = bytes.fromhex(mac_address.replace(":", "").lower())
p_key = bytes.fromhex(aeskey.lower())
self.aeskeys[p_mac] = p_key
# pylint: disable=unused-variable
ble_parser = BleParser(aeskeys=self.aeskeys)
sensor_msg, tracker_msg = ble_parser.parse_raw_data(data)

assert sensor_msg["firmware"] == "Xiaomi (MiBeacon V5 encrypted)"
assert sensor_msg["type"] == "XMPIRO2SXS"
assert sensor_msg["mac"] == "DC8E952DEA43"
assert sensor_msg["packet"] == 11
assert sensor_msg["data"]
assert sensor_msg["motion"] == 1
assert sensor_msg["motion timer"] == 1
assert sensor_msg["illuminance"] == 51.0
assert sensor_msg["rssi"] == -52
23 changes: 23 additions & 0 deletions docs/_devices/Xiaomi_XMPIRO2SXS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
manufacturer: Xiaomi
name: Xiaomi Human Body Sensor 2S
model: XMPIRO2SXS
image: XMPIRO2SXS.png
physical_description:
broadcasted_properties:
- illuminance
- motion
- battery
- rssi
broadcasted_property_notes:
- property: illuminance
note: is measured in lux.
- property: motion
note: Motion state is ‘motion detected’ or ‘clear’.
broadcast_rate:
active_scan:
encryption_key: True
custom_firmware:
notes: >
- You can use the [reset_timer](configuration_params#reset_timer) option if you want to use a different time to set the sensor to `motion clear`.
---
Binary file added docs/assets/images/XMPIRO2SXS.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 8b93e95

Please sign in to comment.