Add Android TV Remote debug logs to help with zeroconf issue (#117960)

This commit is contained in:
tronikos 2024-05-29 06:50:13 -07:00 committed by GitHub
parent 9e342a61f3
commit 3d15e15e59
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 2 deletions

View File

@ -30,6 +30,7 @@ async def async_setup_entry(
hass: HomeAssistant, entry: AndroidTVRemoteConfigEntry hass: HomeAssistant, entry: AndroidTVRemoteConfigEntry
) -> bool: ) -> bool:
"""Set up Android TV Remote from a config entry.""" """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)) api = create_api(hass, entry.data[CONF_HOST], get_enable_ime(entry))
@callback @callback
@ -79,7 +80,7 @@ async def async_setup_entry(
entry.async_on_unload( entry.async_on_unload(
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, on_hass_stop) 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) entry.async_on_unload(api.disconnect)
return True return True
@ -87,9 +88,13 @@ async def async_setup_entry(
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry.""" """Unload a config entry."""
_LOGGER.debug("async_unload_entry: %s", entry.data)
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS) 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.""" """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) await hass.config_entries.async_reload(entry.entry_id)

View File

@ -3,6 +3,7 @@
from __future__ import annotations from __future__ import annotations
from collections.abc import Mapping from collections.abc import Mapping
import logging
from typing import Any from typing import Any
from androidtvremote2 import ( from androidtvremote2 import (
@ -27,6 +28,8 @@ from homeassistant.helpers.device_registry import format_mac
from .const import CONF_ENABLE_IME, DOMAIN from .const import CONF_ENABLE_IME, DOMAIN
from .helpers import create_api, get_enable_ime from .helpers import create_api, get_enable_ime
_LOGGER = logging.getLogger(__name__)
STEP_USER_DATA_SCHEMA = vol.Schema( STEP_USER_DATA_SCHEMA = vol.Schema(
{ {
vol.Required("host"): str, vol.Required("host"): str,
@ -139,6 +142,7 @@ class AndroidTVRemoteConfigFlow(ConfigFlow, domain=DOMAIN):
self, discovery_info: zeroconf.ZeroconfServiceInfo self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> ConfigFlowResult: ) -> ConfigFlowResult:
"""Handle zeroconf discovery.""" """Handle zeroconf discovery."""
_LOGGER.debug("Android TV device found via zeroconf: %s", discovery_info)
self.host = discovery_info.host self.host = discovery_info.host
self.name = discovery_info.name.removesuffix("._androidtvremote2._tcp.local.") self.name = discovery_info.name.removesuffix("._androidtvremote2._tcp.local.")
self.mac = discovery_info.properties.get("bt") self.mac = discovery_info.properties.get("bt")
@ -148,6 +152,7 @@ class AndroidTVRemoteConfigFlow(ConfigFlow, domain=DOMAIN):
self._abort_if_unique_id_configured( self._abort_if_unique_id_configured(
updates={CONF_HOST: self.host, CONF_NAME: self.name} 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}}) self.context.update({"title_placeholders": {CONF_NAME: self.name}})
return await self.async_step_zeroconf_confirm() return await self.async_step_zeroconf_confirm()