Versioner sammenlignet

Nøgle

  • Linjen blev tilføjet.
  • Denne linje blev fjernet.
  • Formatering blev ændret.

Indholdsfortegnelse

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

But, starting it on Docker on my Home Laptop (also used for Home Assistant on Docker and Plex Media Server):

...

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.


NR 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 pretty much everywherehome 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 it 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:

Kodeblok
<VirtualHost nodered.mos-eisley.dk:80>

        ServerName nodered.mos-eisley.dk

        LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" combined
        ErrorLog ${APACHE_LOG_DIR}/nodered.mos-eisley.dk-error.log
        CustomLog ${APACHE_LOG_DIR}/nodered.mos-eisley.dk-access.log combined

		RewriteEngine on
        RewriteCond %{HTTP:Upgrade} ^WebSocket$ [NC]
        RewriteCond %{HTTP:Connection} Upgrade$ [NC]
        RewriteRule .*/(.*) "ws://cantina.mos-eisley.dk:1890/$1" [P,L]

        ProxyPreserveHost On
        ProxyRequests Off
        ProxyPass / http://cantina.mos-eisley.dk:1890/
        ProxyPassReverse / http://cantina.mos-eisley.dk:1890/

        <Proxy *>
        Order deny,allow
        Deny from all
        Allow from xxx.xxx.xxx.xxx
        Allow from yyy.yyy.yyy.yyy

		Authtype Basic
        Authname "Password Required"
        AuthUserFile /etc/apache2/.htpasswd
        Require valid-user
        </Proxy>

</VirtualHost>

Creating password:

Kodeblok
sudo htpasswd -c /etc/apache2/.htpasswd <username>
Kodeblok
titlecantina.mos-eisley.dk
<VirtualHost *:1890>
        ServerAdmin webmaster@localhost

		RewriteEngine on
        RewriteCond %{HTTP:Upgrade} ^WebSocket$ [NC]
        RewriteCond %{HTTP:Connection} Upgrade$ [NC]
        RewriteRule .*/(.*) "ws://localhost:1880/$1" [P,L]

        ProxyPreserveHost On
        ProxyRequests Off
        ProxyPass / http://localhost:1880/
        ProxyPassReverse / http://localhost:1880/

        <Proxy *>
        Order deny,allow
        Deny from all   
        Allow from 77.243.52.144 # www.mos-eisley.dk
        Allow from 10            # Local Lan 
        </Proxy>

</VirtualHost>

...

Adding Node-RED To Home Assistant

Node-RED

In Node-RED, under Settings → Palette - Add "node-red-contrib-home-assistant-websocket":

Home Assistant

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.

...

The "Listen" is listening om MQTT Directly and turns on the ZenseHome ceiling outlet (just to be sure) and turns on the Philis Philips Hue lightbulbs , the latter 2 both through Home Assistant.

I have also used the Philips Hue Zone "Christophers Ceiling Light" instead of turning on all three bulbs indivudually.

...

Added the toogle for the Home Assistant entity (A Philips Hue Plug):

And wired them together:

...