Fix Yamaha MusicCast zone sleep select entity (#87041)
parent
ee30f5afcc
commit
5b728a41de
|
@ -55,12 +55,3 @@ TRANSLATION_KEY_MAPPING = {
|
|||
"zone_LINK_CONTROL": "zone_link_control",
|
||||
"zone_LINK_AUDIO_DELAY": "zone_link_audio_delay",
|
||||
}
|
||||
|
||||
ZONE_SLEEP_STATE_MAPPING = {
|
||||
"off": "off",
|
||||
"30 min": "30_min",
|
||||
"60 min": "60_min",
|
||||
"90 min": "90_min",
|
||||
"120 min": "120_min",
|
||||
}
|
||||
STATE_ZONE_SLEEP_MAPPING = {val: key for key, val in ZONE_SLEEP_STATE_MAPPING.items()}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"name": "MusicCast",
|
||||
"config_flow": true,
|
||||
"documentation": "https://www.home-assistant.io/integrations/yamaha_musiccast",
|
||||
"requirements": ["aiomusiccast==0.14.4"],
|
||||
"requirements": ["aiomusiccast==0.14.7"],
|
||||
"ssdp": [
|
||||
{
|
||||
"manufacturer": "Yamaha Corporation"
|
||||
|
|
|
@ -9,11 +9,7 @@ from homeassistant.core import HomeAssistant
|
|||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from . import DOMAIN, MusicCastCapabilityEntity, MusicCastDataUpdateCoordinator
|
||||
from .const import (
|
||||
STATE_ZONE_SLEEP_MAPPING,
|
||||
TRANSLATION_KEY_MAPPING,
|
||||
ZONE_SLEEP_STATE_MAPPING,
|
||||
)
|
||||
from .const import TRANSLATION_KEY_MAPPING
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
|
@ -48,10 +44,6 @@ class SelectableCapapility(MusicCastCapabilityEntity, SelectEntity):
|
|||
async def async_select_option(self, option: str) -> None:
|
||||
"""Select the given option."""
|
||||
value = {val: key for key, val in self.capability.options.items()}[option]
|
||||
# If the translation key is "zone_sleep", we need to translate
|
||||
# Home Assistant state back to the MusicCast value
|
||||
if self.translation_key == "zone_sleep":
|
||||
value = STATE_ZONE_SLEEP_MAPPING[value]
|
||||
await self.capability.set(value)
|
||||
|
||||
@property
|
||||
|
@ -62,20 +54,9 @@ class SelectableCapapility(MusicCastCapabilityEntity, SelectEntity):
|
|||
@property
|
||||
def options(self) -> list[str]:
|
||||
"""Return the list possible options."""
|
||||
# If the translation key is "zone_sleep", we need to translate
|
||||
# the options to make them compatible with Home Assistant
|
||||
if self.translation_key == "zone_sleep":
|
||||
return list(STATE_ZONE_SLEEP_MAPPING)
|
||||
return list(self.capability.options.values())
|
||||
|
||||
@property
|
||||
def current_option(self) -> str | None:
|
||||
"""Return the currently selected option."""
|
||||
# If the translation key is "zone_sleep", we need to translate
|
||||
# the value to make it compatible with Home Assistant
|
||||
if (
|
||||
value := self.capability.current
|
||||
) is not None and self.translation_key == "zone_sleep":
|
||||
return ZONE_SLEEP_STATE_MAPPING[value]
|
||||
|
||||
return value
|
||||
return self.capability.options.get(self.capability.current)
|
||||
|
|
|
@ -214,7 +214,7 @@ aiolyric==1.0.9
|
|||
aiomodernforms==0.1.8
|
||||
|
||||
# homeassistant.components.yamaha_musiccast
|
||||
aiomusiccast==0.14.4
|
||||
aiomusiccast==0.14.7
|
||||
|
||||
# homeassistant.components.nanoleaf
|
||||
aionanoleaf==0.2.1
|
||||
|
|
|
@ -195,7 +195,7 @@ aiolyric==1.0.9
|
|||
aiomodernforms==0.1.8
|
||||
|
||||
# homeassistant.components.yamaha_musiccast
|
||||
aiomusiccast==0.14.4
|
||||
aiomusiccast==0.14.7
|
||||
|
||||
# homeassistant.components.nanoleaf
|
||||
aionanoleaf==0.2.1
|
||||
|
|
Loading…
Reference in New Issue