From 3d9b2b5ed011f1395318b8f73b32835dfde45e7b Mon Sep 17 00:00:00 2001 From: Gianluca Barbaro Date: Sat, 14 Jan 2017 22:30:24 +0100 Subject: [PATCH] Update vlc.py Added support for additional optional configuration arguments: to send to vlc. It is useful for special configurations of VLC. For example, I have two sound cards on my server, so I defined two vlc media players: media_player: - platform: vlc name: speaker_1 arguments: '--alsa-audio-device=hw:1,0' - platform: vlc name: speaker_2 arguments: '--alsa-audio-device=hw:0,0' This way, by specifying the corresponding entity_id, I can send the output to the desired speaker. It is also useful for TTS. --- homeassistant/components/media_player/vlc.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/media_player/vlc.py b/homeassistant/components/media_player/vlc.py index 3398e7093cc..909dfe0fd77 100644 --- a/homeassistant/components/media_player/vlc.py +++ b/homeassistant/components/media_player/vlc.py @@ -20,28 +20,30 @@ REQUIREMENTS = ['python-vlc==1.1.2'] _LOGGER = logging.getLogger(__name__) +ADDITIONAL_ARGS = 'arguments' SUPPORT_VLC = SUPPORT_PAUSE | SUPPORT_VOLUME_SET | SUPPORT_VOLUME_MUTE | \ SUPPORT_PLAY_MEDIA | SUPPORT_PLAY PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Optional(CONF_NAME): cv.string, + vol.Optional(ADDITIONAL_ARGS): cv.string, }) # pylint: disable=unused-argument def setup_platform(hass, config, add_devices, discovery_info=None): """Setup the vlc platform.""" - add_devices([VlcDevice(config.get(CONF_NAME))]) + add_devices([VlcDevice(config.get(CONF_NAME), config.get(ADDITIONAL_ARGS))]) class VlcDevice(MediaPlayerDevice): """Representation of a vlc player.""" - def __init__(self, name): + def __init__(self, name, arguments): """Initialize the vlc device.""" import vlc - self._instance = vlc.Instance() + self._instance = vlc.Instance(arguments) self._vlc = self._instance.media_player_new() self._name = name self._volume = None