refactor: centralize ADB host/key resolution in helpers.py; drop the three duplicated resolvers
This commit is contained in:
1 parent
d3afda0a25
commit
6b4227cb40
4 files changed
+80
-74
No files matched your search
@@ -24,6 +24,7 @@ from .const import (
|
||||
DEFAULT_NAME,
|
||||
DOMAIN,
|
||||
)
|
||||
from .helpers import discover_adb_host
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@@ -187,23 +188,9 @@ class NvidiaShieldConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
def _resolve_adb_host(self) -> str | None:
|
||||
"""Resolve ADB host from explicit config or the Android TV entity."""
|
||||
host = self._user_data.get(CONF_ADB_HOST)
|
||||
if host:
|
||||
return host
|
||||
|
||||
atv_entity = self._user_data.get(CONF_ANDROIDTV_ENTITY)
|
||||
if not atv_entity:
|
||||
return None
|
||||
|
||||
registry = er.async_get(self.hass)
|
||||
entity_entry = registry.async_get(atv_entity)
|
||||
if not entity_entry or not entity_entry.config_entry_id:
|
||||
return None
|
||||
|
||||
config_entry = self.hass.config_entries.async_get_entry(entity_entry.config_entry_id)
|
||||
if config_entry:
|
||||
return config_entry.data.get("host")
|
||||
return None
|
||||
return self._user_data.get(CONF_ADB_HOST) or discover_adb_host(
|
||||
self.hass, self._user_data.get(CONF_ANDROIDTV_ENTITY)
|
||||
)
|
||||
|
||||
async def async_step_adb_pair(self, user_input=None):
|
||||
"""Step 2: ADB pairing. User clicks Submit after approving on the Shield."""
|
||||
|
||||
Reference in new issue
Block a user