VLC player - Error while setting up platform vlc

Is there someone how can tell me why VLC player won’t be working?

16-12-28 19:35:20 homeassistant.components.media_player: Error while setting up platform vlc
Traceback (most recent call last):
  File "/srv/hass/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py", line 150, in     _async_setup_platform
    entity_platform.add_entities, discovery_info
  File "/usr/lib/python3.4/asyncio/futures.py", line 388, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.4/asyncio/tasks.py", line 286, in _wakeup
   value = future.result()
  File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result
    raise self._exception
  File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/hass/lib/python3.4/site-packages/homeassistant/components/media_player/vlc.py", line 35, in     setup_platform
   add_devices([VlcDevice(config.get(CONF_NAME))])
  File "/srv/hass/lib/python3.4/site-packages/homeassistant/components/media_player/vlc.py", line 44, in __init__
    self._instance = vlc.Instance()
  File "/home/hass/.homeassistant/deps/vlc.py", line 1551, in __new__
    return libvlc_new(len(args), args)
  File "/home/hass/.homeassistant/deps/vlc.py", line 3903, in libvlc_new
    ctypes.c_void_p, ctypes.c_int, ListPOINTER(ctypes.c_char_p))
  File "/home/hass/.homeassistant/deps/vlc.py", line 246, in _Cfunction
 NameError: no function 'libvlc_new'

Is vlc installed?

Thanks daniel for your reply. This will be automaticly right, if i add the vlc media player in HA?

Yes it should

Is it possible to do this manually? Or will vlc on HA not working if i do this

Is there someone how knows if i can check if VLC is correct installatated?
And how is it posible to install VLC manual if it is not installated?
I use VirtualEnv

sudo apt-get install vlc

2 Likes

Join the question! Home Assistant
0.63.0 Version. VLC media player does not work in HASS writes
Error while setting up platform vlc 10:01 components/media_player/vlc.py (ERROR),
and in log

2018-02-12 09:53:37 WARNING (MainThread) [homeassistant.components.recorder] from version 0.64.0 the 'recorder' component will by default purge data older than 10 days. To keep data longer you must configure 'purge_keep_days' or 'purge_interval'.
2018-02-12 09:53: 39 ERROR (MainThread) [homeassistant.components.media_player] Error while setting up platform vlc
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 84, in async_setup
    SLOW_SETUP_MAX_WAIT, loop=hass.loop)
  File "/usr/lib/python3.6/asyncio/tasks.py", line 358, in wait_for
    return fut.result()
  File "/usr/lib/python3.6/asyncio/futures.py", line 245, in result
    raise self._exception
  File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn (*self.args, * * self.kwargs)
  File "/usr/lib/python3.6/site-packages/homeassistant/components/media_player/vlc.py", line 41, in setup_platform
    config.get(CONF_ARGUMENTS))])
  File "/usr/lib/python3.6/site-packages/homeassistant/components/media_player/vlc.py", line 50, in _ _ init__
    self._instance = vlc.Instance(arguments)
  File "/usr/lib/python3.6/site-packages/vlc.py", line 1551, in _ _ new__
    return libvlc_new(len (args), args)
  File "/usr/lib/python3.6/site-packages/vlc.py", line 3903, in libvlc_new
    ctypes.c_void_p, ctypes.c_int, ListPOINTER(ctypes.c_char_p))
  File "/usr/lib/python3.6/site-packages/vlc.py", line 246, in _Cfunction
    raise NameError('no function %r' % (name,))
NameError: no function 'libvlc_new'

How can this be solved? VLC installed

Try

REQUIREMENTS = [‘python-vlc==3.0.101’]

After your proposed changes, we lost all media players and there were data errors:

Mon Feb 12 2018 12:09:55 GMT+0300 (MSK)

Unable to find service media_player/play_media

Mon Feb 12 2018 12:07:09 GMT+0300 (MSK)

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File “/usr/lib/python3.6/asyncio/tasks.py”, line 182, in _step
result = coro.throw(exc)
File “/usr/lib/python3.6/site-packages/homeassistant/setup.py”, line 57, in async_setup_component
return (yield from task)
File “/usr/lib/python3.6/asyncio/futures.py”, line 332, in iter
yield self # This tells Task to wait for completion.
File “/usr/lib/python3.6/asyncio/tasks.py”, line 250, in _wakeup
future.result()
File “/usr/lib/python3.6/asyncio/futures.py”, line 245, in result
raise self._exception
File “/usr/lib/python3.6/asyncio/tasks.py”, line 180, in _step
result = coro.send(None)
File “/usr/lib/python3.6/site-packages/homeassistant/setup.py”, line 119, in _async_setup_component
conf_util.async_process_component_config(hass, config, domain)
File “/usr/lib/python3.6/site-packages/homeassistant/config.py”, line 628, in async_process_component_config
platform = get_platform(domain, p_name)
File “/usr/lib/python3.6/site-packages/homeassistant/loader.py”, line 104, in get_platform
return get_component(PLATFORM_FORMAT.format(domain, platform))
File “/usr/lib/python3.6/site-packages/homeassistant/loader.py”, line 142, in get_component
module = importlib.import_module(path)
File “/usr/lib/python3.6/importlib/init.py”, line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File “”, line 994, in _gcd_import
File “”, line 971, in _find_and_load
File “”, line 955, in _find_and_load_unlocked
File “”, line 665, in _load_unlocked
File “”, line 674, in exec_module
File “”, line 781, in get_code
File “”, line 741, in source_to_code
File “”, line 219, in _call_with_frames_removed
File “/usr/lib/python3.6/site-packages/homeassistant/components/media_player/vlc.py”, line 21
REQUIREMENTS = ['python-vlc==3.0.101]
^
SyntaxError: EOL while scanning string literal

and

Mon Feb 12 2018 12:07:05 GMT+0300 (MSK)

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File “/usr/lib/python3.6/asyncio/tasks.py”, line 180, in _step
result = coro.send(None)
File “/usr/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py”, line 243, in _async_add_entity
‘Entity id already exists: {}’.format(entity.entity_id))
homeassistant.exceptions.HomeAssistantError: Entity id already exists: automation.temperature_25

all log

2018-02-12 12:23:02 WARNING (MainThread) [homeassistant.components.recorder] From version 0.64.0 the ‘recorder’ component will by default purge data older than 10 days. To keep data longer you must configure ‘purge_keep_days’ or ‘purge_interval’.
2018-02-12 12:23:03 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File “/usr/lib/python3.6/asyncio/tasks.py”, line 180, in _step
result = coro.send(None)
File “/usr/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py”, line 243, in _async_add_entity
‘Entity id already exists: {}’.format(entity.entity_id))
homeassistant.exceptions.HomeAssistantError: Entity id already exists: automation.temperature_25
2018-02-12 12:23:04 ERROR (MainThread) [homeassistant.components.media_player] Error while setting up platform vlc
Traceback (most recent call last):
File “/usr/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py”, line 84, in async_setup
SLOW_SETUP_MAX_WAIT, loop=hass.loop)
File “/usr/lib/python3.6/asyncio/tasks.py”, line 358, in wait_for
return fut.result()
File “/usr/lib/python3.6/asyncio/futures.py”, line 245, in result
raise self._exception
File “/usr/lib/python3.6/concurrent/futures/thread.py”, line 56, in run
result = self.fn(*self.args, **self.kwargs)
File “/usr/lib/python3.6/site-packages/homeassistant/components/media_player/vlc.py”, line 40, in setup_platform
config.get(CONF_ARGUMENTS))])
File “/usr/lib/python3.6/site-packages/homeassistant/components/media_player/vlc.py”, line 49, in init
self._instance = vlc.Instance(arguments)
File “/usr/lib/python3.6/site-packages/vlc.py”, line 1551, in new
return libvlc_new(len(args), args)
File “/usr/lib/python3.6/site-packages/vlc.py”, line 3903, in libvlc_new
ctypes.c_void_p, ctypes.c_int, ListPOINTER(ctypes.c_char_p))
File “/usr/lib/python3.6/site-packages/vlc.py”, line 246, in _Cfunction
raise NameError(‘no function %r’ % (name,))
NameError: no function ‘libvlc_new’

There was a missing ’

Try

REQUIREMENTS = [‘python-vlc==3.0.101’]

Has anyone solved the issue with vlc? All that was cited above did not help! Here is the log file itself!

Summary
2018-02-22 21:36:25 WARNING (MainThread) [homeassistant.components.recorder] From version 0.64.0 the 'recorder' component will by default purge data older than 10 days. To keep data longer you must configure 'purge_keep_days' or 'purge_interval'.
2018-02-22 21:36:27 ERROR (MainThread) [homeassistant.components.media_player] Error while setting up platform vlc
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 84, in async_setup
    SLOW_SETUP_MAX_WAIT, loop=hass.loop)
  File "/usr/lib/python3.6/asyncio/tasks.py", line 358, in wait_for
    return fut.result()
  File "/usr/lib/python3.6/asyncio/futures.py", line 245, in result
    raise self._exception
  File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/lib/python3.6/site-packages/homeassistant/components/media_player/vlc.py", line 41, in setup_platform
    config.get(CONF_ARGUMENTS))])
  File "/usr/lib/python3.6/site-packages/homeassistant/components/media_player/vlc.py", line 50, in __init__
    self._instance = vlc.Instance(arguments)
  File "/usr/lib/python3.6/site-packages/vlc.py", line 1551, in __new__
    return libvlc_new(len(args), args)
  File "/usr/lib/python3.6/site-packages/vlc.py", line 3903, in libvlc_new
    ctypes.c_void_p, ctypes.c_int, ListPOINTER(ctypes.c_char_p))
  File "/usr/lib/python3.6/site-packages/vlc.py", line 246, in _Cfunction
    raise NameError('no function %r' % (name,))
NameError: no function 'libvlc_new'
2018-02-22 21:36:33 WARNING (SyncWorker_9) [urllib3.connectionpool] Failed to parse headers (url=http://192.168.13.102:8081/): [StartBoundaryNotFoundDefect(), MultipartInvariantViolationDefect()], unparsed data: ''
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 399, in _make_request
    assert_header_parsing(httplib_response.msg)
  File "/usr/lib/python3.6/site-packages/urllib3/util/response.py", line 66, in assert_header_parsing
    raise HeaderParsingError(defects=defects, unparsed_data=unparsed_data)
urllib3.exceptions.HeaderParsingError: [StartBoundaryNotFoundDefect(), MultipartInvariantViolationDefect()], unparsed data: ''
2018-02-22 21:36:33 WARNING (MainThread) [homeassistant.components.http.ban] Login attempt or request with invalid authentication from 172.30.33.3
2018-02-22 21:36:33 WARNING (SyncWorker_4) [urllib3.connectionpool] Failed to parse headers (url=http://192.168.13.102:8081/): [StartBoundaryNotFoundDefect(), MultipartInvariantViolationDefect()], unparsed data: ''
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 399, in _make_request
    assert_header_parsing(httplib_response.msg)
  File "/usr/lib/python3.6/site-packages/urllib3/util/response.py", line 66, in assert_header_parsing
    raise HeaderParsingError(defects=defects, unparsed_data=unparsed_data)
urllib3.exceptions.HeaderParsingError: [StartBoundaryNotFoundDefect(), MultipartInvariantViolationDefect()], unparsed data: ''

and file vlc.py

Summary
"""
Provide functionality to interact with vlc devices on the network.

For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/media_player.vlc/
"""
import logging

import voluptuous as vol

from homeassistant.components.media_player import (
    SUPPORT_PAUSE, SUPPORT_PLAY_MEDIA, SUPPORT_STOP, SUPPORT_VOLUME_MUTE,
    SUPPORT_VOLUME_SET, SUPPORT_PLAY, MediaPlayerDevice, PLATFORM_SCHEMA,
    MEDIA_TYPE_MUSIC)

from homeassistant.const import (CONF_NAME, STATE_IDLE, STATE_PAUSED,
                                 STATE_PLAYING)
import homeassistant.helpers.config_validation as cv
import homeassistant.util.dt as dt_util

REQUIREMENTS = ['python-vlc==3.0.101']

_LOGGER = logging.getLogger(__name__)

CONF_ARGUMENTS = 'arguments'
DEFAULT_NAME = 'Vlc'

SUPPORT_VLC = SUPPORT_PAUSE | SUPPORT_VOLUME_SET | SUPPORT_VOLUME_MUTE | \
    SUPPORT_PLAY_MEDIA | SUPPORT_PLAY | SUPPORT_STOP

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Optional(CONF_NAME): cv.string,
    vol.Optional(CONF_ARGUMENTS, default=''): cv.string,
})


# pylint: disable=unused-argument
def setup_platform(hass, config, add_devices, discovery_info=None):
    """Set up the vlc platform."""
    add_devices([VlcDevice(config.get(CONF_NAME, DEFAULT_NAME),
                           config.get(CONF_ARGUMENTS))])


class VlcDevice(MediaPlayerDevice):
    """Representation of a vlc player."""

    def __init__(self, name, arguments):
        """Initialize the vlc device."""
        import vlc
        self._instance = vlc.Instance(arguments)
        self._vlc = self._instance.media_player_new()
        self._name = name
        self._volume = None
        self._muted = None
        self._state = None
        self._media_position_updated_at = None
        self._media_position = None
        self._media_duration = None

    def update(self):
        """Get the latest details from the device."""
        import vlc
        status = self._vlc.get_state()
        if status == vlc.State.Playing:
            self._state = STATE_PLAYING
        elif status == vlc.State.Paused:
            self._state = STATE_PAUSED
        else:
            self._state = STATE_IDLE
        self._media_duration = self._vlc.get_length()/1000
        position = self._vlc.get_position() * self._media_duration
        if position != self._media_position:
            self._media_position_updated_at = dt_util.utcnow()
            self._media_position = position

        self._volume = self._vlc.audio_get_volume() / 100
        self._muted = (self._vlc.audio_get_mute() == 1)

        return True

    @property
    def name(self):
        """Return the name of the device."""
        return self._name

    @property
    def state(self):
        """Return the state of the device."""
        return self._state

    @property
    def volume_level(self):
        """Volume level of the media player (0..1)."""
        return self._volume

    @property
    def is_volume_muted(self):
        """Boolean if volume is currently muted."""
        return self._muted

    @property
    def supported_features(self):
        """Flag media player features that are supported."""
        return SUPPORT_VLC

    @property
    def media_content_type(self):
        """Content type of current playing media."""
        return MEDIA_TYPE_MUSIC

    @property
    def media_duration(self):
        """Duration of current playing media in seconds."""
        return self._media_duration

    @property
    def media_position(self):
        """Position of current playing media in seconds."""
        return self._media_position

    @property
    def media_position_updated_at(self):
        """When was the position of the current playing media valid."""
        return self._media_position_updated_at

    def media_seek(self, position):
        """Seek the media to a specific location."""
        track_length = self._vlc.get_length()/1000
        self._vlc.set_position(position/track_length)

    def mute_volume(self, mute):
        """Mute the volume."""
        self._vlc.audio_set_mute(mute)
        self._muted = mute

    def set_volume_level(self, volume):
        """Set volume level, range 0..1."""
        self._vlc.audio_set_volume(int(volume * 100))
        self._volume = volume

    def media_play(self):
        """Send play command."""
        self._vlc.play()
        self._state = STATE_PLAYING

    def media_pause(self):
        """Send pause command."""
        self._vlc.pause()
        self._state = STATE_PAUSED

    def media_stop(self):
        """Send stop command."""
        self._vlc.stop()
        self._state = STATE_IDLE

    def play_media(self, media_type, media_id, **kwargs):
        """Play media from a URL or file."""
        if not media_type == MEDIA_TYPE_MUSIC:
            _LOGGER.error(
                "Invalid media type %s. Only %s is supported",
                media_type, MEDIA_TYPE_MUSIC)
            return
        self._vlc.set_media(self._instance.media_new(media_id))
        self._vlc.play()
        self._state = STATE_PLAYING

@dionisgr
I just setup the VLC as tts using this post:

You need to first manually install the VLC. I had to run apt-get update command also. Some packages were missing.

Test it with the services menu in HA.
Service: tts.google_say

JSON:
{“entity_id”:“media_player.kirka”,
“message”:“You have successfully installed text to speech service!”}

Just modify the media player you are using. I named mine kirka.