More Alexa Marvels

Some of you may recall that in the dim and distant past, Aidan and I wrote a SKILL for Amazon’s Alexa – which let us do anything by simply passing the speech back to Node-Red… and we could sent text as speech to Alexa. Well, that relied on SSL port access and writing skills and… we’re still waiting for something easier and so without effort, that arbitrary response is still  a little way off, but..

If you want REAL EASY  - read on. (updated 13/10/2017)

So I’ve been using HA-Bridge alongside Node-Red and some MQTT to control devices around the house but today (and I mean TODAY) I have something easier.

Reader Antonio yesterday pointed me to a tweet by Nathan Chantrell who was writing about a new Node-Red node called npm install node-red-contrib-alexa-local

Well, I had to give it a go last night – failure – crashed my Node-Red and Alexa didn’t want to know about it. So started a series of communications with Torin Nguyen – the author of this node.

And I’m delighted to say I just got the latest version – 0.2.4  - and… it works!

This does NOT get any easier. Starting point here is a Raspberry Pi but basically, Node-Red on anything  I guess.

I loaded up the node (as usual sitting in my /home/pi/.node-red directory and invoking the above chant).

I dropped two nodes onto the Node-Red desktop and gave them names “big boy” and “little boy”.   I invoked the magic words to Alexa “Alexa, find devices” – and after the obligatory and INTENSELY ANNOYING advert for Philips crappy light bulbs, TWO new devices appeared on my network.

I kid you not – THAT easy. I had entered nothing more than names for these two nodes.

I said the following:

“Alexa, turn little boy on”

“Alexa, turn big boy off”

“Alexa set little boy temperature to 25”

and below – you will see the output sent to the debug window of Node-Red – note that I set the debug to show the WHOLE OBJECT, not just the payload.  If you only want on and off - payload alone will do the job.

image

I should imagine the picture above paints 1000 words – 3 outputs with which you can do what you want. You could if you wish join a load of these to one function and extract “device_name” or send them off, each to their own function to do what you want – brightness and temperature both produce a change in “bri”

So on, off, set brightness to, set temperature to… all work.

Brightness up and down ALSO work but until recently there were some issues so you really DO need 0.2.7 version as a minimum.  One issue was - what if for some reason the brilliance/temperature was adjusted externally - by a Node-Red timer for example - well, now there is an input to reprogram the value.. check out information here.

https://www.npmjs.com/package/node-red-contrib-alexa-local

I still need some external logic for increments and decrements - and the fact that ON is 100% whereas to me, ON should be the last value you set!!! However all of that is do-able in Node-Red..  I look forward to the continued development of this interesting node!!!

Facebooktwittergoogle_pluspinterestlinkedin

16 thoughts on “More Alexa Marvels

  1. Peter, if you are using Sonoff devices you can configure them to emulate a single Wemo device or a Hue Bridge. Alexa will then detect them directly and you can still control them over MQTT too.

    Agree that this Node is showing a lot of promise. I did try the early version and yes, it did crash node red.

    1. Hi Garry - yes I use the Sonoff devices all the time - and their ability to do this themselves is fairly new - but custom software has been around for a long time for these to do that.

      Personally I like to keep it all in one place where I can visually do updates.... and so until we get to the point where we can easily talk both ways to Alexa - preferably with all the faff of SSL connections etc etc - then this new node is looking good...

      Now the author is aware of the crash thing - it seems ok once set up anyway he's looking at that and we've just exchanged communication about increase and decrease - I've suggested he could simply output + or minus instead of an absolute value as in Node-Red we're probably passing the output of that node to our own function node ANYWAY which means we then get to decide for ourselves what increase/decrease to apply... I'm encouraged at the quick rate of return of communications which leads me to think this node could be a little winner real soon! The other point of course is that even people who use Sonoffs - use other stuff as well which might not be Alexa-aware - and this is an easy way to add them into the mix. My priority with devices is that they talk MQTT as I use that as my preferred means of talking to everything. Again, at the simplest level, MQTT is trivial to use.

      1. Hi Pete, totally agree, an exciting development. MQTT is also the only way that makes sense for me too. Using this node also allows the control of more than one device at a time too. I just tried the latest version and it hasn't crashed node-red yet.

        I did go down the SSL route too, writing skills on the Alexa Dev platform. It's been a very rewarding experience and does let you program some meaningful responses using Alexa, but just to turn on a lamp it is extreme overkill!

        Exciting times!

        1. We spent ages on that, Garry and I could have Alexa say whatever I wanted. We arranged things so that Alexa simply interpreted the spoken word and sent what it thought was said back to us. A simple parser then took care of that - I had two problems, Alexa would substitute any near enough valid word... so you can't rely on it sending back "Turn the brown light on" - it could return "turn the round light on" or anything sounding the same. My other problem was - while seeing the benefit of SSL, I cannot for the life of me see the benefit of INSISTING on port 433 - which is what Amazon do - and my service provider in Spain reserves that port for debugging the WIMAX connectio - so no chance of having incoming 433 without a lot of faff - I'm really hoping that overall, ultimately Google get their finger out and give us a better solution - for now - this node is looking like a decent one way solution - that and of course, HA-Bridge which again I use with MQTT.

  2. I once again would recommend the Node Red Alexa Home Skill Bridge which is documented at https://alexa-node-red.bm.hardill.me.uk/docs. They have recently updated it further so that now not only can you do the usual on/off/dim/unlock etc, you can query Alexa for the current thermostat setting and current temperature, you can also setup custom ranges and responses so that for instance you can get Alexa to respond "I can only set the thermostat to between 15 and 30 degrees" if you exceed the chosen range. But most recently they have added colour bulbs so you can request a colour or colour temperature and alexa will return a hue, saturation and brightness. Works very well, has been very reliable and is installed in seconds.

    1. Hi Steve

      I just went to the site and noted..

      Due to a failure on the 4th October all updates to the devices or new accounts created between 29th Septeber and 4th October have been lost. I appologies and I'm working to make sure it can't happen again

      I've had a look here and indeed it does look flexible - but in terms of ease of setup - we're not quite in the same ballpark there.

      I'll give it a go.. Also presumably this only applies to US and UK readers - there are a lot of Europeans in here.

    2. Good morning Steve - I just took a look here https://alexa-node-red.bm.hardill.me.uk/docs and things are worse than I suggested... look at the fine print and some of the commands only work (according to Amazon) in the USA and that includes setting the colour - really the one reason that might've pushed some of us in the direction of that Node. Given the international nature of audiences to blogs like this - I really can't suggest going down that route right now. Perhaps when Amazon get their act together and remember that there is a big world out there.

      1. The listed restrictions to the US are out of date and unless Berkshire has become the 51st state of the union recently I can vouch that all facilities work well in the UK. I can't speak for Germany which is I believe the only other officially supported territory outside the US. But as you say given that Amazon have restricted availability of the Echo range both geographically and linguistically it does make any discussion re Alexa somewhat parochial.

        1. Hi Steve - well - UK is one up - and one I obviously favour - but of course I'm also aware that regular readers and contributors to this blog come from Italy, Germany and other European countries. Still - worth a play for those of us who are in the privileged countries. That loss of information announced the other day worried me a little and makes me wonder how resilient the server is on that this all sits on - we're used to big companies having systems over multiple continents and if they go bust someone else takes over - but what happens when servers are owned by an individual, costing them money - and they lose interest. I guess that's why I favour hosting my own logging graphics using Grafana - I log information for years and don't want to find that the service is no longer available. And so it is here with this skill. Do we know how that service is hosted?

  3. See updated blog - new developments including the ability to preset the percentage/brilliance value - which is really essential if you want things to turn on at a predetermined level and not 100%... or if you have external timers which might adjust settings outside of verbal control. This is coming along nicely.

    1. But hang fire as I didn't get expected results... awaiting feedback. This is what I get - anyone experimenting may want to check

      Turn it on – value goes to 100, inject 45, nothing happens. Turn it off – the output value goes to 0. Turn it on – the value goes to 100.

      Surely that is not right - if you set a brilliance for a lamp - and turn it off - you'd expect it to go back to where it was when you turn it back on? Similarly heating - you'd not expect the heating to go to 100 when you turn it on.

      But this….

      Alexa – increase the temperature of big boy..

      That turned it ON at 100.

      Set input to 45 (inject input).

      Alexa – decrease the temperature of big boy…

      That set the value to 24

      That’s REALLY not right…

      I've put the above into GIT - awaiting feedback.

  4. I stopped using ha-bridge in favor of this node. 300+ MB freed from Raspberry Pi 3.

    I am using it to control X10 lights and turn on/off TVs using IR leds controlled by ESP8266. Other TV command using my own Alexa skill.

    Thank you.

    I also saw node-red-contrib-wemo-emulator. Works good too.

    1. Hi Juan, what do you use as the X10 interface. I use Heyu with Firecracker but am looking for something I can use on an esp8266.
      I too have started using this node instead of HA-Bridge. Good find Peter!

      1. I use a program I wrote in C language, communicating with CM11A Serial Computer Interface. Initially it was used just to receive motion sensors information and send SMS to my cellular phone. Later, I added functionality to turn devices (Lamps, wall switches, and appliance modules) on/off/dim from Node-red. Communication between Node-red and my program is using UDP.

        Good idea about using ESP8266 to interface with CM11A. Communication between Node-red and ESP8266 could be MQTT for flexibility. The only issue here is that CM11A uses RS232 interface not TTL.

        I think you can still use firecracker with ESP8266 (A lever converter 3.3 5V will be required) since Firecracker uses Microchip micro controller which is 12 volts tolerant (RS232 levels) but in fact works at 5 volts. You could give it a try. Do a google search for CM11A protocol.

        1. Thanks Juan, I may give that a try. I’m currently using RF to control Magicfly/Etekcity wireless outlets with Node Red and ESP8266/RF433. I’m hoping to use a similar setup with X10 transceivers and motion detectors. X10’s 310 MHz frequency has been a bit of a challenge.

  5. Everything was working great but at some point today my echos can no longer discover my devices using this node anymore.
    I've restarted node red, had Alexa forget my 5 devices, rebooted, etc.
    But no joy.
    Anyone else seen this behavior? Hopefully it's just temporary.
    As an aside, the esp devices I've been controlling with this are:
    12v pwm controlled bedside reading lamp. It was simple to get the dimming to work.
    4 120v SSR controlled power outlets.

    Previously I controlled all these devices using an iPod app using the NetIO tool.
    BTW - that control still works Ok.

Leave a Reply

Your email address will not be published. Required fields are marked *