mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Add support for MiScale V1 (#97081)
This commit is contained in:
parent
35f21dcf9c
commit
672313c8ab
@ -6,6 +6,10 @@
|
|||||||
"connectable": false,
|
"connectable": false,
|
||||||
"service_data_uuid": "0000181b-0000-1000-8000-00805f9b34fb"
|
"service_data_uuid": "0000181b-0000-1000-8000-00805f9b34fb"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"connectable": false,
|
||||||
|
"service_data_uuid": "0000181d-0000-1000-8000-00805f9b34fb"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"connectable": false,
|
"connectable": false,
|
||||||
"service_data_uuid": "0000fd50-0000-1000-8000-00805f9b34fb"
|
"service_data_uuid": "0000fd50-0000-1000-8000-00805f9b34fb"
|
||||||
@ -20,5 +24,5 @@
|
|||||||
"dependencies": ["bluetooth_adapters"],
|
"dependencies": ["bluetooth_adapters"],
|
||||||
"documentation": "https://www.home-assistant.io/integrations/xiaomi_ble",
|
"documentation": "https://www.home-assistant.io/integrations/xiaomi_ble",
|
||||||
"iot_class": "local_push",
|
"iot_class": "local_push",
|
||||||
"requirements": ["xiaomi-ble==0.19.1"]
|
"requirements": ["xiaomi-ble==0.20.0"]
|
||||||
}
|
}
|
||||||
|
@ -525,6 +525,11 @@ BLUETOOTH: list[dict[str, bool | str | int | list[int]]] = [
|
|||||||
"domain": "xiaomi_ble",
|
"domain": "xiaomi_ble",
|
||||||
"service_data_uuid": "0000181b-0000-1000-8000-00805f9b34fb",
|
"service_data_uuid": "0000181b-0000-1000-8000-00805f9b34fb",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"connectable": False,
|
||||||
|
"domain": "xiaomi_ble",
|
||||||
|
"service_data_uuid": "0000181d-0000-1000-8000-00805f9b34fb",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"connectable": False,
|
"connectable": False,
|
||||||
"domain": "xiaomi_ble",
|
"domain": "xiaomi_ble",
|
||||||
|
@ -2687,7 +2687,7 @@ wyoming==1.1.0
|
|||||||
xbox-webapi==2.0.11
|
xbox-webapi==2.0.11
|
||||||
|
|
||||||
# homeassistant.components.xiaomi_ble
|
# homeassistant.components.xiaomi_ble
|
||||||
xiaomi-ble==0.19.1
|
xiaomi-ble==0.20.0
|
||||||
|
|
||||||
# homeassistant.components.knx
|
# homeassistant.components.knx
|
||||||
xknx==2.11.1
|
xknx==2.11.1
|
||||||
|
@ -1969,7 +1969,7 @@ wyoming==1.1.0
|
|||||||
xbox-webapi==2.0.11
|
xbox-webapi==2.0.11
|
||||||
|
|
||||||
# homeassistant.components.xiaomi_ble
|
# homeassistant.components.xiaomi_ble
|
||||||
xiaomi-ble==0.19.1
|
xiaomi-ble==0.20.0
|
||||||
|
|
||||||
# homeassistant.components.knx
|
# homeassistant.components.knx
|
||||||
xknx==2.11.1
|
xknx==2.11.1
|
||||||
|
@ -105,6 +105,22 @@ HHCCJCY10_SERVICE_INFO = BluetoothServiceInfoBleak(
|
|||||||
connectable=False,
|
connectable=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
MISCALE_V1_SERVICE_INFO = BluetoothServiceInfoBleak(
|
||||||
|
name="MISCA",
|
||||||
|
address="50:FB:19:1B:B5:DC",
|
||||||
|
device=generate_ble_device("00:00:00:00:00:00", None),
|
||||||
|
rssi=-60,
|
||||||
|
manufacturer_data={},
|
||||||
|
service_data={
|
||||||
|
"0000181d-0000-1000-8000-00805f9b34fb": b"\x22\x9e\x43\xe5\x07\x04\x0b\x10\x13\x01"
|
||||||
|
},
|
||||||
|
service_uuids=["0000181d-0000-1000-8000-00805f9b34fb"],
|
||||||
|
source="local",
|
||||||
|
advertisement=generate_advertisement_data(local_name="Not it"),
|
||||||
|
time=0,
|
||||||
|
connectable=False,
|
||||||
|
)
|
||||||
|
|
||||||
MISCALE_V2_SERVICE_INFO = BluetoothServiceInfoBleak(
|
MISCALE_V2_SERVICE_INFO = BluetoothServiceInfoBleak(
|
||||||
name="MIBFS",
|
name="MIBFS",
|
||||||
address="50:FB:19:1B:B5:DC",
|
address="50:FB:19:1B:B5:DC",
|
||||||
@ -112,7 +128,7 @@ MISCALE_V2_SERVICE_INFO = BluetoothServiceInfoBleak(
|
|||||||
rssi=-60,
|
rssi=-60,
|
||||||
manufacturer_data={},
|
manufacturer_data={},
|
||||||
service_data={
|
service_data={
|
||||||
"0000181b-0000-1000-8000-00805f9b34fb": b"\x02\xa6\xe7\x07\x07\x07\x0b\x1f\x1d\x1f\x02\xfa-"
|
"0000181b-0000-1000-8000-00805f9b34fb": b"\x02&\xb2\x07\x05\x04\x0f\x02\x01\xac\x01\x86B"
|
||||||
},
|
},
|
||||||
service_uuids=["0000181b-0000-1000-8000-00805f9b34fb"],
|
service_uuids=["0000181b-0000-1000-8000-00805f9b34fb"],
|
||||||
source="local",
|
source="local",
|
||||||
|
@ -6,6 +6,7 @@ from homeassistant.core import HomeAssistant
|
|||||||
|
|
||||||
from . import (
|
from . import (
|
||||||
HHCCJCY10_SERVICE_INFO,
|
HHCCJCY10_SERVICE_INFO,
|
||||||
|
MISCALE_V1_SERVICE_INFO,
|
||||||
MISCALE_V2_SERVICE_INFO,
|
MISCALE_V2_SERVICE_INFO,
|
||||||
MMC_T201_1_SERVICE_INFO,
|
MMC_T201_1_SERVICE_INFO,
|
||||||
make_advertisement,
|
make_advertisement,
|
||||||
@ -513,6 +514,48 @@ async def test_hhccjcy10_uuid(hass: HomeAssistant) -> None:
|
|||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
|
|
||||||
|
async def test_miscale_v1_uuid(hass: HomeAssistant) -> None:
|
||||||
|
"""Test MiScale V1 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_V1_SERVICE_INFO)
|
||||||
|
|
||||||
|
await hass.async_block_till_done()
|
||||||
|
assert len(hass.states.async_all()) == 2
|
||||||
|
|
||||||
|
mass_non_stabilized_sensor = hass.states.get(
|
||||||
|
"sensor.mi_smart_scale_b5dc_mass_non_stabilized"
|
||||||
|
)
|
||||||
|
mass_non_stabilized_sensor_attr = mass_non_stabilized_sensor.attributes
|
||||||
|
assert mass_non_stabilized_sensor.state == "86.55"
|
||||||
|
assert (
|
||||||
|
mass_non_stabilized_sensor_attr[ATTR_FRIENDLY_NAME]
|
||||||
|
== "Mi Smart Scale (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_smart_scale_b5dc_mass")
|
||||||
|
mass_sensor_attr = mass_sensor.attributes
|
||||||
|
assert mass_sensor.state == "86.55"
|
||||||
|
assert mass_sensor_attr[ATTR_FRIENDLY_NAME] == "Mi Smart Scale (B5DC) Mass"
|
||||||
|
assert mass_sensor_attr[ATTR_UNIT_OF_MEASUREMENT] == "kg"
|
||||||
|
assert mass_sensor_attr[ATTR_STATE_CLASS] == "measurement"
|
||||||
|
|
||||||
|
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:
|
async def test_miscale_v2_uuid(hass: HomeAssistant) -> None:
|
||||||
"""Test MiScale V2 UUID.
|
"""Test MiScale V2 UUID.
|
||||||
|
|
||||||
@ -533,35 +576,34 @@ async def test_miscale_v2_uuid(hass: HomeAssistant) -> None:
|
|||||||
assert len(hass.states.async_all()) == 3
|
assert len(hass.states.async_all()) == 3
|
||||||
|
|
||||||
mass_non_stabilized_sensor = hass.states.get(
|
mass_non_stabilized_sensor = hass.states.get(
|
||||||
"sensor.mi_body_composition_scale_2_b5dc_mass_non_stabilized"
|
"sensor.mi_body_composition_scale_b5dc_mass_non_stabilized"
|
||||||
)
|
)
|
||||||
mass_non_stabilized_sensor_attr = mass_non_stabilized_sensor.attributes
|
mass_non_stabilized_sensor_attr = mass_non_stabilized_sensor.attributes
|
||||||
assert mass_non_stabilized_sensor.state == "58.85"
|
assert mass_non_stabilized_sensor.state == "85.15"
|
||||||
assert (
|
assert (
|
||||||
mass_non_stabilized_sensor_attr[ATTR_FRIENDLY_NAME]
|
mass_non_stabilized_sensor_attr[ATTR_FRIENDLY_NAME]
|
||||||
== "Mi Body Composition Scale 2 (B5DC) Mass Non Stabilized"
|
== "Mi Body Composition Scale (B5DC) Mass Non Stabilized"
|
||||||
)
|
)
|
||||||
assert mass_non_stabilized_sensor_attr[ATTR_UNIT_OF_MEASUREMENT] == "kg"
|
assert mass_non_stabilized_sensor_attr[ATTR_UNIT_OF_MEASUREMENT] == "kg"
|
||||||
assert mass_non_stabilized_sensor_attr[ATTR_STATE_CLASS] == "measurement"
|
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 = hass.states.get("sensor.mi_body_composition_scale_b5dc_mass")
|
||||||
mass_sensor_attr = mass_sensor.attributes
|
mass_sensor_attr = mass_sensor.attributes
|
||||||
assert mass_sensor.state == "58.85"
|
assert mass_sensor.state == "85.15"
|
||||||
assert (
|
assert (
|
||||||
mass_sensor_attr[ATTR_FRIENDLY_NAME]
|
mass_sensor_attr[ATTR_FRIENDLY_NAME] == "Mi Body Composition Scale (B5DC) Mass"
|
||||||
== "Mi Body Composition Scale 2 (B5DC) Mass"
|
|
||||||
)
|
)
|
||||||
assert mass_sensor_attr[ATTR_UNIT_OF_MEASUREMENT] == "kg"
|
assert mass_sensor_attr[ATTR_UNIT_OF_MEASUREMENT] == "kg"
|
||||||
assert mass_sensor_attr[ATTR_STATE_CLASS] == "measurement"
|
assert mass_sensor_attr[ATTR_STATE_CLASS] == "measurement"
|
||||||
|
|
||||||
impedance_sensor = hass.states.get(
|
impedance_sensor = hass.states.get(
|
||||||
"sensor.mi_body_composition_scale_2_b5dc_impedance"
|
"sensor.mi_body_composition_scale_b5dc_impedance"
|
||||||
)
|
)
|
||||||
impedance_sensor_attr = impedance_sensor.attributes
|
impedance_sensor_attr = impedance_sensor.attributes
|
||||||
assert impedance_sensor.state == "543"
|
assert impedance_sensor.state == "428"
|
||||||
assert (
|
assert (
|
||||||
impedance_sensor_attr[ATTR_FRIENDLY_NAME]
|
impedance_sensor_attr[ATTR_FRIENDLY_NAME]
|
||||||
== "Mi Body Composition Scale 2 (B5DC) Impedance"
|
== "Mi Body Composition Scale (B5DC) Impedance"
|
||||||
)
|
)
|
||||||
assert impedance_sensor_attr[ATTR_UNIT_OF_MEASUREMENT] == "ohm"
|
assert impedance_sensor_attr[ATTR_UNIT_OF_MEASUREMENT] == "ohm"
|
||||||
assert impedance_sensor_attr[ATTR_STATE_CLASS] == "measurement"
|
assert impedance_sensor_attr[ATTR_STATE_CLASS] == "measurement"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user