Spotify Integration

Begonnen von gloob, 07 Juni 2015, 11:34:15

Vorheriges Thema - Nächstes Thema

gloob

Hallo,

Gibt es eigentlich eine Möglichkeit Spotify in FHEM zu steuern?
Ich habe hier 3 Spotify Connect Receiver Module und würde die gerne ansteuern.
Raspberry Pi 3 | miniCUL 433MHz | nanoCUL 868 MHz | nanoCUL 433 MHz | MySensors WLAN Gateway | LaCrosse WLAN Gateway | SignalESP 433 MHz | SignalESP 868 MHz | HM-MOD-UART WLAN Gateway | IR - 360 Grad WLAN Gateway

gravidi

Hallo Gloob,

ich meine es gibt keine Spotify connect Receiver Module. Du meinst sicherleich Receiver/Geräte die Spotify Connect haben und somit Spotify nutzen können.
Jenach Gerätetyp gibt es vielleicht ein Modul für Fhem wo du wiederum über das Gerät Spotify ansprechen kannst.

Vielleicht schreibst du mal was für Geräte du genau hast.

Grüße

Grav
FHEM: 5.6 RPI2 / CUL / BLUETOOTH / HMCFGLAN
ESXi HomeServer
CISCO WAP371 AC Cluster / 3 APs
CISCO ASA5505 SEC
Zodac HTPC & 2x RPI HTPC / 2x Trendnet HD IPCam PoE

gloob

Hallo,

Ich habe mehrere Rocki Play von http://www.myrocki.com/.

Diese kann ich aus der Spotify iPhone App auch bedienen. Schöner wäre natürlich eine Integration in FHEM.

Anfang würde es mir reichen die Musik zu starten oder zu stoppen.
Raspberry Pi 3 | miniCUL 433MHz | nanoCUL 868 MHz | nanoCUL 433 MHz | MySensors WLAN Gateway | LaCrosse WLAN Gateway | SignalESP 433 MHz | SignalESP 868 MHz | HM-MOD-UART WLAN Gateway | IR - 360 Grad WLAN Gateway

peterchen89

Gibt übrigens für Spotify Connect auch ein Open Source Projekt https://github.com/Fornoth/spotify-connect-web. Funktioniert bei mir auch schon auf dem Raspi :-).
FHEM 5.5 auf HP ProLiant MicroServer G7 N54L 8 GB Ubuntu 14.04 LTS.
1x HM-CFG-LAN, 1x HM-CFG-USB, 7x HM-CC-RT-DN, 5x HM-SEC-SC-2, 1x HM-SEC-SCo, 2x HM-TC-IT-WM-W-EU, 2x HM-LC-Sw1-Pl, 2x HM-ES-PMSw1-Pl, 4x HM-PB-2-WM55-2, 1x HM-PB-6-WM55, 1x HM-WDS10-TH-O, 1x CUL433, 6x Pollin Funksteckdose

funt4stic

Hallo peterchen89,

ich bin leider ziemlicher Neuling im Bereich FHEM und Linux. Jetzt versuche ich seit drei Tagen dieses Spotify-Connect-Web zu installieren und kriege es einfach nicht ans Laufen. Vielleicht kannst du oder irgendwer anders ja helfen.

Bei dem verwendeten System handelt es sich um Ubuntu Server 14.04.2 LTS auf einem alten Asus Eeepc.

Wenn ich die Anleitung auf Github zum Spotiy-Connect-Web befolge (Quickstart using a prebuild Chroot), dann bekomme ich am Ende, wenn ich das Programm starten will

./spotify-connect-web.sh --username 12345678 --password xyz123 --bitrate 320

Die folgende Fehlermeldung:

chroot: der Befehl ,,bash" konnte nicht ausgeführt werden: Exec format error

Wenn ich einen Container mit Docker erstellen will mit

sudo docker build -t spotify-connect-web .

gibt's die folgende Fehlermeldung

Sending build context to Docker daemon 353.8 kB
Sending build context to Docker daemon
Step 0 : FROM armelbuild/debian:jessie
---> 17874659bb09
Step 1 : RUN apt-get update
---> Running in e476f7925319
2015/07/13 19:58:57 exec format error
2015/07/13 21:58:58 The command [/bin/sh -c apt-get update] returned a non-zero code: 1


Ich habe leider keine Ahnung, was ich tun soll...

Gruß
Jan

Wernieman

Kenne mich jetzt mit Spotify nicht aus, aber Deine erste Fehlermeldung chroot: der Befehl ,,bash" konnte nicht ausgeführt werden: Exec format error bedeutet, das Deine chhroot-Umgebung kaputt ist. Das dort befindliche "bash", unter Unix auch "nur" in Programm", ist eben nicht ein Funktionierendes. Wie hast Du chroot-Umgebung runtergeladen/installiert?

- Bitte um Input für Output
- When there is a Shell, there is a Way
- Wann war Dein letztes Backup?

Wie man Fragen stellt: https://tty1.net/smart-questions_de.html

funt4stic

#6
Das chroot habe ich anhand der Anleitung auf https://github.com/Fornoth/spotify-connect-web installiert.

curl -O http://spotify-connect-web.s3-website.eu-central-1.amazonaws.com/spotify-connect-web.sh
chmod u+x spotify-connect-web.sh
./spotify-connect-web.sh install


Das hat auch soweit ohne Fehlermeldung installiert.

Die ganze Anleitung zu dem Github-Projekt ist für mich als Linux-Laie ziemlich unverständlich. Ich brauche aber unbedingt eine Lösung, um meinen Spotify-Connect-Receiver über das Terminal anzusteuern. Eine andere Lösung als diese, die ohne einen Spotify Client funktioniert habe ich nicht finden können.


Wernieman

Habe mir mal das Script angeguckt .. für die Fehleranalyse würde ich vorschlagen, das Du es mal manuell ausprobierst

Hier mal der Inhalt des Scriptes:

#!/bin/bash
set -e

DIR=~/spotify-connect-web-chroot

if [ "$1" == "install" ]; then
        mkdir -p $DIR
        cd $DIR
        curl http://spotify-connect-web.s3-website.eu-central-1.amazonaws.com/spotify-connect-web.tar.gz | sudo tar xz
else
        trap "sudo umount $DIR/dev $DIR/proc" EXIT
        sudo mount --bind /dev $DIR/dev
        sudo mount -t proc proc $DIR/proc/
        sudo cp /etc/resolv.conf $DIR/etc/
        sudo chroot $DIR bash -c "cd /usr/src/app && python main.py $*"
fi


Und mal die "Manuelle" Ausführung, als User, der es dann starten soll:

DIR=~/spotify-connect-web-chroot
mkdir $DIR
cd $DIR
wget http://spotify-connect-web.s3-website.eu-central-1.amazonaws.com/spotify-connect-web.tar.gz
tar -xzf spotify-connect-web.tar.gz


Und Ergebnis bitte Melden ...
- Bitte um Input für Output
- When there is a Shell, there is a Way
- Wann war Dein letztes Backup?

Wie man Fragen stellt: https://tty1.net/smart-questions_de.html

funt4stic

Also, ich habe es mal manuel installiert, wie du es beschrieben hast...


funt4stic@ubuntu:~$ ls
fhem-5.6.deb  git  spotify_appkey.key
funt4stic@ubuntu:~$ DIR=~/spotify-connect-web-chroot
funt4stic@ubuntu:~$ mkdir $DIR
funt4stic@ubuntu:~$ cd $DIR
funt4stic@ubuntu:~/spotify-connect-web-chroot$ wget http://spotify-connect-web.s3-website.eu-central-1.amazonaws.com/spotify-connect-web.tar.gz
--2015-07-14 16:24:58--  http://spotify-connect-web.s3-website.eu-central-1.amazonaws.com/spotify-connect-web.tar.gz
Auflösen des Hostnamen »spotify-connect-web.s3-website.eu-central-1.amazonaws.com (spotify-connect-web.s3-website.eu-central-1.amazonaws.com)«... 54.231.194.39
Verbindungsaufbau zu spotify-connect-web.s3-website.eu-central-1.amazonaws.com (spotify-connect-web.s3-website.eu-central-1.amazonaws.com)|54.231.194.39|:80... verbunden.
HTTP-Anforderung gesendet, warte auf Antwort... 200 OK
Länge: 179138368 (171M) [application/x-tar]
In »»spotify-connect-web.tar.gz«« speichern.

100%[======================================>] 179.138.368 9,94MB/s   in 19s

2015-07-14 16:25:18 (8,81 MB/s) - »»spotify-connect-web.tar.gz«« gespeichert [179138368/179138368]

funt4stic@ubuntu:~/spotify-connect-web-chroot$ tar -xzf spotify-connect-web.tar.gz
funt4stic@ubuntu:~/spotify-connect-web-chroot$ ls
bin   dev  home  media  opt   root  sbin                        srv  tmp  var
boot  etc  lib   mnt    proc  run   spotify-connect-web.tar.gz  sys  usr
funt4stic@ubuntu:~/spotify-connect-web-chroot$


Das hat also ohne Fehlermeldung funktioniert. Danach habe ich die Befehle im "else" Teil der Datei ausgeführt...

funt4stic@ubuntu:~/spotify-connect-web-chroot$ trap "sudo umount $DIR/dev $DIR/proc" EXIT
funt4stic@ubuntu:~/spotify-connect-web-chroot$ sudo mount --bind /dev $DIR/dev
[sudo] password for funt4stic:
funt4stic@ubuntu:~/spotify-connect-web-chroot$ sudo mount -t proc proc $DIR/proc/
funt4stic@ubuntu:~/spotify-connect-web-chroot$ sudo cp /etc/resolv.conf $DIR/etc
funt4stic@ubuntu:~/spotify-connect-web-chroot$ sudo chroot $DIR bash -c "cd /usr/src/app && python main.py $*"
chroot: der Befehl ,,bash" konnte nicht ausgeführt werden: Exec format error
funt4stic@ubuntu:~/spotify-connect-web-chroot$


Dieser letzte Befehl scheint also fehlerhaft zu sein...

sudo chroot $DIR bash -c "cd /usr/src/app && python main.py $*"

Gruß
Jan




Wernieman

Hast Du ein 64 oder ein 32Bit-System?

Muß ich mir mal heute Abend auf meinem System ansehen ....
- Bitte um Input für Output
- When there is a Shell, there is a Way
- Wann war Dein letztes Backup?

Wie man Fragen stellt: https://tty1.net/smart-questions_de.html

funt4stic

Ich habe ein 32bit System.

Anscheinend stimmt mit der chroot-Umgebung etwas nicht. Ohne chroot-Umgebung kann ich die Main.py ausführen...

sudo python main.py

... ich bekomme dann allerdings die folgende Fehlermeldung...

Zitat/usr/bin/ld: Inkompatible /usr/lib/gcc/i686-linux-gnu/4.8/../../../../lib/libspotify_embedded_shared.so wird übersprungen bei der Suche nach -lspotify_embedded_shared
/usr/bin/ld: Inkompatible /usr/lib/../lib/libspotify_embedded_shared.so wird übersprungen bei der Suche nach -lspotify_embedded_shared
/usr/bin/ld: Inkompatible /usr/lib/gcc/i686-linux-gnu/4.8/../../../libspotify_embedded_shared.so wird übersprungen bei der Suche nach -lspotify_embedded_shared
/usr/bin/ld: Inkompatible //usr/lib/libspotify_embedded_shared.so wird übersprungen bei der Suche nach -lspotify_embedded_shared
/usr/bin/ld: cannot find -lspotify_embedded_shared
collect2: error: ld returned 1 exit status
Traceback (most recent call last):
  File "main.py", line 8, in <module>
    from connect_ffi import ffi, lib
  File "/home/funt4stic/spotify-connect-web-chroot/usr/src/app/connect_ffi.py", line 19, in <module>
    libraries=[str('spotify_embedded_shared')])
  File "/usr/local/lib/python2.7/dist-packages/cffi/api.py", line 373, in verify
    lib = self.verifier.load_library()
  File "/usr/local/lib/python2.7/dist-packages/cffi/verifier.py", line 96, in load_library
    self._compile_module()
  File "/usr/local/lib/python2.7/dist-packages/cffi/verifier.py", line 192, in _compile_module
    outputfilename = ffiplatform.compile(tmpdir, self.get_extension())
  File "/usr/local/lib/python2.7/dist-packages/cffi/ffiplatform.py", line 38, in compile
    outputfilename = _build(tmpdir, ext)
  File "/usr/local/lib/python2.7/dist-packages/cffi/ffiplatform.py", line 65, in _build
    raise VerificationError('%s: %s' % (e.__class__.__name__, e))
cffi.ffiplatform.VerificationError: LinkError: command 'i686-linux-gnu-gcc' failed with exit status 1

Die angeblich fehlende Datei "libspotify_embedded_shared.so". Die Datei ist aber im Verzeichnis /usr/lib vorhanden. Laut Anleitung soll die entsprechende Datei aus der "Rocki Play" Firmware ja funktionieren.

Ich bin mit meinem Latein am Ende...

Wernieman

Gibt es ein Supportforum o.Ä. dafür? Etwas Stimmt mit der chroot-Umgebung, bzw. dem enthaltendem bash nicht ....

p.s. kannst Du mal ein file auf die bash in der chroot Umgebung machen? Also

file /pfad/zur/chroot/Umgebung/wo/bash/liegt/bash

Falls Du nicht weist, wo bash liegt:
cd /pfad/zur/chroot/Umgebung
find . -name bash -exec file {} \;
- Bitte um Input für Output
- When there is a Shell, there is a Way
- Wann war Dein letztes Backup?

Wie man Fragen stellt: https://tty1.net/smart-questions_de.html

funt4stic

#12
Hallo Wernieman,

ein Supportforum gibts meines Wissens nach nicht, nur die Projektseite auf Github.

Zitatbash: ELF 32-bit LSB  executable, ARM, EABI5 version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=8ab870f6f5cbbb621b85763f557b41832a3f3181, stripped

Ich habe das ganze inzwischen auf mal auf nem 64bit System getestet, das hat aber nichts geändert. Beim Ausführen der "main.py" ohne chroot bin ich etwas weitergekommen. Ich habe scheinbar eine kompatible"libspotify_embedded_shared.so" gefunden und musste noch einige Module installieren. Jetzt bekomme ich "nurnoch" folgende Fehlermeldung:

ZitatTraceback (most recent call last):
  File "main.py", line 8, in <module>
    from connect_ffi import ffi, lib
  File "/home/jan/spotify-connect-web-chroot/usr/src/app/connect_ffi.py", line 1, in <module>
    from cffi import FFI
ImportError: No module named cffi

Leider lässt sich CFFI nicht installieren  >:(

//EDIT: CFFI benötigte das Modul "python-dev" und ließ sich danach installieren.

jetzt bekomme ich die nächsten Fehler  :P

Zitat__pycache__/_cffi__x8b237976x2c265354.c: In function '_cffi_f_SpGetPreset':
__pycache__/_cffi__x8b237976x2c265354.c:1509:3: warning: passing argument 2 of 'SpGetPreset' from incompatible pointer type [enabled by default]
   { result = SpGetPreset(x0, x1); }
   ^
In file included from __pycache__/_cffi__x8b237976x2c265354.c:209:0:
./spotify.h:156:9: note: expected 'size_t *' but argument is of type 'unsigned int *'
SpError SpGetPreset(SpPreset *preset, size_t *size);
         ^
/usr/bin/ld: cannot find -lspotify_embedded_shared
collect2: error: ld returned 1 exit status
Traceback (most recent call last):
  File "main.py", line 8, in <module>
    from connect_ffi import ffi, lib
  File "/home/jan/spotify-connect-web-chroot/usr/src/app/connect_ffi.py", line 19, in <module>
    libraries=[str('spotify_embedded_shared')])
  File "/usr/local/lib/python2.7/dist-packages/cffi/api.py", line 373, in verify
    lib = self.verifier.load_library()
  File "/usr/local/lib/python2.7/dist-packages/cffi/verifier.py", line 96, in load_library
    self._compile_module()
  File "/usr/local/lib/python2.7/dist-packages/cffi/verifier.py", line 192, in _compile_module
    outputfilename = ffiplatform.compile(tmpdir, self.get_extension())
  File "/usr/local/lib/python2.7/dist-packages/cffi/ffiplatform.py", line 38, in compile
    outputfilename = _build(tmpdir, ext)
  File "/usr/local/lib/python2.7/dist-packages/cffi/ffiplatform.py", line 65, in _build
    raise VerificationError('%s: %s' % (e.__class__.__name__, e))
cffi.ffiplatform.VerificationError: LinkError: command 'x86_64-linux-gnu-gcc' failed with exit status 1

Ich denke, wenn peterchen89 sich nicht mehr meldet, bei dem es ja anscheinend läuft, dann gebe ich auf...



Wernieman

Du hast doch einen X86-Rechnerchen? Die bash ist aber laut file für ARM ....

Zu Deiner Fehlermeldung: Das sieht mir jetzt nach einem heftigen Fehler im Code aus ...
- Bitte um Input für Output
- When there is a Shell, there is a Way
- Wann war Dein letztes Backup?

Wie man Fragen stellt: https://tty1.net/smart-questions_de.html

okenny

Hate jemand diese Software mit FHEM integriert? Wenn so, wie?

Ich würde gerne FHEM nutzen um Lautstärke zu ändern, Wiederhabe anhalten usw....geht das?

neumann

Hallo zusammen!

Ich habe mich dem Thema nun angenommen und ein umfangreiches Modul zur Steuerung von Spotify (Connect) geschrieben.
Es ist bereits eingecheckt, schaut gerne mal rein :)
Bei Fragen in dem Thread: https://forum.fhem.de/index.php/topic,72490.0.html

Liebe Grüße
Oskar
Modulentwickler
- Spotify #72490
- Nello #75127