Automating a Humidifier with Node-red and a Broadlink RM3 Mini: Part 2 Voice Control and Home-Assistant

The final Flow

Ok, so if you’re following along from Part 1 today am going to deal with how I integrated the Node-red controlling Humidifier into Home-Assistant itself and how I set it up to be controlled via Amazon Alexa.

Firstly, whilst the Broadlink Mini has been rock solid, I am aware that IR control doesn’t provide feedback. That being said, there’s only so far you can go with a device that isn’t “smart” so I have to work with what I’ve been given. You could potentially put it on a power monitoring smart plug to try and measure the values to determine when it’s on versus in standby, but for our use case, it’s unecessary.

I fired up Hassio (Home-Assistant) and immediately went into my configuration.yaml file and added these lines:

input_boolean in home-assistant
input_boolean in home-assistant

This essentially creates dummy switches for want of a better phrase. I double checked my configuration and once it came back with no errors, I proceeded to restart the Home-Assistant server.

I then switched into Node-red and using the Home-Assistant palette, I created the following layout:

 

Humidifier Integration
Humidifier Integration into Node-red and Home-Assistant

 

Now as confusing as this may initially look, it only builds on what we’ve already done in Part 1 so if you need a refresh, now might be a good idea to go and check back.

I have essentially just added the three input booleans that we set up in home-assistant into node-red. The idea being that if one of the input booleans (dummy switches) is switched on, it will trigger the state-change node to actually tigger the function and switch on the desired effect. Thus making the dummy switch actually useful. I will show you an example of the coding that went into one of these state nodes.

Home-Assistant State Node
Home-Assistant State Node

 

I have left the inject/timestamp nodes in there just to allow myself the ability to independently trigger the flow for testing purposes. I also leave the debug node in there for the same reason. In reality, once this is set up the nodes can be removed.

You’ll notce that I have a switch node on the night mode flow. This is because the humidifier can only be in night mode or auto mode. Switching to either disables the other. If you switch off Night Mode, then the switch triggers the “off pathway” which turns Auto Mode on, thereby cancelling night mode. You can see how the simple switch mode is set up below:

simple switch node
simple switch node

 

If I was to remove the testing and separate inputs, the complete Node-red flow would look as follows:

complete clean flow
complete clean flow

 

Our work in node-red is complete. Note I didn’t bother adding a state or inject for the lamp mode, as we prefer the humidifer without any lights showing, but I left the mode here so that in the future we could possibly revisit it (i’d already captured the IR command).

Again, should I wish this to come on or off at a certain time in the day, I can add further triggers into the flow, but for now I will keep this relatively simple. We now need to switch back into home-assistant where we can finish the UI side of things.

Once back in Home-Assistant/Hassio, we need to configure the card in the user interface. Click on the top right three small dots and “configure UI” to bring up the configuration menu. Then add an entities card. I completed the card as below, as per my input booleans I created earlier:

 

entities card configuration

entities card configuration

 

Which resulted in this final card showing on my bedroom’s home page:

I quickly checked the various toggles and all worked perfectly. At this point in time, if this is all you’re looking to do, you can stop here. However, I wanted to move forwards further and use Amazon’s Alexa to control things directly.

For this you need to go here and set up an account:  https://alexa-node-red.bm.hardill.me.uk/

You then need to download and install the corresponding palette in node-red: node-red-contrib-alexa-home-skill

This will give you the following nodes in node-red:

 

node-red-contrib-alexa-home-skill
node-red-contrib-alexa-home-skill

 

Once you’ve got this far, you need to login to https://alexa-node-red.bm.hardill.me.uk/ and then add-devices. I simply set up the following:

 

Setting up the Humidifier
Setting up the Humidifier

 

I also set up:

 

Setting up Night Mode
Setting up Night Mode

 

Once they were both set up. I then went back to Node-red and added the following:

 

Voice Control Flow
Voice Control Flow

 

Note, as you double click and configure the Alexa nodes you will need to login with the same details you set up for the website account. If we take humidifer node- this is what the code looks like.

 

alexa-home node
alexa-home node

 

I tidied up the nodes from what we had used earlier, and added the switches there just for good housekeeping. I repeated the process with Night Mode. Once they were both complete, i deployed the nodes and then switched to the Amazon Alexa app on my phone. In the app I essentially told Alexa to discover new devices and after about 30 seconds both Night Mode and Humidifer appeared as switches in the app.

It was at this point that we started testing the functions. Alexa was able to switch on both the humidifer and night mode as requested. The only caveat is that if the humidifer is not already on, switching on or off night mode has no effect, but that’s fine.

 

The final Flow
The final Flow

 

 

I hope this tutorial has helped to show you what can be done in Node-red. It’s extremely powerful, and once you’re familiar with the software, copying and pasting nodes and just changing small snips of code allow you to build complex flows extremely quickly.

Check out my other blog posts for more information on some of the flows we have in the home.

 

 

 

Leave a Reply