Closed tb59427 closed 1 year ago
Hi,
interesting question. Did not try anything like that before.
Instead of calling the player in the container it might be possible to call vlc on the remote machine instead.
Which docker image do you use? karsten13/magicmirror
?
How do you start it? Plain docker, docker-compose, portainer or something else?
You will need to configure password-less ssh authentication with a key and map the directory containing the key to the container.
I use a container environment for development and do have a Hifiberry Amp2 connected to one of my mirrors. Maybe i do have time to test it the next days.
To get the volume buttons to work you will need to configure a custom command for the MMM-Volume, too.
Could not wait to try some things ;-)
The ssh approach works well in my setup. Things you need to do:
Create a ssh key pair. I.e. on the Pi with the Hifiberry connected:
mkdir /tmp/mirror-ssh
ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/pi/.ssh/id_rsa): /tmp/mirror-ssh/id_rsa
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /tmp/mirror-ssh/id_rsa
Your public key has been saved in /tmp/mirror-ssh/id_rsa.pub
The key fingerprint is:
SHA256:TD0CmsuQXOVuVx8w02+8ICxV27CBjpsopTQBV8EpqXc pi@nbtux
The key's randomart image is:
+---[RSA 3072]----
| ..o==o +++ |
| . +++o. .o+.* |
| +.oo. o=+ +o. |
| .o+oEooo+o..+ |
| oo=o.S+ ..o . |
| o...o . |
| . |
| |
| |
+----[SHA256]-----+
Allow password-less ssh access to the Hifiberry Host:
ssh-copy-id -i /tmp/mirror-ssh/id_rsa.pub pi@YOUR_HIFIBERRY_IP
Copy the dicrectory /tmp/mirror-ssh
to your Synology to a location you can map it to the mirror image
Configure the Mirror docker to use the image karsten13/magicmirror:fat
as the latest
image does not contain the ssh command
Configure the Mirror docker to map the directory "mirror-ssh" to the location /home/node/.ssh
in the container
Use the following custom command configuration for this module (replace HIFI_BERRY_IP
with the Ip of your Hifiberry Host):
{
module: "MMM-MplayerRadio",
header: "Radio",
position: "top_center",
config: {
customCommand: "/usr/bin/ssh",
customCommandArgs: ["pi@HIFI_BERRY_IP", "/usr/bin/vlc -I dummy ###URL###"],
stations: [
{
title: "Antenne.de",
url: "http://play.antenne.de/antenne.m3u",
logo: "https://upload.wikimedia.org/wikipedia/commons/a/ac/Antenne-bayern-logo.png",
},
],
},
},
Hi Tom,
am using bastilimbach/docker-magicmirror - can be easily configured via Synology's gui.
cheers -tb
Hi (again),
will try this out in the morning - busy this evening....thanks for your kind support.
cheers Torsten
The bastilimbach/docker-magicmirror
does contain the ssh command but you will need to map the mirror-ssh
directory to /root/.ssh
instead of /home/node/.ssh
.
Will report back here, once I had a chance to follow your guidelines...
Do you know if you are using "Alsa" or "Pulseaudio" on the HifiBerry?
If you use Bullseye
release of Raspberry OS you are using "Pulseaudio".
Dunno - uname -a says this Linux MasterLink 5.15.78-v7l #1 SMP Wed Feb 22 13:21:34 UTC 2023 armv7l GNU/Linux
If you use "Pulseaudio" you can place the two scripts in the attached zip file (getVolume.bash
and setVolume.bash
) into the home directory (usually /home/pi
) of your Hifiberry.
If you setup the password-less login successfully you can then configure MMM-Volume to call the scripts instead of the local ones:
{
module: "MMM-Volume",
position: "top_left", // It is meaningless. but you should set.
config: {
usePresetScript: null,
getVolumeScript: `ssh pi@HIFI_BERRY_IP \"/home/pi/getVolume.bash\"`, //get 0~100
setVolumeScript: `ssh pi@HIFI_BERRY_IP \"/home/pi/setVolume.bash #VOLUME#\"`, //set 0~100
volumeOnStart: 50,
}
},
Could you run
cat /etc/os-release
The result should look something like:
PRETTY_NAME="Raspbian GNU/Linux 11 (bullseye)"
NAME="Raspbian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"
By the way i would suggest to switch to the docker image karsten13/magicmirror:fat
. The one of bastilimbach
is pretty out-dated and karsten13
is one of the MagicMirror² maintainers.
But you will need to change some directory mappings to get the other image to work.
The output of uname -a
looks a little bit like you are running "HiFiBerryOS".
I did not try that till now. Maybe there is no vlc media player installed the audio control will not work.
Will need to check that out tomorrow but the output of cat /etc/os-release
would be very helpful.
NAME=Buildroot VERSION=2021.11-dirty ID=buildroot VERSION_ID=2021.11 PRETTY_NAME="Buildroot 2021.11"
I am pretty sure that's HiFiBerry OS. Maybe I can look at it tomorrow.
By the way i would suggest to switch to the docker image
karsten13/magicmirror:fat
. The one ofbastilimbach
is pretty out-dated andkarsten13
is one of the MagicMirror² maintainers.
Hmm - looking at the description this would require a pi to run. I am currently running my magic mirror server on my synology NAS, though. Switching to the more current version from Karsten would mean, I had to compeletely rebuild my pi setup. That would take some time I suppose.
And yes, the system I am running is HifiberryOS.
I did not try to run the image of karsten13
on my Synology but i run it on my Desktop which is a x64 Intel system.
But it makes no difference at the moment.
Just checked out HifiBerry OS and installed it with spare SD card. It is a closed system which does not have any option to install a player like vlc
.
It provides a REST-API which can be used to control the volume and/or start/stop the player.
But i do not see any chance to run a custom station or tell via REST to activate a specific station.
Yeah, found that,too, this morning.
Regarding the server version of karsten13 I'll try to install it once I understand the folder mapping requirements...
HifiBerry OS uses mpd
under the hood but i can not get the daemon to run a custom playlist.
There may be a chance to control mpd
with the preinstalled tool mpc
I think i found a way to wrap the commands to a simple script which can be used by the module.
With the attempt to install karsten13 version of magicmirror I managed to kill my whole install - neither the old nor the new install now works. So - reinstalling first :-)
Sh... Good luck with it.
I release a new version 0.0.11
of this module a few seconds ago which contains the wrapper for HiFiBerryOS and instructions in the Readme of how to use it.
I think the trickiest part is to setup the ssh authentication first now.
Edit: Fixed another bug. Please use latest 0.0.12
instead.
I found some more (old) bugs which i want to fix. Sorry for the short distances of the releases. There will be another one in a couple of minutes cause there are problems if stations get changed to quickly and a wrapper is used.
Version 0.0.13
is out now.
Station changes now should be possible, too.
I tried the fat
image of karsten13
on my DS420+ a few minutes ago.
There is one pitfall while creating the container cause the command to run needs to be specified. It can not be changed after the container has been created and needs to be npm run server
.
While creating the container, after the page where network is configured there is page with "Additional options" at the end. In the "Additional Options" there is a tab called "Ausführungsbefehl" (i use the german version, do not know how Synology named it in the english one).
docker/mm/css
docker/mm/modules
docker/mm/ssh
and mapped them to
/opt/magic_mirror/config
/opt/magic_mirror/css
/opt/magic_mirror/modules
/home/node/.ssh
You then can start the container and add a additional Terminal under Details
to run /bin/bash
.
In this terminal you can run the commands to clone the modules and install them.
I needed to change the ownership of the ssh folder to the user id of the user node
in the new terminal by calling:
chown -R 1000:1000 /home/node/.ssh
After this everything worked like a charm.
Hi Tom,
took a different route: installed all on a raspi now. Works really well - thanks for the work to integrate hifiberries. Works really well...
cheers Torsten
Maybe the Pi is the better choice anyway. Resources of the NAS are very limeted except you have one of the really big ones.
Great to hear that the HiFiBerryOS integration works. I will close the ticket then.
Hi Tom,
am contemplating adding this module to my magicmirror. I have a Hifiberry connected to my stereo and the Magicmirror runs on a different box (docker on synology NAS). Would it be possible (and if so, any pointers appreciated) to stream a radio station to a remote Hifiberry?
thanks for any pointers Torsten