Skip to content

Commit

Permalink
enigma2: fix exception when device in deep sleep, fix previous track (#…
Browse files Browse the repository at this point in the history
…107296)

enigma2: fix exception when device in deep sleep; previous track
  • Loading branch information
autinerd committed Jan 6, 2024
1 parent a03ac3d commit 9b1a8a1
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions homeassistant/components/enigma2/media_player.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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."""
Expand Down

0 comments on commit 9b1a8a1

Please sign in to comment.