Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. JavaScript
    5. Fehlermeldung Javascript

    NEWS

    • Neuer Blog: Fotos und Eindrücke aus Solingen

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

    • ioBroker goes Matter ... Matter Adapter in Stable

    Fehlermeldung Javascript

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

      Moin @ all
      Kann mir jemand sagen wie ich diese Fehlermeldung weg bekomme?
      Angemaulte Zeile im Script ist diese:
      let objHistory = JSON.parse(obj.state.val);

      javascript.0
      2023-11-26 07:47:59.691	error	at processImmediate (node:internal/timers:476:21)
      
      javascript.0
      2023-11-26 07:47:59.690	error	at Immediate._onImmediate (/opt/iobroker/node_modules/@iobroker/js-controller-adapter/src/lib/adapter/adapter.ts:11220:62)
      
      javascript.0
      2023-11-26 07:47:59.690	error	at Object.stateChange (/opt/iobroker/node_modules/iobroker.javascript/main.js:645:29)
      
      javascript.0
      2023-11-26 07:47:59.690	error	at Object.callback (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1266:38)
      
      javascript.0
      2023-11-26 07:47:59.689	error	at Object.<anonymous> (script.js.Datenpunkte.AlexaHistoryWir(J):111:31)
      
      javascript.0
      2023-11-26 07:47:59.688	error	at JSON.parse (<anonymous>)
      
      javascript.0
      2023-11-26 07:47:59.686	error	Error in callback: SyntaxError: Unexpected end of JSON input
      
      T 1 Reply Last reply Reply Quote 0
      • T
        TT-Tom @MalleRalle last edited by

        @malleralle

        Dein State wird nicht als JSON erkannt, wie sieht der Inhalt den aus und zeige auch mal die Objekteigenschaften vom Datenpunkt.

        MalleRalle 1 Reply Last reply Reply Quote 0
        • MalleRalle
          MalleRalle @TT-Tom last edited by MalleRalle

          @tt-tom
          Vielen Dank für den Tip
          Der Datenpunkt stand auf value.
          Habe ihn auf json geändert und Fehlermeldung ist weg.

          T 1 Reply Last reply Reply Quote 0
          • T
            ticaki Developer @MalleRalle last edited by ticaki

            @malleralle

            Der Fehler kommt AFAIK aber eher daher, dass da kein ordenltichen JSON drin stand. type=string ist Pflicht und das im Datenpunkt mindestens das hier steht: '{}' - heißt ein String {}

            Ich hab bei sowas immer diese Lesefunktion drin sinngemäß:

            let j
            try {
              j = JSON.parse(irgendwas)
            } catch (e) {
              j = {};
            }
            
            MalleRalle 1 Reply Last reply Reply Quote 1
            • MalleRalle
              MalleRalle @ticaki last edited by MalleRalle

              @ticaki
              Hmm ja, iobroker neu gestartet und Fehlermeldung wieder da.
              Das Script kommt von hier.
              Könntest Du da, wenn mal Zeit ist mal reinschauen und mir sagen ob ich da auch etwas ändern kann.
              https://github.com/Mic-M/iobroker-alexa-history-vis-script

              Ich habe da am 19.07.2022 ein Issue erstellt.
              Schein aber nicht mehr gepflegt zu werden.

              Der Datenpunkt schaut so aus:

              {
                "common": {
                  "name": "Alexa History: JSON for VIS table",
                  "type": "string",
                  "read": true,
                  "write": true,
                  "role": "value",
                  "def": ""
                },
                "native": {},
                "type": "state",
                "_id": "javascript.0.Alexa2.History.JSON_Table",
                "acl": {
                  "object": 1636,
                  "state": 1636,
                  "owner": "system.user.admin",
                  "ownerGroup": "system.group.administrator"
                },
                "from": "system.adapter.admin.0",
                "user": "system.user.admin",
                "ts": 1700985600618
              }
              
              T 1 Reply Last reply Reply Quote 0
              • T
                ticaki Developer @MalleRalle last edited by

                @malleralle

                Jo ersetze die Zeile let objhistory und let summary durch das hier

                let objHistory 
                try {
                  objHistory = JSON.parse(obj.state.val);
                } catch (e) {
                  return;
                }
                if (!objHistory['summary']) return;
                
                let summary   = objHistory['summary'];
                
                MalleRalle 1 Reply Last reply Reply Quote 1
                • MalleRalle
                  MalleRalle @ticaki last edited by

                  @ticaki
                  Vielen lieben Dank für Deine Bemühungen.
                  Das funktioniert Perfekt.
                  Fehlermeldungen beim start vom Javascript Adapter sind weg.

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

                  Support us

                  ioBroker
                  Community Adapters
                  Donate

                  637
                  Online

                  31.8k
                  Users

                  80.0k
                  Topics

                  1.3m
                  Posts

                  javascript
                  3
                  7
                  375
                  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