From 4b162f09bd0177a5c40deafa5e2546759dcab21a Mon Sep 17 00:00:00 2001 From: tronikos Date: Thu, 3 Jul 2025 11:15:47 -0700 Subject: [PATCH] Bump androidtvremote2 to 0.2.3 (#148042) --- .../components/androidtv_remote/manifest.json | 2 +- .../androidtv_remote/media_player.py | 18 +++++++++--------- .../components/androidtv_remote/remote.py | 3 ++- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- 5 files changed, 14 insertions(+), 13 deletions(-) diff --git a/homeassistant/components/androidtv_remote/manifest.json b/homeassistant/components/androidtv_remote/manifest.json index 7896f7eefc8..9f41d8230c6 100644 --- a/homeassistant/components/androidtv_remote/manifest.json +++ b/homeassistant/components/androidtv_remote/manifest.json @@ -7,6 +7,6 @@ "integration_type": "device", "iot_class": "local_push", "loggers": ["androidtvremote2"], - "requirements": ["androidtvremote2==0.2.2"], + "requirements": ["androidtvremote2==0.2.3"], "zeroconf": ["_androidtvremote2._tcp.local."] } diff --git a/homeassistant/components/androidtv_remote/media_player.py b/homeassistant/components/androidtv_remote/media_player.py index ac1c62e0826..e4f653cbcf1 100644 --- a/homeassistant/components/androidtv_remote/media_player.py +++ b/homeassistant/components/androidtv_remote/media_player.py @@ -5,7 +5,7 @@ from __future__ import annotations import asyncio from typing import Any -from androidtvremote2 import AndroidTVRemote, ConnectionClosed +from androidtvremote2 import AndroidTVRemote, ConnectionClosed, VolumeInfo from homeassistant.components.media_player import ( BrowseMedia, @@ -75,13 +75,11 @@ class AndroidTVRemoteMediaPlayerEntity(AndroidTVRemoteBaseEntity, MediaPlayerEnt else current_app ) - def _update_volume_info(self, volume_info: dict[str, str | bool]) -> None: + def _update_volume_info(self, volume_info: VolumeInfo) -> None: """Update volume info.""" if volume_info.get("max"): - self._attr_volume_level = int(volume_info["level"]) / int( - volume_info["max"] - ) - self._attr_is_volume_muted = bool(volume_info["muted"]) + self._attr_volume_level = volume_info["level"] / volume_info["max"] + self._attr_is_volume_muted = volume_info["muted"] else: self._attr_volume_level = None self._attr_is_volume_muted = None @@ -93,7 +91,7 @@ class AndroidTVRemoteMediaPlayerEntity(AndroidTVRemoteBaseEntity, MediaPlayerEnt self.async_write_ha_state() @callback - def _volume_info_updated(self, volume_info: dict[str, str | bool]) -> None: + def _volume_info_updated(self, volume_info: VolumeInfo) -> None: """Update the state when the volume info changes.""" self._update_volume_info(volume_info) self.async_write_ha_state() @@ -102,8 +100,10 @@ class AndroidTVRemoteMediaPlayerEntity(AndroidTVRemoteBaseEntity, MediaPlayerEnt """Register callbacks.""" await super().async_added_to_hass() - self._update_current_app(self._api.current_app) - self._update_volume_info(self._api.volume_info) + if self._api.current_app is not None: + self._update_current_app(self._api.current_app) + if self._api.volume_info is not None: + self._update_volume_info(self._api.volume_info) self._api.add_current_app_updated_callback(self._current_app_updated) self._api.add_volume_info_updated_callback(self._volume_info_updated) diff --git a/homeassistant/components/androidtv_remote/remote.py b/homeassistant/components/androidtv_remote/remote.py index 40220834e53..612d27de189 100644 --- a/homeassistant/components/androidtv_remote/remote.py +++ b/homeassistant/components/androidtv_remote/remote.py @@ -63,7 +63,8 @@ class AndroidTVRemoteEntity(AndroidTVRemoteBaseEntity, RemoteEntity): self._attr_activity_list = [ app.get(CONF_APP_NAME, "") for app in self._apps.values() ] - self._update_current_app(self._api.current_app) + if self._api.current_app is not None: + self._update_current_app(self._api.current_app) self._api.add_current_app_updated_callback(self._current_app_updated) async def async_will_remove_from_hass(self) -> None: diff --git a/requirements_all.txt b/requirements_all.txt index e0fbd3ccdc6..f80bb901946 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -477,7 +477,7 @@ amcrest==1.9.8 androidtv[async]==0.0.75 # homeassistant.components.androidtv_remote -androidtvremote2==0.2.2 +androidtvremote2==0.2.3 # homeassistant.components.anel_pwrctrl anel-pwrctrl-homeassistant==0.0.1.dev2 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 7d16f98d736..0211c9803c9 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -453,7 +453,7 @@ amberelectric==2.0.12 androidtv[async]==0.0.75 # homeassistant.components.androidtv_remote -androidtvremote2==0.2.2 +androidtvremote2==0.2.3 # homeassistant.components.anova anova-wifi==0.17.0