Running NodeRed on Windows or on Docker: some functionality questions

Hello,

I'm new to NodeRed and am looking at it as a replacement for EventGhost. I first will need to decide if I will run NodeRed on Docker or directly on my Windows host. I would prefer the former, but am aware that some of my desired functionality may become much more complicated if not impossible. Hence my question...

I use EventGhost on my PC as a bridge between my home-automation (Loxone) and my PC (used as htpc, Logitech Squeezebox Server and controller of directly connected rs232 devices). As such, I would like to have the following functionality:

  1. send/receive TCP or UDP commands and react accordingly
  2. communicate with other network appliances (TV, washer, ...)
  3. receive and decode XAP packets (a UDP-based protocol, for communication with the Logitech server)
  4. bidirectional control of rs232 devices (for now: an amplifier and an arduino)
  5. launch programs on Windows
  6. emulate keypresses on Windows

Regarding possibilities, I guess everything would be directly possible if NodeRed would run directly on Window (of course: protocols have to be known, but I mean it would mainly be a documentation/knowledge issue rather than a technical one)... I this the case?

Trying to move this to Docker, I figured out the following:

  1. TCP/UDP: No problem
  2. Appliances: No problem
  3. XAP: No problem if it receives the UDP (and also, there are flows for the Logitech Server)
  4. RS232: Perhaps possible with hub4com (from com0com suite) running on Windows to communicate with a TCP port which maps to a rs232 port
  5. Launch programs: Here it probably gets tricky.... Can you launch a program on the hosts from Docker? WMI?
  6. Emulate keypresses: I guess this would not be possible from Docker to the host?

Sorry for a long first post, but I would like to make a good starting choice. It won't be that difficult to move from Docker to Windows or vice versa, but it is better to know from the start that some things are too problematic (I tend to get myself stuck on such things :-)).

Thanks for any advice,

Jörg

  1. TCP and UDP comms are well supported by Node-RED. As for the others
  2. You will need to review what contributed nodes are available by searching through the flows site.
  3. As above
  4. Should be doable. Certainly anything that Windows can recognise as a COM port should be fine.
  5. Yes, Node-RED is built on Node.js and has the exec node. Though Windows does have a nasty habit of spawning a temporary command window.
  6. This is a much harder ask. Remember that Node-RED is a SERVER tool primarily. Servers do not expect to run in the context of a desktop and so cannot expect to have access to the desktop UI. Having said that, you can run Node-RED under Electron which does expect to be in the desktop context and should, therefor have access to the UI. Not sure if any nodes exist that make use of it though, you would need to check.

Not by default as mentioned above. You would need the Electron version to be able to run in that context.

Re Docker - Docker on Windows desktops not really a terribly well supported environment - if only because the Docker Desktop app for Windows is not free (for enterprise/commercial use anyway). There are other ways to run the container of course but all add overheads and complexity that is generally undesirable in my view.

Potentially but probably hard to configure.

No, I don't think so.


I spotted this which might help - but I've not tried it: RobotJS - Node.js Desktop Automation - however, by the docs, it looks like it might cover #6 and I'm going to try it out myself. It is a Node.JS tool so you might need to use it in a function node to start with. But perhaps someone will wrap it in a convenient custom node?

1 Like

Thank you for your very clear replies. (it does seem running on Windows directly will be easier than the Docker approach)

About the keyboard presses: it is the first time I hear of Electron. Thank you also for the link regarding RobotJS, I will check out both that one and Electron.

Before posting I searched the library and thought this node would be sufficient to help me with the keyboard emulation: nbr-keyb-mouse (node) - Node-RED but I'm not sure I fully grasp the functionality.

edit: I just found that there are simple VBS scripts that can send keyboard presses... perhaps it is easy to launch a VBS script for the purpose of keyboard emulation (link: cmd - Sendkeys from command prompt - Stack Overflow ) ? Or execute a tool such as AutoHotKey ( https://www.autohotkey.com/ )?

If you want some examples of RobotJS being used in a flow in Node-RED, I built a proof of concept to transfer commands from a Dualshock 4 controller to a remote PC to play local coop games with my brother who lives out of state.

2 Likes

Also ChatGPT can be useful in writing VBS scripts that can send keyboard presses

Stuff like this at least:

cmd.exe /c echo set WshShell = WScript.CreateObject("WScript.Shell") > %temp%\\temp.vbs && echo WshShell.SendKeys "^i" >> %temp%\\temp.vbs && echo WScript.Sleep 250 >> %temp%\\temp.vbs && echo WshShell.SendKeys "^v" >> %temp%\\temp.vbs && echo WScript.Sleep 250 >> %temp%\\temp.vbs && echo WshShell.SendKeys "{TAB}{TAB}{TAB}{TAB}{ENTER}" >> %temp%\\temp.vbs && cscript //nologo %temp%\\temp.vbs && del %temp%\\temp.vbs
1 Like

I did wonder about something like that. Might well be an option.

Yes, I've used that in the past though not for a long time.

Well, that is certainly a rather weird GitHub config. But it looks like it might work.
image

Update: Some other node.js possibilities:

And of course, you could use PowerShell scripts as well - these have the benefit of being able to access .net and so can link into different apps. You can also use them to automate Windows at a lower level than the UI and if you are using Office apps, you get good access to Office automation as well.

1 Like

Thanks for the replies and suggestions. Interesting to see there many options.

The functionality to start a program and send keystrokes is mainly to allow me to have some control from the Loxone home automation app: it will allow me to use that app to e.g. start the netflix app, and start/stop playback, change the volume, ..

The RobotJS solution and some others look very nice, but also more complicated... From what I quickly read, I would be tempted to try first with Powershell scripts. It does not seem too complicated and does not seem to depend on obscure constructions (unlike e.g. the nbr-keyb-mouse node). My current Eventghost approach depends on some obscure and home-made solutions which kept growing over the years and as a result is not easy to maintain. With the disappearance of its website (still on github, but a lot of community was lost), I think it is time to move to something else. :slight_smile: Starting from scratch with NodeRED, I should probably limit the amount of new stuff to be sure I get something working. :slight_smile:

1 Like

Good luck and please do let us know how you get on.

I will. Don't expect any updates soon: quite busy with work and so... I plan to reinstall Windows (perhaps even venture to move to Windows 11 on an i7-4970k) :). Problem is that it is all very connected through EventGhost, so I have to make sure that I switch off the functionality in EventGhost, add it in NodeRED and modify the home automation system for the change. A bit annoying on a working system... but I'll have to make the move.

Thanks again.

While looking for Powershell scripts and things, I learned that there is some remote powershell functionality over ssh: PowerShell Remoting Over SSH - PowerShell | Microsoft Learn.

And there is Powershell for Linux...

Long shot: would that mean I can install Powershell on my Docker container, and use it to run Powershell scripts on the host (the host would be the remote computer, scripts would be launched from container)?

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