diff --git a/src/xiaomi_ble/devices.py b/src/xiaomi_ble/devices.py index 53d01a9..431d350 100644 --- a/src/xiaomi_ble/devices.py +++ b/src/xiaomi_ble/devices.py @@ -81,6 +81,7 @@ class DeviceEntry: name="Motion Sensor", model="HS1BB(MI)", ), + 0x3F0F: DeviceEntry(name="Flood and Rain Sensor", model="RS1BB(MI)"), 0x01AA: DeviceEntry( name="Temperature/Humidity Sensor", model="LYWSDCGQ", diff --git a/src/xiaomi_ble/parser.py b/src/xiaomi_ble/parser.py index 04d3aa8..1416ef4 100644 --- a/src/xiaomi_ble/parser.py +++ b/src/xiaomi_ble/parser.py @@ -1044,6 +1044,16 @@ def obj4805( return {} +def obj4806( + xobj: bytes, device: XiaomiBluetoothDeviceData, device_type: str +) -> dict[str, Any]: + """Moisture""" + device.update_predefined_binary_sensor( + BinarySensorDeviceClass.MOISTURE, xobj[0] > 0 + ) + return {} + + def obj4818( xobj: bytes, device: XiaomiBluetoothDeviceData, device_type: str ) -> dict[str, Any]: @@ -1428,6 +1438,7 @@ def obj4e1c( 0x4803: obj4803, 0x4804: obj4804, 0x4805: obj4805, + 0x4806: obj4806, 0x4818: obj4818, 0x4A01: obj4a01, 0x4A08: obj4a08, @@ -1620,7 +1631,7 @@ def _parse_xiaomi( xiaomi_mac = xiaomi_mac_reversed[::-1] if xiaomi_mac != source_mac: _LOGGER.debug( - "MAC address doesn't match data frame. Expected: %s, Got: %s)", + "MAC address doesn't match data frame. Expected: %s, Got: %s", to_mac(xiaomi_mac), to_mac(source_mac), ) diff --git a/tests/test_parser.py b/tests/test_parser.py index fd763ef..05eb95f 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -2483,6 +2483,52 @@ def test_Xiaomi_MS1BB_MI_obj4a13(): ) +def test_Xiaomi_RS1BB_MI_obj4806(): + """Test Xiaomi parser for Linptech RS1BB(MI) with obj4806.""" + data_string = b"XY\x0f?JgL\xb98\xc1\xa4\xd6\xe5{\x83\x04\x00\x00\xd0\x1e\x0bK" + advertisement = bytes_to_service_info(data_string, address="A4:C1:38:B9:4C:67") + bindkey = "33ede53321bc73c790a8daae4581f3d5" + + device = XiaomiBluetoothDeviceData(bindkey=bytes.fromhex(bindkey)) + assert device.supported(advertisement) + assert device.bindkey_verified + assert device.update(advertisement) == SensorUpdate( + title="Flood and Rain Sensor 4C67 (RS1BB(MI))", + devices={ + None: SensorDeviceInfo( + name="Flood and Rain Sensor 4C67", + manufacturer="Xiaomi", + model="RS1BB(MI)", + hw_version=None, + sw_version="Xiaomi (MiBeacon V5 encrypted)", + ) + }, + entity_descriptions={ + KEY_SIGNAL_STRENGTH: SensorDescription( + device_key=KEY_SIGNAL_STRENGTH, + device_class=DeviceClass.SIGNAL_STRENGTH, + native_unit_of_measurement="dBm", + ), + }, + entity_values={ + KEY_SIGNAL_STRENGTH: SensorValue( + name="Signal Strength", device_key=KEY_SIGNAL_STRENGTH, native_value=-60 + ), + }, + binary_entity_descriptions={ + KEY_MOISTURE: BinarySensorDescription( + device_key=KEY_MOISTURE, + device_class=BinarySensorDeviceClass.MOISTURE, + ), + }, + binary_entity_values={ + KEY_MOISTURE: BinarySensorValue( + name="Moisture", device_key=KEY_MOISTURE, native_value=False + ), + }, + ) + + def test_Xiaomi_XMWXKG01YL(): """Test Xiaomi parser for XMWXKG01YL Switch (double button).""" data_string = b"XYI\x19Os\x12\x87\x83\xed\xdc\x0b48\n\x02\x00\x00\x8dI\xae("