From 2793e6cdd878ef09a95aac515114715d58e68c74 Mon Sep 17 00:00:00 2001 From: teldri Date: Mon, 25 May 2020 22:07:58 +0200 Subject: [PATCH] Fallback lg_soundbar sound mode on unknown value (#35892) * fallback if equaliser setting unknown to temescal * fallback if equaliser setting unknown to temescal Change Author * fix return values, moved fallback code * add comment to temporary fix --- homeassistant/components/lg_soundbar/media_player.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/lg_soundbar/media_player.py b/homeassistant/components/lg_soundbar/media_player.py index f3c89d6138e..a10b46f89ce 100644 --- a/homeassistant/components/lg_soundbar/media_player.py +++ b/homeassistant/components/lg_soundbar/media_player.py @@ -114,6 +114,11 @@ class LGDevice(MediaPlayerEntity): self._device.get_settings() self._device.get_product_info() + # Temporary fix until handling of unknown equaliser settings is integrated in the temescal library + for equaliser in self._equalisers: + if equaliser >= len(temescal.equalisers): + temescal.equalisers.append("unknown " + str(equaliser)) + @property def name(self): """Return the name of the device.""" @@ -139,9 +144,8 @@ class LGDevice(MediaPlayerEntity): @property def sound_mode(self): """Return the current sound mode.""" - - if self._equaliser == -1: - return "" + if self._equaliser == -1 or self._equaliser >= len(temescal.equalisers): + return None return temescal.equalisers[self._equaliser] @property @@ -156,7 +160,7 @@ class LGDevice(MediaPlayerEntity): def source(self): """Return the current input source.""" if self._function == -1: - return "" + return None return temescal.functions[self._function] @property