Get FHEM device shadow (all readings from device)
Uses the jsonlist module to get a JSON representation of all the current device readings and their values. The result format is generated from the more verbose JSON representation from FHEM, and it is similar to AWS IoT, i.e., it contains a top-level reported
element.
The http request node needs to be configured with the FHEM URL and respective CSRF token.
The flow can be used as a subflow and expects msg.device
to contain the FHEM device name.
If the FHEM installation has CSRF enabled, it is recommended to set a fixed CSRF token with attr WEB csrfToken <token>
.
[{"id":"4d1f98b0.642758","type":"http request","z":"4b0fa5fe.fa0fdc","name":"fhem request","method":"GET","ret":"obj","url":"https://fhem.domain.tld/fhem?cmd=jsonlist2+{{device}}&XHR=1&fwcsrf=<csrftoken>","tls":"","x":343,"y":149,"wires":[["62206b38.707924"]]},{"id":"62206b38.707924","type":"function","z":"4b0fa5fe.fa0fdc","name":"","func":"var res = {};\n\nfor (var r in msg.payload.Results[0].Readings) {\n res[r] = msg.payload.Results[0].Readings[r].Value;\n}\n\nmsg.payload = { reported: res };\nreturn msg;","outputs":1,"noerr":0,"x":593,"y":149,"wires":[[]]}]