filter websocket input in order to get all devices except temp
-
I want to receive all devices via websocket except one wire sensors. How has the filter command to look like?
All devices but temp or temp and no other device.I am using node-red with the websocket set command which works ok, but the filter command seems not to work.
Any help appreciated.
-
I have solved the problem. Sorry for the quick post.
Attached please find the command flow for filter[{"id":"46e364e3.e7c2ec","type":"function","z":"cad50249.94c0e","name":"","func":"msg.payload = {\"cmd\":\"filter\", \"devices\":[\"ai\",\"input\",\"ao\",\"relay\"]}; \nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":280,"y":860,"wires":[["a3e4b046.69f93","c16f715d.8fbe1"]]},{"id":"c16f715d.8fbe1","type":"websocket out","z":"cad50249.94c0e","name":"ws://localhost:8080/ws","server":"","client":"84e45387.411c2","x":540,"y":860,"wires":[]},{"id":"418d6f8c.c0e61","type":"inject","z":"cad50249.94c0e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":"5","topic":"","payload":"","payloadType":"date","x":110,"y":860,"wires":[["46e364e3.e7c2ec"]]},{"id":"84e45387.411c2","type":"websocket-client","z":"","path":"ws://localhost:8080/ws","tls":"","wholemsg":"false"}]
-
one important thing at the end:
as soon as you apply a filter the received msg.payload from websocket comes in an array.
this means:
before the applied filter you could your device with msg.payload.dev
with applied filter you must read the device as msg.payload[0].dev !!!