Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. [Vorlage] Spotify Skript

    NEWS

    • ioBroker@Smart Living Forum Solingen, 14.06. - Agenda added

    • ioBroker goes Matter ... Matter Adapter in Stable

    • Monatsrückblick - April 2025

    [Vorlage] Spotify Skript

    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      mikiline last edited by

      • Die Playlist muss Laufen

      • Die Playlist muss im Spotify-Adapter bekannt sein

      Ansonsten kann ich Dir ohne Weitere Infos keine Angaben machen.

      1 Reply Last reply Reply Quote 0
      • R
        rnbprofi last edited by

        @mikiline:

        • Die Playlist muss Laufen

        • Die Playlist muss im Spotify-Adapter bekannt sein

        Ansonsten kann ich Dir ohne Weitere Infos keine Angaben machen. `

        Habe ich geprüft. Jetzt zeigt er mehr an, aber nicht die Liste. Folgend mein Script.

        ! createState("javascript.2.Spotify.PlayList.TrackList", function () {
        ! });
        ! createState("javascript.2.Spotify.PlayList.TrackTitle", function () {
        ! });
        ! createState("javascript.2.Spotify.PlayList.TrackID", function () {
        ! });
        ! createState("javascript.2.Spotify.PlayList.PlayThis", function () {
        ! });
        ! createState("javascript.2.Spotify.PlayList.PlayList", function () {
        ! });
        ! on({id: 'javascript.2.Spotify.PlaybackInfo.Playlist', change: "ne"}, function (obj) {
        ! var AktuellePlaylist = getState('javascript.2.Spotify.PlaybackInfo.Playlist').val;
        ! setState("javascript.2.Spotify.PlayList.PlayList"/javascript.2.Spotify.PlayList.TrackID/, AktuellePlaylist);
        ! str_AktuellePlaylist = AktuellePlaylist.replace(/ /g, '');
        ! str_AktuellePlaylist = 'javascript.2.Spotify.Playlists.' + str_AktuellePlaylist + '.Track_List';
        ! setState("javascript.2.Spotify.PlayList.TrackList"/javascript.2.Spotify.PlayList.TrackID/, str_AktuellePlaylist);
        ! var json = JSON.parse(JSON.stringify(getState(str_AktuellePlaylist).val));
        ! var PlayListid ;
        ! var PlayListTitle ;
        ! for(var i = 0; i < json.length; i++) {
        ! PlayListid += json__.id + ';';
        ! PlayListTitle += json__.title + ';';
        ! }
        ! PlayListid = PlayListid.slice(9,-1);
        ! PlayListTitle = PlayListTitle.slice(9,-1);
        ! setState("javascript.2.Spotify.PlayList.TrackID"/javascript.2.Spotify.PlayList.TrackID/, PlayListid);
        ! setState("javascript.2.Spotify.PlayList.TrackTitle"/javascript.2.Spotify.PlayList.TrackID/, PlayListTitle);
        ! });
        ! on({id: 'javascript.2.Spotify.PlayList.PlayThis', change: "ne"}, function (obj) {
        ! setState("javascript.2.Spotify.Player.TrackId"/track idto play/, getState("javascript.2.Spotify.PlayList.PlayThis").val);
        ! });____ __ 5211_screenshot_2018-04-07_07.58.42_preview.png __

        1 Reply Last reply Reply Quote 0
        • M
          mikiline last edited by

          die Variablen aus meinem Skript "spotify-premium.0." darfst du nicht ändern…..denn das ist der Spotify Adapter aus dem die Werte für das Skript geholt werden

          Du darfst wenn schon nur die "javascript.0." in Deine ändern.

          Wenn du mein Skript 1:1 übernimmst sollte es gehen.....denk du hast auch einen Javascript.0 Object

          1 Reply Last reply Reply Quote 0
          • R
            rnbprofi last edited by

            @mikiline:

            die Variablen aus meinem Skript "spotify-premium.0." darfst du nicht ändern…..denn das ist der Spotify Adapter aus dem die Werte für das Skript geholt werden

            Du darfst wenn schon nur die "javascript.0." in Deine ändern.

            Wenn du mein Skript 1:1 übernimmst sollte es gehen.....denk du hast auch einen Javascript.0 Object `

            Verstanden. Habe tatsächlich .2. da sich die erste Instanz verabschiedet hat… wenn ich neu installiere, da erstellt er automatisch die nächste Instanz...

            Muss ich dann auch "spotify-premium.0." auch auf "spotify-premium.2." ändern?

            1 Reply Last reply Reply Quote 0
            • M
              mikiline last edited by

              das änderst du in die instanz in der spotify-adapter läuft…....

              1 Reply Last reply Reply Quote 0
              • twonky
                twonky last edited by

                Nach einem Monat gibt es mal wieder eine neue Version vom Adapter: https://github.com/twonky4/ioBroker.spotify-premium

                Changelog:

                • automatisches Aktualisieren der Geräte und Playlisten (im Adapter konfigurierbar)

                • neuer State Devices.GERÄTNAME.is_available zeigt an ob ein Gerät verfügbar ist

                • zeigt Warnmeldung http 202 nur noch als debug und nur noch einmal an

                • die States Player.Shuffle, Player.Playlist_ID, Player.TrackId und Player.Volume zeigen ebenfalls den aktuellen Wert an

                • neue States Playlists.PLAYLISTNAME.image_url, PlaybackInfo.Playlist_image_url, PlaybackInfo.Album_image_url

                • den State PlaybackInfo.image_url als deprecated markiert. Wird bei Neuinstallation nicht mehr mit angelegt und in zukünftigen Versionen nicht mehr aktualisiert

                • das Ändern des State Playlists.PLAYLISTNAME.Track_List funktioniert nun wie in Luckys Skript. Man kann direkt einen Titel aus einer Playlist abspielen, wenn der State mit dessen Positionsnummer befüllt wird.

                1 Reply Last reply Reply Quote 0
                • M
                  mikiline last edited by

                  Super und herzlichen Dank für die Mühe!

                  Der State "Playlists.PLAYLISTNAME.Track_ID" wird bei mir nicht erstellt…...muss ich etwas zusätzliches tun?

                  Löschen und neu Anlegen oder sowas?
                  2678_spotify.png

                  1 Reply Last reply Reply Quote 0
                  • M
                    mikiline last edited by

                    So….hab mal alle Playlists gelöscht und neu einlesen lassen.

                    nur werden die States image_url erstellt, jedoch der State Track_ID immer noch nicht. Des Weiteren ist mir aufgefallen, das unter der Track_List nur noch ein Liedname steht. Das war vorher anders, oder ? stand da nicht [Object][object] ?

                    Anbei noch ein Bild der Objecte einer Playlist nach dem Adapter Update (über Github, keine Neuinstallation)
                    2678_spotify.png

                    1 Reply Last reply Reply Quote 0
                    • twonky
                      twonky last edited by

                      Sorry habe mich verschrieben. Ich meinte nicht Playlists.PLAYLISTNAME.Track_ID sondern Playlists.PLAYLISTNAME.Track_List.

                      Ich bin durcheinander gekommen, weil Track_ID ein common-part von Track_List ist.

                      1 Reply Last reply Reply Quote 0
                      • M
                        mikiline last edited by

                        @twonky:

                        • das Ändern des State Playlists.PLAYLISTNAME.Track_List funktioniert nun wie in Luckys Skript. Man kann direkt einen Titel aus einer Playlist abspielen, wenn der State mit dessen Positionsnummer befüllt wird.

                          Dann hört die Playlist aber auf zu spielen und der Player befindet sich im "Track" Modus. Heisst: die Playlist wird nicht weiter abgespielt sobald der ausgwählte Track abgespielt wurde.

                          Ist das korrekt? `

                        1 Reply Last reply Reply Quote 0
                        • twonky
                          twonky last edited by

                          Ja, das ist korrekt. War in Lucky's Skript so.

                          Aber wo ich jetzt so drüber nachdenke macht es vlt. mehr Sinn die PlayList an der gegebenen Stelle zu starten.

                          1 Reply Last reply Reply Quote 0
                          • M
                            mikiline last edited by

                            @twonky:

                            Ja, das ist korrekt. War in Lucky's Skript so.

                            Aber wo ich jetzt so drüber nachdenke macht es vlt. mehr Sinn die PlayList an der gegebenen Stelle zu starten. `

                            Genau deswegen die Frage 😉

                            Denn die Playlist ist dann nämlich raus und man muss wieder manuell die Playlist anstossen…...

                            Ps: nicht starten, sondern dort weiter abzuspielen (ob mit Shuffle "on" oder ohne)

                            Hier noch mein angepasstes Skript für die Titelauswahl in einer Playlist auf die neue Version vom Spotify Adapter

                            ! createState("javascript.0.Spotify.PlayList.TrackList", function () {
                            ! });
                            ! createState("javascript.0.Spotify.PlayList.TrackID", function () {
                            ! });
                            ! createState("javascript.0.Spotify.PlayList.PlayThis", function () {
                            ! });
                            ! createState("javascript.0.Spotify.PlayTrackInList", function () {
                            ! });
                            ! on({id: 'spotify-premium.0.PlaybackInfo.Playlist', change: "ne"}, function (obj) {
                            ! if (getState('spotify-premium.0.PlaybackInfo.Playlist').val.length > 3) {
                            ! var str_AktuellePlaylist = getState('spotify-premium.0.PlaybackInfo.Playlist').val;
                            ! str_AktuellePlaylist = str_AktuellePlaylist.replace(/ /g, '');
                            ! var str_AktuelleTracklist = getState('spotify-premium.0.Playlists.' + str_AktuellePlaylist + '.Track_List_String').val;
                            ! setState('javascript.0.Spotify.PlayTrackInList'/javascript.0.Spotify.PlayList.TrackID/, 'spotify-premium.0.Playlists.' + str_AktuellePlaylist + '.Track_List');
                            ! setState('javascript.0.Spotify.PlayList.TrackList'/javascript.0.Spotify.PlayList.TrackID/, str_AktuelleTracklist);
                            ! var TrackID = str_AktuelleTracklist.split(';');
                            ! TrackID.forEach (listArray);
                            ! MyTrackID = MyTrackID.slice(9,-1);
                            ! var MyTrackID;
                            ! function listArray (elem, index) {
                            ! MyTrackID += index + ";";
                            ! }
                            ! setState("javascript.0.Spotify.PlayList.TrackID"/javascript.0.Spotify.PlayList.TrackID/, MyTrackID);
                            ! }
                            ! });
                            ! on({id: 'javascript.0.Spotify.PlayList.PlayThis', change: "ne"}, function (obj) {
                            ! setState(getState('javascript.0.Spotify.PlayTrackInList').val, getState("javascript.0.Spotify.PlayList.PlayThis").val);
                            ! });

                            1 Reply Last reply Reply Quote 0
                            • S
                              spraxel last edited by

                              Nun hat es mich erwischt. Spotify Premium Adapter läuft nicht mehr.

                              Bekomme laufend folgende Fehlermeldung im Log

                              ! host.ioBroker-Pi 2018-04-24 20:55:01.237 info Restart adapter system.adapter.spotify-premium.0 because enabled
                              ! host.ioBroker-Pi 2018-04-24 20:55:01.237 error instance system.adapter.spotify-premium.0 terminated with code 0 (OK)
                              ! Caught 2018-04-24 20:55:01.237 error by controller[0]: at IncomingMessage.g (events.js:292:16)
                              ! Caught 2018-04-24 20:55:01.236 error by controller[0]: at IncomingMessage. (/opt/iobroker/node_modules/iobroker.spotify-premium/node_modules/request/request.js:1085:12)
                              ! Caught 2018-04-24 20:55:01.236 error by controller[0]: at Request.emit (events.js:188:7)
                              ! Caught 2018-04-24 20:55:01.236 error by controller[0]: at emitOne (events.js:96:13)
                              ! Caught 2018-04-24 20:55:01.236 error by controller[0]: at Request. (/opt/iobroker/node_modules/iobroker.spotify-premium/node_modules/request/request.js:1163:10)
                              ! Caught 2018-04-24 20:55:01.236 error by controller[0]: at Request.emit (events.js:191:7)
                              ! Caught 2018-04-24 20:55:01.236 error by controller[0]: at emitTwo (events.js:106:13)
                              ! Caught 2018-04-24 20:55:01.236 error by controller[0]: at Request.self.callback (/opt/iobroker/node_modules/iobroker.spotify-premium/node_modules/request/request.js:186:22)
                              ! Caught 2018-04-24 20:55:01.235 error by controller[0]: at Request._callback (/opt/iobroker/node_modules/iobroker.spotify-premium/main.js:166:45)
                              ! Caught 2018-04-24 20:55:01.235 error by controller[0]: at Object.parse (native)
                              ! Caught 2018-04-24 20:55:01.234 error by controller[0]: SyntaxError: Unexpected end of JSON input
                              ! spotify-premium.0 2018-04-24 20:55:01.205 info terminating
                              ! spotify-premium.0 2018-04-24 20:55:01.165 error at IncomingMessage.g (events.js:292:16)
                              ! spotify-premium.0 2018-04-24 20:55:01.165 error at IncomingMessage. (/opt/iobroker/node_modules/iobroker.spotify-premium/node_modules/request/request.js:1085:12)
                              ! spotify-premium.0 2018-04-24 20:55:01.165 error at Request.emit (events.js:188:7)
                              ! spotify-premium.0 2018-04-24 20:55:01.165 error at emitOne (events.js:96:13)
                              ! spotify-premium.0 2018-04-24 20:55:01.165 error at Request. (/opt/iobroker/node_modules/iobroker.spotify-premium/node_modules/request/request.js:1163:10)
                              ! spotify-premium.0 2018-04-24 20:55:01.165 error at Request.emit (events.js:191:7)
                              ! spotify-premium.0 2018-04-24 20:55:01.165 error at emitTwo (events.js:106:13)
                              ! spotify-premium.0 2018-04-24 20:55:01.165 error at Request.self.callback (/opt/iobroker/node_modules/iobroker.spotify-premium/node_modules/request/request.js:186:22)
                              ! spotify-premium.0 2018-04-24 20:55:01.165 error at Request._callback (/opt/iobroker/node_modules/iobroker.spotify-premium/main.js:166:45)
                              ! spotify-premium.0 2018-04-24 20:55:01.165 error at Object.parse (native)
                              ! spotify-premium.0 2018-04-24 20:55:01.165 error SyntaxError: Unexpected end of JSON input
                              ! spotify-premium.0 2018-04-24 20:55:01.160 error uncaught exception: Unexpected end of JSON input

                              Jemand ne Ahnung woran es liegen könnte? Habe nichts geändert und es lief jetzt Wochen lang ohne Probleme

                              1 Reply Last reply Reply Quote 0
                              • S
                                spraxel last edited by

                                Jetzt gerade mit neuer Client ID und Client Secret probiert und auch das funktioniert nicht.

                                1 Reply Last reply Reply Quote 0
                                • Mic
                                  Mic Developer last edited by

                                  Das gleiche leider bei mir. Habe auch die Instanz und Objekte "spotify-premium.0" gelöscht, neu hinzugefügt, Autorisierung neu durchgeführt, etc., und es kommt immer wieder zu den Fehlern.

                                  ! host.raspberrypi 2018-04-24 21:19:55.242 info Restart adapter system.adapter.spotify-premium.0 because enabled
                                  ! host.raspberrypi 2018-04-24 21:19:55.242 error instance system.adapter.spotify-premium.0 terminated with code 0 (OK)
                                  ! host.raspberrypi 2018-04-24 21:19:55.241 error Caught by controller[0]: at IncomingMessage.g (events.js:292:16)
                                  ! host.raspberrypi 2018-04-24 21:19:55.241 error Caught by controller[0]: at IncomingMessage. (/opt/iobroker/node_modules/iobroker.spotify-premium/node_modules/request/request.js:1085:12)
                                  ! host.raspberrypi 2018-04-24 21:19:55.241 error Caught by controller[0]: at Request.emit (events.js:188:7)
                                  ! host.raspberrypi 2018-04-24 21:19:55.239 error Caught by controller[0]: at emitOne (events.js:96:13)
                                  ! host.raspberrypi 2018-04-24 21:19:55.239 error Caught by controller[0]: at Request. (/opt/iobroker/node_modules/iobroker.spotify-premium/node_modules/request/request.js:1163:10)
                                  ! host.raspberrypi 2018-04-24 21:19:55.239 error Caught by controller[0]: at Request.emit (events.js:191:7)
                                  ! host.raspberrypi 2018-04-24 21:19:55.239 error Caught by controller[0]: at emitTwo (events.js:106:13)
                                  ! host.raspberrypi 2018-04-24 21:19:55.239 error Caught by controller[0]: at Request.self.callback (/opt/iobroker/node_modules/iobroker.spotify-premium/node_modules/request/request.js:186:22)
                                  ! host.raspberrypi 2018-04-24 21:19:55.239 error Caught by controller[0]: at Request._callback (/opt/iobroker/node_modules/iobroker.spotify-premium/main.js:166:45)
                                  ! host.raspberrypi 2018-04-24 21:19:55.238 error Caught by controller[0]: at Object.parse (native)
                                  ! host.raspberrypi 2018-04-24 21:19:55.237 error Caught by controller[0]: SyntaxError: Unexpected end of JSON input
                                  ! spotify-premium.0 2018-04-24 21:19:55.168 error SyntaxError: Unexpected end of JSON input at Object.parse (native) at Request._callback (/opt/iobroker/node_modules/iobroker.spotify-premium/main.js:166:45) at Request.self.callback (/opt/
                                  ! spotify-premium.0 2018-04-24 21:19:55.165 error uncaught exception: Unexpected end of JSON input
                                  ! spotify-premium.0 2018-04-24 21:19:49.543 info starting. Version 0.1.2 in /opt/iobroker/node_modules/iobroker.spotify-premium, node: v6.14.1

                                  1 Reply Last reply Reply Quote 0
                                  • twonky
                                    twonky last edited by

                                    Ich habe das Problem auch. Schein aktuell eine Störung bei Spotify zu sein, der Dienst meldet zwar ein http 200, sendet aber keine Daten. Heißt also einfach warten, bis es wieder geht.

                                    1 Reply Last reply Reply Quote 0
                                    • Mic
                                      Mic Developer last edited by

                                      Danke für Deine sehr schnelle Rückmeldung twonky, dann lasst uns mal abwarten.

                                      Übrigens herzlichen Dank für Deine Arbeit, die Du hier rein steckst! Dies ebenso an Lucky, der das Script gestartet hat. Very much appreciated

                                      1 Reply Last reply Reply Quote 0
                                      • S
                                        spraxel last edited by

                                        Also bis dato funktioniert es immer noch nicht. Irgend eine Lösung?

                                        1 Reply Last reply Reply Quote 0
                                        • twonky
                                          twonky last edited by

                                          Ich habe mir das jetzt mal genauer angesehen. Spotify hat ihre API geändert, wenn gerade kein Device aktiv ist. Habs behoben, Version 0.1.3 ist jetzt verfügbar: https://github.com/twonky4/ioBroker.spotify-premium

                                          1 Reply Last reply Reply Quote 0
                                          • lobomau
                                            lobomau last edited by

                                            Sauber! Läuft wieder! 🙂

                                            1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post

                                            Support us

                                            ioBroker
                                            Community Adapters
                                            Donate

                                            715
                                            Online

                                            31.7k
                                            Users

                                            79.7k
                                            Topics

                                            1.3m
                                            Posts

                                            javascript
                                            95
                                            745
                                            186824
                                            Loading More Posts
                                            • Oldest to Newest
                                            • Newest to Oldest
                                            • Most Votes
                                            Reply
                                            • Reply as topic
                                            Log in to reply
                                            Community
                                            Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
                                            The ioBroker Community 2014-2023
                                            logo