From 2b14d407c09ee31727d699f1063d37d256bd3ade Mon Sep 17 00:00:00 2001 From: markferry Date: Sun, 8 Jan 2017 22:59:26 +0000 Subject: [PATCH] onkyo: fix selecting sources with only one name (#5221) --- homeassistant/components/media_player/onkyo.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/media_player/onkyo.py b/homeassistant/components/media_player/onkyo.py index 28f8dd1bf6b..fa06f938b58 100644 --- a/homeassistant/components/media_player/onkyo.py +++ b/homeassistant/components/media_player/onkyo.py @@ -111,13 +111,21 @@ class OnkyoDevice(MediaPlayerDevice): current_source_raw = self.command('input-selector query') if not (volume_raw and mute_raw and current_source_raw): return - for source in current_source_raw[1]: + + # eiscp can return string or tuple. Make everything tuples. + if isinstance(current_source_raw[1], str): + current_source_tuples = \ + (current_source_raw[0], (current_source_raw[1],)) + else: + current_source_tuples = current_source_raw + + for source in current_source_tuples[1]: if source in self._source_mapping: self._current_source = self._source_mapping[source] break else: self._current_source = '_'.join( - [i for i in current_source_raw[1]]) + [i for i in current_source_tuples[1]]) self._muted = bool(mute_raw[1] == 'on') self._volume = int(volume_raw[1], 16) / 80.0