Add load_media_failed callback to cast MediaStatusListener (#70048)
This commit is contained in:
parent
ce302f4540
commit
c7c011d772
5 changed files with 34 additions and 12 deletions
|
@ -10,6 +10,7 @@ from urllib.parse import urlparse
|
|||
|
||||
import aiohttp
|
||||
import attr
|
||||
import pychromecast
|
||||
from pychromecast import dial
|
||||
from pychromecast.const import CAST_TYPE_GROUP
|
||||
from pychromecast.models import CastInfo
|
||||
|
@ -98,7 +99,12 @@ class ChromeCastZeroconf:
|
|||
return cls.__zconf
|
||||
|
||||
|
||||
class CastStatusListener:
|
||||
class CastStatusListener(
|
||||
pychromecast.controllers.media.MediaStatusListener,
|
||||
pychromecast.controllers.multizone.MultiZoneManagerListener,
|
||||
pychromecast.controllers.receiver.CastStatusListener,
|
||||
pychromecast.socket_client.ConnectionStatusListener,
|
||||
):
|
||||
"""Helper class to handle pychromecast status callbacks.
|
||||
|
||||
Necessary because a CastDevice entity or dynamic group can create a new
|
||||
|
@ -124,23 +130,27 @@ class CastStatusListener:
|
|||
if not cast_device._cast_info.is_audio_group:
|
||||
self._mz_mgr.register_listener(chromecast.uuid, self)
|
||||
|
||||
def new_cast_status(self, cast_status):
|
||||
def new_cast_status(self, status):
|
||||
"""Handle reception of a new CastStatus."""
|
||||
if self._valid:
|
||||
self._cast_device.new_cast_status(cast_status)
|
||||
self._cast_device.new_cast_status(status)
|
||||
|
||||
def new_media_status(self, media_status):
|
||||
def new_media_status(self, status):
|
||||
"""Handle reception of a new MediaStatus."""
|
||||
if self._valid:
|
||||
self._cast_device.new_media_status(media_status)
|
||||
self._cast_device.new_media_status(status)
|
||||
|
||||
def new_connection_status(self, connection_status):
|
||||
def load_media_failed(self, item, error_code):
|
||||
"""Handle reception of a new MediaStatus."""
|
||||
if self._valid:
|
||||
self._cast_device.load_media_failed(item, error_code)
|
||||
|
||||
def new_connection_status(self, status):
|
||||
"""Handle reception of a new ConnectionStatus."""
|
||||
if self._valid:
|
||||
self._cast_device.new_connection_status(connection_status)
|
||||
self._cast_device.new_connection_status(status)
|
||||
|
||||
@staticmethod
|
||||
def added_to_multizone(group_uuid):
|
||||
def added_to_multizone(self, group_uuid):
|
||||
"""Handle the cast added to a group."""
|
||||
|
||||
def removed_from_multizone(self, group_uuid):
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"name": "Google Cast",
|
||||
"config_flow": true,
|
||||
"documentation": "https://www.home-assistant.io/integrations/cast",
|
||||
"requirements": ["pychromecast==11.0.0"],
|
||||
"requirements": ["pychromecast==12.0.0"],
|
||||
"after_dependencies": [
|
||||
"cloud",
|
||||
"http",
|
||||
|
|
|
@ -10,6 +10,7 @@ import logging
|
|||
|
||||
import pychromecast
|
||||
from pychromecast.controllers.homeassistant import HomeAssistantController
|
||||
from pychromecast.controllers.media import MEDIA_PLAYER_ERROR_CODES
|
||||
from pychromecast.controllers.multizone import MultizoneManager
|
||||
from pychromecast.controllers.receiver import VOLUME_CONTROL_TYPE_FIXED
|
||||
from pychromecast.quick_play import quick_play
|
||||
|
@ -390,6 +391,17 @@ class CastMediaPlayerEntity(CastDevice, MediaPlayerEntity):
|
|||
self.media_status_received = dt_util.utcnow()
|
||||
self.schedule_update_ha_state()
|
||||
|
||||
def load_media_failed(self, item, error_code):
|
||||
"""Handle load media failed."""
|
||||
_LOGGER.debug(
|
||||
"[%s %s] Load media failed with code %s(%s) for item %s",
|
||||
self.entity_id,
|
||||
self._cast_info.friendly_name,
|
||||
error_code,
|
||||
MEDIA_PLAYER_ERROR_CODES.get(error_code, "unknown code"),
|
||||
item,
|
||||
)
|
||||
|
||||
def new_connection_status(self, connection_status):
|
||||
"""Handle updates of connection status."""
|
||||
_LOGGER.debug(
|
||||
|
|
|
@ -1390,7 +1390,7 @@ pycfdns==1.2.2
|
|||
pychannels==1.0.0
|
||||
|
||||
# homeassistant.components.cast
|
||||
pychromecast==11.0.0
|
||||
pychromecast==12.0.0
|
||||
|
||||
# homeassistant.components.pocketcasts
|
||||
pycketcasts==1.0.0
|
||||
|
|
|
@ -929,7 +929,7 @@ pybotvac==0.0.23
|
|||
pycfdns==1.2.2
|
||||
|
||||
# homeassistant.components.cast
|
||||
pychromecast==11.0.0
|
||||
pychromecast==12.0.0
|
||||
|
||||
# homeassistant.components.climacell
|
||||
pyclimacell==0.18.2
|
||||
|
|
Loading…
Add table
Reference in a new issue