mirror of
https://github.com/home-assistant/core.git
synced 2026-09-27 09:58:07 -04:00
Add support for MiScale V2 (#96807)
* Add support for MiScale V2 * Add icon to impedance * Reduce mass sensors
This commit is contained in:
@@ -105,6 +105,22 @@ HHCCJCY10_SERVICE_INFO = BluetoothServiceInfoBleak(
|
||||
connectable=False,
|
||||
)
|
||||
|
||||
MISCALE_V2_SERVICE_INFO = BluetoothServiceInfoBleak(
|
||||
name="MIBFS",
|
||||
address="50:FB:19:1B:B5:DC",
|
||||
device=generate_ble_device("00:00:00:00:00:00", None),
|
||||
rssi=-60,
|
||||
manufacturer_data={},
|
||||
service_data={
|
||||
"0000181b-0000-1000-8000-00805f9b34fb": b"\x02\xa6\xe7\x07\x07\x07\x0b\x1f\x1d\x1f\x02\xfa-"
|
||||
},
|
||||
service_uuids=["0000181b-0000-1000-8000-00805f9b34fb"],
|
||||
source="local",
|
||||
advertisement=generate_advertisement_data(local_name="Not it"),
|
||||
time=0,
|
||||
connectable=False,
|
||||
)
|
||||
|
||||
MISSING_PAYLOAD_ENCRYPTED = BluetoothServiceInfoBleak(
|
||||
name="LYWSD02MMC",
|
||||
address="A4:C1:38:56:53:84",
|
||||
|
||||
@@ -4,7 +4,12 @@ from homeassistant.components.xiaomi_ble.const import DOMAIN
|
||||
from homeassistant.const import ATTR_FRIENDLY_NAME, ATTR_UNIT_OF_MEASUREMENT
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from . import HHCCJCY10_SERVICE_INFO, MMC_T201_1_SERVICE_INFO, make_advertisement
|
||||
from . import (
|
||||
HHCCJCY10_SERVICE_INFO,
|
||||
MISCALE_V2_SERVICE_INFO,
|
||||
MMC_T201_1_SERVICE_INFO,
|
||||
make_advertisement,
|
||||
)
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
from tests.components.bluetooth import inject_bluetooth_service_info_bleak
|
||||
@@ -506,3 +511,60 @@ async def test_hhccjcy10_uuid(hass: HomeAssistant) -> None:
|
||||
|
||||
assert await hass.config_entries.async_unload(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
|
||||
async def test_miscale_v2_uuid(hass: HomeAssistant) -> None:
|
||||
"""Test MiScale V2 UUID.
|
||||
|
||||
This device uses a different UUID compared to the other Xiaomi sensors.
|
||||
"""
|
||||
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()) == 3
|
||||
|
||||
mass_non_stabilized_sensor = hass.states.get(
|
||||
"sensor.mi_body_composition_scale_2_b5dc_mass_non_stabilized"
|
||||
)
|
||||
mass_non_stabilized_sensor_attr = mass_non_stabilized_sensor.attributes
|
||||
assert mass_non_stabilized_sensor.state == "58.85"
|
||||
assert (
|
||||
mass_non_stabilized_sensor_attr[ATTR_FRIENDLY_NAME]
|
||||
== "Mi Body Composition Scale 2 (B5DC) Mass Non Stabilized"
|
||||
)
|
||||
assert mass_non_stabilized_sensor_attr[ATTR_UNIT_OF_MEASUREMENT] == "kg"
|
||||
assert mass_non_stabilized_sensor_attr[ATTR_STATE_CLASS] == "measurement"
|
||||
|
||||
mass_sensor = hass.states.get("sensor.mi_body_composition_scale_2_b5dc_mass")
|
||||
mass_sensor_attr = mass_sensor.attributes
|
||||
assert mass_sensor.state == "58.85"
|
||||
assert (
|
||||
mass_sensor_attr[ATTR_FRIENDLY_NAME]
|
||||
== "Mi Body Composition Scale 2 (B5DC) Mass"
|
||||
)
|
||||
assert mass_sensor_attr[ATTR_UNIT_OF_MEASUREMENT] == "kg"
|
||||
assert mass_sensor_attr[ATTR_STATE_CLASS] == "measurement"
|
||||
|
||||
impedance_sensor = hass.states.get(
|
||||
"sensor.mi_body_composition_scale_2_b5dc_impedance"
|
||||
)
|
||||
impedance_sensor_attr = impedance_sensor.attributes
|
||||
assert impedance_sensor.state == "543"
|
||||
assert (
|
||||
impedance_sensor_attr[ATTR_FRIENDLY_NAME]
|
||||
== "Mi Body Composition Scale 2 (B5DC) Impedance"
|
||||
)
|
||||
assert impedance_sensor_attr[ATTR_UNIT_OF_MEASUREMENT] == "ohm"
|
||||
assert impedance_sensor_attr[ATTR_STATE_CLASS] == "measurement"
|
||||
|
||||
assert await hass.config_entries.async_unload(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
Reference in New Issue
Block a user