Skip to content
  • Home
  • Aktuell
  • Tags
  • 0 Ungelesen 0
  • Kategorien
  • Unreplied
  • Beliebt
  • GitHub
  • Docu
  • Hilfe
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Standard: (Kein Skin)
  • Kein Skin
Einklappen
ioBroker Logo

Community Forum

donate donate
  1. ioBroker Community Home
  2. Deutsch
  3. Skripten / Logik
  4. JavaScript
  5. [gelöst] You are assigning a undefined to the

NEWS

  • Jahresrückblick 2025 – unser neuer Blogbeitrag ist online! ✨
    BluefoxB
    Bluefox
    16
    1
    1.0k

  • Neuer Blogbeitrag: Monatsrückblick - Dezember 2025 🎄
    BluefoxB
    Bluefox
    13
    1
    698

  • Weihnachtsangebot 2025! 🎄
    BluefoxB
    Bluefox
    25
    1
    2.0k

[gelöst] You are assigning a undefined to the

Geplant Angeheftet Gesperrt Verschoben JavaScript
javascript
11 Beiträge 3 Kommentatoren 595 Aufrufe 2 Watching
  • Älteste zuerst
  • Neuste zuerst
  • Meiste Stimmen
Antworten
  • In einem neuen Thema antworten
Anmelden zum Antworten
Dieses Thema wurde gelöscht. Nur Nutzer mit entsprechenden Rechten können es sehen.
  • S Offline
    S Offline
    skokarl
    schrieb am zuletzt editiert von skokarl
    #1

    Tut mir leid, ich muss nochmal fragen,
    ich verstehe es nicht.

    Volume kann ich fehlerfrei abfragen, bei artist ( oder ähnlichem ) meckert er.
    Volume ist ne Zahl, artist ein String.
    Aber zum Zeitpunkt der Abfrage ist artist auch nicht NULL oderso,
    aber ich kann die Fehlermeldung nicht richtig einordnen.

    var value = obj.state.val;
      var oldValue = obj.oldState.val;  
    
          var tablet;
          var wohnl;
    
        try {
    
              require("request")('http://192.168.178.56:5005/tablet/state/', function (error, response, result) 
    
              {
    
    			  tablet =  JSON.parse(result);
    
    			 setState("javascript.0.sonos.tabletvol", tablet.volume); 
                            setState("javascript.0.sonos.artist", tablet.artist);
    
    
          }).on("error", function (e) {console.error(e);});
    
        } catch (e) { console.error(e); }
    
    

    1.PNG

    im Log

    You are assigning a undefined to the state "javascript.0.sonos.artist" which expects a string. Please fix your code to use a string or change the state type to undefined. This warning might become an

    da kommen die Daten her :

    1.PNG

    IOBroker mit Proxmox auf Celeron Nuc mit 16 GB und Debian11, Sonos API, Echo Show 15 als Wandtablet, Homematic IP, HUE, Sonos, Echos, DS718+ als Backup

    AsgothianA paul53P 2 Antworten Letzte Antwort
    0
    • S skokarl

      Tut mir leid, ich muss nochmal fragen,
      ich verstehe es nicht.

      Volume kann ich fehlerfrei abfragen, bei artist ( oder ähnlichem ) meckert er.
      Volume ist ne Zahl, artist ein String.
      Aber zum Zeitpunkt der Abfrage ist artist auch nicht NULL oderso,
      aber ich kann die Fehlermeldung nicht richtig einordnen.

      var value = obj.state.val;
        var oldValue = obj.oldState.val;  
      
            var tablet;
            var wohnl;
      
          try {
      
                require("request")('http://192.168.178.56:5005/tablet/state/', function (error, response, result) 
      
                {
      
      			  tablet =  JSON.parse(result);
      
      			 setState("javascript.0.sonos.tabletvol", tablet.volume); 
                              setState("javascript.0.sonos.artist", tablet.artist);
      
      
            }).on("error", function (e) {console.error(e);});
      
          } catch (e) { console.error(e); }
      
      

      1.PNG

      im Log

      You are assigning a undefined to the state "javascript.0.sonos.artist" which expects a string. Please fix your code to use a string or change the state type to undefined. This warning might become an

      da kommen die Daten her :

      1.PNG

      AsgothianA Offline
      AsgothianA Offline
      Asgothian
      Developer
      schrieb am zuletzt editiert von
      #2

      @skokarl Bist du sicher das Artist im JSON ein String ist ?

      Setz doch mal den State nicht mit tablet.artist sondern mit JSON.stringify(Tablet.

      A.

      ioBroker auf RPi4 - Hardware soweit wie möglich via Zigbee.
      "Shit don't work" ist keine Fehlermeldung, sondern ein Fluch.

      S 1 Antwort Letzte Antwort
      0
      • AsgothianA Asgothian

        @skokarl Bist du sicher das Artist im JSON ein String ist ?

        Setz doch mal den State nicht mit tablet.artist sondern mit JSON.stringify(Tablet.

        A.

        S Offline
        S Offline
        skokarl
        schrieb am zuletzt editiert von skokarl
        #3

        @Asgothian

        das ist ja ne coole Idee, hab ich gar nicht dran gedacht.
        Probiere ich sobald ich wieder zu Hause bin.

        Aber wenn kein String was könnte es sonst sein ??

        IOBroker mit Proxmox auf Celeron Nuc mit 16 GB und Debian11, Sonos API, Echo Show 15 als Wandtablet, Homematic IP, HUE, Sonos, Echos, DS718+ als Backup

        AsgothianA 1 Antwort Letzte Antwort
        0
        • S skokarl

          @Asgothian

          das ist ja ne coole Idee, hab ich gar nicht dran gedacht.
          Probiere ich sobald ich wieder zu Hause bin.

          Aber wenn kein String was könnte es sonst sein ??

          AsgothianA Offline
          AsgothianA Offline
          Asgothian
          Developer
          schrieb am zuletzt editiert von
          #4

          @skokarl meine Vermutung: ein Array, für den Fall das ein Musikstück von 2 Künstlern zusammen gespielt wird.

          A.

          ioBroker auf RPi4 - Hardware soweit wie möglich via Zigbee.
          "Shit don't work" ist keine Fehlermeldung, sondern ein Fluch.

          S 1 Antwort Letzte Antwort
          0
          • AsgothianA Asgothian

            @skokarl meine Vermutung: ein Array, für den Fall das ein Musikstück von 2 Künstlern zusammen gespielt wird.

            A.

            S Offline
            S Offline
            skokarl
            schrieb am zuletzt editiert von
            #5

            @Asgothian

            hatte ich das richtig verstanden ?

            geht so nicht.

            1.PNG

            IOBroker mit Proxmox auf Celeron Nuc mit 16 GB und Debian11, Sonos API, Echo Show 15 als Wandtablet, Homematic IP, HUE, Sonos, Echos, DS718+ als Backup

            AsgothianA 1 Antwort Letzte Antwort
            0
            • S skokarl

              @Asgothian

              hatte ich das richtig verstanden ?

              geht so nicht.

              1.PNG

              AsgothianA Offline
              AsgothianA Offline
              Asgothian
              Developer
              schrieb am zuletzt editiert von
              #6

              @skokarl
              Da fehlt eine ) am Ende.

              setState("javascript.0.sonos.artist", JSON.stringify(tablet.artist));
              

              A.

              ioBroker auf RPi4 - Hardware soweit wie möglich via Zigbee.
              "Shit don't work" ist keine Fehlermeldung, sondern ein Fluch.

              S 1 Antwort Letzte Antwort
              0
              • AsgothianA Asgothian

                @skokarl
                Da fehlt eine ) am Ende.

                setState("javascript.0.sonos.artist", JSON.stringify(tablet.artist));
                

                A.

                S Offline
                S Offline
                skokarl
                schrieb am zuletzt editiert von skokarl
                #7

                @Asgothian

                Wie blöd, Sorry.

                Ne, geht trotzdem nicht. Ich werd weich.

                setState("javascript.0.sonos.artist", JSON.stringify(tablet.artist));
                
                14:43:33.136	warn	javascript.0 at Request._callback (script.js.sonos.sonos_state:28:15)
                

                LOG :

                javascript.0	2019-08-25 14:43:33.131	warn	at Request.self.callback (/opt/iobroker/node_modules/iobroker.javascript/node_modules/request/request.js:185:22)
                javascript.0	2019-08-25 14:43:33.131	warn	at Request._callback (script.js.sonos.sonos_state:28:15)
                javascript.0	2019-08-25 14:43:33.131	warn	at setState (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1276:20)
                javascript.0	2019-08-25 14:43:33.130	warn	You are assigning a undefined to the state "javascript.0.sonos.artist" which expects a string. Please fix your code to use a string or change the state type to undefined.
                
                

                IOBroker mit Proxmox auf Celeron Nuc mit 16 GB und Debian11, Sonos API, Echo Show 15 als Wandtablet, Homematic IP, HUE, Sonos, Echos, DS718+ als Backup

                AsgothianA paul53P 2 Antworten Letzte Antwort
                0
                • S skokarl

                  @Asgothian

                  Wie blöd, Sorry.

                  Ne, geht trotzdem nicht. Ich werd weich.

                  setState("javascript.0.sonos.artist", JSON.stringify(tablet.artist));
                  
                  14:43:33.136	warn	javascript.0 at Request._callback (script.js.sonos.sonos_state:28:15)
                  

                  LOG :

                  javascript.0	2019-08-25 14:43:33.131	warn	at Request.self.callback (/opt/iobroker/node_modules/iobroker.javascript/node_modules/request/request.js:185:22)
                  javascript.0	2019-08-25 14:43:33.131	warn	at Request._callback (script.js.sonos.sonos_state:28:15)
                  javascript.0	2019-08-25 14:43:33.131	warn	at setState (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1276:20)
                  javascript.0	2019-08-25 14:43:33.130	warn	You are assigning a undefined to the state "javascript.0.sonos.artist" which expects a string. Please fix your code to use a string or change the state type to undefined.
                  
                  
                  AsgothianA Offline
                  AsgothianA Offline
                  Asgothian
                  Developer
                  schrieb am zuletzt editiert von
                  #8

                  @skokarl
                  Mach doch mal eine debug Ausgabe mit JSON.stringify(tablet) damit du siehst was da wirklich drin steht.

                  A.

                  ioBroker auf RPi4 - Hardware soweit wie möglich via Zigbee.
                  "Shit don't work" ist keine Fehlermeldung, sondern ein Fluch.

                  1 Antwort Letzte Antwort
                  1
                  • S skokarl

                    @Asgothian

                    Wie blöd, Sorry.

                    Ne, geht trotzdem nicht. Ich werd weich.

                    setState("javascript.0.sonos.artist", JSON.stringify(tablet.artist));
                    
                    14:43:33.136	warn	javascript.0 at Request._callback (script.js.sonos.sonos_state:28:15)
                    

                    LOG :

                    javascript.0	2019-08-25 14:43:33.131	warn	at Request.self.callback (/opt/iobroker/node_modules/iobroker.javascript/node_modules/request/request.js:185:22)
                    javascript.0	2019-08-25 14:43:33.131	warn	at Request._callback (script.js.sonos.sonos_state:28:15)
                    javascript.0	2019-08-25 14:43:33.131	warn	at setState (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1276:20)
                    javascript.0	2019-08-25 14:43:33.130	warn	You are assigning a undefined to the state "javascript.0.sonos.artist" which expects a string. Please fix your code to use a string or change the state type to undefined.
                    
                    
                    paul53P Offline
                    paul53P Offline
                    paul53
                    schrieb am zuletzt editiert von paul53
                    #9

                    @skokarl sagte:

                    geht trotzdem nicht.

                    Füge mal

                    log(result);
                    

                    ein, um zu sehen, ob "artist" überhaupt übergeben wird und wenn ja, was übergeben wird.

                    Bitte verzichtet auf Chat-Nachrichten, denn die Handhabung ist grauenhaft !
                    Produktiv: RPi 2 mit S.USV, HM-MOD-RPI und SLC-USB-Stick mit root fs

                    1 Antwort Letzte Antwort
                    0
                    • S skokarl

                      Tut mir leid, ich muss nochmal fragen,
                      ich verstehe es nicht.

                      Volume kann ich fehlerfrei abfragen, bei artist ( oder ähnlichem ) meckert er.
                      Volume ist ne Zahl, artist ein String.
                      Aber zum Zeitpunkt der Abfrage ist artist auch nicht NULL oderso,
                      aber ich kann die Fehlermeldung nicht richtig einordnen.

                      var value = obj.state.val;
                        var oldValue = obj.oldState.val;  
                      
                            var tablet;
                            var wohnl;
                      
                          try {
                      
                                require("request")('http://192.168.178.56:5005/tablet/state/', function (error, response, result) 
                      
                                {
                      
                      			  tablet =  JSON.parse(result);
                      
                      			 setState("javascript.0.sonos.tabletvol", tablet.volume); 
                                              setState("javascript.0.sonos.artist", tablet.artist);
                      
                      
                            }).on("error", function (e) {console.error(e);});
                      
                          } catch (e) { console.error(e); }
                      
                      

                      1.PNG

                      im Log

                      You are assigning a undefined to the state "javascript.0.sonos.artist" which expects a string. Please fix your code to use a string or change the state type to undefined. This warning might become an

                      da kommen die Daten her :

                      1.PNG

                      paul53P Offline
                      paul53P Offline
                      paul53
                      schrieb am zuletzt editiert von
                      #10

                      @skokarl sagte:

                      da kommen die Daten her :

                      Dann muss die Auswertung von "artist" so erfolgen:

                      setState("javascript.0.sonos.artist", tablet.currentTrack.artist);
                      

                      Bitte verzichtet auf Chat-Nachrichten, denn die Handhabung ist grauenhaft !
                      Produktiv: RPi 2 mit S.USV, HM-MOD-RPI und SLC-USB-Stick mit root fs

                      1 Antwort Letzte Antwort
                      1
                      • S Offline
                        S Offline
                        skokarl
                        schrieb am zuletzt editiert von
                        #11

                        @paul53

                        Hallo Paul, meine Frau fragt gerade ob Du eigentlich manchmal denkst was für Vollpfosten hier fragen ....:joy:

                        Ich war eben noch am schreiben als Deine Antwort kam,
                        und wollte Dich fragen ob es sowas wie Untervariablen in Javascript gibt.

                        Ich hatte mir die Daten nochmal mit der http Adresse angesehen und da ist mir auch
                        aufgefallen das Volume in der "root" ist, artist oder stationName aber nicht...

                        Geht. Vielen lieben Dank.

                        IOBroker mit Proxmox auf Celeron Nuc mit 16 GB und Debian11, Sonos API, Echo Show 15 als Wandtablet, Homematic IP, HUE, Sonos, Echos, DS718+ als Backup

                        1 Antwort Letzte Antwort
                        0
                        Antworten
                        • In einem neuen Thema antworten
                        Anmelden zum Antworten
                        • Älteste zuerst
                        • Neuste zuerst
                        • Meiste Stimmen


                        Support us

                        ioBroker
                        Community Adapters
                        Donate

                        758

                        Online

                        32.6k

                        Benutzer

                        82.0k

                        Themen

                        1.3m

                        Beiträge
                        Community
                        Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen | Einwilligungseinstellungen
                        ioBroker Community 2014-2025
                        logo
                        • Anmelden

                        • Du hast noch kein Konto? Registrieren

                        • Anmelden oder registrieren, um zu suchen
                        • Erster Beitrag
                          Letzter Beitrag
                        0
                        • Home
                        • Aktuell
                        • Tags
                        • Ungelesen 0
                        • Kategorien
                        • Unreplied
                        • Beliebt
                        • GitHub
                        • Docu
                        • Hilfe