1
mirror of https://github.com/home-assistant/core synced 2024-07-15 09:42:11 +02:00

enigma2: fix exception when device in deep sleep, fix previous track (#107296)

enigma2: fix exception when device in deep sleep; previous track
This commit is contained in:
Sid 2024-01-06 11:18:32 +01:00 committed by GitHub
parent a03ac3ddcd
commit 9b1a8a1129
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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 @@ from homeassistant.const import (
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 @@ class Enigma2Device(MediaPlayerEntity):
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."""