Bump androidtvremote2 to 0.2.3 (#148042)

This commit is contained in:
tronikos 2025-07-03 11:15:47 -07:00 committed by GitHub
parent 9c558fabcd
commit 4b162f09bd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 14 additions and 13 deletions

View File

@ -7,6 +7,6 @@
"integration_type": "device", "integration_type": "device",
"iot_class": "local_push", "iot_class": "local_push",
"loggers": ["androidtvremote2"], "loggers": ["androidtvremote2"],
"requirements": ["androidtvremote2==0.2.2"], "requirements": ["androidtvremote2==0.2.3"],
"zeroconf": ["_androidtvremote2._tcp.local."] "zeroconf": ["_androidtvremote2._tcp.local."]
} }

View File

@ -5,7 +5,7 @@ from __future__ import annotations
import asyncio import asyncio
from typing import Any from typing import Any
from androidtvremote2 import AndroidTVRemote, ConnectionClosed from androidtvremote2 import AndroidTVRemote, ConnectionClosed, VolumeInfo
from homeassistant.components.media_player import ( from homeassistant.components.media_player import (
BrowseMedia, BrowseMedia,
@ -75,13 +75,11 @@ class AndroidTVRemoteMediaPlayerEntity(AndroidTVRemoteBaseEntity, MediaPlayerEnt
else current_app 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.""" """Update volume info."""
if volume_info.get("max"): if volume_info.get("max"):
self._attr_volume_level = int(volume_info["level"]) / int( self._attr_volume_level = volume_info["level"] / volume_info["max"]
volume_info["max"] self._attr_is_volume_muted = volume_info["muted"]
)
self._attr_is_volume_muted = bool(volume_info["muted"])
else: else:
self._attr_volume_level = None self._attr_volume_level = None
self._attr_is_volume_muted = None self._attr_is_volume_muted = None
@ -93,7 +91,7 @@ class AndroidTVRemoteMediaPlayerEntity(AndroidTVRemoteBaseEntity, MediaPlayerEnt
self.async_write_ha_state() self.async_write_ha_state()
@callback @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.""" """Update the state when the volume info changes."""
self._update_volume_info(volume_info) self._update_volume_info(volume_info)
self.async_write_ha_state() self.async_write_ha_state()
@ -102,8 +100,10 @@ class AndroidTVRemoteMediaPlayerEntity(AndroidTVRemoteBaseEntity, MediaPlayerEnt
"""Register callbacks.""" """Register callbacks."""
await super().async_added_to_hass() await super().async_added_to_hass()
self._update_current_app(self._api.current_app) if self._api.current_app is not None:
self._update_volume_info(self._api.volume_info) 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_current_app_updated_callback(self._current_app_updated)
self._api.add_volume_info_updated_callback(self._volume_info_updated) self._api.add_volume_info_updated_callback(self._volume_info_updated)

View File

@ -63,7 +63,8 @@ class AndroidTVRemoteEntity(AndroidTVRemoteBaseEntity, RemoteEntity):
self._attr_activity_list = [ self._attr_activity_list = [
app.get(CONF_APP_NAME, "") for app in self._apps.values() 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) self._api.add_current_app_updated_callback(self._current_app_updated)
async def async_will_remove_from_hass(self) -> None: async def async_will_remove_from_hass(self) -> None:

2
requirements_all.txt generated
View File

@ -477,7 +477,7 @@ amcrest==1.9.8
androidtv[async]==0.0.75 androidtv[async]==0.0.75
# homeassistant.components.androidtv_remote # homeassistant.components.androidtv_remote
androidtvremote2==0.2.2 androidtvremote2==0.2.3
# homeassistant.components.anel_pwrctrl # homeassistant.components.anel_pwrctrl
anel-pwrctrl-homeassistant==0.0.1.dev2 anel-pwrctrl-homeassistant==0.0.1.dev2

View File

@ -453,7 +453,7 @@ amberelectric==2.0.12
androidtv[async]==0.0.75 androidtv[async]==0.0.75
# homeassistant.components.androidtv_remote # homeassistant.components.androidtv_remote
androidtvremote2==0.2.2 androidtvremote2==0.2.3
# homeassistant.components.anova # homeassistant.components.anova
anova-wifi==0.17.0 anova-wifi==0.17.0