Skip to content

Commit 2f00f29

Browse files
authored
fix: fix regression in occupancy status check (#266)
1 parent a3e279b commit 2f00f29

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

src/xiaomi_ble/parser.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,12 +1121,18 @@ def obj4818(
11211121
def obj484e(
11221122
xobj: bytes, device: XiaomiBluetoothDeviceData, device_type: str
11231123
) -> dict[str, Any]:
1124-
"""From miot-spec: occupancy-status: uint8: 0 - No One, 1 - Has One,
1125-
2 - Quick Check"""
1126-
"""Translate to: occupancy: bool: 0 - Clear, 1 - Detected, 2 - Clear"""
1127-
device.update_predefined_binary_sensor(
1128-
BinarySensorDeviceClass.OCCUPANCY, xobj[0] == 1
1129-
)
1124+
"""From miot-spec: occupancy-status: uint8: 0 - No One, 1 - Has One"""
1125+
"""Translate to: occupancy: bool: 0 - Clear, 1 - Detected"""
1126+
if device_type == "XMOSB01XS":
1127+
"""Translate to: occupancy: bool: 0 - Clear, 1 - Detected, 2 - Clear"""
1128+
device.update_predefined_binary_sensor(
1129+
BinarySensorDeviceClass.OCCUPANCY, xobj[0] == 1
1130+
)
1131+
else:
1132+
"""Translate to: occupancy: bool: 0 - Clear, 1 - Detected"""
1133+
device.update_predefined_binary_sensor(
1134+
BinarySensorDeviceClass.OCCUPANCY, xobj[0] > 0
1135+
)
11301136
return {}
11311137

11321138

tests/test_parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3746,7 +3746,7 @@ def test_Xiaomi_ES3_occupancy_on():
37463746
},
37473747
binary_entity_values={
37483748
KEY_BINARY_OCCUPANCY: BinarySensorValue(
3749-
device_key=KEY_BINARY_OCCUPANCY, name="Occupancy", native_value=False
3749+
device_key=KEY_BINARY_OCCUPANCY, name="Occupancy", native_value=True
37503750
),
37513751
},
37523752
)

0 commit comments

Comments
 (0)