Node-Red Working Slider to Control Brightness

Hello fellow HA’ers,

If you haven’t played around with Node-Red yet with hass.io, I highly suggest trying it out. It’s made a lot of things much simpler for me with regards to creating complex automations and UI dashboards…

I struggled with this particular item for a solid few days but was finally successful. I searched high and low reading many articles but really couldn’t find any solid examples of exactly how to do this so I just hacked away at it until it worked for me… The key to success is using the ‘debug’ node in Node-Red to view the output of various operations and trying to figure out how to structure the payloads of a message. I’m not a programmer by trade but have enough experience looking at examples and banging my head on the wall long enough to figure things out usually…

Hopefully this will help some folks out from spending days trying to do the same thing without being a genius programmer…

Using the Node-Red dashboard UI slider component along with a function node and HA service node, I was able to create a slider which controlled the brightness for my lights.

Quick little screenshot of my testbed in Node Red:

Here is the code for the Node-Red function node:


var newMsg =  {
        payload: {"data":{"brightness":msg.payload}}
    };
return newMsg;

Here it is in the Node-Red UI:

You can put any other supported attributes in the payload as well such as color, etc…

Using the Node Red Dashboard (https://flows.nodered.org/node/node-red-dashboard), I was able to throw this extremely simple and quick test dashboard together literally in less than a few minutes:

By using ‘Cut and Paste’, I created three more dedicated sliders in the UI in less than 15 seconds:

Wonderful little application and works great to get dashboards together quickly and for a number of different platforms since it is browser-based… My long term plan is to somehow put together a ‘Floorplan’ like UI using Node-Red since it is so easy to prototype things without having to constantly restart HASS to see the results…

Anyways, my tiny little contribution back to the community who has helped me tremendously in the very short amount of time I switched over to HASS from Smartthings… Which incidentally, I bridged quite successfully using MQTT with the help of this board as well. MQTT is a fantastic ‘Switzerland’ for IOT in my opinion…

Been absolutely loving the journey so far…

Cheers,

11 Likes

@IndieFilmmaker Awesome! I’ve also started today with Node-red and boy is it amazing… would you care sharing your code here so that I can learn a bit from this example?