refactor(config): drop the androidtv media_player entity path end-to-end (t41)

The user ruling: this integration REPLACES both old integrations, so nothing may
depend on an androidtv/androidtv_remote entity anymore.

Removed:
* the setup-form field + its entity selector (CONF_ANDROIDTV_ENTITY is no longer
  offered, only read by the migration that drops it);
* the entity-derived unique_id derivation (_unique_id_from_atv_device, t29 G2)
  and, with it, every registry lookup for another integration's devices — the
  user step now sets NO unique_id at all; the protocol MAC learned during
  pairing is the identity;
* the Jellyfin auto-detect's second tier (the atv entity's friendly_name) — it
  now uses the entry name the user typed or the device name from discovery;
* the app-name and app-id tiers (media_player.app_name/app_id + the shared
  resolve_app_name chain, the Current App sensor, the sensor's state-change
  listener and its `_androidtv_state` helper) — the manager's store is the only
  source;
* the "transitional external entity" command tier in every path: `_cmd` and the
  pan-media_player service call are gone, and so is the fallback in _media_cmd,
  _remote_key_cmd, the §7 channel-digit sequence and the intent self-heal retry
  (an intent no transport served now surrenders to the truth instead of
  delegating);
* the entity-derived power signal (`_on_source_change`'s "device off clears the
  intent" check no longer watches another integration's entity; the power
  LADDER — protocol is_on → ADB wake → power switch — is unchanged).

turn_on/turn_off are native now: they send the protocol POWER key and, like the
remote entity, send nothing when the known state already matches (no superfluous
toggle). An ADB-only entry (protocol skipped) has no power write path — the
manager owns the socket and exposes no device-keyevent, which is what the old
delegation used to cover.

helpers.discover_adb_host — the one helper that derived a host from another
integration's config entry — is deleted; button.py (granted to this task) reads
the entry's own address fields instead of the entity, so the Pair ADB button
keeps working.

Present-day entries that still carry the key are unaffected (nothing reads it);
the v3 migration that drops it lands with the host unification.

Verified: 309 passed / 2 skipped, 310 / 1 with androidtvremote2, ruff clean,
drift engine exit 0 on HEAD (13 modules, 58 imports, 35 call arguments, 6
awaited HA calls) and 16 passed in the real-HA drift suite. The stub harness's
legacy service recorder became a watchdog: any HA service call from the media
player now fails the routing tests instead of being the expected outcome.
This commit is contained in:
James Mackay committed 2026-10-11 06:09:43 +01:00
1 parent 60d884b76a
commit 86aa2827a2
9 files changed
+247 -351

No files matched your search

+3 -11
View File
@@ -578,7 +578,7 @@ class TestDiscoveryPrefill:
await flow.async_step_zeroconf(_discovery())
result = await flow.async_step_user(
_user_input(**{CONF_ANDROIDTV_ENTITY: "", CONF_ADB_ENABLED: False})
_user_input(**{CONF_ADB_ENABLED: False})
)
assert result["errors"] == {"base": "no_state_source"}
@@ -630,7 +630,6 @@ class TestNoDeadEndPairing:
form = await flow.async_step_user(
_user_input(
**{
CONF_ANDROIDTV_ENTITY: "",
CONF_PROTOCOL_ENABLED: True,
CONF_PROTOCOL_HOST: DISCOVERED_HOST,
}
@@ -662,7 +661,6 @@ class TestNoDeadEndPairing:
form = await flow.async_step_user(
_user_input(
**{
CONF_ANDROIDTV_ENTITY: "",
CONF_ADB_ENABLED: True,
CONF_ADB_HOST: DISCOVERED_HOST,
}
@@ -695,7 +693,6 @@ class TestNoDeadEndPairing:
form = await flow.async_step_user(
_user_input(
**{
CONF_ANDROIDTV_ENTITY: "",
CONF_ADB_ENABLED: True,
CONF_PROTOCOL_ENABLED: True,
CONF_ADB_HOST: DISCOVERED_HOST,
@@ -718,7 +715,6 @@ class TestNoDeadEndPairing:
await flow.async_step_user(
_user_input(
**{
CONF_ANDROIDTV_ENTITY: "",
CONF_ADB_ENABLED: True,
CONF_PROTOCOL_ENABLED: True,
CONF_ADB_HOST: DISCOVERED_HOST,
@@ -742,7 +738,6 @@ class TestNoDeadEndPairing:
form = await flow.async_step_user(
_user_input(
**{
CONF_ANDROIDTV_ENTITY: "",
CONF_PROTOCOL_ENABLED: True,
CONF_PROTOCOL_HOST: DISCOVERED_HOST,
}
@@ -767,7 +762,6 @@ class TestNoDeadEndPairing:
form = await flow.async_step_user(
_user_input(
**{
CONF_ANDROIDTV_ENTITY: "",
CONF_ADB_ENABLED: True,
CONF_ADB_HOST: DISCOVERED_HOST,
}
@@ -787,7 +781,7 @@ class TestNoDeadEndPairing:
test_connect = _patch_adb(monkeypatch, module)
flow, _hass = _new_flow(module, tmp_path)
await flow.async_step_user(
_user_input(**{CONF_ANDROIDTV_ENTITY: "", CONF_ADB_ENABLED: True})
_user_input(**{CONF_ADB_ENABLED: True})
)
result = await flow.async_step_adb_pair(
@@ -806,7 +800,6 @@ class TestNoDeadEndPairing:
await flow.async_step_user(
_user_input(
**{
CONF_ANDROIDTV_ENTITY: "",
CONF_PROTOCOL_ENABLED: True,
CONF_PROTOCOL_HOST: DISCOVERED_HOST,
}
@@ -835,7 +828,7 @@ class TestNoDeadEndPairing:
_patch_adb(monkeypatch, module, connected=False)
flow, _hass = _new_flow(module, tmp_path)
await flow.async_step_user(
_user_input(**{CONF_ANDROIDTV_ENTITY: "", CONF_ADB_ENABLED: True})
_user_input(**{CONF_ADB_ENABLED: True})
)
result = await flow.async_step_adb_pair({CONF_ADB_PORT: 5555})
@@ -850,7 +843,6 @@ class TestNoDeadEndPairing:
await flow.async_step_user(
_user_input(
**{
CONF_ANDROIDTV_ENTITY: "",
CONF_ADB_ENABLED: True,
CONF_ADB_HOST: DISCOVERED_HOST,
}