smartir clone
@@ -27,13 +27,15 @@ CONF_UNIQUE_ID = 'unique_id'
CONF_DEVICE_CODE = 'device_code'
CONF_CONTROLLER_DATA = "controller_data"
CONF_POWER_SENSOR = 'power_sensor'
+CONF_SOURCE_NAMES = 'source_names'
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Optional(CONF_UNIQUE_ID): cv.string,
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
vol.Required(CONF_DEVICE_CODE): cv.positive_int,
vol.Required(CONF_CONTROLLER_DATA): cv.string,
- vol.Optional(CONF_POWER_SENSOR): cv.entity_id
+ vol.Optional(CONF_POWER_SENSOR): cv.entity_id,
+ vol.Optional(CONF_SOURCE_NAMES): dict
})
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
@@ -119,6 +121,13 @@ class SmartIRMediaPlayer(MediaPlayerDevice, RestoreEntity):
if 'sources' in self._commands and self._commands['sources'] is not None:
self._support_flags = self._support_flags | SUPPORT_SELECT_SOURCE
+ for source, new_name in config.get(CONF_SOURCE_NAMES, {}).items():
+ if source in self._commands['sources']:
+ if new_name is not None:
+ self._commands['sources'][new_name] = self._commands['sources'][source]
+
+ del self._commands['sources'][source]
+
#Sources list
for key in self._commands['sources']:
self._sources_list.append(key)
