Add missing stabilized binary sensor description for Xiaomi BLE scales (#182328)

This commit is contained in:
Rasad Regmi
2026-09-16 07:26:56 +02:00
committed by GitHub
parent 7819e3ad3c
commit 32ad04c584
3 changed files with 37 additions and 5 deletions
@@ -101,6 +101,9 @@ BINARY_SENSOR_DESCRIPTIONS = {
key=ExtendedBinarySensorDeviceClass.PRY_THE_DOOR,
device_class=BinarySensorDeviceClass.TAMPER,
),
ExtendedBinarySensorDeviceClass.STABILIZED: BinarySensorEntityDescription(
key=ExtendedBinarySensorDeviceClass.STABILIZED,
),
ExtendedBinarySensorDeviceClass.TOOTHBRUSH: BinarySensorEntityDescription(
key=ExtendedBinarySensorDeviceClass.TOOTHBRUSH,
),
@@ -16,7 +16,7 @@ from homeassistant.const import (
from homeassistant.core import HomeAssistant
from homeassistant.util import dt as dt_util
from . import make_advertisement
from . import MISCALE_V2_SERVICE_INFO, make_advertisement
from tests.common import MockConfigEntry, async_fire_time_changed
from tests.components.bluetooth import (
@@ -175,6 +175,35 @@ async def test_opening(hass: HomeAssistant) -> None:
await hass.async_block_till_done()
async def test_miscale_v2_stabilized_binary_sensor(hass: HomeAssistant) -> None:
"""Test MiScale V2 stabilized binary sensor."""
entry = MockConfigEntry(
domain=DOMAIN,
unique_id="50:FB:19:1B:B5:DC",
)
entry.add_to_hass(hass)
assert await hass.config_entries.async_setup(entry.entry_id)
await hass.async_block_till_done()
inject_bluetooth_service_info_bleak(hass, MISCALE_V2_SERVICE_INFO)
await hass.async_block_till_done()
assert len(hass.states.async_all()) == 4
stabilized_sensor = hass.states.get(
"binary_sensor.mi_body_composition_scale_b5dc_stabilized"
)
assert stabilized_sensor.state == STATE_ON
assert (
stabilized_sensor.attributes[ATTR_FRIENDLY_NAME]
== "Mi Body Composition Scale (B5DC) Stabilized"
)
assert await hass.config_entries.async_unload(entry.entry_id)
await hass.async_block_till_done()
async def test_opening_problem_sensors(hass: HomeAssistant) -> None:
"""Test setting up a opening binary sensor with additional problem sensors."""
entry = MockConfigEntry(
+4 -4
View File
@@ -692,7 +692,7 @@ async def test_miscale_v1_uuid(hass: HomeAssistant) -> None:
inject_bluetooth_service_info_bleak(hass, MISCALE_V1_SERVICE_INFO)
await hass.async_block_till_done()
assert len(hass.states.async_all()) == 2
assert len(hass.states.async_all()) == 3
mass_non_stabilized_sensor = hass.states.get(
"sensor.mi_smart_scale_b5dc_weight_non_stabilized"
@@ -734,7 +734,7 @@ async def test_miscale_v2_uuid(hass: HomeAssistant) -> None:
inject_bluetooth_service_info_bleak(hass, MISCALE_V2_SERVICE_INFO)
await hass.async_block_till_done()
assert len(hass.states.async_all()) == 3
assert len(hass.states.async_all()) == 4
mass_non_stabilized_sensor = hass.states.get(
"sensor.mi_body_composition_scale_b5dc_weight_non_stabilized"
@@ -844,7 +844,7 @@ async def test_sleepy_device(hass: HomeAssistant) -> None:
inject_bluetooth_service_info_bleak(hass, MISCALE_V1_SERVICE_INFO)
await hass.async_block_till_done()
assert len(hass.states.async_all()) == 2
assert len(hass.states.async_all()) == 3
mass_non_stabilized_sensor = hass.states.get(
"sensor.mi_smart_scale_b5dc_weight_non_stabilized"
@@ -895,7 +895,7 @@ async def test_sleepy_device_restore_state(hass: HomeAssistant) -> None:
inject_bluetooth_service_info_bleak(hass, MISCALE_V1_SERVICE_INFO)
await hass.async_block_till_done()
assert len(hass.states.async_all()) == 2
assert len(hass.states.async_all()) == 3
mass_non_stabilized_sensor = hass.states.get(
"sensor.mi_smart_scale_b5dc_weight_non_stabilized"