NEWS
MQTT Json
-
Hallo,
habe eine Scriptvorlage auf meine Bedürfnisse angepasst, mache aber irgend einen Fehler.
Ich hätte jetzt erwartet, dass mir das Script die Datenpunkte unter "alias.0.tasmota" anlegt. Leider klappt das nicht.Die Daten kommen über einen IR Lesekopf am Stromzähler über Tasmota.
Kann mir jemand sagen was ich hier falsch mache?const JSPath = "alias.0" // JS- Pfad const parsedStatesPath = JSPath + ".tasmota" // Pfad fuer geparste States const zigbee2mqttJsonPath = "mqtt.0.tele.tasmota_192_168_50_134_strom.SENSOR" //Pfad fuer zigbee2mqtt Json Objekte let IDs = []; $("[id=" + zigbee2mqttJsonPath + ".*]").each(function (id) { IDs.push(id) }) on({id: IDs, change: "ne"}, function (obj) { let JsonObj = JSON.parse(obj.state.val) Object.keys(JsonObj).forEach(function(key){ if (getState(obj.id.replace(zigbee2mqttJsonPath, parsedStatesPath)).notExist){ createState(obj.id.replace(zigbee2mqttJsonPath, parsedStatesPath) + '.' + key, JsonObj[key], {read: true, write: true, type: typeof(JsonObj[key]), name: '' , desc: ''},function(){ setState(obj.id.replace(zigbee2mqttJsonPath, parsedStatesPath) + '.' + key, JsonObj[key]) }) }else { setState(obj.id.replace(zigbee2mqttJsonPath, parsedStatesPath) + '.' + key, JsonObj[key]) }; }) }) -
Hallo,
habe eine Scriptvorlage auf meine Bedürfnisse angepasst, mache aber irgend einen Fehler.
Ich hätte jetzt erwartet, dass mir das Script die Datenpunkte unter "alias.0.tasmota" anlegt. Leider klappt das nicht.Die Daten kommen über einen IR Lesekopf am Stromzähler über Tasmota.
Kann mir jemand sagen was ich hier falsch mache?const JSPath = "alias.0" // JS- Pfad const parsedStatesPath = JSPath + ".tasmota" // Pfad fuer geparste States const zigbee2mqttJsonPath = "mqtt.0.tele.tasmota_192_168_50_134_strom.SENSOR" //Pfad fuer zigbee2mqtt Json Objekte let IDs = []; $("[id=" + zigbee2mqttJsonPath + ".*]").each(function (id) { IDs.push(id) }) on({id: IDs, change: "ne"}, function (obj) { let JsonObj = JSON.parse(obj.state.val) Object.keys(JsonObj).forEach(function(key){ if (getState(obj.id.replace(zigbee2mqttJsonPath, parsedStatesPath)).notExist){ createState(obj.id.replace(zigbee2mqttJsonPath, parsedStatesPath) + '.' + key, JsonObj[key], {read: true, write: true, type: typeof(JsonObj[key]), name: '' , desc: ''},function(){ setState(obj.id.replace(zigbee2mqttJsonPath, parsedStatesPath) + '.' + key, JsonObj[key]) }) }else { setState(obj.id.replace(zigbee2mqttJsonPath, parsedStatesPath) + '.' + key, JsonObj[key]) }; }) }) -
Danke hab ich auf "0_userdata.0" geändert aber der Datenpunkt wird leider nicht angelegt.
Das Log sagt folgendes.
javascript.0 2023-06-26 16:34:10.527 info script.js.common.Skript_5: registered 0 subscriptions, 0 schedules, 0 messages, 0 logs and 0 file subscriptions -
Danke hab ich auf "0_userdata.0" geändert aber der Datenpunkt wird leider nicht angelegt.
Das Log sagt folgendes.
javascript.0 2023-06-26 16:34:10.527 info script.js.common.Skript_5: registered 0 subscriptions, 0 schedules, 0 messages, 0 logs and 0 file subscriptions -
Das Script liegt unter "common".
Der String sieht so aus.
{"Time":"2023-06-26T16:05:50","E320":{"Total_out":5096.790,"Total_in":3976.460,"Power_in":-6219.000,"Meter_Number":"0a014c475a0003804049"}}

-
Hallo,
habe eine Scriptvorlage auf meine Bedürfnisse angepasst, mache aber irgend einen Fehler.
Ich hätte jetzt erwartet, dass mir das Script die Datenpunkte unter "alias.0.tasmota" anlegt. Leider klappt das nicht.Die Daten kommen über einen IR Lesekopf am Stromzähler über Tasmota.
Kann mir jemand sagen was ich hier falsch mache?const JSPath = "alias.0" // JS- Pfad const parsedStatesPath = JSPath + ".tasmota" // Pfad fuer geparste States const zigbee2mqttJsonPath = "mqtt.0.tele.tasmota_192_168_50_134_strom.SENSOR" //Pfad fuer zigbee2mqtt Json Objekte let IDs = []; $("[id=" + zigbee2mqttJsonPath + ".*]").each(function (id) { IDs.push(id) }) on({id: IDs, change: "ne"}, function (obj) { let JsonObj = JSON.parse(obj.state.val) Object.keys(JsonObj).forEach(function(key){ if (getState(obj.id.replace(zigbee2mqttJsonPath, parsedStatesPath)).notExist){ createState(obj.id.replace(zigbee2mqttJsonPath, parsedStatesPath) + '.' + key, JsonObj[key], {read: true, write: true, type: typeof(JsonObj[key]), name: '' , desc: ''},function(){ setState(obj.id.replace(zigbee2mqttJsonPath, parsedStatesPath) + '.' + key, JsonObj[key]) }) }else { setState(obj.id.replace(zigbee2mqttJsonPath, parsedStatesPath) + '.' + key, JsonObj[key]) }; }) }) -
nur mal gefragt: kommen deine Daten über MQTT - Adapter als JSON?
wäre das vielleicht eine Variante ohne Script
