Cleanup search for mac in samsungtv (#67374)

* Add logging on config_entry update

* Add search for mac

* Use info

Co-authored-by: epenet <epenet@users.noreply.github.com>
pull/67448/head
epenet 2022-03-01 18:21:40 +01:00 committed by GitHub
parent 6dacf75aaf
commit 418808d873
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 6 deletions

View File

@ -156,6 +156,7 @@ async def _async_create_bridge_with_updated_data(
info: dict[str, Any] | None = None
if not port or not method:
LOGGER.debug("Attempting to get port or method for %s", host)
if method == METHOD_LEGACY:
port = LEGACY_PORT
else:
@ -167,6 +168,7 @@ async def _async_create_bridge_with_updated_data(
"Failed to determine connection method, make sure the device is on."
)
LOGGER.info("Updated port to %s and method to %s for %s", port, method, host)
updated_data[CONF_PORT] = port
updated_data[CONF_METHOD] = method
@ -174,17 +176,22 @@ async def _async_create_bridge_with_updated_data(
mac: str | None = entry.data.get(CONF_MAC)
if not mac:
LOGGER.debug("Attempting to get mac for %s", host)
if info:
mac = mac_from_device_info(info)
else:
mac = await bridge.async_mac_from_device()
if not mac:
mac = await hass.async_add_executor_job(
partial(getmac.get_mac_address, ip=host)
)
if mac:
updated_data[CONF_MAC] = mac
if not mac:
mac = await hass.async_add_executor_job(
partial(getmac.get_mac_address, ip=host)
)
if mac:
LOGGER.info("Updated mac to %s for %s", mac, host)
updated_data[CONF_MAC] = mac
else:
LOGGER.info("Failed to get mac for %s", host)
if updated_data:
data = {**entry.data, **updated_data}