Pandora (Pianobar) error

I am trying to use the Pandora component but I keep getting the error below. Also, Pianobar works fine when I open it in terminal on my raspberry pi.

homeassistant.core: Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File “/usr/lib/python3.4/asyncio/tasks.py”, line 237, in _step
result = next(coro)
File “/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py”, line 387, in _update_entity_states
yield from update_coro
File “/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/helpers/entity.py”, line 227, in async_update_ha_state
attr = self.state_attributes or {}
File “/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/media_player/init.py”, line 821, in state_attributes
in ATTR_TO_PROPERTY if getattr(self, attr) is not None
File “/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/media_player/init.py”, line 821, in
in ATTR_TO_PROPERTY if getattr(self, attr) is not None
File “/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/media_player/pandora.py”, line 178, in media_title
self.update_playing_status()
File “/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/media_player/pandora.py”, line 228, in update_playing_status
response = self._query_for_playing_status()
File “/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/media_player/pandora.py”, line 238, in _query_for_playing_status
self._clear_buffer()
File “/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/media_player/pandora.py”, line 349, in _clear_buffer
while not self._pianobar.expect(’.+’, timeout=0.1):
AttributeError: ‘NoneType’ object has no attribute ‘expect’

Which installer did you use?

I installed home assistant in virtualenv and followed the instructions for Pandora from here https://home-assistant.io/components/media_player.pandora/

Thanks!

Try switching to your ha user and run the piano bar command from the virtual environment. I had the same issue in the past. My generic Pi user could run piano bar but the hass user couldn’t.

The errors when trying from command line should be a lot more clear.

Looks like this thread has cooled off but I have a similar issue occurring and have gotten as far as trying to fire up Pianobar from the HA virtual environment. I have the AIO installer.

To provide a bit of background, I previously got Pianobar working from the “pi” user and have it up and running a USB soundcard by changing the default card from “0” to “1” in the alsa.conf file as well as blacklisting the onboard soundcard by creating a file in the modprobe.d folder. As I said, this all works great in the “pi” user and “aplay -l” shows the expected USB soundcard.

Back to the HA command line, when trying to run pianobar I receive the following:

Welcome to pianobar (2016.06.02-dev)! Press ? for a list of commands.
(i) Login... Ok.
(i) Get stations... Ok.
|>  Station "Thumbprint Radio" (3174011433391744017)
(i) Receiving new playlist... Ok.
|>  "Do What You Do" by "Mudvayne" on "The New Game"
MobaXterm X11 proxy: Unsupported authorisation protocol
xcb_connection_has_error() returned true
Failed to create secure directory (/home/homeassistant/.config/pulse): Operation                                                     not permitted
MobaXterm X11 proxy: Unsupported authorisation protocol
ALSA lib confmisc.c:768:(parse_card) cannot find card '1'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_card_driver return                                                    ed error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_concat returned er                                                    ror: No such file or directory
ALSA lib confmisc.c:1251:(snd_func_refer) error evaluating name
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned err                                                    or: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directo                                                    ry
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM front
ALSA lib confmisc.c:768:(parse_card) cannot find card '1'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_card_driver return                                                    ed error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_concat returned er                                                    ror: No such file or directory
ALSA lib confmisc.c:1251:(snd_func_refer) error evaluating name
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned err                                                    or: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directo                                                    ry
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM default
/!\ Cannot open audio device.

Interestingly, when inside the virtual environment and running “aplay -l” I am told that no soundcards are found. This might be part of my problem. How can I direct the HA user to find my soundcard?

Thanks,
Rob

Welp, after adding user ‘homeassistant’ to the audio group, I can now startup pianobar from the command line of the homeassistant user so that’s something. However, still no joy from the HA UI. My log shows the following when trying to power on the Pandora panel on the UI:

 17-04-08 16:29:11 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/home/homeassistant/.homeassistant/deps/pexpect/expect.py", line 97, in expect_loop
    incoming = spawn.read_nonblocking(spawn.maxread, timeout)
  File "/home/homeassistant/.homeassistant/deps/pexpect/pty_spawn.py", line 452, in read_nonblocking
    raise TIMEOUT('Timeout exceeded.')
pexpect.exceptions.TIMEOUT: Timeout exceeded.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.4/asyncio/tasks.py", line 233, in _step
    result = coro.throw(exc)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/core.py", line 1010, in _event_to_service_call
    yield from service_handler.func(service_call)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/media_player/__init__.py", line 365, in async_service_handler
    yield from getattr(player, method['method'])(**params)
  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/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/media_player/pandora.py", line 120, in turn_on
    self.update_playing_status()
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/media_player/pandora.py", line 228, in update_playing_status
    response = self._query_for_playing_status()
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/media_player/pandora.py", line 244, in _query_for_playing_status
    'Receiving new playlist'])
  File "/home/homeassistant/.homeassistant/deps/pexpect/spawnbase.py", line 315, in expect
    timeout, searchwindowsize, async)
  File "/home/homeassistant/.homeassistant/deps/pexpect/spawnbase.py", line 339, in expect_list
    return exp.expect_loop(timeout)
  File "/home/homeassistant/.homeassistant/deps/pexpect/expect.py", line 104, in expect_loop
    return self.timeout(e)
  File "/home/homeassistant/.homeassistant/deps/pexpect/expect.py", line 68, in timeout
    raise TIMEOUT(msg)
pexpect.exceptions.TIMEOUT: Timeout exceeded.
<pexpect.pty_spawn.spawn object at 0x6e530f90>
command: /usr/local/bin/pianobar
args: ['/usr/local/bin/pianobar']
searcher: None
buffer (last 100 chars): b'ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM default\r\n\x1b[2K/!\\ Cannot open audio device.\r\n'
before (last 100 chars): b'ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM default\r\n\x1b[2K/!\\ Cannot open audio device.\r\n'
after: <class 'pexpect.exceptions.TIMEOUT'>
match: None
match_index: None
exitstatus: None
flag_eof: False
pid: 1362
child_fd: 17
closed: False
timeout: 30
delimiter: <class 'pexpect.exceptions.EOF'>
logfile: None
logfile_read: None
logfile_send: None
maxread: 2000
ignorecase: False
searchwindowsize: None
delaybeforesend: 0.05
delayafterclose: 0.1
delayafterterminate: 0.1

As I said, I used the all-in-one for my install. Any thoughts welcome.

Rob

I know this is an old thread but did anyone ever get this figured out. I seemed to have ran into the same problem.

running into this as well. did you get yours working?

I had it working on my last system but that was over a year ago. the install instructions don’t work anymore. I can play from the cli just fine.

Having the exact same problem running a similar setup…

running home assistant in virtualenv, pianobar works great commandline as the home assistant user.

Anyone with any luck or thoughts?

I went through a month of trying things but could not figure this out. All I could determine is that it was some permission problem where (some) users could run pianobar fine, but the homeassistant user could not. I finally followed the instructions here to make sure pulseaudio could run as any user and that fixed the issue.