@paul53
Vielen Dank, das funzt.
NEWS
Latest posts made by Klaus-Anders
-
Bitte um Hilfe bei MQTT zerlegen
Hallo,
ich habe Probleme beim zerlegen von einem Mqtt String.
Der von hier verwendete Script zeigt keine Fehler.
Es werden aber keine Datenpunkte angelegt.
Ich kapier das einfach nicht, liegt wohl am Alter.hier mal der Script
const JSPath = '0_userdata.0'/Example state/ // JS- Pfad
const parsedStatesPath = JSPath + ".Pelletofen" // Pfad fuer geparste States
const zigbee2mqttJsonPath = 'mqtt.0.service'/service/
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])
};
})
})Vilen Dank schonmal im voraus.
Klaus