After seeing some of the stuff my colleague Martin has done with Node-RED, I wanted to switch to oit, despite my KISS strategy, and Node-RED just introduces another device to mange.
Installing Node-RED as a Docker container
And it was running on http://sparrow:1880. I saw some wierd stuff in the start, until i pressed "Deploy" the first time, after that every thing has just bee working.
Node-RED has no (as far as I know currently, any users or admin/management in front of it by default, and I wanted to be able to use it from home and work/work-vpn... so I created a dual stack of Reverse Proxies:
Setting the browser to http://nodered.mos-eisley.dk it hits my Confluence Server (in a Datacenter) and the Apache2 on it proxies it to http://cantina,mos-eisley.dk:1890 (Fiber Router with port forward to Home laptop), and the Apache2 on the Laptop proxies it to sparrow:1880 (the Docker container on the Home Laptop).
On both Apache2 I have IP Restrictions, and on the first, username/password - otherwise all people at work could change my Node-RED setup:
With this setup I can use it from xxx.xxx.xxx.xxx and yyy.yyy.yyy.yyy that represents some well known adresses like work and fiber.
Adding Node-RED To Home Assistant
In Node-RED, under Settings → Palette - Add "node-red-contrib-home-assistant-websocket":
In Home Assistant, Add "Node-RED Companion" as an Integration:
Check out https://zachowj.github.io/node-red-contrib-home-assistant-websocket/guide/custom_integration/ for some tips also.
And You are ready to go.
Now, Home Assistent is my "heart" of the Installation, but starting to use it, I realize that it has Integrations for Philips Hue and MQTT directly, so Home Assistant could be bypassed for several automations.... I guess that more religion than tech...
My first Automatins in Home Assistant was to bridge my propritary ZenseHome system to Philips Hue:
Later on, ZenseHome actually got native Hue support... but Im stil using Home Assistant.
So, I moved this to Node-Red:
The "Listen" is listening om MQTT Directly and turns on the ZenseHome ceiling outlet (just to be sure) and turns on the Philips Hue lightbulbs through Home Assistant.
I have also used the Philips Hue Zone "Christophers Ceiling Light" instead of turning on all three bulbs indivudually.
So, I moved all these similar automations from Home Assistant to Node-Red in no time!
Stream Deck Support
My youngest son got a Stream Deck and we wanted to be able to trigger stuff from the buttons, so I looked into the Home Assistant API - and well, You need authetications and all sorts of "complicated" stuff.
So I turned to Node-Red, and found the "http in" node, which setup and url that Node-RED listens on:
Added the toogle for the Home Assistant entity (A Philips Hue Plug):
And wired them together:
Now, going to http://sparrow:1880/switch-vr simply toggles the VR on/off - no authentication or similar needed, the URL can be put directly into the Stream Deck software and assigned to a Button.
I looked into messaging (Home Assistant already setup for twillo) and found that Facebook Messenger are possible, but the setup is complicated.
So I turned (as and SMS alternative) to Discord, from the Settings → Palette - Add "node-red-contrib-discord-advanced":
The setup is a bit complicated - follow the links on https://github.com/Markoudstaal/node-red-contrib-discord-advanced
Before sending the Discord Message, a "function" node will set the message (msg) - that is the Yellow/orabge "Prepare Message":
The "msg.channel" is and ID and can be found in the URL for the Channel when running Discord in a Browser, its NOT a string like "#home-assistant". Thank for Support from the coders.
And so, a few messages to Discord: