From 0df30782a623204be2941da74ddee5bb110dd03b Mon Sep 17 00:00:00 2001 From: Jeff Irion Date: Wed, 13 Apr 2022 00:38:07 -0700 Subject: [PATCH] Bump androidtv to 0.0.67 (improve connect attempt logging) (#69721) --- .../components/androidtv/manifest.json | 2 +- .../components/androidtv/media_player.py | 19 +++++++++++++++---- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/homeassistant/components/androidtv/manifest.json b/homeassistant/components/androidtv/manifest.json index 729cac082c7..7bddd13c833 100644 --- a/homeassistant/components/androidtv/manifest.json +++ b/homeassistant/components/androidtv/manifest.json @@ -4,7 +4,7 @@ "documentation": "https://www.home-assistant.io/integrations/androidtv", "requirements": [ "adb-shell[async]==0.4.2", - "androidtv[async]==0.0.66", + "androidtv[async]==0.0.67", "pure-python-adb[async]==0.3.0.dev0" ], "codeowners": ["@JeffLIrion", "@ollo69"], diff --git a/homeassistant/components/androidtv/media_player.py b/homeassistant/components/androidtv/media_player.py index b532845ea9d..f0e20620a65 100644 --- a/homeassistant/components/androidtv/media_player.py +++ b/homeassistant/components/androidtv/media_player.py @@ -251,6 +251,9 @@ class ADBDevice(MediaPlayerEntity): ATTR_HDMI_INPUT: None, } + # The number of consecutive failed connect attempts + self._failed_connect_count = 0 + def _process_config(self): """Load the config options.""" _LOGGER.debug("Loading configuration options") @@ -450,9 +453,13 @@ class AndroidTVDevice(ADBDevice): async def async_update(self): """Update the device state and, if necessary, re-connect.""" # Check if device is disconnected. - if not self.available: + if not self._attr_available: # Try to connect - self._attr_available = await self.aftv.adb_connect(always_log_errors=False) + if await self.aftv.adb_connect(log_errors=self._failed_connect_count == 0): + self._failed_connect_count = 0 + self._attr_available = True + else: + self._failed_connect_count += 1 # If the ADB connection is not intact, don't update. if not self.available: @@ -535,9 +542,13 @@ class FireTVDevice(ADBDevice): async def async_update(self): """Update the device state and, if necessary, re-connect.""" # Check if device is disconnected. - if not self.available: + if not self._attr_available: # Try to connect - self._attr_available = await self.aftv.adb_connect(always_log_errors=False) + if await self.aftv.adb_connect(log_errors=self._failed_connect_count == 0): + self._failed_connect_count = 0 + self._attr_available = True + else: + self._failed_connect_count += 1 # If the ADB connection is not intact, don't update. if not self.available: diff --git a/requirements_all.txt b/requirements_all.txt index 4156f8eaf1b..1b9dea8d17e 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -292,7 +292,7 @@ ambiclimate==0.2.1 amcrest==1.9.7 # homeassistant.components.androidtv -androidtv[async]==0.0.66 +androidtv[async]==0.0.67 # homeassistant.components.anel_pwrctrl anel_pwrctrl-homeassistant==0.0.1.dev2 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 61dbfb3c825..33259ce001e 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -249,7 +249,7 @@ amberelectric==1.0.4 ambiclimate==0.2.1 # homeassistant.components.androidtv -androidtv[async]==0.0.66 +androidtv[async]==0.0.67 # homeassistant.components.apprise apprise==0.9.7