enigma2: fix exception when device in deep sleep, fix previous track (#107296)
enigma2: fix exception when device in deep sleep; previous trackpull/107388/head
parent
a03ac3ddcd
commit
9b1a8a1129
|
@ -1,6 +1,7 @@
|
||||||
"""Support for Enigma2 media players."""
|
"""Support for Enigma2 media players."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from aiohttp.client_exceptions import ClientConnectorError
|
||||||
from openwebif.api import OpenWebIfDevice
|
from openwebif.api import OpenWebIfDevice
|
||||||
from openwebif.enums import RemoteControlCodes, SetVolumeOption
|
from openwebif.enums import RemoteControlCodes, SetVolumeOption
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
@ -20,6 +21,7 @@ from homeassistant.const import (
|
||||||
CONF_USERNAME,
|
CONF_USERNAME,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.exceptions import PlatformNotReady
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.config_validation import PLATFORM_SCHEMA
|
from homeassistant.helpers.config_validation import PLATFORM_SCHEMA
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
@ -96,9 +98,13 @@ async def async_setup_platform(
|
||||||
source_bouquet=config.get(CONF_SOURCE_BOUQUET),
|
source_bouquet=config.get(CONF_SOURCE_BOUQUET),
|
||||||
)
|
)
|
||||||
|
|
||||||
async_add_entities(
|
try:
|
||||||
[Enigma2Device(config[CONF_NAME], device, await device.get_about())]
|
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):
|
class Enigma2Device(MediaPlayerEntity):
|
||||||
|
@ -165,8 +171,8 @@ class Enigma2Device(MediaPlayerEntity):
|
||||||
await self._device.send_remote_control_action(RemoteControlCodes.CHANNEL_UP)
|
await self._device.send_remote_control_action(RemoteControlCodes.CHANNEL_UP)
|
||||||
|
|
||||||
async def async_media_previous_track(self) -> None:
|
async def async_media_previous_track(self) -> None:
|
||||||
"""Send next track command."""
|
"""Send previous track command."""
|
||||||
self._device.send_remote_control_action(RemoteControlCodes.CHANNEL_DOWN)
|
await self._device.send_remote_control_action(RemoteControlCodes.CHANNEL_DOWN)
|
||||||
|
|
||||||
async def async_mute_volume(self, mute: bool) -> None:
|
async def async_mute_volume(self, mute: bool) -> None:
|
||||||
"""Mute or unmute."""
|
"""Mute or unmute."""
|
||||||
|
|
Loading…
Reference in New Issue