Added Files

This commit is contained in:
Joachim Hummel committed 2021-12-11 10:39:06 +00:00
1 parent 9e15b0bab0
commit d5cce2311f
2 files changed
+1

No files matched your search

+1
View File
@@ -0,0 +1 @@
[{"id":"25b11cba.cef60c","type":"subflow","name":"topic filter","info":"## MQTT Topic filter\n\n### Description\nFilters messages based on the value of `msg.topic` using standard MQTT topic filter notation.\n* `#` match all\n* `+` match one level\n\n### example filters\n* `home/+/temperature` \n * will match `home/bedroom/temperature`\n * will match `home/livingroom/temperature`\n * will not match `home/room/1/temperature`\n * will not match `room/1/temperature`\n* `home/#` \n * will match `home/location`\n * will match `home/livingroom/temperature`\n * will match `home/livingroom/humidity`\n * will not match `room/1/temperature`\n\n\n### Outputs\n\n#### Output 1 - match\nMessages with a topic that matches the `topic filter` will be sent out this output.\n\n#### Output 2 - no match\nMessages with a topic that does not match the `topic filter` will be sent out this output to permit next level filtering\n","category":"function","in":[{"x":68,"y":80,"wires":[{"id":"8635ef98.051688"}]}],"out":[{"x":340,"y":48,"wires":[{"id":"8635ef98.051688","port":0}]},{"x":340,"y":96,"wires":[{"id":"8635ef98.051688","port":1}]}],"env":[{"name":"filter","type":"str","value":"","ui":{"label":{"en-US":"Topic filter"},"type":"input","opts":{"types":["str"]}}},{"name":"status","type":"bool","value":"true","ui":{"label":{"en-US":"Show topic"},"type":"input","opts":{"types":["bool"]}}}],"color":"#D8BFD8","outputLabels":["Match","No Match"],"icon":"font-awesome/fa-filter","status":{"x":548,"y":160,"wires":[{"id":"45101d0d.e1f88c","port":0},{"id":"ddfcc22.bc6bc4","port":0}]}},{"id":"8635ef98.051688","type":"function","z":"25b11cba.cef60c","name":"filter","func":"var a = msg.topic;\nvar b = env.get(\"filter\") || '#';\n\nif(a===b) { return [msg, null]; }\nif(b==='#') { \n if(a) return [msg, null]; //if topic is something, OK\n return [null, msg];//otherwise, fail!\n}\nvar nameSegments = a.split('/');\nvar filterSegments = b.split('/');\nfor (var i = 0; i < filterSegments.length; i++) {\n var topicSegment = nameSegments[i];\n var patternSegment = filterSegments[i];\n var match = false;\n if(topicSegment === patternSegment) { match = true; }\n if(patternSegment === '+') { match = true; }\n if(patternSegment === '#') { return [msg, null]; }\n if(match === false) { return [null, msg]; }\n}\nif(nameSegments.length !== filterSegments.length) { return [null, msg]; }\n\nreturn [msg, null];\n","outputs":2,"noerr":0,"initialize":"","finalize":"","x":192,"y":80,"wires":[[],[]]},{"id":"7d929e05.684e","type":"inject","z":"25b11cba.cef60c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":148,"y":160,"wires":[["c9d341ce.724848"]]},{"id":"45101d0d.e1f88c","type":"function","z":"25b11cba.cef60c","name":"","func":"var b = env.get(\"filter\") || '#';\nnode.status({text:b})\nmsg.payload = b;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":428,"y":144,"wires":[[]]},{"id":"c9d341ce.724848","type":"switch","z":"25b11cba.cef60c","name":"","property":"status","propertyType":"env","rules":[{"t":"true"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":290,"y":160,"wires":[["45101d0d.e1f88c"],["ddfcc22.bc6bc4"]]},{"id":"ddfcc22.bc6bc4","type":"function","z":"25b11cba.cef60c","name":"","func":"node.status({})\ndelete msg.payload;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":428,"y":192,"wires":[[]]},{"id":"9ba2a6f1bec1b7f2","type":"tab","label":"QO-100","disabled":false,"info":"[Blogartikel](https://blog.unixweb.de/aufbau-einer-qo-100-sende-und-empfangstation-qrv/)","env":[]},{"id":"553859a056a3a9fa","type":"group","z":"9ba2a6f1bec1b7f2","name":"","style":{"label":true,"color":"#addb7b","fill":"#e3f3d3"},"nodes":["c2f5eb272eac5c5f","cc60a6dd93dd3244","359f4d4fd685e0d1","b9fa04c1b5752afe","d215763a18f731ca","75b6482b8a9a2df4","1edd79e76fc773c6","3563a9718410bd9a","6ddec929453a1205","893ff6bf6e897f01","67932b2d7f19fc5c","62c9cef31b53a92f","cc1b24ef4d605dbe","91e04efb82cf0220","081e6924568948d6","08510d364969b808","d092f9e556521811","ba506444841b3ba2","6d3858104e9a8ec1","e2265a9cae75b92b","fdff7ad7ae4096f4","d104d1752f65d33e","e0e8e651f997ddc6","e0337b4ba6f1808e","9a32ce4ed64f1dd0","76b5fe96cf5167f6","da7082cf6b59d27e","3f567cd2a2eea6b8","de8aa673b431f513","fa5d5ed532d632d3","65b9376e7b7d4c58","ee1c7a4358e5cf49","6557e981a8ac880f","3f8d1208f83e5d04","2af2890510b9505e","82fe499fa634bf20"],"env":[],"x":34,"y":59,"w":1032,"h":922},{"id":"c2f5eb272eac5c5f","type":"mqtt in","z":"9ba2a6f1bec1b7f2","g":"553859a056a3a9fa","name":"QO-100 Power / Volt","topic":"esp3/sensor/#","qos":"2","datatype":"auto","broker":"d1df93ca.89d618","nl":false,"rap":true,"rh":0,"inputs":0,"x":170,"y":180,"wires":[["d104d1752f65d33e","e0e8e651f997ddc6"]]},{"id":"cc60a6dd93dd3244","type":"function","z":"9ba2a6f1bec1b7f2","g":"553859a056a3a9fa","name":"","func":"\nreturn msg;","outputs":1,"nLine truncated
View File
Whitespace-only changes.