mirror of
https://github.com/home-assistant/core.git
synced 2025-07-20 19:57:07 +00:00
Enforce MediaPlayerState in denonavr media player (#82847)
This commit is contained in:
parent
afe01c2434
commit
7a1907e540
@ -8,7 +8,7 @@ import logging
|
|||||||
from typing import Any, TypeVar
|
from typing import Any, TypeVar
|
||||||
|
|
||||||
from denonavr import DenonAVR
|
from denonavr import DenonAVR
|
||||||
from denonavr.const import POWER_ON
|
from denonavr.const import POWER_ON, STATE_OFF, STATE_ON, STATE_PAUSED, STATE_PLAYING
|
||||||
from denonavr.exceptions import (
|
from denonavr.exceptions import (
|
||||||
AvrCommandError,
|
AvrCommandError,
|
||||||
AvrForbiddenError,
|
AvrForbiddenError,
|
||||||
@ -78,6 +78,14 @@ _R = TypeVar("_R")
|
|||||||
_P = ParamSpec("_P")
|
_P = ParamSpec("_P")
|
||||||
|
|
||||||
|
|
||||||
|
DENON_STATE_MAPPING = {
|
||||||
|
STATE_ON: MediaPlayerState.ON,
|
||||||
|
STATE_OFF: MediaPlayerState.OFF,
|
||||||
|
STATE_PLAYING: MediaPlayerState.PLAYING,
|
||||||
|
STATE_PAUSED: MediaPlayerState.PAUSED,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
config_entry: ConfigEntry,
|
config_entry: ConfigEntry,
|
||||||
@ -243,9 +251,9 @@ class DenonDevice(MediaPlayerEntity):
|
|||||||
await self._receiver.async_update_audyssey()
|
await self._receiver.async_update_audyssey()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def state(self):
|
def state(self) -> MediaPlayerState | None:
|
||||||
"""Return the state of the device."""
|
"""Return the state of the device."""
|
||||||
return self._receiver.state
|
return DENON_STATE_MAPPING.get(self._receiver.state)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def source_list(self):
|
def source_list(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user