Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detachment of the list of commands for selecting a signal source from the list of signal sources. #912

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions custom_components/smartir/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,14 @@ def __init__(self, hass, config, device_data):
self._commands = device_data['commands']

self._state = STATE_OFF
self._sources_list_commands = {}
self._sources_list = []
self._source = None
self._support_flags = 0

self._device_class = config.get(CONF_DEVICE_CLASS)

#Supported features
# Supported features
if 'off' in self._commands and self._commands['off'] is not None:
self._support_flags = self._support_flags | SUPPORT_TURN_OFF

Expand All @@ -129,20 +130,22 @@ def __init__(self, hass, config, device_data):
if 'sources' in self._commands and self._commands['sources'] is not None:
self._support_flags = self._support_flags | SUPPORT_SELECT_SOURCE | SUPPORT_PLAY_MEDIA

self._sources_list_commands = self._commands['sources'].copy()

for source, new_name in config.get(CONF_SOURCE_NAMES, {}).items():
if source in self._commands['sources']:
if source in self._sources_list_commands:
if new_name is not None:
self._commands['sources'][new_name] = self._commands['sources'][source]
self._sources_list_commands[new_name] = self._sources_list_commands[source]

del self._commands['sources'][source]
del self._sources_list_commands[source]

#Sources list
for key in self._commands['sources']:
# Sources list
for key in self._sources_list_commands:
self._sources_list.append(key)

self._temp_lock = asyncio.Lock()

#Init the IR/RF controller
# Init the IR/RF controller
self._controller = get_controller(
self.hass,
self._supported_controller,
Expand Down Expand Up @@ -263,7 +266,7 @@ async def async_mute_volume(self, mute):
async def async_select_source(self, source):
"""Select channel from source."""
self._source = source
await self.send_command(self._commands['sources'][source])
await self.send_command(self._sources_list_commands[source])
self.async_write_ha_state()

async def async_play_media(self, media_type, media_id, **kwargs):
Expand Down
Loading