NEWS
"steuere" mit Datentyp "object"
-
Hallo,
seit einiger Zeit funktioniert mein Deconz Adapter für eine Tradfri Leuchte nicht mehr. Die Variable "xy", welche ich immer über einen String gesteuert habe:
will plötzlich ein "object" als Datentyp. Der Log sagt:
(1720) You are assigning a string to the state "deconz.0.Lights.6.xy" which expects a object. Please fix your code to use a object or change the state type to string. This warning might become an erro
Die RAW Daten des Datenpunktes sehen so aus:
Also "type" = "object". Ob das schon immer so war, weiss ich leider nicht.
Mal unabhängig davon, dass ich nicht weiss, wieso der String plötzlich nicht mehr funktioniert, ist nun die Frage, wie ich im blockly nicht einen Wert steuern kann, sondern ein "object".
Danke vorab.
Gruß
Matthias -
Man Nehme:
den Block:
Erweitere diesen um 2 textkonstanten, eine am Anfang ("["), eine am Ende ("]")und füttere damit diesen Block (den mit dem orangenen Rahmen):
und stecke das ganze in das setState.A.
-
Nachtrag:
Damit bekommst du dann zumindest ein Objekt in den State geschrieben. Ob es. das "korrekte" Objekt ist hängt letztendlich vom Adapter ab. Das kann ich nicht sagen da ich diesen nicht einsetze.
A.
-
@matzinger sagte: Die RAW Daten des Datenpunktes sehen so aus:
Erstelle ein Issue auf Github: common.def als String passt nicht zu common.type = "object".
@matzinger sagte in "steuere" mit Datentyp "object":
wieso der String plötzlich nicht mehr funktioniert,
Funktioniert er wirklich nicht mehr? Der js-controller erzeugt (vorerst) nur eine Warnung.
@Jey-Cee empfahl, common.type auf "string" zu ändern.
-
@asgothian Danke schonmal. Leider klappt es so auch nicht. Ich habe das Skript wie folgt verändert:
und bekomme im Log dann Folgendes:
javascript.0 2021-08-03 08:30:47.271 info (1720) State value to set for "deconz.0.Lights.6.xy" has to be stringified but received type "object" javascript.0 2021-08-03 08:30:47.269 info (1720) State value to set for "deconz.0.Lights.6.xy" has to be stringified but received type "object" javascript.0 2021-08-03 08:30:47.255 info (1720) State value to set for "deconz.0.Lights.6.xy" has to be stringified but received type "object" javascript.0 2021-08-03 08:30:47.252 warn (1720) at processImmediate (internal/timers.js:456:21) javascript.0 2021-08-03 08:30:47.252 warn (1720) at Immediate._onImmediate (/opt/iobroker/node_modules/iobroker.js-controller/lib/adapter.js:5706:41) javascript.0 2021-08-03 08:30:47.252 warn (1720) at Object.stateChange (/opt/iobroker/node_modules/iobroker.javascript/main.js:502:29) javascript.0 2021-08-03 08:30:47.252 warn (1720) at Object.callback (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1075:38) javascript.0 2021-08-03 08:30:47.251 warn (1720) at Object.<anonymous> (script.js.common.Skript_1LoxBettboden_temp:13:5) javascript.0 2021-08-03 08:30:47.251 warn (1720) at setState (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1427:20) javascript.0 2021-08-03 08:30:47.249 warn (1720) You are assigning a array to the state "deconz.0.Lights.6.xy" which expects a object. Please fix your code to use a object or change the state type to array. This warning might become an error javascript.0 2021-08-03 08:30:47.247 warn (1720) at processImmediate (internal/timers.js:456:21) javascript.0 2021-08-03 08:30:47.247 warn (1720) at Immediate._onImmediate (/opt/iobroker/node_modules/iobroker.js-controller/lib/adapter.js:5706:41) javascript.0 2021-08-03 08:30:47.247 warn (1720) at Object.stateChange (/opt/iobroker/node_modules/iobroker.javascript/main.js:502:29) javascript.0 2021-08-03 08:30:47.246 warn (1720) at Object.callback (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1075:38) javascript.0 2021-08-03 08:30:47.246 warn (1720) at Object.<anonymous> (script.js.common.Skript_1LoxBettboden_temp:13:5) javascript.0 2021-08-03 08:30:47.245 warn (1720) at setState (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1427:20) javascript.0 2021-08-03 08:30:47.244 warn (1720) You are assigning a array to the state "deconz.0.Lights.6.xy" which expects a object. Please fix your code to use a object or change the state type to array. This warning might become an error javascript.0 2021-08-03 08:30:47.239 warn (1720) at processImmediate (internal/timers.js:456:21) javascript.0 2021-08-03 08:30:47.239 warn (1720) at Immediate._onImmediate (/opt/iobroker/node_modules/iobroker.js-controller/lib/adapter.js:5706:41) javascript.0 2021-08-03 08:30:47.238 warn (1720) at Object.stateChange (/opt/iobroker/node_modules/iobroker.javascript/main.js:502:29) javascript.0 2021-08-03 08:30:47.237 warn (1720) at Object.callback (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1075:38) javascript.0 2021-08-03 08:30:47.236 warn (1720) at Object.<anonymous> (script.js.common.Skript_1LoxBettboden_temp:13:5) javascript.0 2021-08-03 08:30:47.235 warn (1720) at setState (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1427:20) javascript.0 2021-08-03 08:30:47.231 warn (1720) You are assigning a array to the state "deconz.0.Lights.6.xy" which expects a object. Please fix your code to use a object or change the state type to array. This warning might become an error
Hab ich irgendwas falsche gemackt?
Gruß und Danke
Matthias -
@paul53 also die Lampe reagiert nicht mehr und bleibt aus und der xy Wert wird rot angezeigt
-
@matzinger sagte in "steuere" mit Datentyp "object":
Hab ich irgendwas falsche gemackt?
Warhrscheinlich ja, allerdings auf "Anweisung".
Mein problem ist das ich den Adapter nicht einsetze und damit nicht weiss was der für ein Objekt erwartet. Das mit dem Array ([]) war ein Versuch.
Ich würde vorschlagen das du erst einmal versuchst den Typ des State im Objektbaum manuell wie von @paul53 vorgeschlagen auf "string" setzt und dann schaust ob du mit dem ummodifizierten Skript die Farbe steuern kannst.
A.
-
@asgothian wenn ich den Typ auf "string" ändere, kommt folgende Fehlermeldung:
deconz.0 2021-08-03 10:41:58.572 warn (1815) {"address":"/lights/6/state","description":"invalid value, , for parameter, xy","type":7}
-
Es gibt im Prinzip 3 Möglichkeiten, wovon eine sicherlich funktioniert:
-
@paul53 Leider ergeben alle 3 Möglichkeiten nur Fehler:
ergibt
javascript.0 2021-08-03 14:05:54.750 warn (1720) at processImmediate (internal/timers.js:456:21) javascript.0 2021-08-03 14:05:54.750 warn (1720) at Immediate._onImmediate (/opt/iobroker/node_modules/iobroker.js-controller/lib/adapter.js:5706:41) javascript.0 2021-08-03 14:05:54.749 warn (1720) at Object.stateChange (/opt/iobroker/node_modules/iobroker.javascript/main.js:502:29) javascript.0 2021-08-03 14:05:54.744 warn (1720) at Object.callback (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1075:38) javascript.0 2021-08-03 14:05:54.743 warn (1720) at Object.<anonymous> (script.js.common.Skript_1LoxBettboden_temp:13:5) javascript.0 2021-08-03 14:05:54.743 warn (1720) at setState (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1427:20) javascript.0 2021-08-03 14:05:54.741 warn (1720) You are assigning a string to the state "deconz.0.Lights.6.xy" which expects a object. Please fix your code to use a object or change the state type to string. This warning might become an erro javascript.0 2021-08-03 14:05:54.736 warn (1720) at processImmediate (internal/timers.js:456:21) javascript.0 2021-08-03 14:05:54.735 warn (1720) at Immediate._onImmediate (/opt/iobroker/node_modules/iobroker.js-controller/lib/adapter.js:5706:41) javascript.0 2021-08-03 14:05:54.735 warn (1720) at Object.stateChange (/opt/iobroker/node_modules/iobroker.javascript/main.js:502:29) javascript.0 2021-08-03 14:05:54.735 warn (1720) at Object.callback (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1075:38) javascript.0 2021-08-03 14:05:54.734 warn (1720) at Object.<anonymous> (script.js.common.Skript_1LoxBettboden_temp:13:5) javascript.0 2021-08-03 14:05:54.734 warn (1720) at setState (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1427:20) javascript.0 2021-08-03 14:05:54.732 warn (1720) You are assigning a string to the state "deconz.0.Lights.6.xy" which expects a object. Please fix your code to use a object or change the state type to string. This warning might become an erro javascript.0 2021-08-03 14:05:54.729 warn (1720) at processImmediate (internal/timers.js:456:21) javascript.0 2021-08-03 14:05:54.729 warn (1720) at Immediate._onImmediate (/opt/iobroker/node_modules/iobroker.js-controller/lib/adapter.js:5706:41) javascript.0 2021-08-03 14:05:54.728 warn (1720) at Object.stateChange (/opt/iobroker/node_modules/iobroker.javascript/main.js:502:29) javascript.0 2021-08-03 14:05:54.728 warn (1720) at Object.callback (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1075:38) javascript.0 2021-08-03 14:05:54.727 warn (1720) at Object.<anonymous> (script.js.common.Skript_1LoxBettboden_temp:18:5) javascript.0 2021-08-03 14:05:54.726 warn (1720) at setState (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1427:20) javascript.0 2021-08-03 14:05:54.724 warn (1720) You are assigning a string to the state "deconz.0.Lights.6.xy" which expects a object. Please fix your code to use a object or change the state type to string. This warning might become an erro
ergibt:
javascript.0 2021-08-03 14:01:43.110 info (1720) State value to set for "deconz.0.Lights.6.xy" has to be stringified but received type "object" deconz.0 2021-08-03 14:01:43.074 warn (1815) Code 400: Bad request set light state 6: [{"error":{"address":"/lights/6/state","description":"body contains invalid JSON","type":2}}]
und
erzeugt
javascript.0 2021-08-03 14:08:35.862 info (1720) State value to set for "deconz.0.Lights.6.xy" has to be stringified but received type "object" javascript.0 2021-08-03 14:08:35.859 warn (1720) at processImmediate (internal/timers.js:456:21) javascript.0 2021-08-03 14:08:35.859 warn (1720) at Immediate._onImmediate (/opt/iobroker/node_modules/iobroker.js-controller/lib/adapter.js:5706:41) javascript.0 2021-08-03 14:08:35.858 warn (1720) at Object.stateChange (/opt/iobroker/node_modules/iobroker.javascript/main.js:502:29) javascript.0 2021-08-03 14:08:35.858 warn (1720) at Object.callback (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1075:38) javascript.0 2021-08-03 14:08:35.857 warn (1720) at Object.<anonymous> (script.js.common.Skript_1LoxBettboden_temp:13:5) javascript.0 2021-08-03 14:08:35.857 warn (1720) at setState (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1427:20) javascript.0 2021-08-03 14:08:35.850 warn (1720) You are assigning a array to the state "deconz.0.Lights.6.xy" which expects a object. Please fix your code to use a object or change the state type to array. This warning might become an error javascript.0 2021-08-03 14:08:35.848 info (1720) State value to set for "deconz.0.Lights.6.xy" has to be stringified but received type "object" javascript.0 2021-08-03 14:08:35.845 warn (1720) at processImmediate (internal/timers.js:456:21) javascript.0 2021-08-03 14:08:35.845 warn (1720) at Immediate._onImmediate (/opt/iobroker/node_modules/iobroker.js-controller/lib/adapter.js:5706:41) javascript.0 2021-08-03 14:08:35.845 warn (1720) at Object.stateChange (/opt/iobroker/node_modules/iobroker.javascript/main.js:502:29) javascript.0 2021-08-03 14:08:35.844 warn (1720) at Object.callback (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1075:38) javascript.0 2021-08-03 14:08:35.844 warn (1720) at Object.<anonymous> (script.js.common.Skript_1LoxBettboden_temp:13:5) javascript.0 2021-08-03 14:08:35.843 warn (1720) at setState (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1427:20) javascript.0 2021-08-03 14:08:35.842 warn (1720) You are assigning a array to the state "deconz.0.Lights.6.xy" which expects a object. Please fix your code to use a object or change the state type to array. This warning might become an error javascript.0 2021-08-03 14:08:35.839 warn (1720) at processImmediate (internal/timers.js:456:21) javascript.0 2021-08-03 14:08:35.839 warn (1720) at Immediate._onImmediate (/opt/iobroker/node_modules/iobroker.js-controller/lib/adapter.js:5706:41) javascript.0 2021-08-03 14:08:35.838 warn (1720) at Object.stateChange (/opt/iobroker/node_modules/iobroker.javascript/main.js:502:29) javascript.0 2021-08-03 14:08:35.838 warn (1720) at Object.callback (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1075:38) javascript.0 2021-08-03 14:08:35.838 warn (1720) at Object.<anonymous> (script.js.common.Skript_1LoxBettboden_temp:13:5) javascript.0 2021-08-03 14:08:35.837 warn (1720) at setState (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1427:20) javascript.0 2021-08-03 14:08:35.836 warn (1720) You are assigning a array to the state "deconz.0.Lights.6.xy" which expects a object. Please fix your code to use a object or change the state type to array. This warning might become an error
-
@matzinger
Die Warnungen kommen, wenn common.type nicht dem tatsächlichen Datentyp entspricht. Wichtig ist: Hat eine der 3 Versionen die Farbe richtig ausgegeben? Wenn ja, welche?@matzinger sagte in "steuere" mit Datentyp "object":
info (1720) State value to set for "deconz.0.Lights.6.xy" has to be stringified but received type "object"
könnte bedeuten, dass aus dem Array ein JSON gemacht werden muss:
Das macht in neuer Version (ab 5.2.0) aber schon der Javascript-Adapter.
Update den Javascript-Adapter auf Version 5.2.8, ändere common.type in "array" (siehe Deconz) und dann: -
@paul53 Objekt nach JSON erzeugt den gleichen Fehler wie oben.
javascript.0 2021-08-04 09:40:26.521 warn (1720) at processImmediate (internal/timers.js:456:21) javascript.0 2021-08-04 09:40:26.521 warn (1720) at Immediate._onImmediate (/opt/iobroker/node_modules/iobroker.js-controller/lib/adapter.js:5706:41) javascript.0 2021-08-04 09:40:26.520 warn (1720) at Object.stateChange (/opt/iobroker/node_modules/iobroker.javascript/main.js:502:29) javascript.0 2021-08-04 09:40:26.520 warn (1720) at Object.callback (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1075:38) javascript.0 2021-08-04 09:40:26.519 warn (1720) at Object.<anonymous> (script.js.common.Skript_1LoxBettboden_temp:13:5) javascript.0 2021-08-04 09:40:26.518 warn (1720) at setState (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1427:20) javascript.0 2021-08-04 09:40:26.517 warn (1720) You are assigning a string to the state "deconz.0.Lights.6.xy" which expects a object. Please fix your code to use a object or change the state type to string. This warning might become an erro javascript.0 2021-08-04 09:40:26.510 warn (1720) at processImmediate (internal/timers.js:456:21) javascript.0 2021-08-04 09:40:26.510 warn (1720) at Immediate._onImmediate (/opt/iobroker/node_modules/iobroker.js-controller/lib/adapter.js:5706:41) javascript.0 2021-08-04 09:40:26.510 warn (1720) at Object.stateChange (/opt/iobroker/node_modules/iobroker.javascript/main.js:502:29) javascript.0 2021-08-04 09:40:26.509 warn (1720) at Object.callback (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1075:38) javascript.0 2021-08-04 09:40:26.509 warn (1720) at Object.<anonymous> (script.js.common.Skript_1LoxBettboden_temp:13:5) javascript.0 2021-08-04 09:40:26.508 warn (1720) at setState (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1427:20) javascript.0 2021-08-04 09:40:26.496 warn (1720) You are assigning a string to the state "deconz.0.Lights.6.xy" which expects a object. Please fix your code to use a object or change the state type to string. This warning might become an erro
Das mit dem Javastript Adapter verstehe ich leider nicht. Die 5.1.3 ist die aktuelle stable version. Wenn ich den Verwahrungsort auf Beta stelle zeigt er mir als Verfügbare version 4.6.26 an
-
@matzinger sagte: Wenn ich den Verwahrungsort auf Beta stelle
Nimm den:
@matzinger sagte in "steuere" mit Datentyp "object":
Objekt nach JSON erzeugt den gleichen Fehler wie oben.
Du hast common.type nicht in "string" geändert. Die Farbe wurde aber richtig übertragen?
-
@paul53 Du hast Recht, das hatte ich vergessen. Dann kommt folgende Meldung:
deconz.0 2021-08-05 07:49:21.112 warn (1815) {"address":"/lights/6/state","description":"invalid value, , for parameter, xy","type":7} deconz.0 2021-08-05 07:49:21.099 warn (1815) {"address":"/lights/6/state","description":"invalid value, , for parameter, xy","type":7} deconz.0 2021-08-05 07:49:21.067 warn (1815) {"address":"/lights/6/state","description":"invalid value, , for parameter, xy","type":7}
Nach der o.g. Meldung stellt sich der Type wieder von alleine auf "object" um. Beim nächsten Ausführen kommt dann wieder die lange Fehlermeldung vom Javascript Adapter.
Habe den Javasript Adapter nun auf 5.2.8 aktualisiert. Wenn ich nun ein Array übergebe, bekomme ich keine Fehler oder warnungen mehr im Log. der neue xy Wert wird auch übergeben, springt allerdings danach auf rot. Die Farbe der Lampe ändert sich nicht.
-
@matzinger sagte: Nach der o.g. Meldung stellt sich der Type wieder von alleine auf "object" um.
Wirklich? Dann update den Deconz-Adapter von Github: Änderung von "xy" ist heute eingeflossen.
-
@paul53 ich habe nun auf 1.3.18 aktualisiert. Leider keine Änderung. Wenn ich ein Array übergebe, meckert der er, dass er ein Objekt will. Wenn ich ein JSON übergebe, schreibt er den neuen Wert zwar in den Datenpunkt, der wird aber gleich wieder rot und die Farbe der Lampe ändert sich nicht.
-
@matzinger sagte: ich habe nun auf 1.3.18 aktualisiert.
1.3.18 ist nicht aktuell, sondern nur die Version auf Github (über Katze installieren). Die Versionsnummer ändert sich dabei nicht.
@matzinger sagte in "steuere" mit Datentyp "object":
meckert der er, dass er ein Objekt will.
In der Github-Version ist auf "array" korrigiert.
-
@paul53 Es geht wieder!!!!
Vielen vielen Dank für den Support.