From 361b39c4c3e6dff87207555eaf8b76be27994504 Mon Sep 17 00:00:00 2001 From: dcmeglio <21957250+dcmeglio@users.noreply.github.com> Date: Tue, 14 Feb 2023 20:20:55 -0500 Subject: [PATCH] Move denonavr state update callbacks to async_added_to_hass (#88147) Move state update callbacks to async_added_to_hass. --- homeassistant/components/denonavr/config_flow.py | 1 - homeassistant/components/denonavr/media_player.py | 6 ++++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/denonavr/config_flow.py b/homeassistant/components/denonavr/config_flow.py index 2a6669f5606..e93fba09a9d 100644 --- a/homeassistant/components/denonavr/config_flow.py +++ b/homeassistant/components/denonavr/config_flow.py @@ -106,7 +106,6 @@ class DenonAvrFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): self.show_all_sources = DEFAULT_SHOW_SOURCES self.zone2 = DEFAULT_ZONE2 self.zone3 = DEFAULT_ZONE3 - self.use_telnet = DEFAULT_USE_TELNET_NEW_INSTALL self.d_receivers: list[dict[str, Any]] = [] @staticmethod diff --git a/homeassistant/components/denonavr/media_player.py b/homeassistant/components/denonavr/media_player.py index 1d153077cdf..5e636c5cfae 100644 --- a/homeassistant/components/denonavr/media_player.py +++ b/homeassistant/components/denonavr/media_player.py @@ -247,8 +247,6 @@ class DenonDevice(MediaPlayerEntity): and MediaPlayerEntityFeature.SELECT_SOUND_MODE ) - self._receiver.register_callback("ALL", self._telnet_callback) - self._telnet_was_healthy: bool | None = None async def _telnet_callback(self, zone, event, parameter): @@ -258,6 +256,10 @@ class DenonDevice(MediaPlayerEntity): self.async_write_ha_state() + async def async_added_to_hass(self) -> None: + """Register for telnet events.""" + self._receiver.register_callback("ALL", self._telnet_callback) + async def async_will_remove_from_hass(self) -> None: """Clean up the entity.""" self._receiver.unregister_callback("ALL", self._telnet_callback)