Replaced the foobar.py and now I’ve got the following error when clicking “Check config”
Invalid config for [media_player.foobar]: string value is None for dictionary value @ data['password']. Got None string value is None for dictionary value @ data['username']. Got None. (See ?, line ?). Please check the docs at https://home-assistant.io/components/media_player.foobar/
Additionally creating credentials and adding them to the entity worked, and it now shows up but having a requirement for the credentials is less than ideal.
One question: is there any way to surface the currently playing track info on the main entity card rather than only when clicking on the card itself?
Also, where is it pulling the track info from? I ask because I notice that the tracks do not match the capitalization’s that I have showing in foobar.
@BRTPOB, Thanks a lot for the feedback, i updated foobar.py and fixed the authentication issue where missing username and password in configuration caused an error.
Regarding the entity card, could you please attache a screen shot? are you using lovelace UI? i’m asking since i havn’t yet given it a try (I dont use the UI much) and not sure what it looks like. i use the old large media player card and it shows the entity name, album art including the artist and title info with some media control buttons.
Re, the track info, this is fetched via HTTP using the foobar2000 foo_httpcontrol plugin.
I took a look at the plugin template and the the hass component, it does not seem that I do any capitalization manipulation.
You can fetch it manually if you would like using curl or a browser. http://<media_player_ip_address>:<media_player_port>/pyfoobar2k?param3=state.json
The information returned is defined in files state.json and config which are part of the template you imported into foobar2000 from the pyfoobar2k package.
These files use foobar2000’s built-in metadata formatting fields, for example the track info is accessed by the template using these fields %title%, %album% and %artist%
This page provides more info about this and also explains what happens when a certain piece of info or metadata is missing. https://wiki.hydrogenaud.io/index.php?title=Foobar2000:Title_Formatting_Reference#Remapped_metadata_fields
You could try changing fields in config file like %artist% to %album artist% or %track artist% to experiment with it.
As for the naming, for example, this is what foobar is showing me: https://linx.eskimomafia.com/q5pzjghy.png, but in the screenshot above (ovpx1t87), you can see the With is capitalized, which is what I was curious about.
Edit: using the JSON link you added, here’s what I’m seeing:
artist
“Johnny Cash”
title
“Christmas with You”
album
“The Classic Christmas Album”
volume
“100”
volumedb
“0”
isPlaying
“1”
isPaused
“0”
itemPlayingPos
“1”
itemPlayingLen
“127”
albumArt
“/pyfoobar2k/albumart_7393”
So as you can see, it’s getting the naming properly, but for some reason it’s not displaying it as it shows in foobar.
I understand the issue better now, unfortunately I’m not sure about the origin of the capitalization, since i pass this info “as is” from the json fetched from foobar2000.
However, i think i’ve found a way to troubleshoot this further, if you check the entities page on home assistant UI http://<hass_ip>:8123/dev-state while media is playing, you can see all of the entitiy’s attributes, you should be able to see the track info (such as media_title:) as it is seen by home assistant.
if that shows the track title correctly, i have to guess the UI card does some kind of text reformatting.
I hope this helps.
Foobar is all set up and I’ve been using foo_httpcontrol from an android app for a few years (but all up to date). I can access pyfoobar2k from any pc in the network all fine:
I get the error:
2019-04-06 15:37:35 ERROR (SyncWorker_9) [homeassistant.loader] Error loading custom_components.media_player.foobar. Make sure all dependencies are installed
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/homeassistant/loader.py", line 183, in _load_file
module = importlib.import_module(path)
File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/config/custom_components/media_player/foobar.py", line 14, in <module>
from homeassistant.components.media_player import (
ImportError: cannot import name 'MEDIA_TYPE_MUSIC' from 'homeassistant.components.media_player' (/usr/local/lib/python3.7/site-packages/homeassistant/components/media_player/__init__.py)
2019-04-06 15:37:35 ERROR (SyncWorker_9) [homeassistant.loader] Unable to find platform foobar.
2019-04-06 15:37:36 ERROR (MainThread) [homeassistant.components.hassio] Platform not found: media_player.foobar
I’m running 0.91 and have tried your trick above ( To fix this, you may need to copy a few more files ( reproduce_state.py, const.py, __init__.py ) from your home assistant installation path lib/python3.6/site-packages/homeassistant/components/media_player/ and place these next to the foobar.py file under <home_assistant_config_dir>/custom_components/media_player/) and I’ve tried both media_player/foobar.py and foobar/media_player.py.
@Greenhouse I think the trick described in the github pull request i shared earlier is not needed as I’m running the component successfully without it on version 0.90.1.
I do recommend to follow @BRTPOB’s suggestion where custom components need to be on their on folder, even though i believe it is not related to your error message;
You should rename foobar.py to media_player.py and place it under custom_components/foobar/media_player.py
The error you attached looks similar to an ImportError i fixed on my last update, could you please make sure you’re using the latest version of home-assistant-foobar2k?
Hey @ed0zer, I’m running into the following after having upgraded to Python 3.8:
Error while setting up platform foobar
Traceback (most recent call last):
File "/opt/homeassistant/lib/python3.8/site-packages/homeassistant/helpers/entity_platform.py", line 150, in _async_setup_platform
await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT)
File "/usr/local/lib/python3.8/asyncio/tasks.py", line 483, in wait_for
return fut.result()
File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/home/offspring/.homeassistant/custom_components/foobar/media_player.py", line 56, in setup_platform
from pyfoobar2k import FoobarRemote
ModuleNotFoundError: No module named 'pyfoobar2k'
What am I missing/doing wrong?
EDIT: figured it out. Had to re-run pip3 install pyfoobar2k to get it to work.
New guy here… if anyone is still interested, I am trying to play audio from spotify to up2stream boards AND hassio… well, foobar2000 is a supported host of Arylic’s up2stream boards. Any clues on how to stream spotify to both?
Hey, i got this component working mostly fine on my instance and I love it, but i’m getting thousands of errors like this:
2020-05-17 19:49:59 WARNING (MainThread) [homeassistant.util.async_] Detected I/O inside the event loop. This is causing stability issues. Please report issue to the custom component author for foobar doing I/O at custom_components/foobar/media_player.py, line 268: self._track_position = int(self._remote.state()['itemPlayingPos']
@ed0zer, are you still supporting this component? It’s been spitting out a warning for a while now that…
WARNING:homeassistant.components.media_player:MediaPlayerDevice is deprecated, modify FoobarDevice to extend MediaPlayerEntity
My ODC got me to dig around a bit and it appears that it’s simply a matter of renaming MediaPlayerDevice to MediaPlayerEntity per Entity class names change that was made back in May.
Hacking my local copy of the component seems to fix the warning and it still works.