diff --git a/homeassistant/components/enigma2/media_player.py b/homeassistant/components/enigma2/media_player.py index 598ab1afffecbe..aa1b5270557dfa 100644 --- a/homeassistant/components/enigma2/media_player.py +++ b/homeassistant/components/enigma2/media_player.py @@ -1,6 +1,7 @@ """Support for Enigma2 media players.""" from __future__ import annotations +from aiohttp.client_exceptions import ClientConnectorError from openwebif.api import OpenWebIfDevice from openwebif.enums import RemoteControlCodes, SetVolumeOption import voluptuous as vol @@ -20,6 +21,7 @@ CONF_USERNAME, ) from homeassistant.core import HomeAssistant +from homeassistant.exceptions import PlatformNotReady import homeassistant.helpers.config_validation as cv from homeassistant.helpers.config_validation import PLATFORM_SCHEMA from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -96,9 +98,13 @@ async def async_setup_platform( source_bouquet=config.get(CONF_SOURCE_BOUQUET), ) - async_add_entities( - [Enigma2Device(config[CONF_NAME], device, await device.get_about())] - ) + try: + about = await device.get_about() + except ClientConnectorError as err: + await device.close() + raise PlatformNotReady from err + + async_add_entities([Enigma2Device(config[CONF_NAME], device, about)]) class Enigma2Device(MediaPlayerEntity): @@ -165,8 +171,8 @@ async def async_media_next_track(self) -> None: await self._device.send_remote_control_action(RemoteControlCodes.CHANNEL_UP) async def async_media_previous_track(self) -> None: - """Send next track command.""" - self._device.send_remote_control_action(RemoteControlCodes.CHANNEL_DOWN) + """Send previous track command.""" + await self._device.send_remote_control_action(RemoteControlCodes.CHANNEL_DOWN) async def async_mute_volume(self, mute: bool) -> None: """Mute or unmute."""