EddyG wrote: ↑Monday 20 December 2021 16:50
I am looking for that method for some time. Could you share the methode?
How do you maintain the table and how do you use the table in flows?
Code: Select all
[{"id":"79237bef.304494","type":"inject","z":"9581f007.eb9af","name":"1h","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"3600","crontab":"","once":true,"onceDelay":"4","topic":"","payloadType":"date","x":70,"y":80,"wires":[["e07f694d.49acf8"]]},{"id":"e07f694d.49acf8","type":"http request","z":"9581f007.eb9af","name":"","method":"GET","ret":"obj","paytoqs":"ignore","url":"http://192.168.1.200:8080/json.htm?type=devices&filter=all&used=true&displayhidden=1","tls":"","persist":false,"proxy":"","authType":"","x":210,"y":80,"wires":[["2ea5769c.9f707a"]]},{"id":"2ea5769c.9f707a","type":"function","z":"9581f007.eb9af","name":"Build Name:{idx,Type} table","func":"// objectsList = msg.payload=JSON.parse(msg.payload).result\nobjectsList = msg.payload.result\nreturnObject={}\nobjectsList.map(x => {returnObject[x.Name] =\n {idx : x.idx, Type : x.Type}})\nmsg.payload=returnObject\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":420,"y":80,"wires":[["70abef6e.88497"]]},{"id":"70abef6e.88497","type":"function","z":"9581f007.eb9af","name":"Store global idxTable","func":"global.set('idxTable',msg.payload,\"memoryOnly\");\nglobal.set('idxTable',msg.payload,\"file\");//\"file\"\nnode.status({text:`idxTable: stored`,fill:'green',shape:'dot'});\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":660,"y":80,"wires":[[]]}]
In nodered settings adapt your storage configuration, mine is:
Code: Select all
contextStorage: {
default: "memoryOnly",
memoryOnly: { module: 'memory' },
file: { module: 'localfilesystem' }
},
In http request adapt your domoticz address
In addition to idx, "Type" is also stored since it is usefull in some cases
To use it simply do
Code: Select all
IDX = global.get('idxTable','memoryOnly')['<your device name>'].idx;
TYPE = global.get('idxTable','memoryOnly')['<your device name>'].Type;