1
0
mirror of https://github.com/home-assistant/core synced 2024-07-08 20:17:01 +00:00

Address device helper review comments (#120615)

* Address review comments from #119761

* Address review comments from #119761

* Address review comments from #119761

* Remove reference from config entry
This commit is contained in:
dougiteixeira 2024-06-27 03:50:20 -03:00 committed by GitHub
parent 28e72753ad
commit 617ab48fa9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 7 deletions

View File

@ -26,7 +26,10 @@ def async_device_info_to_link_from_entity(
hass: HomeAssistant,
entity_id_or_uuid: str,
) -> dr.DeviceInfo | None:
"""DeviceInfo with information to link a device to a configuration entry in the link category from a entity id or entity uuid."""
"""DeviceInfo with information to link a device from an entity.
DeviceInfo will only return information to categorize as a link.
"""
return async_device_info_to_link_from_device_id(
hass,
@ -39,7 +42,10 @@ def async_device_info_to_link_from_device_id(
hass: HomeAssistant,
device_id: str | None,
) -> dr.DeviceInfo | None:
"""DeviceInfo with information to link a device to a configuration entry in the link category from a device id."""
"""DeviceInfo with information to link a device from a device id.
DeviceInfo will only return information to categorize as a link.
"""
dev_reg = dr.async_get(hass)
@ -58,7 +64,11 @@ def async_remove_stale_devices_links_keep_entity_device(
entry_id: str,
source_entity_id_or_uuid: str,
) -> None:
"""Remove the link between stales devices and a configuration entry, keeping only the device that the informed entity is linked to."""
"""Remove the link between stale devices and a configuration entry.
Only the device passed in the source_entity_id_or_uuid parameter
linked to the configuration entry will be maintained.
"""
async_remove_stale_devices_links_keep_current_device(
hass=hass,
@ -73,9 +83,10 @@ def async_remove_stale_devices_links_keep_current_device(
entry_id: str,
current_device_id: str | None,
) -> None:
"""Remove the link between stales devices and a configuration entry, keeping only the device informed.
"""Remove the link between stale devices and a configuration entry.
Device passed in the current_device_id parameter will be kept linked to the configuration entry.
Only the device passed in the current_device_id parameter linked to
the configuration entry will be maintained.
"""
dev_reg = dr.async_get(hass)

View File

@ -169,7 +169,7 @@ async def test_remove_stale_device_links_keep_entity_device(
config_entry.entry_id
)
# After cleanup, only one device is expected to be linked to the configuration entry if at least source_entity_id_or_uuid or device_id was given, else zero
# After cleanup, only one device is expected to be linked to the config entry
assert len(devices_config_entry) == 1
assert current_device in devices_config_entry
@ -220,7 +220,7 @@ async def test_remove_stale_devices_links_keep_current_device(
config_entry.entry_id
)
# After cleanup, only one device is expected to be linked to the configuration entry
# After cleanup, only one device is expected to be linked to the config entry
assert len(devices_config_entry) == 1
assert current_device in devices_config_entry