Hi all, In a recent thread, I promised @Trying_to_learn that I would revisit a project I started quite a long time ago now, which is a replacement for the MQTT Explorer desktop app.
So here is my first draft. It is still very basic but it demonstrates the principles. If you have anything you particularly want to see, let me know. Not promising anything but I will certainly add to the backlog.
The idea here is to have a useful, purely web-based view into an MQTT environment. But also to showcase what Node-RED and UIBUILDER can achieve.
All the clever front-end bits are done in the front-end code and Node-RED is simply used to provide the environment, the connector to MQTT and the comms to the front-end. I am just dumping the output from an MQTT-in node straight to UIBUILDER. With a rate limiter thrown in just to be on the safe side.
Eventually, I will doubtless add the ability to send MQTT messages as well but for now, it is just a very simple UI using native HTML, CSS and JavaScript. No front-end frameworks are used or needed.
Please note that I am making use of fairly new CSS features. These all work in all current desktop (and I think mobile - let me know) browsers. I am using the UIBUILDER uib-brand CSS file as the base and I use the built-in uibuilder.sysntaxHighlight(data) function to do some simple but nice formatting of the MQTT payloads. The tree view is native HTML <details> and <summary> tags. The layout uses CSS grid. The details display uses HTML <template> elements that are cloned to the details panel as needed which saves a load of processing and memory storage of data.
I haven't cached the inputs as yet, if you're MQTT broker is anything like mine, you will have a LOT of data flowing through. However, it probably makes sense to cache the latest retained messages which I will do. With UIBUILDER, you can easily use multiple uib-cache nodes to have different strategies for different topics. You might, for example, want to cache a thousand of some critical message but not of others.
I will share the front-end code for this in a follow-up message shortly.
[{"id":"9f1e743afa926865","type":"uibuilder","z":"4393d057899d5287","name":"","topic":"","url":"mqtt-explorer","okToGo":true,"fwdInMessages":false,"allowScripts":false,"allowStyles":false,"copyIndex":true,"templateFolder":"blank","extTemplate":"","showfolder":false,"reload":false,"sourceFolder":"src","deployedVersion":"5.0.0-dev.2","showMsgUib":false,"title":"A Node-RED replacement for MQTT Explorer","descr":"","editurl":"vscode://file/D:\\src\\uibRoot/mqtt-explorer/?windowId=_blank","x":1040,"y":200,"wires":[["7d8dc679995a88bd"],["affb2d9a74d04af4"]]},{"id":"c97df9205436c418","type":"mqtt in","z":"4393d057899d5287","name":"","topic":"#","qos":"2","datatype":"auto","broker":"1fe2972256cb8a87","nl":false,"rap":true,"rh":0,"inputs":0,"x":190,"y":180,"wires":[["9bc3728ee0f43c66"]]},{"id":"ae90065eb89d6ad5","type":"switch","z":"4393d057899d5287","name":"Filter out some very high volume topics","property":"topic","propertyType":"msg","rules":[{"t":"cont","v":"nrlog","vt":"str"},{"t":"cont","v":"telegraf","vt":"str"},{"t":"else"}],"checkall":"false","repair":false,"outputs":3,"x":570,"y":180,"wires":[[],[],["046efcf288d44964"]]},{"id":"a8081162a034775c","type":"mqtt in","z":"4393d057899d5287","name":"","topic":"$SYS/#","qos":"2","datatype":"auto","broker":"1fe2972256cb8a87","nl":false,"rap":true,"rh":0,"inputs":0,"x":190,"y":240,"wires":[[]]},{"id":"7d8dc679995a88bd","type":"debug","z":"4393d057899d5287","name":"","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"true","targetType":"full","statusVal":"","statusType":"counter","x":1175,"y":180,"wires":[],"l":false},{"id":"affb2d9a74d04af4","type":"debug","z":"4393d057899d5287","name":"","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"true","targetType":"full","statusVal":"","statusType":"counter","x":1175,"y":220,"wires":[],"l":false},{"id":"046efcf288d44964","type":"delay","z":"4393d057899d5287","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"10000","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":850,"y":200,"wires":[["9f1e743afa926865"]]},{"id":"9bc3728ee0f43c66","type":"change","z":"4393d057899d5287","name":"Add \\n Timestamp","rules":[{"t":"set","p":"lastUpdate","pt":"msg","to":"","tot":"date"}],"action":"","property":"","from":"","to":"","reg":false,"x":330,"y":180,"wires":[["ae90065eb89d6ad5"]]},{"id":"1fe2972256cb8a87","type":"mqtt-broker","name":"mqtt5-testing","broker":"home.knightnet.co.uk","port":"1883","clientid":"desktop-nr-mqtt5-testing","autoConnect":true,"usetls":false,"protocolVersion":"5","keepalive":"60","cleansession":true,"birthTopic":"DEV/mqtt5-testing","birthQos":"0","birthRetain":"false","birthPayload":"Online","birthMsg":{},"closeTopic":"DEV/mqtt5-testing","closeQos":"0","closeRetain":"false","closePayload":"Offline","closeMsg":{},"willTopic":"DEV/mqtt5-testing","willQos":"0","willRetain":"false","willPayload":"Broken","willMsg":{},"sessionExpiry":""},{"id":"d99e9240e9cdc815","type":"global-config","env":[],"modules":{"node-red-contrib-uibuilder":"7.6.0"}}]


