From 8db88192a82a51e11cb788f14a71c92b2a7d6edc Mon Sep 17 00:00:00 2001 From: Bas Nijholt Date: Tue, 13 Oct 2020 20:13:48 +0200 Subject: [PATCH] Fix KEF LSX becoming unavailable (#41700) * Do not use asyncio.gather because the speaker only allows one concurrent connection * bump to aiokef=0.2.16 --- homeassistant/components/kef/manifest.json | 2 +- homeassistant/components/kef/media_player.py | 26 +++++++++++--------- requirements_all.txt | 2 +- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/homeassistant/components/kef/manifest.json b/homeassistant/components/kef/manifest.json index 496d7bae0f2..7441b599063 100644 --- a/homeassistant/components/kef/manifest.json +++ b/homeassistant/components/kef/manifest.json @@ -3,5 +3,5 @@ "name": "KEF", "documentation": "https://www.home-assistant.io/integrations/kef", "codeowners": ["@basnijholt"], - "requirements": ["aiokef==0.2.13", "getmac==0.8.2"] + "requirements": ["aiokef==0.2.16", "getmac==0.8.2"] } diff --git a/homeassistant/components/kef/media_player.py b/homeassistant/components/kef/media_player.py index d033592cb3f..892bb0adac0 100644 --- a/homeassistant/components/kef/media_player.py +++ b/homeassistant/components/kef/media_player.py @@ -1,6 +1,5 @@ """Platform for the KEF Wireless Speakers.""" -import asyncio from datetime import timedelta from functools import partial import ipaddress @@ -164,7 +163,11 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= dtype = type(options[0]) # int or float platform.async_register_entity_service( name, - {vol.Required(option): vol.All(vol.Coerce(dtype), vol.In(options))}, + { + vol.Required(option): vol.All( + vol.Coerce(float), vol.Coerce(dtype), vol.In(options) + ) + }, f"set_{which}", ) @@ -365,17 +368,16 @@ class KefMediaPlayer(MediaPlayerEntity): # The LSX is able to respond when off the LS50 has to be on. return - (mode, *rest) = await asyncio.gather( - self._speaker.get_mode(), - self._speaker.get_desk_db(), - self._speaker.get_wall_db(), - self._speaker.get_treble_db(), - self._speaker.get_high_hz(), - self._speaker.get_low_hz(), - self._speaker.get_sub_db(), + mode = await self._speaker.get_mode() + self._dsp = dict( + desk_db=await self._speaker.get_desk_db(), + wall_db=await self._speaker.get_wall_db(), + treble_db=await self._speaker.get_treble_db(), + high_hz=await self._speaker.get_high_hz(), + low_hz=await self._speaker.get_low_hz(), + sub_db=await self._speaker.get_sub_db(), + **mode._asdict(), ) - keys = ["desk_db", "wall_db", "treble_db", "high_hz", "low_hz", "sub_db"] - self._dsp = dict(zip(keys, rest), **mode._asdict()) async def async_added_to_hass(self): """Subscribe to DSP updates.""" diff --git a/requirements_all.txt b/requirements_all.txt index 5af57aa982f..20662c5c3ae 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -197,7 +197,7 @@ aioimaplib==0.7.15 aiokafka==0.6.0 # homeassistant.components.kef -aiokef==0.2.13 +aiokef==0.2.16 # homeassistant.components.lifx aiolifx==0.6.7