Amazon Alexa / Echo controlling Opto Digital Output - How To

Had a bit of fun over the weekend… Got my Amazon Echo controlling a digital output on my garage rack of Opto 22 I/O.

First the hardware. I have a free standing bank of 6 fluorescent tubes to use as a work light.
When they are not in use, they hook on some chain hanging from my garage roof.
Since they are free standing, I have a longish extension cord that they plug into. On the Opto end, I simply have a 120AC plug and socket with a break in the active line that goes to a SNAP-OMR6-C mechanical relay module. It simply turns power on and off to the light just like a light switch.
For the longest time, I have been using groov as the only way of flipping the digital point state. For the most part, its not a problem. In the kitchen we have computer that always has a Chrome browser running, so you just hit the button the way through to the garage.

Yesterday, all that changed.

Enter Node-RED.

There is a Node that emulates a Belkin Wemo. This is important for two reasons, firstly, it means that this flow only works on digital outputs. Secondly, it means that everything stays inside your network. No phoning out to the cloud just to turn a switch on or off.
This means that its pretty quick, and it means that you don’t have a major pile of security / https / applications / skills to jump through to get going.

So, here is how it looks in my Node-RED web dashboard.

Pretty simple huh.
The Wemo node is simply configured for a payload of 0 when off and 1 when on.
The PAC Node just points to the digital output. That’s it.

Here is the flow, you will need to tweak the digital output to match your PAC IP address and I/O name.
(Remember, your PAC needs to be running Firmware Ver 9.5a or better).

[{“id”:“fc2dedfc.7edbd”,“type”:“wemo-emulator”,“z”:“de358902.74cf18”,“name”:“garage light”,“friendlyName”:“garage light”,“serial”:“1”,“port”:“44001”,“onTopic”:“on”,“onPayload”:“1”,“offTopic”:“off”,“offPayload”:“0”,“x”:132.85714285714283,“y”:105.71428571428571,“wires”:[[“d0c1c672.ba4cd8”]]},{“id”:“d0c1c672.ba4cd8”,“type”:“pac-write”,“z”:“de358902.74cf18”,“device”:“47fe29ec.29b8e8”,“dataType”:“dig-output”,“tagName”:“garage_light_6_fluro”,“tableStartIndex”:"",“value”:"",“valueType”:“msg.payload”,“name”:"",“x”:403.3333282470703,“y”:106.66667175292969,“wires”:[[]]},{“id”:“47fe29ec.29b8e8”,“type”:“pac-device”,“z”:"",“address”:“”,“protocol”:“http”}]

So, now the only thing you need to know is that last week (honestly, this is the real reason I got all this going) Amazon added a new wake word… Now you have a choice of Amazon (boring), Echo (Okish), Alexa (Who?) and … Computer.

On the way out to the garage, just yell ‘Computer, turn on the garage light’.
Before you can get there… You can see the light!

1 Like

Nice example of integrating technology. There has to be many applications out there for this kind of link up. Wasn’t aware that “computer” can now be used as an Alexa triggerword.

I think the really amazing part about this technology is Alexa understanding Aussi accents perfectly. Amazon seem to have put a whole data center of processing power behind this. :joy:

On a slightly related subject and for any OptoGeek out there planning dire deeds in the hot tub, don’t forget to switch off your Alexa speaker first and do remember that your water meter may still be watching.

Police ask Alexa “Did you witness a murder?”

Thanks George… The sad/funny part is that when we first got ‘Computer’, my wife and kids could use it with no problems.
Me and my rotten accent on the other hand… yeah, lets just say that we have had to do a bunch of voice training and she is only slowly coming to understand me. Mostly. Sometimes.

I was attempting to mimic your work here but I was unable to get the Alexa skill added for Wemo. Is there some trick to this that I am overlooking? We do not have a Wemo hub in our office.

David, the nice thing (and the main reason I went this way) is that you don’t need a ‘skill’. (Personal rant - I cant stand skills and think the implementation of them is fundamentally broken).

Alexa knows how to talk to a Wemo out of the box.
Set up the Node-RED node and then go into the Alexa app on your phone, navigate to ‘Smart Home’ from the main menu.
From there, click on ‘Discover Devices’ from the ‘Your Devices’ section.
What happens then is that Alexa puts a UDP broadcast storm out over your network and all the Wemos, fake or otherwise, respond back with their device name (and other details).
Thus they are added to the list of devices in your home.
From then on, Alexa can control that point with a ‘turn on’ or ‘turn off’ command as you heard on the video.
(I called my fake Wemo device ‘the tv’, as just calling it tv felt weird when saying it out loud - Computer! Turn off tv - yeah, nah).

So, in short, add the node, deploy, discover via the Alexa app and you are pretty much done.

Lets know if you get it going, or ask more questions if you don’t.

Thanks for the help. We are working on getting Alexa to turn on the hot tub that is controlled by PAC.

1 Like

We got it working. Our network is segmented and that was why it did not work the first time. We are looking into how to send values and strings based on voice commands. Have you done this yet?

1 Like

Ah, yes, the broadcast would have trouble jumping networks, that explains it… Sweet.

In short, no. It is pretty high up on my list to test and experiment with ways to get Alexa to do more than just on / off control.
Ultimately the goal was to be able to tell Alexa to set something at 22% and to ask her what a temperature is.

(Super short term, yes, this is easy to do, just set up as many Wemo switches as you need, each switch sets a value, so for example, ask Alexa to ‘turn on twenty two percent’ and then in the code, tweak the ‘on’ command she sends to be a value - this I have working, but yes, its a bit clunky and I am sure there is a limit to the number of Wemos she will support).

Nice work, Ben! And a great demo.

To be clear, this terrific Alexa/Node-RED/Opto 22 PAC demo won’t work on a groov Box with Node-RED. You’ll need Node-RED running on Windows or another computing platform where you have control over the firewall to allow communications on various ports. Unfortunately, at this time, the groov Box doesn’t permit allowing/denying custom firewall ports.

The way the Wemo Emulator Node-RED node works is it listens on whatever port you configure in the node itself. For example, in Ben’s sample flow code he’s posted here, he’s configured the node to listen on port 44001. For the node to “listen” on that port, the firewall for the computer that Node-RED is running on has to open port 44001. The “listening” action is required first for configuring Alexa during the “Discover Devices” step in the Alexa App, then for subsequent commands to perform the function.

But again, very cool demo and another example of the power of Node-RED for “wiring together hardware devices, APIs and online services in new and interesting ways.”

For Amazon Alexa fans, I created a skill to demonstrate how you can not only CONTROL (output) something, but also get/monitor info from your control system (e.g. via a groov API endpoint, with one of our groov Boxes here in the building that’s connected to the internet).

The “skill” creation process wasn’t as clunky as the first time I looked at it (back when the Echo came out). Lots more examples, videos, etc., but it’s still much trickier than something like IFTTT.

Also, I see there are some new Alexa nodes on, but I’ve not tried any of them.

Anyone else programming w/Alexa these days?