Fix error in homekit_controller causing some entities to get an incorrect unique id (#53848)

This commit is contained in:
Jc2k 2021-08-02 04:59:32 +01:00 committed by GitHub
parent 8c5620e74b
commit 73bc62949b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 354 additions and 10 deletions

View file

@ -60,7 +60,7 @@ async def test_ecobee3_setup(hass):
assert climate_state.attributes["max_humidity"] == 50
climate_sensor = entity_registry.async_get("sensor.homew_current_temperature")
assert climate_sensor.unique_id == "homekit-123456789012-aid:1-sid:16-cid:16"
assert climate_sensor.unique_id == "homekit-123456789012-aid:1-sid:16-cid:19"
occ1 = entity_registry.async_get("binary_sensor.kitchen")
assert occ1.unique_id == "homekit-AB1C-56"

View file

@ -37,7 +37,7 @@ async def test_koogeek_p1eu_setup(hass):
# Assert the power sensor is detected
entry = entity_registry.async_get("sensor.koogeek_p1_a00aa0_real_time_energy")
assert entry.unique_id == "homekit-EUCP03190xxxxx48-aid:1-sid:21-cid:21"
assert entry.unique_id == "homekit-EUCP03190xxxxx48-aid:1-sid:21-cid:22"
helper = Helper(
hass,

View file

@ -45,7 +45,7 @@ async def test_koogeek_ls1_setup(hass):
# Assert that the power sensor entity is correctly added to the entity registry
entry = entity_registry.async_get("sensor.koogeek_sw2_187a91_real_time_energy")
assert entry.unique_id == "homekit-CNNT061751001372-aid:1-sid:14-cid:14"
assert entry.unique_id == "homekit-CNNT061751001372-aid:1-sid:14-cid:18"
helper = Helper(
hass,

View file

@ -0,0 +1,91 @@
"""Make sure that Mysa Living is enumerated properly."""
from homeassistant.helpers import device_registry as dr, entity_registry as er
from tests.components.homekit_controller.common import (
Helper,
setup_accessories_from_file,
setup_test_accessories,
)
async def test_mysa_living_setup(hass):
"""Test that the accessory can be correctly setup in HA."""
accessories = await setup_accessories_from_file(hass, "mysa_living.json")
config_entry, pairing = await setup_test_accessories(hass, accessories)
entity_registry = er.async_get(hass)
device_registry = dr.async_get(hass)
# Check that the switch entity is handled correctly
entry = entity_registry.async_get("sensor.mysa_85dda9_current_humidity")
assert entry.unique_id == "homekit-AAAAAAA000-aid:1-sid:20-cid:27"
helper = Helper(
hass,
"sensor.mysa_85dda9_current_humidity",
pairing,
accessories[0],
config_entry,
)
state = await helper.poll_and_get_state()
assert state.attributes["friendly_name"] == "Mysa-85dda9 - Current Humidity"
device = device_registry.async_get(entry.device_id)
assert device.manufacturer == "Empowered Homes Inc."
assert device.name == "Mysa-85dda9"
assert device.model == "v1"
assert device.sw_version == "2.8.1"
assert device.via_device_id is None
# Assert the humidifier is detected
entry = entity_registry.async_get("sensor.mysa_85dda9_current_temperature")
assert entry.unique_id == "homekit-AAAAAAA000-aid:1-sid:20-cid:25"
helper = Helper(
hass,
"sensor.mysa_85dda9_current_temperature",
pairing,
accessories[0],
config_entry,
)
state = await helper.poll_and_get_state()
assert state.attributes["friendly_name"] == "Mysa-85dda9 - Current Temperature"
# The sensor should be part of the same device
assert entry.device_id == device.id
# Assert the light is detected
entry = entity_registry.async_get("light.mysa_85dda9")
assert entry.unique_id == "homekit-AAAAAAA000-40"
helper = Helper(
hass,
"light.mysa_85dda9",
pairing,
accessories[0],
config_entry,
)
state = await helper.poll_and_get_state()
assert state.attributes["friendly_name"] == "Mysa-85dda9"
# The light should be part of the same device
assert entry.device_id == device.id
# Assert the climate entity is detected
entry = entity_registry.async_get("climate.mysa_85dda9")
assert entry.unique_id == "homekit-AAAAAAA000-20"
helper = Helper(
hass,
"climate.mysa_85dda9",
pairing,
accessories[0],
config_entry,
)
state = await helper.poll_and_get_state()
assert state.attributes["friendly_name"] == "Mysa-85dda9"
# The light should be part of the same device
assert entry.device_id == device.id

View file

@ -20,7 +20,7 @@ async def test_vocolinc_flowerbud_setup(hass):
# Check that the switch entity is handled correctly
entry = entity_registry.async_get("number.vocolinc_flowerbud_0d324b")
assert entry.unique_id == "homekit-AM01121849000327-aid:1-sid:30-cid:30"
assert entry.unique_id == "homekit-AM01121849000327-aid:1-sid:30-cid:38"
helper = Helper(
hass, "number.vocolinc_flowerbud_0d324b", pairing, accessories[0], config_entry
@ -73,7 +73,7 @@ async def test_vocolinc_flowerbud_setup(hass):
entry = entity_registry.async_get(
"sensor.vocolinc_flowerbud_0d324b_current_humidity"
)
assert entry.unique_id == "homekit-AM01121849000327-aid:1-sid:30-cid:30"
assert entry.unique_id == "homekit-AM01121849000327-aid:1-sid:30-cid:33"
helper = Helper(
hass,