fhempy: spotify

Begonnen von dominik, 01 Januar 2021, 21:01:06

Vorheriges Thema - Nächstes Thema

dominik

Hallo,

da ich gerade die Spotify Integration für Googlecast gebaut habe, war es nur mehr eine Kleinigkeit ein Spotify Modul dafür zu bauen und daher habe ich das mal umgesetzt. Login erfolgt über seinen Spotify Account.

Mit dem Attribut "spotify_connect" auf "on" kann man auch direkt in FHEM Musik hören. Ja, richtig verstanden. Einfach FHEM Web öffnen und das Spotify Device öffnen und danach über die Spotify App "FHEM Web Player" als Device auswählen.

Installationsanleitung fhempy
https://github.com/dominikkarall/fhempy#installation

Spotify
https://github.com/dominikkarall/fhempy/blob/master/FHEM/bindings/python/fhempy/lib/spotify/README.md
fhempy -  https://github.com/fhempy/fhempy: GoogleCast, Tuya, UPnP, Ring, EQ3BT, Nespresso, Xiaomi, Spotify, Object Detection, ...
Kaffeespende: https://paypal.me/todominik

Superposchi

Hab das Device angelegt, hier das list:
Internals:
   .AttrList  update_status_interval update_devices_interval default_device spotify_connect:on,off IODev event-aggregator event-min-interval event-on-change-reading event-on-update-reading oldreadings stateFormat:textField-long timestamp-on-change-reading
   .FhemMetaInternals 1
   DEF        spotify
   FUUID      5fef78cc-f33f-793a-8c26-8a899e2cb8311976
   FVERSION   10_PythonModule.pm:0.182830/2019-01-16
   IODev      local_pybinding
   NAME       Spotify
   NR         188
   PYTHONTYPE spotify
   STATE      connected
   TYPE       PythonModule
   .attraggr:
   .attrminint:
   READINGS:
     2021-01-01 22:22:36   login           <html><a href="https://accounts.spotify.com/authorize?xxx</a><br></html>
     2021-01-01 22:32:23   state           connected
     2021-01-01 22:32:23   user            xxx xxx (xxx.xxx@gmx.de)
   args:
     Spotify
     PythonModule
     spotify
   argsh:
Attributes:
   IODev      local_pybinding
   group      Spotify
   icon       mqtt_bridge_2
   room       Devices
Autorisierungscode habe ich "geschwärzt", ist aber korrekt.

ZitatMit dem Attribut "spotify_connect" auf "on" kann man auch direkt in FHEM Musik hören. Ja, richtig verstanden. Einfach FHEM Web öffnen und das Spotify Device öffnen und danach über die Spotify App "FHEM Web Player" als Device auswählen.
Damit komme ich nicht klar.

Ich möchte gerne Spotify auf einem Google Nest ausgeben, dass ebenfalls mit Pythonbindings angebunden ist. Es sollte automatisch gestartet werden ohne eine Webseite/PC öffnen zu müssen, direkt vom Server per Event ausgelöst. Geht das?

dominik

Ja klar...
https://github.com/dominikkarall/fhempy/blob/master/FHEM/bindings/python/fhempy/lib/googlecast/README.md

googlecast übernimmt den Start und danach kannst du mit dem Spotify Modul weiter steuern.
fhempy -  https://github.com/fhempy/fhempy: GoogleCast, Tuya, UPnP, Ring, EQ3BT, Nespresso, Xiaomi, Spotify, Object Detection, ...
Kaffeespende: https://paypal.me/todominik

Superposchi

Das Spotify-Modul bekomme ich nicht ans Laufen, kommt immer die Fehlermeldung "Cannot load module Spotify"

Außerdem funktionieren meine Ausgabegeräte (Google Nest) seit dem Update nicht mehr. Hier das Listing von einem der Nests:
Internals:
   .AttrList  .*
   .FhemMetaInternals 1
   DEF        googlecast "Schlafzimmerlautsprecher"
   FUUID      5fba773c-f33f-793a-5007-c9bf0d1a378d6c54
   FVERSION   10_PythonModule.pm:0.182830/2019-01-16
   IODev      local_pybinding
   NAME       Schlafzimmerlautsprecher
   NR         92
   PYTHONTYPE googlecast
   STATE      Module failed to load: googlecast
Maybe you need to update fhempy on this or remote peer.

Stacktrace:
Traceback (most recent call last):
  File "/opt/fhem/.local/lib/python3.7/site-packages/fhempy/lib/fhem_pythonbinding.py", line 241, in _onMessage
    module_object = importlib.import_module(pymodule)
  File "/usr/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 "/opt/fhem/.local/lib/python3.7/site-packages/fhempy/lib/googlecast/googlecast.py", line 28, in <module>
    import spotify_token as st
ModuleNotFoundError: No module named 'spotify_token'

   TYPE       PythonModule
   .attraggr:
   .attreocr:
     .*
   .attrminint:
   .attrtocr:
     .*
   READINGS:
     2021-01-01 15:31:16   app_id         
     2020-11-22 20:55:53   cast_type       cast
     2021-01-01 02:10:52   connection      connected
     2021-01-01 15:31:16   display_name   
     2020-12-22 19:38:03   icon_url       
     2020-11-22 20:55:53   ignore_cec      0
     2020-11-22 20:55:53   is_active_input 0
     2020-11-22 20:55:53   is_stand_by     1
     2020-12-12 18:50:03   mediaAlbum     
     2020-12-12 18:50:03   mediaArtist     
     2020-12-28 21:35:08   mediaContentId 
     2020-12-28 21:35:08   mediaContentType
     2020-12-28 21:30:08   mediaCurrentPosPercent
     2020-12-28 21:30:08   mediaCurrentPosition
     2020-12-28 21:35:08   mediaDuration   
     2020-12-12 18:50:03   mediaImageHeight
     2020-12-12 18:50:03   mediaImageUrl   
     2020-12-12 18:50:03   mediaImageWidth
     2020-12-28 21:35:08   mediaPlayerState UNKNOWN
     2020-12-28 21:35:08   mediaStreamType UNKNOWN
     2020-12-12 18:50:03   mediaTitle     
     2020-11-22 20:55:53   model_name      Google Nest Mini
     2020-11-22 20:55:53   mute            0
     2020-11-22 20:55:53   name            Schlafzimmerlautsprecher
     2021-01-01 15:31:16   session_id     
     2021-01-01 22:26:09   state           Module failed to load: googlecast
Maybe you need to update fhempy on this or remote peer.

Stacktrace:
Traceback (most recent call last):
  File "/opt/fhem/.local/lib/python3.7/site-packages/fhempy/lib/fhem_pythonbinding.py", line 241, in _onMessage
    module_object = importlib.import_module(pymodule)
  File "/usr/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 "/opt/fhem/.local/lib/python3.7/site-packages/fhempy/lib/googlecast/googlecast.py", line 28, in <module>
    import spotify_token as st
ModuleNotFoundError: No module named 'spotify_token'

     2021-01-01 15:31:16   status_text     
     2020-12-28 21:35:08   transport_id   
     2020-11-22 20:55:53   uuid            dbef8319-c89c-e735-11f6-ce7777b133b2
     2021-01-01 15:26:28   volume          26
   args:
     Schlafzimmerlautsprecher
     PythonModule
     googlecast
     Schlafzimmerlautsprecher
   argsh:
Attributes:
   IODev      local_pybinding
   event-on-change-reading .*
   group      Audiosystem
   icon       audio_loudness
   room       Devices,GAssistant
   timestamp-on-change-reading .*
   userattr   favorite_1 favorite_2 favorite_3 favorite_4 favorite_5
   verbose    2

Müssen die neu angelegt werden?

dominik

Das fhempy spotify Modul hast du schon am Laufen, sonst würdest du deinen Username nicht sehen.

Mach mal
sudo -u fhem pip3 install spotify_token
danach FHEM Neustart. Aus irgendeinem Grund ist das bei dir nicht automatisch installiert worden.
fhempy -  https://github.com/fhempy/fhempy: GoogleCast, Tuya, UPnP, Ring, EQ3BT, Nespresso, Xiaomi, Spotify, Object Detection, ...
Kaffeespende: https://paypal.me/todominik

Superposchi

Wird mit einem Fehlercode 1 im Terminal beendet:
Collecting spotify_token                                                                                                                                                                                                                       
  Downloading https://files.pythonhosted.org/packages/d6/f5/9bf0e6664d6afa27e7329c949707d9c3ce143b1154895d0f49b836952bf4/spotify_token-1.0.0-py2.py3-none-any.whl                                                                               
Collecting beautifulsoup4>=4.8.1 (from spotify_token)                                                                                                                                                                                           
  Downloading https://files.pythonhosted.org/packages/d1/41/e6495bd7d3781cee623ce23ea6ac73282a373088fcd0ddc809a047b18eae/beautifulsoup4-4.9.3-py3-none-any.whl (115kB)                                                                         
    100% |████████████████████████████████| 122kB 2.2MB/s                                                                                                                                                                                       
Collecting lxml>=4.4.1 (from spotify_token)                                                                                                                                                                                                     
  Downloading https://files.pythonhosted.org/packages/db/f7/43fecb94d66959c1e23aa53d6161231dca0e93ec500224cf31b3c4073e37/lxml-4.6.2.tar.gz (3.2MB)                                                                                             
    100% |████████████████████████████████| 3.2MB 114kB/s                                                                                                                                                                                       
    Complete output from command python setup.py egg_info:                                                                                                                                                                                     
    Building lxml version 4.6.2.                                                                                                                                                                                                               
    Building without Cython.                                                                                                                                                                                                                   
    Error: Please make sure the libxml2 and libxslt development packages are installed.                                                                                                                                                         
                                                                                                                                                                                                                                               
    ----------------------------------------                                                                                                                                                                                                   
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-tywvj4bw/lxml/

dominik

sudo apt install libxml2-dev libxslt-dev

Was hast du für ein System? RPi?
fhempy -  https://github.com/fhempy/fhempy: GoogleCast, Tuya, UPnP, Ring, EQ3BT, Nespresso, Xiaomi, Spotify, Object Detection, ...
Kaffeespende: https://paypal.me/todominik

Superposchi

#7
Nach einem Neustart des Containers steht bei allen Googlecast Devices  "Installing updates..."

P.S. gerade ist beim ersten Device die Anzeige auf "Installation finished. Define now..." gewechselt und er versucht offensichtlich Fhem neuzustarten

Mein Fhem läuft in einem Docker Container auf einem QNAP NAS. Befehl kann ich im Augenblick nicht ausführen, Fhem muss erst mal korrekt gestartet sein. Melde mich dann noch mal.

Super, jetzt hat sich das halbe NAS abgeschossen nach dem Update. Ich komme weder an den Fhem Container dran noch an andere Anwendungen die auf dem NAS laufen.

dominik

FHEM wird durch das Modul nicht neu gestartet. Es führt nur das Define aus nachdem alles installiert ist.

Was meinst mit abgeschossen? Ich hab kein Dicker und kein NAS.
fhempy -  https://github.com/fhempy/fhempy: GoogleCast, Tuya, UPnP, Ring, EQ3BT, Nespresso, Xiaomi, Spotify, Object Detection, ...
Kaffeespende: https://paypal.me/todominik

Superposchi

Also NAS ist wieder da, keine Ahnung was das gerade war.

Die Devices stehen alle wieder auf "Installing updates..."
Zusetzlich ist mein Pushover-Device jetzt auf "Disconnected"

Der Befehl wurde komplett ausgeführt.

Mit abgeschossen meine ich, das nichts mehr funktioniert, die Webanwendungen sind nicht erreichbar, die Container gestoppt, quasi runtergefahren.

dominik

Hast jetzt schon per apt installiert?
fhempy -  https://github.com/fhempy/fhempy: GoogleCast, Tuya, UPnP, Ring, EQ3BT, Nespresso, Xiaomi, Spotify, Object Detection, ...
Kaffeespende: https://paypal.me/todominik

Superposchi

Ja hab ich, und auch neugestartet. Bis auf die Googlecast-Devices ist wieder alles connected bzw. opened. Nur die Cast-Devices zeigen nach wie vor "Installing updates..." an.

dominik

Dann bitte das PythonBinding Log posten.
fhempy -  https://github.com/fhempy/fhempy: GoogleCast, Tuya, UPnP, Ring, EQ3BT, Nespresso, Xiaomi, Spotify, Object Detection, ...
Kaffeespende: https://paypal.me/todominik

Superposchi

Hab auch gerade mal parallel probiert was über das Spotify-Device abzuspielen.

set Spotify play https://open.spotify.com/playlist/2RxtpesK6vFl9g4q9YQdwD kommt kein Ton raus, weder auf dem Notebook, noch auf einem anderen Gerät.
Mir ist auch nicht klar, wie mit diesem Befehl ein anderes Gerät wie z.B. der Google-Nest (Wohnzimmerlautsprecher) angesprochen werden soll.

dominik

Deine Installation von spotify-token schlägt immer fehl. Kann ich morgen genauer schauen

Spotify: Premium required steht im Log, mit Free Account geht es nicht.
fhempy -  https://github.com/fhempy/fhempy: GoogleCast, Tuya, UPnP, Ring, EQ3BT, Nespresso, Xiaomi, Spotify, Object Detection, ...
Kaffeespende: https://paypal.me/todominik