Sending mqtt once character at a time

Hi all,

I need to send text one character at a time, as typed, to an mqtt topic, including enter and control codes.

It seems it requires all sorts of workarounds by using input buttons and a send button.

It seems using the ui text input I can do only so much. I'm open to suggestions.


It would be a large security hole if any website could act as a key stroke logger, I doubt this is possible from client side Javascript without some sort of browser plugin, but i could be wrong.

ftelnet is able to accomplish this but I don't know the inner workings of it and it's probably way beyond my knowledge of how it all works.

Can you elaborate on the use case, it seems you want to emulate a terminal program of some sort ?

Yes you could say that.

My bulletin board software allows the sysop to spy on a node. Often used for bug reporting and the like. Currently you can only spy on one node at a time. The output from each node is also published to a mqtt topic.

Now, if I want to type something back on the terminal, I would like it to be in real time. Again, each node has its own mqtt input topic that can be subscribed to to push data to the node.

I know this probably isn't something that a mqtt dashboard was supposed to do, but it would be interesting to find a workable solution.

If you set the delay on the text input to 0ms then it will only send the complete text when you press enter.

Could that fit your needs then ?

It will but that's not going to work which is why I said I want it to send each character as its typed.

Sending each char is easy, it other keys that is difficult, e.g. return, ctrl c, etc

[{"id":"6a0760d2438c3725","type":"ui_text_input","z":"b9860b4b9de8c8da","name":"","label":"","tooltip":"","group":"2d4fe667.28f8ba","order":12,"width":0,"height":0,"passthru":false,"mode":"text","delay":"100","topic":"topic","sendOnBlur":true,"className":"","topicType":"msg","x":140,"y":700,"wires":[["6554c0432a776f21"]]},{"id":"6554c0432a776f21","type":"change","z":"b9860b4b9de8c8da","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$substring($$.payload, -1)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":320,"y":700,"wires":[["fa71db22acf62d16","ccd50e05ab6af6e8"]]},{"id":"fa71db22acf62d16","type":"ui_text","z":"b9860b4b9de8c8da","group":"2d4fe667.28f8ba","order":13,"width":0,"height":0,"name":"","label":"text","format":"{{msg.payload}}","layout":"row-spread","className":"","style":false,"font":"","fontSize":16,"color":"#000000","x":510,"y":720,"wires":[]},{"id":"ccd50e05ab6af6e8","type":"debug","z":"b9860b4b9de8c8da","name":"debug 326","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":470,"y":660,"wires":[]},{"id":"2d4fe667.28f8ba","type":"ui_group","name":"demo","tab":"1caa8458.b17814","order":2,"disp":true,"width":"18","collapse":false,"className":""},{"id":"1caa8458.b17814","type":"ui_tab","name":"Demo","icon":"dashboard","order":2,"disabled":false,"hidden":false}]
1 Like

OK, I'll take a look. I'm not sure how to use that code you sent but I'll figure it out.

Here's a suggestion for a 'demo flow' using @E1cid's posting above...

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.