From 3d15e15e5910927bddf7a96ac842b5b519a4bdaa Mon Sep 17 00:00:00 2001 From: tronikos Date: Wed, 29 May 2024 06:50:13 -0700 Subject: [PATCH] Add Android TV Remote debug logs to help with zeroconf issue (#117960) --- homeassistant/components/androidtv_remote/__init__.py | 9 +++++++-- homeassistant/components/androidtv_remote/config_flow.py | 5 +++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/androidtv_remote/__init__.py b/homeassistant/components/androidtv_remote/__init__.py index dcd08cf6fc3..6a55e9971ac 100644 --- a/homeassistant/components/androidtv_remote/__init__.py +++ b/homeassistant/components/androidtv_remote/__init__.py @@ -30,6 +30,7 @@ async def async_setup_entry( hass: HomeAssistant, entry: AndroidTVRemoteConfigEntry ) -> bool: """Set up Android TV Remote from a config entry.""" + _LOGGER.debug("async_setup_entry: %s", entry.data) api = create_api(hass, entry.data[CONF_HOST], get_enable_ime(entry)) @callback @@ -79,7 +80,7 @@ async def async_setup_entry( entry.async_on_unload( hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, on_hass_stop) ) - entry.async_on_unload(entry.add_update_listener(update_listener)) + entry.async_on_unload(entry.add_update_listener(async_update_options)) entry.async_on_unload(api.disconnect) return True @@ -87,9 +88,13 @@ async def async_setup_entry( async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Unload a config entry.""" + _LOGGER.debug("async_unload_entry: %s", entry.data) return await hass.config_entries.async_unload_platforms(entry, PLATFORMS) -async def update_listener(hass: HomeAssistant, entry: ConfigEntry) -> None: +async def async_update_options(hass: HomeAssistant, entry: ConfigEntry) -> None: """Handle options update.""" + _LOGGER.debug( + "async_update_options: data: %s options: %s", entry.data, entry.options + ) await hass.config_entries.async_reload(entry.entry_id) diff --git a/homeassistant/components/androidtv_remote/config_flow.py b/homeassistant/components/androidtv_remote/config_flow.py index 2fd9f607218..a9b32c22700 100644 --- a/homeassistant/components/androidtv_remote/config_flow.py +++ b/homeassistant/components/androidtv_remote/config_flow.py @@ -3,6 +3,7 @@ from __future__ import annotations from collections.abc import Mapping +import logging from typing import Any from androidtvremote2 import ( @@ -27,6 +28,8 @@ from homeassistant.helpers.device_registry import format_mac from .const import CONF_ENABLE_IME, DOMAIN from .helpers import create_api, get_enable_ime +_LOGGER = logging.getLogger(__name__) + STEP_USER_DATA_SCHEMA = vol.Schema( { vol.Required("host"): str, @@ -139,6 +142,7 @@ class AndroidTVRemoteConfigFlow(ConfigFlow, domain=DOMAIN): self, discovery_info: zeroconf.ZeroconfServiceInfo ) -> ConfigFlowResult: """Handle zeroconf discovery.""" + _LOGGER.debug("Android TV device found via zeroconf: %s", discovery_info) self.host = discovery_info.host self.name = discovery_info.name.removesuffix("._androidtvremote2._tcp.local.") self.mac = discovery_info.properties.get("bt") @@ -148,6 +152,7 @@ class AndroidTVRemoteConfigFlow(ConfigFlow, domain=DOMAIN): self._abort_if_unique_id_configured( updates={CONF_HOST: self.host, CONF_NAME: self.name} ) + _LOGGER.debug("New Android TV device found via zeroconf: %s", self.name) self.context.update({"title_placeholders": {CONF_NAME: self.name}}) return await self.async_step_zeroconf_confirm()