INSTAR Deutschland GmbH

Node-RED and Alexa



A Node-RED node to control things via Amazon Alexa. Use voice commands to control your INSTAR IP camera without the need for an Amazon Alexa Skill - no Cloud required. We are going to use the node-red-contrib-alexa-local to create an endpoint for Alexa to control. It was designed to emulate a Philips Hue bridge & device within local network. Amazon Echo is hardcoded to support only on/off/dimming command via this route. Any other type of support has to go through the Alexa Skills route (cloud-based).

Be aware:

At the moment of writing only the Alexa Echo and Alexa Echo Dot Gen 1 & 2 are supported. The Node doesn't support Echo Gen 2, Echo Dot Gen 3 & Echo Plus local devices discovery yet and Echo Show, Echo Spot, Sonos One do not have the capability to discovery devices locally.

A Echo Dot Gen 2 was used for this tutorial.

Node-RED

We already installed Node-RED under under Windows and on a Raspberry Pi. Open the admin panel and go to the Manage Palette menu to install the alexa-local node:


Node-RED and Alexa

Node-RED and Alexa

You should see a new Input Node called alexa local. Drag it onto the working area and double-click it. Type in a function name - e.g. Area One. This is the name that Alexa will use to identify the device. And the name you have to use to select it - so choose it's name wisely.


Node-RED and Alexa

Node-RED and Alexa

Connect a Debug Node to it's output and Deploy the flow. Then ask "Alexa, discover devices" - Alexa should reply that it discovered Area One.

You can test it by issuing the following commands:

  • "Alexa, turn off Area One"
  • "Alexa, switch on Area One"

Node-RED and Alexa

You will see that the corresponding payloads - on or off are received by the Alexa Local Node. To be able to send percentage values, we will have to add a little Function Node to our flow. It needs to be connected to the output of the Alexa Local Node and listens for a Brightness value to be send with the Alexa command. Remember that we are exploiting a function here that is meant to be used by local light switches on your network?


Node-RED and Alexa

The function leaves the payload intact - if the incoming command is of the ON/OFF nature. But if a brightness value is send, it will set this to become the payload of the message:

var a = {payload :msg.bri };
var b = { payload:msg.on_off_command };
var c = { payload: msg.payload };
 

if ( msg.on_off_command === true){
 return c;
} else {
 return a ;
}

You can now use the following example commands:

  • "Alexa, set Red Area Sensitivity to 40%"
  • "Alexa, set Red Area Sensitivity sensitivity to 30"
  • "Alexa, increase Red Area Sensitivity"
  • "Alexa, decrease Red Area Sensitivity"

Node-RED and Alexa

You will see the % values transmitted in the Debug Node.

Tutorials