Node-Red BigTimer Example

I am constantly asked about using Bigtimer (node-red-contrib-bigtimer) and so here’s an example of how I am using it in conjunction with both Amazon’s Alexa (voice control) – and the Node-Red Dashboard.

BigTimer

So in this example, Amazon Alexa is being used courtesy of HA-Bridge – which is part of my normal setup for any Raspberry Pi or similar device, along with Node-Red itself and Mosquitto for communications.

Here we see my cabinet timer. Essentially I have a drinks cabinet which lights up with internal white LED strip from dusk until I think midnight.  The first output from the Bigtimer goes off to MQTT (no particular reason why in this case it goes off to a separate node) and quite happily runs automatically as-is.

For any number of reasons I may want to override that lighting. For example if I decide to have an early night, I may want to turn off that and other lights. I can simply say “Alexa, turn the cabinet off” to over-ride the timer settings.

Overrides on the timer work by sending one of the following to the input of the timer.  1, 0, “auto” – the latter of course simply returns the time to it’s auto state. The overrides are only good to the next auto change of state (deliberately).

So in Ha-Bridge I have 2 simple settings – on and off. I’ve added the Mosquitto utilities to the mix so that I can send a message via the command line – and this is how I do that in Ha-Bridge. Below you see the setup for the cabinet.

Ha-Bridge

As you can see my password is blurred out.  So Ha-Bridge on hearing “Alexa, cabinet on” or similar, sends a command line message to publish a message of topic “alexa_cabinet”  with the value 1. For those unfamiliar with the mosquitto_pub application – P means password, –u means user, –m means message and as you can see I’m using a local MQTT broker (Mosquitto).

This is picked up by the MQTT input node and fed straight into the BigTimer input as is the Off command.

I wanted, in addition a control for Node-Red Dashboard as Alexa is only good if you happen to be in the same room as the Amazon device…

Node-Red Dashboard

If you look at the first image you will see the middle output of the node feeds into the Node-Red Dashboard “Cabinet ON/OFF” control -  this is to ensure that (once a minute) the dashboard on-off control actually reflects the state of the output whether on auto or manual override.  The actual outputs of the control  send 1 or 0 (or in the case of the blue button “auto” to MQTT – to the same topic – i.e. “alexa_cabinet”. Sadly Ha-Bridge is very restrictive in what you can actually do so it is not possible to say “Alexa set cabinet to auto”. This can be done by other means but they are currently a little messy.

This of course is only one of several devices I have using this technique, it works well. So above you see an example of using MQTT along with both Alexa and buttons to control an output without having to store any global state variables etc. Simple.

Facebooktwittergoogle_pluspinterestlinkedin

14 thoughts on “Node-Red BigTimer Example

  1. Hi Peter,
    So HA bridge is in your script ? Great write up as alway. Still waiting for Australia to get the Alexa dots on sale here.

  2. Hello Peter

    I have had a great deal of success using Node-Red Alexa Home Skill Bridge which operates in a fashion pretty much identical to what you describe. I use big timer to automate lights on and off and use an Echo Dot to give me over-rides to those settings if I want individual or groups of devices on or off. Just my 2 cents, but this technology really excites me and "gets me up in the morning" as you say in your blog...

    Bill Miller

  3. Thanks Peter,
    Now all I need is a echo as Australia doesn't have them yet. Plus how to pull a node un to control one. William do you have a youtube channel on how to do it?

  4. Hi Just to affirm what William Miller said above about Alexa Home Skill Bridge. Its a very good node-red module that takes things beyond HA-Bridge. For instance with the Thermostat you can ask for the current temperature and setting as well as change settings and get spoken confirmations . The clever part though is that you can manage the responses - so for instance you can set an acceptable range of thermostat settings and if your command is outside the range Alexa will respond that she can only accept settings from x to y. It also manages door locks and they have said they will extend the lights options to include colour and warmth. It does require an external connection for authorisation but Alexa is of no use without internet anyway. Short of developing your own skills and setting up secure links this is an incredibly easy and quick way to extend Alexa to thermostats and locks as well as simple on/off/dim devices. It is easy to setup as I say but the response API can be a bit finicky so if you want the flows I have already done I can send them.

    1. Steve

      I am about to head off to take a friend to the airport, returning tomorrow night- but I am VERY interested. Right at the start, two of us wrote out own SKILL because none of the solutions including HA-Bridge offered things like user-settable response - instead returning the old OK which is about as much use... giving no real indication as to whether what you'd said had worked or done something completely different. I hit a snag where our solution required HTTPS: and worse on port 433 ONLY - as my provider in Spain uses 433 for remote access and won't budge on that port I had to abandon our own SKILL and use HA-Bridge.

      If this skill you refer to allows me to do my own responses but does not demand that the local site can handle port 433 HTTPS access then this would indeed take it's usefulness FAR beyond HA-Bridge. I'd also like to handle colour control which I can't currently do on HA-Bridge.

      Please do furnish as much information as as you have time for and I'll take a look on Friday.

      1. Hi https://alexa-node-red.bm.hardill.me.uk/docs will explain the setup and current options and you will find it very straightforward. The exact range of responses possible are as per https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/smart-home-skill-api-reference#door-lock-control-and-query-messages which are pretty extensive and may be extensible. I can send the flows that I have if it will save some time and the Alexa channel on the node-red stack account is a good source of info

        1. Sorry to jump in the middle here but I've been playing with Alexa Smart Home Skills (I'm in the US) and I have both good (mostly) and a bad experience. I have a switch, a lock and a Thermostat setup (using MQTT as the devices). I have been able to lock the door but Alexa won't let me unlock it. I did setup node-red to confirm that the door is locked before telling Alexa (yea!). I've been able to feed the room temperature to the MQTT topic for the thermostat so I am getting live temperature readings and it handles the set/get of the settings well.

          I did have an issue when the UK link got a bit wonky in the middle of the night (UK time). A visit to the site showed it slow to respond (Maintenance?). This is an issue with all cloud based HA so it's not unexpected.

          The other bad (not really bad) experience was the documentation. I found that the Alexa web site explained the skills a bit better which allowed me to get the responses bad. What I also found was when Alexa sent the lock command I needed to node-red, I needed to copy the json to the context so the response had it for the response.

    2. Thanks for your comments and links to other info Steve. I often feel out of my league on this forum as I am new to this technology but because of people like Pete and like you I am expanding my knowledge rapidly. I look forward to further posts and comments.

      Bill

      1. The great thing about this fast moving and diverse field is that after 3 months you can be considered an old hand. On the other hand take a break for a few months and you fee; like a dinosaur.

Leave a Reply

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