FHEM Forum

FHEM - Anwendungen => Multimedia => Thema gestartet von: gloob am 07 Juni 2015, 11:34:15

Titel: Spotify Integration
Beitrag von: gloob am 07 Juni 2015, 11:34:15
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.
Titel: Antw:Spotify Integration
Beitrag von: gravidi am 08 Juni 2015, 14:22:53
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
Titel: Antw:Spotify Integration
Beitrag von: gloob am 08 Juni 2015, 14:25:01
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.
Titel: Antw:Spotify Integration
Beitrag von: peterchen89 am 09 Juni 2015, 14:45:58
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 :-).
Titel: Antw:Spotify Integration
Beitrag von: funt4stic am 13 Juli 2015, 22:02:35
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
Titel: Antw:Spotify Integration
Beitrag von: Wernieman am 14 Juli 2015, 10:35:37
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?

Titel: Antw:Spotify Integration
Beitrag von: funt4stic am 14 Juli 2015, 11:10:20
Das chroot habe ich anhand der Anleitung auf https://github.com/Fornoth/spotify-connect-web (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.

Titel: Antw:Spotify Integration
Beitrag von: Wernieman am 14 Juli 2015, 11:51:23
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 ...
Titel: Antw:Spotify Integration
Beitrag von: funt4stic am 14 Juli 2015, 16:32:59
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



Titel: Antw:Spotify Integration
Beitrag von: Wernieman am 15 Juli 2015, 08:47:22
Hast Du ein 64 oder ein 32Bit-System?

Muß ich mir mal heute Abend auf meinem System ansehen ....
Titel: Antw:Spotify Integration
Beitrag von: funt4stic am 15 Juli 2015, 18:04:16
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...
Titel: Antw:Spotify Integration
Beitrag von: Wernieman am 15 Juli 2015, 20:26:07
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 {} \;
Titel: Antw:Spotify Integration
Beitrag von: funt4stic am 17 Juli 2015, 13:50:18
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...


Titel: Antw:Spotify Integration
Beitrag von: Wernieman am 17 Juli 2015, 14:56:12
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 ...
Titel: Antw:Spotify Integration
Beitrag von: okenny am 31 Dezember 2015, 20:41:27
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?
Titel: Antw:Spotify Integration
Beitrag von: neumann am 30 Mai 2017, 09:02:10
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 (https://forum.fhem.de/index.php/topic,72490.0.html)

Liebe Grüße
Oskar