Snapcast not deploying

Hi,

I’m testing snapcast media server component with snapcast server version 0.6.0 using the following configuration:

media_player:
- platform: snapcast
  host: 192.168.1.244

But when deploying home assistant, the snapcast component doesn’t appear and I have the following errors in the home-assistant.log file.

Thanks.

16-04-21 17:08:57 homeassistant.components.media_player: Error while setting up platform snapcast
Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/homeassistant/helpers/entity_component.py", line 94, in _setup_platform
    discovery_info)
  File "/usr/local/lib/python3.4/dist-packages/homeassistant/components/media_player/snapcast.py", line 36, in setup_platform
    add_devices([SnapcastDevice(client) for client in server.clients])
  File "/usr/local/lib/python3.4/dist-packages/homeassistant/helpers/entity_component.py", line 144, in add_entities
    if self.component.add_entity(entity):
  File "/usr/local/lib/python3.4/dist-packages/homeassistant/helpers/entity_component.py", line 111, in add_entity
    self.entity_id_format, entity.name,
  File "/usr/local/lib/python3.4/dist-packages/homeassistant/components/media_player/snapcast.py", line 50, in name
    return self._client.identifier
  File "/home/gpratas/.homeassistant/deps/snapcast/control.py", line 51, in identifier
    if len(self._client.get('name')):
TypeError: object of type 'NoneType' has no len()

Snapcast component currently works with snapcast 0.5.0. I think 0.6.0 made some kind of incompatible change. I can take a look tonight.

Hi. Thanks for your answer.

I’ve tested also with version 0.5.0 and the behavior is the same.

Rgds.

I’m currently testing and updating the component for snapcast 0.6.0. It does have a different configuration.

You can pull this branch if you want to test the update: https://github.com/home-assistant/home-assistant/pull/1908 prior to release.

Sorry to ask. But how do I do that? I’m a power user :slight_smile: but still not a programmer :confused:

I’ve copied the file directly to the respective folder and tested it.

Results:

  • The snapclient’s appeared in the interface;
  • Client name’s don’t appear even when configured in the ~/.config/snapserver/server.json, always appear “Unnamed Device x”;
  • Play/pause don’t work;
  • Volume and mute worked ok.

Play/pause will not work. There is no such concept in the snapcast world. A client is either receiving the stream “playing”, or not, “idle”. And that is controlled by the stream source.

Make sure you are changing the name value under config, not, snapclient. Also, make sure the snapserver is not running when you make the change, otherwise it will be overwritten.

Hi, thanks for the reply. I understand now the play/pause will not work, so they should appear in the interface, since the user will try to click it.

Regarding the ~/.config/snapserver/server.json it looks like this.

Can you tell what might be wrong?

{
“Client”: [
{
“config”: {
“latency”: 0,
“name”: “osmc”,
“stream”: “pipe:///tmp/snapfifo”,
“volume”: {
“muted”: false,
“percent”: 100
}
},
“connected”: false,
“host”: {
“arch”: “armv7l”,
“ip”: “127.0.0.1”,
“mac”: “b8:27:eb:53:42”,
“name”: “osmc”,
“os”: “Open Source Media Center”
},
“lastSeen”: {
“sec”: 1461499034,
“usec”: 14930
},
“snapclient”: {
“name”: “Snapclient”,
“protocolVersion”: 2,
“version”: “0.6.0”
}
},
{
“config”: {
“latency”: 0,
“name”: “Portatil”,
“stream”: “pipe:///tmp/snapfifo”,
“volume”: {
“muted”: false,
“percent”: 100
}
},
“connected”: false,
“host”: {
“arch”: “x86_64”,
“ip”: “192.168.1.68”,
“mac”: “f4:06:69:03:ab:”,
“name”: “Portatil”,
“os”: “Linux Mint 17.2 Rafaela”
},
“lastSeen”: {
“sec”: 1461499034,
“usec”: 497012
},
“snapclient”: {
“name”: “Snapclient”,
“protocolVersion”: 2,
“version”: “0.6.0”
}
},
{
“config”: {
“latency”: 0,
“name”: “Phone”,
“stream”: “pipe:///tmp/snapfifo”,
“volume”: {
“muted”: false,
“percent”: 100
}
},
“connected”: false,
“host”: {
“arch”: “armeabi-v7a”,
“ip”: “192.168.1.65”,
“mac”: “40:88:05:c3:b6”,
“name”: “Phone”,
“os”: “Android 6.0.1”
},
“lastSeen”: {
“sec”: 1461499034,
“usec”: 500651
},
“snapclient”: {
“name”: “Snapclient”,
“protocolVersion”: 2,
“version”: “0.6.0”
}
}
],
“ConfigVersion”: 1
}

Thanks.

I agree that the interface should not show UI that you can’t use. I am only the developer of the backend component though, I don’t know much about the media player front end. I think there is some discussion of a separate UI for AVR-type devices (like receivers – essentially what snapcast is).

Your configuration looks fine. Its possible you may have to restart server and clients, but I’m honestly not sure. If you look at the output of snapserver, do clients connect with the configured name?

The output of the snapserver is the following:

2016-04-25 07-50-10 [Notice] StreamServer::NewConnection: 192.168.1.65
2016-04-25 07-50-10 [Notice] StreamServer::NewConnection: 127.0.0.1
2016-04-25 07-50-10 [out] Hello from 40:88:05:c3:b6, host: android-e16abe94c331a3f0, v0.6.0, ClientName: Snapclient, OS: Android 6.0.1, Arch: armeabi-v7a, Protocol version: 2
2016-04-25 07-50-10 [out] Hello from b8:27:eb:53:42, host: osmc, v0.6.0, ClientName: Snapclient, OS: Open Source Media Center, Arch: armv7l, Protocol version: 2

Hi,

Probably you didn’t had time to look at it again. BTW, the attribute “name:” is not working for snapcast platform,.

I wanted to create a group with all the media servers, but when I state the entity name: of the snapcast, it doesn’t appear.

Thanks.

Rgds.

I am sorry for the stupid question, but do i have to put the adress of the snapcast server or client in the host field? I see this in the logs

File "/home/homeassistant/.homeassistant/deps/snapcast/control.py", line 349, in _transact
    raise Exception('No response received')

It is not a stupid question I am having issues on configuring snapcast on HASS as well. Does anyone have any idea to support me and @Simon_Ku

HASS does not currently support 0.11, so keep that in mind.

What error are you receiving?

Hi! I use snapcast 0.11.1 and get the following error in hass:

2017-05-19 18:36:45 ERROR (MainThread) [homeassistant.components.media_player] Error while setting up platform snapcast
Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/homeassistant/helpers/entity_component.py", line 155, in _async_setup_platform
    entity_platform.schedule_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 "/usr/local/lib/python3.4/dist-packages/homeassistant/components/media_player/snapcast.py", line 43, in setup_platform
    server = snapcast.control.Snapserver(host, port)
  File "/home/pi/.homeassistant/deps/snapcast/control.py", line 164, in __init__
    self.synchronize()
  File "/home/pi/.homeassistant/deps/snapcast/control.py", line 239, in synchronize
    for client in status.get('clients'):
TypeError: 'NoneType' object is not iterable

0.11.x is not supported yet. Hopefully next version.