From 5b728a41de90b50746ae1425e2ae064c495ad0b1 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Tue, 31 Jan 2023 20:37:11 +0100 Subject: [PATCH] Fix Yamaha MusicCast zone sleep select entity (#87041) --- .../components/yamaha_musiccast/const.py | 9 -------- .../components/yamaha_musiccast/manifest.json | 2 +- .../components/yamaha_musiccast/select.py | 23 ++----------------- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- 5 files changed, 5 insertions(+), 33 deletions(-) diff --git a/homeassistant/components/yamaha_musiccast/const.py b/homeassistant/components/yamaha_musiccast/const.py index 5984d73980f266..49234ac38ee266 100644 --- a/homeassistant/components/yamaha_musiccast/const.py +++ b/homeassistant/components/yamaha_musiccast/const.py @@ -55,12 +55,3 @@ "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()} diff --git a/homeassistant/components/yamaha_musiccast/manifest.json b/homeassistant/components/yamaha_musiccast/manifest.json index 8c0b55def69177..afcc64985dca19 100644 --- a/homeassistant/components/yamaha_musiccast/manifest.json +++ b/homeassistant/components/yamaha_musiccast/manifest.json @@ -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" diff --git a/homeassistant/components/yamaha_musiccast/select.py b/homeassistant/components/yamaha_musiccast/select.py index 200d62bde32928..a8ca6162c91aaf 100644 --- a/homeassistant/components/yamaha_musiccast/select.py +++ b/homeassistant/components/yamaha_musiccast/select.py @@ -9,11 +9,7 @@ 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 @@ def translation_key(self) -> str | None: @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) diff --git a/requirements_all.txt b/requirements_all.txt index 6537c5e846428d..11ecbffa1ecded 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -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 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 92c742ee65db39..30c2c02aa50d0c 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -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