Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for Linptech RS1BB(MI) #77

Merged
merged 9 commits into from
May 5, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/xiaomi_ble/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,10 @@ class DeviceEntry:
name="Odor Eliminator",
model="SU001-T",
),
0x3F0F: DeviceEntry(
name="Flood and Rain Sensor",
model="RS1BB"
),
}


Expand Down
10 changes: 10 additions & 0 deletions src/xiaomi_ble/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1044,6 +1044,15 @@ 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]:
Expand Down Expand Up @@ -1428,6 +1437,7 @@ def obj4e1c(
0x4803: obj4803,
0x4804: obj4804,
0x4805: obj4805,
0x4806: obj4806,
0x4818: obj4818,
0x4A01: obj4a01,
0x4A08: obj4a08,
Expand Down
45 changes: 45 additions & 0 deletions tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2482,6 +2482,51 @@ 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:66:E5:67")
kvakulo marked this conversation as resolved.
Show resolved Hide resolved
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 (RS1BB(MI))",
devices={
None: SensorDeviceInfo(
name="Flood and Rain Sensor",
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=-64
kvakulo marked this conversation as resolved.
Show resolved Hide resolved
),
},
binary_entity_descriptions={
KEY_SMOKE: BinarySensorDescription(
device_key=KEY_MOISTURE,
device_class=BinarySensorDeviceClass.MOISTURE,
),
},
binary_entity_values={
KEY_SMOKE: BinarySensorValue(
name="Moisture", device_key=KEY_MOISTURE, native_value=False
),
},
)


def test_Xiaomi_XMWXKG01YL():
"""Test Xiaomi parser for XMWXKG01YL Switch (double button)."""
Expand Down
Loading