Skip to content
  • Home
  • Recent
  • Tags
  • 0 Unread 0
  • Categories
  • Unreplied
  • Popular
  • 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

  • Default (No Skin)
  • No Skin
Collapse
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

  • Monatsrückblick Januar/Februar 2026 ist online!
    BluefoxB
    Bluefox
    17
    1
    402

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

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

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

Scheduled Pinned Locked Moved JavaScript
javascript
11 Posts 3 Posters 655 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    skokarl
    wrote on last edited by 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 Replies Last reply
    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
      wrote on last edited by
      #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 Reply Last reply
      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
        wrote on last edited by 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 Reply Last reply
        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
          wrote on last edited by
          #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 Reply Last reply
          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
            wrote on last edited by
            #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 Reply Last reply
            0
            • S skokarl

              @Asgothian

              hatte ich das richtig verstanden ?

              geht so nicht.

              1.PNG

              AsgothianA Offline
              AsgothianA Offline
              Asgothian
              Developer
              wrote on last edited by
              #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 Reply Last reply
              0
              • AsgothianA Asgothian

                @skokarl
                Da fehlt eine ) am Ende.

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

                A.

                S Offline
                S Offline
                skokarl
                wrote on last edited by 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 Replies Last reply
                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
                  wrote on last edited by
                  #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 Reply Last reply
                  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
                    wrote on last edited by 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 Reply Last reply
                    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
                      wrote on last edited by
                      #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 Reply Last reply
                      1
                      • S Offline
                        S Offline
                        skokarl
                        wrote on last edited by
                        #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 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        Support us

                        ioBroker
                        Community Adapters
                        Donate

                        314

                        Online

                        32.7k

                        Users

                        82.5k

                        Topics

                        1.3m

                        Posts
                        Community
                        Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen | Einwilligungseinstellungen
                        ioBroker Community 2014-2025
                        logo
                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Home
                        • Recent
                        • Tags
                        • Unread 0
                        • Categories
                        • Unreplied
                        • Popular
                        • GitHub
                        • Docu
                        • Hilfe