I’m working on support for foobar2000 (www.foobar2000.org) as media player component and would really appreciate your feedback, this is only the second time i code in python, there was quite a learning curve to get to this point.
I have a working version which i have been playing with for sometime, https://gitlab.com/ed0zer-projects/home-assistant/home-assistant-foobar2k
According to guidelines, i understood it is recommended to create an external module and import it into home assistant component, thus i created a basic class https://gitlab.com/ed0zer-projects/pyfoobar2k to control foobar2000 via http.
It uses foo_httpcontrol component for foobar2000 by oblikoamorale, and requires changes on foobar2000’s end. https://bitbucket.org/oblikoamorale/foo_httpcontrol
There seem to be an issue with source selection, whenever the menu button of the media player card in UI is clicked, a select_source request was sent to switch the source (to the first one) before a source was actually selected, i haven’t figured this out yet, it was annoying so the first source is temporarily ignored for now.
Also tested this with foobarCon remote app for foobar2000, since foo_httpcontrol is already installed, only the template should be imported.
Is anyone interested in this, or willing to test it?
I would like to create a pull request eventually and would appreciate any feedback or guidance on how to proceed from here.
The template files are loading but I’m getting errors:
foo_httpcontrol error: couldn't read foobar2000\foo_httpcontrol_data\pyfoobar2k\foo_httpcontrol_controls_tpl.html (The system cannot find the file specified.
2)
Been a really long time since I last used foo_httpcontrol…
Hi, i’m pretty sure you have installed the plugin and the template correctly, the error you got is due to I haven’t implemented a front html page for it.
I have just added a basic html foo_httpcontrol_controls_tpl.html to the repository, it will show a successful installation of the template. you can add it to “foobar2000\foo_httpcontrol_data\pyfoobar2k” but it is actually not necessary to make it work.
The rest of the setup is home assistant, both the non-template folder pyfoobar2k/ from https://bitbucket.org/ed0zer/pyfoobar2k
and foobar.py from https://bitbucket.org/ed0zer/home-assistant-foobar2k go under
<home_assistant_config_dir>/custom_components/media_player/
-rw-r--r-- 1 hass hass 11K Oct 27 14:00 foobar.py
drwxrwxr-x 3 hass hass 4.0K Mar 2 12:14 pyfoobar2k
Since my original post I’ve fixed some bugs and added a few more functions which also include a turn on/off, options.
These call an Hass script. I created a command_line switch named switch.foobar2k which invokes a bash script and calls Eventghost on my windows desktop to launch/exit foobar2000.
The version in my original post does not include those additions/fixes, I will update these later this weekend.
Thank you, your feedback is appreciated.
I’ve put pyfoobar2k dependency on Pypi, Hass will now install it automatically during startup, thus only ‘foobar.py’ is needed to be placed in custom_components.
Regarding the PR, yes of course, although if I understood correctly, I need to work on tests/tox which i’m not familiar with yet, hopefully i’ll provide all the PR requirements soon.
Any tips on where to begin would be appreciated.
i stuck to configuring foobar2k.
I doublecheck all settings and files but still errors
2018-07-01 12:11:04 ERROR (SyncWorker_3) [homeassistant.util.package] Unable to install package pyfoobar2k==0.2.3: Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by ‘NewConnectionError(’<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0xb6de818c>: Failed to establish a new connection: [Errno -3] Try again’,)‘: /simple/pyfoobar2k/
Retrying (Retry(total=3, connect=None, read=None, redirect=None)) after connection broken by ‘NewConnectionError(’<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0xb6de8f8c>: Failed to establish a new connection: [Errno -3] Try again’,)‘: /simple/pyfoobar2k/
Retrying (Retry(total=2, connect=None, read=None, redirect=None)) after connection broken by ‘NewConnectionError(’<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0xb6de8b4c>: Failed to establish a new connection: [Errno -3] Try again’,)‘: /simple/pyfoobar2k/
Retrying (Retry(total=1, connect=None, read=None, redirect=None)) after connection broken by ‘NewConnectionError(’<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0xb6de8aec>: Failed to establish a new connection: [Errno -3] Try again’,)‘: /simple/pyfoobar2k/
Retrying (Retry(total=0, connect=None, read=None, redirect=None)) after connection broken by ‘NewConnectionError(’<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0xb6de808c>: Failed to establish a new connection: [Errno -3] Try again’,)': /simple/pyfoobar2k/
Could not find a version that satisfies the requirement pyfoobar2k==0.2.3 (from versions: )
No matching distribution found for pyfoobar2k==0.2.3
2018-07-01 12:11:04 ERROR (MainThread) [homeassistant.requirements] Not initializing media_player.foobar because could not install requirement pyfoobar2k==0.2.3
2018-07-01 12:11:04 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform media_player.foobar: Could not install all requirements.
Hass is trying to install the required python package (pyfoobar2k) during startup and it seems to fail.
Can you please try to install the package manually using this command and see if you get the same error?
pip install pyfoobar2k==0.2.3
A brief research on your error message shows that it could be related to network/internet connection, could you please describe your environment?, are you using venv or a proxy?
Hi @keesak, i’m not sure i understand what stage fails, could please describe your environment and post the error message you get?
Have you tried installing the dependency manually for troubleshooting?
Thank you for responding.
Yes, I have tried to install manually and that is where I get the error that there is no module ‘pip.req’. See attached. My environment is Ubuntu 18.04 with Python 2.7 and 3.6
Hi,
Have you managed to get this to work using python 3.6?
Both the custom component and its dependency were written in python 3.5.x, recent versions of Hass use python 3.6+ and should be able to automatically install pyfoobar2k dependency on startup, during the initialization of the media_player.
Hi @cdkonecny
Thank you for letting me know, installation of the dependency via pip was also broken under python 3.6.
I’ve updated the component to fix this and also briefly tested it on home assistant v0.83.1
I moved the repository to Gitlab https://gitlab.com/ed0zer-projects/home-assistant/home-assistant-foobar2k. where you can download the latest version of foobar.py and place it in custom_components
Hey @ed0zer, I’m trying to setup Home Assistant and get the foobar support setup, however whenever I try to run the new setup.py from your last comment, I get the following error:
Hey @BRTPOB, dealing with setup.py is not required to make this work.
setup.py of the dependency package pyfoobar2k is used to package it into a python egg/wheel and make it available via pypi.org for installation via pip package manager, home assistant installs the dependencies automatically during startup.
the only home assistant setup needed here is placing the foobar.py file under <home_assistant_config_dir>/custom_components/media_player/
I hope this helps, let me know if you need further assistance.
I deleted my old post because it’s no longer relevant as I had to re-install HASS and the error went away. That said, I’m currently dealing with the following:
Traceback (most recent call last):
File "/opt/homeassistant/lib/python3.6/site-packages/homeassistant/loader.py", line 147, in _load_file
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 "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/offspring/.homeassistant/custom_components/media_player/foobar.py", line 14, in <module>
from homeassistant.components.media_player import (
ImportError: cannot import name 'MEDIA_TYPE_MUSIC'
Unable to find platform foobar
Platform not found: media_player.foobar
I’ve run pip3 install pyfoobar2k=0.2.3 and pip install pyfoobar2k=0.2.3 but neither command seems to resolve the issue. What am I doing wrong/missing here?
I know it relies on pyfoobar2k, but there’s no instructions on where to place the init.py or foobarhttp.py files. I tried in the root /media_player/pyfoobar2k folder but that seems to not work. Where should I be putting them to get this to work?