Skip to content

Commit

Permalink
Fix issue retrieving sources from SmartThings (issue #301)
Browse files Browse the repository at this point in the history
  • Loading branch information
ollo69 committed Feb 12, 2024
1 parent 51f692c commit 870ca29
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion custom_components/samsungtv_smart/api/smartthings.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,19 @@ def get_source_name(self, source_id: str) -> str:
return map_value.get("name", "")
return ""

def _get_source_list_from_map(self) -> list:
"""Return source list from source map."""
if not self._source_list_map:
return []
source_list = []
for map_value in self._source_list_map:
if source_id := map_value.get("id"):
if source_id.upper() == "DTV":
source_list.append(DIGITAL_TV)
else:
source_list.append(source_id)
return source_list

def set_application(self, app_id):
"""Set running application info."""
if self._use_channel_info:
Expand Down Expand Up @@ -477,10 +490,11 @@ async def async_device_update(self, use_channel_info: bool = None):
)

# Sources and channel
self._source_list = self._load_json_list(dev_data, "supportedInputSources")
self._source_list_map = self._load_json_list(
dev_data, "supportedInputSourcesMap"
)
# self._source_list = self._load_json_list(dev_data, "supportedInputSources")
self._source_list = self._get_source_list_from_map()

if self._is_forced_val and self._forced_count <= 0:
self._forced_count += 1
Expand Down

0 comments on commit 870ca29

Please sign in to comment.