Skip to content

Commit 57d070c

Browse files
authored
feat: add support for Linptech RS1BB(MI) (#77)
* feat: add support for RS1BB
1 parent f861a2f commit 57d070c

File tree

3 files changed

+59
-1
lines changed

3 files changed

+59
-1
lines changed

src/xiaomi_ble/devices.py

+1
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ class DeviceEntry:
8181
name="Motion Sensor",
8282
model="HS1BB(MI)",
8383
),
84+
0x3F0F: DeviceEntry(name="Flood and Rain Sensor", model="RS1BB(MI)"),
8485
0x01AA: DeviceEntry(
8586
name="Temperature/Humidity Sensor",
8687
model="LYWSDCGQ",

src/xiaomi_ble/parser.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -1044,6 +1044,16 @@ def obj4805(
10441044
return {}
10451045

10461046

1047+
def obj4806(
1048+
xobj: bytes, device: XiaomiBluetoothDeviceData, device_type: str
1049+
) -> dict[str, Any]:
1050+
"""Moisture"""
1051+
device.update_predefined_binary_sensor(
1052+
BinarySensorDeviceClass.MOISTURE, xobj[0] > 0
1053+
)
1054+
return {}
1055+
1056+
10471057
def obj4818(
10481058
xobj: bytes, device: XiaomiBluetoothDeviceData, device_type: str
10491059
) -> dict[str, Any]:
@@ -1428,6 +1438,7 @@ def obj4e1c(
14281438
0x4803: obj4803,
14291439
0x4804: obj4804,
14301440
0x4805: obj4805,
1441+
0x4806: obj4806,
14311442
0x4818: obj4818,
14321443
0x4A01: obj4a01,
14331444
0x4A08: obj4a08,
@@ -1620,7 +1631,7 @@ def _parse_xiaomi(
16201631
xiaomi_mac = xiaomi_mac_reversed[::-1]
16211632
if xiaomi_mac != source_mac:
16221633
_LOGGER.debug(
1623-
"MAC address doesn't match data frame. Expected: %s, Got: %s)",
1634+
"MAC address doesn't match data frame. Expected: %s, Got: %s",
16241635
to_mac(xiaomi_mac),
16251636
to_mac(source_mac),
16261637
)

tests/test_parser.py

+46
Original file line numberDiff line numberDiff line change
@@ -2483,6 +2483,52 @@ def test_Xiaomi_MS1BB_MI_obj4a13():
24832483
)
24842484

24852485

2486+
def test_Xiaomi_RS1BB_MI_obj4806():
2487+
"""Test Xiaomi parser for Linptech RS1BB(MI) with obj4806."""
2488+
data_string = b"XY\x0f?JgL\xb98\xc1\xa4\xd6\xe5{\x83\x04\x00\x00\xd0\x1e\x0bK"
2489+
advertisement = bytes_to_service_info(data_string, address="A4:C1:38:B9:4C:67")
2490+
bindkey = "33ede53321bc73c790a8daae4581f3d5"
2491+
2492+
device = XiaomiBluetoothDeviceData(bindkey=bytes.fromhex(bindkey))
2493+
assert device.supported(advertisement)
2494+
assert device.bindkey_verified
2495+
assert device.update(advertisement) == SensorUpdate(
2496+
title="Flood and Rain Sensor 4C67 (RS1BB(MI))",
2497+
devices={
2498+
None: SensorDeviceInfo(
2499+
name="Flood and Rain Sensor 4C67",
2500+
manufacturer="Xiaomi",
2501+
model="RS1BB(MI)",
2502+
hw_version=None,
2503+
sw_version="Xiaomi (MiBeacon V5 encrypted)",
2504+
)
2505+
},
2506+
entity_descriptions={
2507+
KEY_SIGNAL_STRENGTH: SensorDescription(
2508+
device_key=KEY_SIGNAL_STRENGTH,
2509+
device_class=DeviceClass.SIGNAL_STRENGTH,
2510+
native_unit_of_measurement="dBm",
2511+
),
2512+
},
2513+
entity_values={
2514+
KEY_SIGNAL_STRENGTH: SensorValue(
2515+
name="Signal Strength", device_key=KEY_SIGNAL_STRENGTH, native_value=-60
2516+
),
2517+
},
2518+
binary_entity_descriptions={
2519+
KEY_MOISTURE: BinarySensorDescription(
2520+
device_key=KEY_MOISTURE,
2521+
device_class=BinarySensorDeviceClass.MOISTURE,
2522+
),
2523+
},
2524+
binary_entity_values={
2525+
KEY_MOISTURE: BinarySensorValue(
2526+
name="Moisture", device_key=KEY_MOISTURE, native_value=False
2527+
),
2528+
},
2529+
)
2530+
2531+
24862532
def test_Xiaomi_XMWXKG01YL():
24872533
"""Test Xiaomi parser for XMWXKG01YL Switch (double button)."""
24882534
data_string = b"XYI\x19Os\x12\x87\x83\xed\xdc\x0b48\n\x02\x00\x00\x8dI\xae("

0 commit comments

Comments
 (0)