mirror of
https://github.com/home-assistant/core.git
synced 2025-08-14 01:55:18 +02:00
move data prep out of Device assign for clarity
This commit is contained in:
@@ -82,12 +82,19 @@ async def async_setup_entry(hass: HomeAssistant, entry: SqueezeboxConfigEntry) -
|
|||||||
_LOGGER.debug("LMS Status for setup = %s", status)
|
_LOGGER.debug("LMS Status for setup = %s", status)
|
||||||
|
|
||||||
lms.uuid = status[STATUS_QUERY_UUID]
|
lms.uuid = status[STATUS_QUERY_UUID]
|
||||||
|
_LOGGER.debug("LMS %s = '%s' with uuid = %s ", lms.name, host, lms.uuid)
|
||||||
lms.name = (
|
lms.name = (
|
||||||
(STATUS_QUERY_LIBRARYNAME in status and status[STATUS_QUERY_LIBRARYNAME])
|
(STATUS_QUERY_LIBRARYNAME in status and status[STATUS_QUERY_LIBRARYNAME])
|
||||||
and status[STATUS_QUERY_LIBRARYNAME]
|
and status[STATUS_QUERY_LIBRARYNAME]
|
||||||
or host
|
or host
|
||||||
)
|
)
|
||||||
_LOGGER.debug("LMS %s = '%s' with uuid = %s ", lms.name, host, lms.uuid)
|
version = STATUS_QUERY_VERSION in status and status[STATUS_QUERY_VERSION] or None
|
||||||
|
# mac can be missing
|
||||||
|
mac_connect = (
|
||||||
|
STATUS_QUERY_MAC in status
|
||||||
|
and {(CONNECTION_NETWORK_MAC, format_mac(status[STATUS_QUERY_MAC]))}
|
||||||
|
or None
|
||||||
|
)
|
||||||
|
|
||||||
device_registry = dr.async_get(hass)
|
device_registry = dr.async_get(hass)
|
||||||
device = device_registry.async_get_or_create(
|
device = device_registry.async_get_or_create(
|
||||||
@@ -96,13 +103,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: SqueezeboxConfigEntry) -
|
|||||||
name=lms.name,
|
name=lms.name,
|
||||||
manufacturer=MANUFACTURER,
|
manufacturer=MANUFACTURER,
|
||||||
model=SERVER_MODEL,
|
model=SERVER_MODEL,
|
||||||
sw_version=STATUS_QUERY_VERSION in status
|
sw_version=version,
|
||||||
and status[STATUS_QUERY_VERSION]
|
|
||||||
or None,
|
|
||||||
serial_number=lms.uuid,
|
serial_number=lms.uuid,
|
||||||
connections=STATUS_QUERY_MAC in status
|
connections=mac_connect,
|
||||||
and {(CONNECTION_NETWORK_MAC, format_mac(status[STATUS_QUERY_MAC]))}
|
|
||||||
or None,
|
|
||||||
)
|
)
|
||||||
_LOGGER.debug("LMS Device %s", device)
|
_LOGGER.debug("LMS Device %s", device)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user