NEWS
[gelöst] JSON mit mehreren Werten mit Blockly auslesen
-
Habe ein JSON mit mehren Werten. Den habe ich mit einem Blockly ausgelesen und nach dem für mich wichtigen Attribut gesucht. Nun möchte ich das das für die aktuelle Stunde geltende Attribut in einen DP geschrieben wird.
Das klappt aber so nicht. Was muss ich ändern?Hier der JSON file. { hour: 18, startsAt: '2025-07-08T18:00:00.000+02:00', total: 0.3162, output: true }, { hour: 19, startsAt: '2025-07-08T19:00:00.000+02:00', total: 0.3378, output: false }, { hour: 20, startsAt: '2025-07-08T20:00:00.000+02:00', total: 0.3624, output: false }, { hour: 21, startsAt: '2025-07-08T21:00:00.000+02:00', total: 0.3631, output: false }, { hour: 22, startsAt: '2025-07-08T22:00:00.000+02:00', total: 0.3551, output: false }, { hour: 23, startsAt: '2025-07-08T23:00:00.000+02:00', total: 0.3364, output: false }, { hour: 0, startsAt: '2025-07-09T00:00:00.000+02:00', total: 0.3319, output: true }, { hour: 1, startsAt: '2025-07-09T01:00:00.000+02:00', total: 0.3197, output: true }, { hour: 2, startsAt: '2025-07-09T02:00:00.000+02:00', total: 0.3161, output: true }, { hour: 3, startsAt: '2025-07-09T03:00:00.000+02:00', total: 0.3171, output: true }, { hour: 4, startsAt: '2025-07-09T04:00:00.000+02:00', total: 0.3176, output: true }, { hour: 5, startsAt: '2025-07-09T05:00:00.000+02:00', total: 0.3307, output: true }, { hour: 6, startsAt: '2025-07-09T06:00:00.000+02:00', total: 0.3516, output: false }, { hour: 7, startsAt: '2025-07-09T07:00:00.000+02:00', total: 0.3549, output: false }, { hour: 8, startsAt: '2025-07-09T08:00:00.000+02:00', total: 0.3515, output: false } ] 2025-07-08 15:27:20.267 - warn: javascript.0 (12116) script.js.common.Werte_aus_Json: { val: undefined, ack: true } 2025-07-08 15:27:20.271 - info: javascript.0 (12116) State value to set for "0_userdata.0.Tibberlink_Kanäle.Kanal_7_outputjson" has to be type "boolean" but received type "object"
-
@peter-c sagte: das für die aktuelle Stunde geltende Attribut in einen DP geschrieben wird.
Das ist eine Liste, die man mit einer Schleife durchgehen muss.
Was soll passieren, wenn die aktuelle Stunde nicht in der Liste vorhanden ist?
-
@paul53 said in JSON mit mehreren Werten mit Blockly auslesen:
Was soll passieren, wenn die aktuelle Stunde nicht in der Liste vorhanden ist?
Da sollte der Wert false gelten.
-
@peter-c sagte: Da sollte der Wert false gelten.
-
@paul53 Bekomme jede menge Fehler
2025-07-08 16:22:50.338 - [32minfo[39m: admin.0 (7056) ==> Connected system.user.admin from ::ffff:192.168.178.20 2025-07-08 16:22:56.378 - [32minfo[39m: javascript.0 (12116) Stopping script script.js.common.Werte_aus_Json 2025-07-08 16:22:57.537 - [32minfo[39m: javascript.0 (12116) Start JavaScript script.js.common.Werte_aus_Json (Blockly) 2025-07-08 16:22:57.567 - [31merror[39m: javascript.0 (12116) script.js.common.Werte_aus_Json: Cannot parse """: SyntaxError: Unterminated string in JSON at position 1 2025-07-08 16:22:57.568 - [31merror[39m: javascript.0 (12116) script.js.common.Werte_aus_Json: Cannot parse "[": SyntaxError: Unexpected end of JSON input 2025-07-08 16:22:57.568 - [31merror[39m: javascript.0 (12116) script.js.common.Werte_aus_Json: Cannot parse "\": SyntaxError: Unexpected token '\', "\" is not valid JSON 2025-07-08 16:22:57.568 - [31merror[39m: javascript.0 (12116) script.js.common.Werte_aus_Json: Cannot parse "n": SyntaxError: Unexpected end of JSON input 2025-07-08 16:22:57.569 - [31merror[39m: javascript.0 (12116) script.js.common.Werte_aus_Json: Cannot parse " ": SyntaxError: Unexpected end of JSON input 2025-07-08 16:22:57.569 - [31merror[39m: javascript.0 (12116) script.js.common.Werte_aus_Json: Cannot parse " ": SyntaxError: Unexpected end of JSON input 2025-07-08 16:22:57.569 - [31merror[39m: javascript.0 (12116) script.js.common.Werte_aus_Json: Cannot parse "{": SyntaxError: Expected property name or '}' in JSON at position 1 2025-07-08 16:22:57.570 - [31merror[39m: javascript.0 (12116) script.js.common.Werte_aus_Json: Cannot parse "\": SyntaxError: Unexpected token '\', "\" is not valid JSON 2025-07-08 16:22:57.570 - [31merror[39m: javascript.0 (12116) script.js.common.Werte_aus_Json: Cannot parse "n": SyntaxError: Unexpected end of JSON input 2025-07-08 16:22:57.570 - [31merror[39m: javascript.0 (12116) script.js.common.Werte_aus_Json: Cannot parse " ": SyntaxError: Unexpected end of JSON input 2025-07-08 16:22:57.570 - [31merror[39m: javascript.0 (12116) script.js.common.Werte_aus_Json: Cannot parse " ": SyntaxError: Unexpected end of JSON input 2025-07-08 16:22:57.571 - [31merror[39m: javascript.0 (12116) script.js.common.Werte_aus_Json: Cannot parse " ": SyntaxError: Unexpected end of JSON input 2025-07-08 16:22:57.571 - [31merror[39m: javascript.0 (12116) script.js.common.Werte_aus_Json: Cannot parse " ": SyntaxError: Unexpected end of JSON input 2025-07-08 16:22:57.571 - [31merror[39m: javascript.0 (12116) script.js.common.Werte_aus_Json: Cannot parse "\": SyntaxError: Unexpected token '\', "\" is not valid JSON 2025-07-08 16:22:57.572 - [31merror[39m: javascript.0 (12116) script.js.common.Werte_aus_Json: Cannot parse """: SyntaxError: Unterminated string in JSON at position 1 2025-07-08 16:22:57.572 - [31merror[39m: javascript.0 (12116) script.js.common.Werte_aus_Json: Cannot parse "h": SyntaxError: Unexpected token 'h', "h" is not valid JSON 2025-07-08 16:22:57.572 - [31merror[39m: javascript.0 (12116) script.js.common.Werte_aus_Json: Cannot parse "o": SyntaxError: Unexpected token 'o', "o" is not valid JSON 2025-07-08 16:22:57.573 - [31merror[39m: javascript.0 (12116) script.js.common.Werte_aus_Json: Cannot parse "u": SyntaxError: Unexpected token 'u', "u" is not valid JSON 2025-07-08 16:22:57.573 - [31merror[39m: javascript.0 (12116) script.js.common.Werte_aus_Json: Cannot parse "r": SyntaxError: Unexpected token 'r', "r" is not valid JSON 2025-07-08 16:22:57.573 - [31merror[39m: javascript.0 (12116) script.js.common.Werte_aus_Json: Cannot parse "\": SyntaxError: Unexpected token '\', "\" is not valid JSON 2025-07-08 16:22:57.574 - [31merror[39m: javascript.0 (12116) script.js.common.Werte_aus_Json: Cannot parse """: SyntaxError: Unterminated string in JSON at position 1 2025-07-08 16:22:57.574 - [31merror[39m: javascript.0 (12116) script.js.common.Werte_aus_Json: Cannot parse ":": SyntaxError: Unexpected token ':', ":" is not valid JSON 2025-07-08 16:22:57.574 - [31merror[39m: javascript.0 (12116) script.js.common.Werte_aus_Json: Cannot parse " ": SyntaxError: Unexpected end of JSON input 2025-07-08 16:22:57.575 - [31merror[39m: javascript.0 (12116) script.js.common.Werte_aus_Json: Cannot parse ",": SyntaxError: Unexpected token ',', "," is not valid JSON 2025-07-08 16:22:57.575 - [31merror[39m: javascript.0 (12116) script.js.common.Werte_aus_Json: Cannot parse "\": SyntaxError: Unexpected token '\', "\" is not valid JSON 2025-07-08 16:22:57.575 - [31merror[39m: javascript.0 (12116) script.js.common.Werte_aus_Json: Cannot parse "n": SyntaxError: Unexpected end of JSON input 2025-07-08 16:22:57.575 - [31merror[39m: javascript.0 (12116) script.js.common.Werte_aus_Json: Cannot parse " ": SyntaxError: Unexpected end of JSON input 2025-07-08 16:22:57.576 - [31merror[39m: javascript.0 (12116) script.js.common.Werte_aus_Json: Cannot parse " ": SyntaxError: Unexpected end of JSON input 2025-07-08 16:22:57.576 - [31merror[39m: javascript.0 (12116) script.js.common.Werte_aus_Json: Cannot parse " ": SyntaxError: Unexpected end of JSON input 2025-07-08 16:22:57.576 - [31merror[39m: javascript.0 (12116) script.js.common.Werte_aus_Json: Cannot parse " ": SyntaxError: Unexpected end of JSON input
-
@peter-c sagte: Bekomme jede menge Fehler
Sorry, muss natürlich JSON nach Objekt konvertiert werden.
-
Habs umgebaut, es ändert sich an den Fehlermeldungen nichts. Ist das mit der Liste richtig?
2025-07-08 16:32:53.129 - [31merror[39m: javascript.0 (12116) script.js.common.Werte_aus_Json: Cannot parse "n": SyntaxError: Unexpected end of JSON input 2025-07-08 16:32:53.130 - [31merror[39m: javascript.0 (12116) script.js.common.Werte_aus_Json: Cannot parse " ": SyntaxError: Unexpected end of JSON input 2025-07-08 16:32:53.130 - [31merror[39m: javascript.0 (12116) script.js.common.Werte_aus_Json: Cannot parse " ": SyntaxError: Unexpected end of JSON input 2025-07-08 16:32:53.130 - [31merror[39m: javascript.0 (12116) script.js.common.Werte_aus_Json: Cannot parse "}": SyntaxError: Unexpected token '}', "}" is not valid JSON 2025-07-08 16:32:53.130 - [31merror[39m: javascript.0 (12116) script.js.common.Werte_aus_Json: Cannot parse ",": SyntaxError: Unexpected token ',', "," is not valid JSON 2025-07-08 16:32:53.131 - [31merror[39m: javascript.0 (12116) script.js.common.Werte_aus_Json: Cannot parse "\": SyntaxError: Unexpected token '\', "\" is not valid JSON 2025-07-08 16:32:53.131 - [31merror[39m: javascript.0 (12116) script.js.common.Werte_aus_Json: Cannot parse "n": SyntaxError: Unexpected end of JSON input 2025-07-08 16:32:53.131 - [31merror[39m: javascript.0 (12116) script.js.common.Werte_aus_Json: Cannot parse " ": SyntaxError: Unexpected end of JSON input 2025-07-08 16:32:53.131 - [31merror[39m: javascript.0 (12116) script.js.common.Werte_aus_Json: Cannot parse " ": SyntaxError: Unexpected end of JSON input 2025-07-08 16:32:53.132 - [31merror[39m: javascript.0 (12116) script.js.common.Werte_aus_Json: Cannot parse "{": SyntaxError: Expected property name or '}' in JSON at position 1 2025-07-08 16:32:53.132 - [31merror[39m: javascript.0 (12116) script.js.common.Werte_aus_Json: Cannot parse "\": SyntaxError: Unexpected token '\', "\" is not valid JSON 2025-07-08 16:32:53.132 - [31merror[39m: javascript.0 (12116) script.js.common.Werte_aus_Json: Cannot parse "n": SyntaxError: Unexpected end of JSON input 2025-07-08 16:32:53.132 - [31merror[39m: javascript.0 (12116) script.js.common.Werte_aus_Json: Cannot parse " ": SyntaxError: Unexpected end of JSON input 2025-07-08 16:32:53.132 - [31merror[39m: javascript.0 (12116) script.js.common.Werte_aus_Json: Cannot parse " ": SyntaxError: Unexpected end of JSON input 2025-07-08 16:32:53.133 - [31merror[39m: javascript.0 (12116) script.js.common.Werte_aus_Json: Cannot parse " ": SyntaxError: Unexpected end of JSON input 2025-07-08 16:32:53.133 - [31merror[39m: javascript.0 (12116) script.js.common.Werte_aus_Json: Cannot parse " ": SyntaxError: Unexpected end of JSON input 2025-07-08 16:32:53.133 - [31merror[39m: javascript.0 (12116) script.js.common.Werte_aus_Json: Cannot parse "\": SyntaxError: Unexpected token '\', "\" is not valid JSON 2025-07-08 16:32:53.133 - [31merror[39m: javascript.0 (12116) script.js.common.Werte_aus_Json: Cannot parse """: SyntaxError: Unterminated string in JSON at position 1
-
@peter-c sagte: es ändert sich an den Fehlermeldungen nichts.
Offenbar ist das JSON im DP fehlerhaft. Wie sieht es genau aus?
Ist es überhaupt ein JSON oder enthält der DP ein Array? Falls es ein Array ist, darf nicht konvertiert werden. Im ersten Post sieht es nicht nach einem JSON aus. Es ist aber schon gewandelt.
@peter-c sagte in JSON mit mehreren Werten mit Blockly auslesen:
Ist das mit der Liste richtig?
Ja.
-
@paul53 said in JSON mit mehreren Werten mit Blockly auslesen:
Im ersten Post sieht es nicht nach einem JSON aus.
Ist schon ein Json.
Obwohl ich nichts gemacht hatte (war nur kurz Einkaufen) kommen die Fehler jetzt nicht mehr. Komisch... aber danke für die Hilfe.Muss ich das noch mit einem Triggerbaustein verbinden oder läuft das jetzt immer so?
-
@peter-c sagte: Muss ich das noch mit einem Triggerbaustein verbinden oder läuft das jetzt immer so?
Ja, sonst läuft es nur einmal bei Skriptstart.
Zu jeder vollen Stunde: -
@paul53 said in JSON mit mehreren Werten mit Blockly auslesen:
@peter-c sagte: Muss ich das noch mit einem Triggerbaustein verbinden oder läuft das jetzt immer so?
Ja, sonst läuft es nur einmal bei Skriptstart.
Zu jeder vollen Stunde: -