Node-Red and Alexa with Big Timer

tmp96D4I’ve recently updated my setup at home, finally doing away with HA-Bridge and I thought you might like to see this simple setup.

So for beginners, HA-Bridge is a piece of software (a very nice piece of software) that runs on for example a Raspberry Pi, who’s job (in my case) is to talk to Amazon’s Alexa and send off MQTT commands to control things.  In reality I’ve always had it return commands to Node-Red – because many of my controlled items are on timers and I need the two put together.

The reason I need manual input and timers connected, is to turn things off automatically if I forget. For example – a night-light outside might be on a timer from dusk until midnight.  I have an early night and decide to turn off the light manually. It is important that the light then goes back into auto timing mode the next day and doesn’t just stay off permanently.

As developer of Big Timer (node-red-contrib-bigtimer) you’d expect me to make big use of this Node-Red node – and I do – dozens of them. Some time ago I added manual override controls for this node and I’ve usually had Ha-Bridge send an MQTT command which is then picked up by Node-Red and injected into the timer.

Well, some time ago when messing around looking for alternatives to Ha-Bridge, I tested node-red-contrib-alexa-local and it had all sorts of issues – but now I check again they’ve all gone! It truly is lovely though as it stands it can’t handle colour control directly (but then neither does Ha-Bridge) – it will handle numbers from 0 to 100 so you could use your imagination… 

Hence last night I took the plunge and stripped out Ha-Bridge and inserted alexa-local… and it is working a TREAT. Accordingly I’ve added that node to “the script”.

So – assuming you are using Node-Red and big-timer and can or have installed alexa-local – it is all this simple.

tmp4CAA

Here is a tiny, tiny part of my home control setup. On the left the dark cyan node-red-contrib-alexa local nodes, on the right the lime green node-red-contrib-bigtimer nodes.

In a couple of cases, office and house heat, things work another way and I keep the current manual heat offset (which gets reset on every change of program) in global variables – in this case alexa-local simply updates the local variables in those orange function nodes.

By and large however the nodes feed straight into bigtimer – could not be easier. Give the node a name you will use by voice, like “shed green light” and plug it into bigtimer, which, here, is controlling the light via MQTT.

Saying “Alexa, turn shed green light on” will result in one of two things.. either the light will turn on – temporarily overwriting the normal timed sequence, or, Alexa will respond with “I’m sorry I can’t find a device called shit green timer”.  Well, I can’t do much about Alexa’s accuracy I’m afraid.

Enjoy – and if you’re still wondering why I keep banging on about Node-Red – read all about it. As for where to get the nodes… here.

Facebooktwitterpinterestlinkedin

29 thoughts on “Node-Red and Alexa with Big Timer

  1. HI Pete,

    your blog has been invaluable in helping me get to grips with Node red and integrating it into the house controls, I have been working on a system that controls all the TRVs in my house and it’s about 90% working, the problem Ive been having is writing a basic thermostatic function to use with your big timer, just can’t get it to work, anyway I noticed in the example above of your alexa flow you have a function call “Use kitchen panel heater if <20c" , would it be possible to see the code in that function, I'm sure it does what I'm trying to achieve or at the very least something very close.
    Many thanks
    Paul

    1. I simply check the temperature and if less than 20c, use that particular heater. That code is currently in cold storage with most of the rest of my kit as we’re moving home. I won’t have access to it until next month.

      Regards

      Pete

  2. And…
    I ran “update-nodejs-and-nodered” after which I was able to find the new device. I share for those who need the same fix…. 🙂
    (Now using on Pi3 node red 0.17.5, and likely a better nodejs)

    David

  3. Hello,
    I am trying to follow your footsteps with Alexa-local and big timer.
    I am unable to discover the new device using Alexa-local (both from Alexa and from the ios APP.

    (Using on Pi3 node red 0.15.3)

    I am already using wemo emu and that has been working. Any suggestions as to how to troubleshoot or what information would make this query more clear?

    Thank you

  4. I’m having the same problem John was having. Anyone figure this out without having to reinstall? I installed using “the script”

    Regards,

    Mike

    1. I had a spare Rpi and ran the script on that one. The node works on that install but not my production system. My production node-red install was deployed over a year ago using the script. Is it possible that the installation has changed since that time and the PI user permissions to have changed?

      Mike

  5. I’m awaiting a USB 60g drive so will start again when it arrives. Is RASPBIAN STRETCH LITE the preferred base for the script?

    1. Erm, no… the script works with the older Debian and also Xenial and others – compatible boards and software is listed at the top of the script.

      But if you’re putting a board together, you may as well use the latest software – so Stretch works a treat – download the full version.

  6. I get
    pi@atticPI:~ $ sudo netstat -lntpe|grep node
    Proto Recv-Q Send-Q Local Address Foreign Address State User Inode PID/Program name
    tcp 0 0 0.0.0.0:1880 0.0.0.0:* LISTEN 1000 14657 426/node-red

    Is 1000 the number I’m looking for because
    grep 1000/etc/passwd
    made no difference.

  7. I Installed Alexa Local in node red but get error

    “Error: EACCES: permission denied, mkdir ‘/nodered'”

    I installed node red via Pete’s script and don’t know which user it has.

    1. Well, if you installed Node-Red via my script – you certainly should not be having this issue as I’ve put the node on two of my machines and of course I always use the script. That error message doesn’t even make sense.

      I suggest, go to the GIT where the node came from and raise an issue. Last time I did that I got a reply within a couple of hours.

      1. I have already raised the issue and got the reply:

        “which user is NodeRED running with? it is recommended to use root to run it”

        1. sudo netstat -lntpe|grep node

          look for the USER column, note that number, then change it in the WXYZ part of next command, the user will be in the 1st column (separated by 🙂

          grep WXYZ /etc/passwd

        2. Absolutely NOT – that is the exact opposite of the advice from the Node-Red guys !! All my installations have Node-Red running as user Pi.

      2. var msg1 = {payload:”hallway light to 100%” };
        var msg2 = {payload:”hallway light off”};
        var msg3 = {payload:”hallway light on”};
        var msg4 = {payload:”hallway light auto”};
        return [[[{paylaod:”auto”}], “OFF”],”ON”];

        Hi Peter does Alexa understand “AUTO” i cant find a way to get your BT set back to auto. works for on and off great.

        Thanks

        Andy

        1. Hi Andy

          It isn’t what Alexa understands, it is what the emulations understand – so the standard alexa node emulates something that does not understand a lot – basically on/off/up/down and setting a value. Pretty awful really. You can write your own skill to even pull in the words Alexa thinks it has heard but for reasons beyond me, Amazon make that as difficult as possible so most of the emulations like the Node-Red Alexa mode and others take the relatively easy route which does not let you do this.

          I’m waiting for a node that will handle more including colours – but I could be waiting some time.

        2. var msg1 = {payload:”hallway light on” };
          var msg2 = {payload:”hallway light off”};
          var msg3 = {payload:”hallway light auto”};
          return [[[msg1 ], msg2 ], msg3 ];

          This is now my code but still unable to get auto to work

          1. I am just trying out the code

            both codes give an error but the on off works

            here is the MQTT the first 3 lines are the error

            12/9/2017, 1:29:34 PMnode: alexa
            msg : Object
            { payload: “hallway light off”, _msgid: “a82b5c52.c0d19” }

            12/9/2017, 1:29:34 PMnode: hall/table/lamp/switch
            hall/table/lamp/switch : msg : Object
            object
            payload: “ON”
            topic: “hall/table/lamp/switch”
            state: “on”
            value: 1
            autoState: 0
            manualState: 1
            timeout: 1439
            temporaryManual: 1
            permanentManual: 0
            now: 809
            _msgid: “c388847f.1fdfc8”

          2. Woo you are correct deleted the last line and it still works

            so the code is now just

            var msg1 = {payload:”hallway light on” };
            var msg2 = {payload:”hallway light off”};
            var msg3 = {payload:”hallway light auto”};

Comments are closed.