mirror of
https://github.com/home-assistant/core.git
synced 2026-09-26 17:31:15 -04:00
Add missing stabilized binary sensor description for Xiaomi BLE scales (#182328)
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user