BigTimer – Scargill’s Tech Weblog


BigTimerNodeRED is a incredible and highly effective but straightforward to make use of programming device for wiring collectively {hardware} gadgets, APIs and on-line companies in new and attention-grabbing methods. For extra data on Node-Pink go to the Node-Pink website.

In spite of everything, you most likely don’t flip the skin lights ON at 6pm!! You almost certainly need them ON when it will get DARK. Good to see BigTimer featured HERE.

Bigtimer
Bigtimer
Bigtimer

BigTimer is my very own creation and is (IMHO) essentially the most highly effective and best-ever, most complete timing node for Node-Pink, offering a basic goal timer in addition to dealing with summer time/winter accurately in addition to (importantly) lighting-up time (for which it is best to present your longitude and latitude from Google maps or comparable).

February 2023 fastened a mistake within the July-December exclusion months….

THIS web page is the house of BigTimer. Questions on BigTimer must be positioned within the feedback part right here. I’m at present pondering how one can add winter and summer time choices for on-off instances with out making the setup web page extra cluttered – concepts welcome.

Replace January 9, 2022

Added new “away” command – in minutes for now (away X) which could be so long as you want and can maintain the primary output off till you clear it with (away 0) or it runs out – this must be totally examined earlier than deploying and also you MUST have “repeat” ticked within the dialog for this to work . Additionally, one useful weblog subscriber identified a difficulty – special occasion included – month 9 was defective – fastened – many because of everybody for you suggestions on this highly regarded timer).

V2.8.1 fastened bug launched in 2.8.0 to 2nd output payload.

Finish of replace

I don’t plan to spend any extra time looking by means of Node-Pink boards for BigTimer queries, sorry… and the supply is NOT in GITHUB  – you could have the total supply when you could have BigTimer itself – the entire thing is just 2 information (a .js file and an .html file).

In model 2.5.0 I added separate on-off randomisation choices.

The panel on the proper is sort of outdated now with many further objects within the precise panel.

For readability: BigTimer works in minutes – in a DAY which consists of hours and minutes 00:00 to 23:59, the place minute 1439 is the final minute of the day – that’s the reason there is no such thing as a MIDNIGHT within the settings. For those who want one thing to occur at or close to midnight –  I’ve now added a DAY END choice to the OFF dropdown containers – equating to 23:59 or one minute earlier than “midnight” (the latter is the truth is is the start of the subsequent day).

At it’s easiest, BigTimer is a single block which can be utilized because the equal of a easy mechanical timer, seeding different Node-Pink nodes or instantly manipulating gadgets by, for instance, MQTT protocol. The MQTT-compatible payload (ON and OFF msg)  is the primary output and it is best to put a worth in there even when not utilizing MQTT. ON and OFF TEXT fields are non-obligatory – for speech or no matter use you take note of.

BigTimers can be utilized singly or in teams. Full assist is offered for nightfall/sundown daybreak/dawn and variations additionally for day/week/month (and particular days) management.

BigTimer has three outputs, the primary of which updates when there’s a change of state and presents one among two messages (for, for instance, MQTT or different management mechanism)

The node presents outputs appropriate for MQTT, speech and databases (however you don’t HAVE to make use of any of those). It’s also possible to manually over-ride the UTC time setting on the host pc if required.

The second of three outputs presents a easy 1 or 0 each minute within the output “payload” and in addition presents further data reflecting the standing message in msg.state, message.time and others – see the complete msg object output in debug for extra.

The third output presents a message which could possibly be used for speech or debugging.

There’s additionally real-time standing data displayed under every BigTimer node.

As all the time, the newest node-red-contrib-bigtimer is on the market at node-red-flows and at npmjs.com – put “scargill” within the search and also you’ll see all my nodes and flows.

I’ve had the odd remark about BigTimer not giving the output somebody needs… if the msg.payload from output 1 isn’t what you want, change it. Let me give an instance, the segmented swap in BLYNK, assuming 3 outputs for this instance – offers and desires values “1”, “2” and “3” – which I exploit for “off” “auto” and “on” states in BigTimer. A easy operate node on both facet of BigTimer types out that drawback.

tmp71EF

Observe the Blynk “Write Occasion” node on the left and the Blynk “Write” node on the proper.

The capabilities are straightforward. Blynk could be controlling the lighting or the gray handbook overrides, OR BigTimer could also be working a schedule – it is crucial that every one 3 strategies are suitable and that they keep in SYNC.

First operate node:

if (msg.payload=="1") msg.payload="off";
else if (msg.payload=="2") msg.payload="auto";
else msg.payload="on";
return msg;

Second operate node:

if (msg.state=="off") { msg.payload="1"; return msg; }
if (msg.state=="auto") { msg.payload="2"; return msg; }
if (msg.state=="on") { msg.payload="3"; return msg; }

Straightforward – I’ve a ton of variations on that for various eventualities.

Again in February 2018 I added moonrise and moonset – in addition to enhancing the structure and docs. The “moonrise” code in module sunCalc appears lower than excellent so though I added the moonrise and moonset properties in 2.1.3 BigTimer, there have been points resolved in moonrise and moonset (from model 2.17 on) because of including my very own checking to the sunCalc module.

Current additions/adjustments embody timestamp on outputs, further on/off inputs, enhancements to “timer” enter choice (default seconds) instance:

timer X (minutes)

timeoff X (minutes)

Options added in December 2018 embody a seconds timer and even/odd day of the month choice. In handbook override (injection), assuming the timer is off, inject “timer 30” to show it on for 30 seconds. That is additionally helpful if in case you have lights turning off at midnight for instance and also you want an additional hour of sunshine and don’t need to have to recollect to show them off on the finish of that interval. Inject “timer 3600”.

As early as 2017, I added “toggle” override mode and as I then realised that the little icon was not fairly the proper format and may look odd on some individuals’s methods – one thing identified by the FRED individuals who need to use my nodes… I up to date node-red-contrib-bigtimer, node-red-contrib-timeout, node-red-contrib-diode, node-red-contrib-grove and node-red-contrib-esplogin and in addition moved them to the “superior” class.

BigTimer
BigTimers

What: Node-Pink-Contrib-Bigtimer is each a easy timer – and a full-function timer – relying in your wants. At it’s easiest, you set on and off instances, the subject and payload you’ll want to exit to, say, MQTT and your longitude and latitude (most browsers will fill this in robotically), you then set your schedule and you might be performed.

Why: Current timers didn’t do what I wished – additionally – I’ve a watering system – I need it to run at nightfall and daybreak every single day – however not in December by means of February (ice)!  I needed to have management over each days of the week and months. Current timers didn’t try this both. Many gave the impression to be primarily based on the outdated mechanical timers however with out shifting components. That gained’t do.

Firstly: the title. It’s a timer – but it surely’s a BIG one – so I referred to as it BigTimer. (notice: the unique “Scheduler” node is not developed – BigTimer does every little thing Scheduler did and far, way more).

Secondly: it has an enter. You may inject varied phrases into BigTimer – and get prompt over-ride motion. “1” or “on”, “0” or “off”. “auto” or  “default”, “timer”, “sync”, “handbook” and so forth.

Does that want explaining? “on” for handbook override to on, “off” for handbook override to  off (each of which reset on the subsequent auto state change), “default” or “auto” to return the timer to regular operation. Extra particulars additional on.

Guide Override: For those who set the timer to activate, say at nightfall and off at midnight, you possibly can override the setting in the course of the day by sending “on” to the enter. This override will reset on the subsequent auto change of state.

Please notice: “evening” and “endNight” are included for completeness however will not be assured to work relying the place you might be on the planet. Maybe higher to stay with nightfall/daybreak, sundown/dawn and so forth.

For those who inject “handbook” together with  “on” and “off”, the state will change till the set timeout (in minutes) instances out – so in case you flip the lights on in handbook mode (as in opposition to easy override) and overlook you probably did it?

The unit will return to default operation in X minutes (which you’ll be able to set – defaulting to 24 hours – 1440 minutes) after any handbook change you make.

It’s also possible to ship a “sync” command which merely outputs the present state with a facet impact of decrementing the timeout counter – helpful for testing.

Here’s a check setup for BigTimer, simply utilizing merely injection nodes:

BigTimer test setup

And right here’s what occurs in case you manually press ON (a easy inject  on this instance – you possibly can ship that message within the payload by any means you want)…

Bigtimer test setup[6]

However what are these different two outputs?

Output 1: is a message – you management the subject and payload – so I exploit it, for instance, as I do, to ship a message to MQTT to regulate one thing. You may have this message exit as soon as – or each minute. There are different parts to the msg object on the primary and second outputs, use these further messages or not as you favor.

Object

On this instance (model 1.5.5 of BigTimer onwards) you see varied objects within the output -also notice that this view is in Node-Pink 0.18.5 – I strongly suggest you improve if utilizing an earlier model.

You may see the worth in msg.payload which is no matter you enter to be able to fireplace a message off to a different node or operate to make one thing occur. As well as (and never important for regular operation) we’ve got msg.state, msg.worth, msg.AutoState, msg.manualState and others.

For easy use, you possibly can after all ignore the extra outputs, however they’re helpful for checking. msg.state reveals “on”, “off”. “auto” or “none” and within the case of the primary two outputs, msg.length reveals the time till the subsequent change of state and msg.now reveals the time in minutes since midnight.

Output 2: outputs a 1 or 0 each minute when checking (in msg.payload) – you need to use that to gentle up one thing.

Output 3: places out one other textual content message in msg.payload which you’ll be able to set – I level it to a speech synth so it would say “exterior lighting approaching”. There’s one message for the ON state, one other for the OFF state. Ignore it in case you don’t have a use for it.

December 2018: Typical use of BigTimer in my dwelling, controlling ESP8266 and different gadgets and accepting management from handbook overrides both instantly in Node-Pink or for instance within the Node-Pink Dashboard (cell or PC screens).

BigTimer use in my UK home

And to get this node?

Be sure you are in your Node-Pink set up folder (for instance /dwelling/pi/.node-red) and sort:

npm set up node-red-contrib-bigtimer

So in my case, I hold all my nodes below /dwelling/pi/.node-red/node-modules.  So I do the set up from /dwelling/pi/.node-red

Restart Node-red and Bob’s your uncle – it ought to seem on the left with the opposite Nodes.

Truly at present (in 2020/2021) there is no such thing as a longer any want to make use of NPM set up; merely set up utilizing the palette supervisor in Node-Pink itself.

As well as, I’ve not too long ago, as a response to a smart request from one among our weblog readers, modified the code in order that if both the ON payload or OFF payload is clean – then no message shall be despatched at the moment – this implies now you can simply OR timers collectively. So in case you want a number of time intervals in a day or different sophisticated setup you possibly can merely use a variety of timers and really feel the primary output to at least one widespread vacation spot!

Right here’s an instance of TWO timers merely sending stuff to a debug node for testing…

two BIGTIMERS

Backtrack for Freshmen: Node-Pink is a simple-to-use however very highly effective visible device for wiring the Web of Issues and a device for connecting collectively {hardware} gadgets, APIs and on-line companies in new and attention-grabbing methods. It’s also a number of enjoyable.

I management a variety of ESP-8266/ESP32 gadgets utilizing RPi4 (although older variations of RPi work effectively). You may after all run Node-Pink and the opposite instruments on a variety of machines – Orange Pi, Odroid C2 and so forth utilizing Debian, DietPi, Xenial and so forth. I’ve even had my regular set up script “The Script” working on a laptop computer utilizing Mint Linux (a while in the past).

On this specific RPi I run MQTT (Mosquito with Websockets), SQLITE, NGINX and Node-Pink. I began utilizing Blynk as my cell distant controller then went on to utilizing ImperiHome then Node-Pink Dashboard which has (IMHO) so very a lot potential, nevertheless it additionally has awful RGB management so for some time I reverted again to Blynk.  I then used Nextion touch-LCD show gadgets for native shows and now (2021) I exploit low-cost ILI9341 shows with ESP-HOME, the code speaking again to Node-Pink. All of this may be managed inside Node-Pink. For those who discover this attention-grabbing you may like my outdated  dwelling management 2018 publish right here or the early Nextion Wi-Fi Contact Show article.

Above is a screenshot of a typical setup… click on on the picture to enlarge.

So in whole you could have a timer you possibly can set to go on and off at particular instances of the day, or nightfall and daybreak, on sure days, sure months, you possibly can even set it to run on particular days of the month (Christmas day?) and even sure weekdays of each month (second Tuesday) – as of model 2.0.0 (August 2018) these could be included or excluded.

You may tick a field to have output on power-up or not, you possibly can tick a field to have the node auto-repeat the message each minute or not. You may add constructive and unfavourable offsets to the instances (together with nightfall and daybreak and so forth.), you possibly can optionally add your OWN offset to the UTC time of the host pc and also you even choose a random worth inside the limits of the offsets (safety lighting and so forth.) You may quickly droop the schedule through a tick field or a message.

And listed here are the phrases the node will settle for on the enter to override computerized operations. The enter is just not case-sensitive.

sync merely compelled output
on or 1 flip the output on
off or 0 flip the output off
default or auto return to auto state
cease cease the scheduler
on_override manually override the on time ( specify time as minutes or hours:minutes) – additionally in case you specify the time in minutes, you need to use particular values like:

5000=daybreak
5001=nightfall
5002=solarNoon
5003=dawn
5004=sundown
5005=evening
5006=nightEnd

off_override manually override the off time( specify time as minutes or hours:minutes) – additionally in case you specify the time in minutes, you need to use particular values like:

5000=daybreak
5001=nightfall
5002=solarNoon
5003=dawn
5004=sundown
5005=evening
5006=nightEnd

timer a current characteristic permitting handbook override for X seconds (timer X) – helpful for watering methods and so forth.

In August 2020 I added geo_override, fastened some minor “timer” points and in addition with assist from one among you – added on_offset_override and off_offset_override – updating the second output message accordingly.

Within the drop-down containers for on and off instances you possibly can choose instances or phrases like nightfall, daybreak, dawn, sundown, evening and so forth. All are depending on the longitude and latitude you place into the related containers and can modify every single day as crucial.

A great way to find out about BigTimer is to place a debug node (set to point out the whole message) on the highest output – and inject textual content payloads (utilizing the INJECT node) to the inputs as demonstrated above.

Output from error and warnFrom the primary output, in addition to the conventional msg.payload, you possibly can extract msg.state which could be “on”, “off”, or “auto” – and msg.worth which could be 1 or 0.  That is in order that if you’re utilizing say, ImperiHome and retailer states in world variables, if the time reverts again to auto, you possibly can let ImperiHome know what is occurring.

One other option to check BigTimer  is as follows..

Big Timer Node

Within the FUNCTION nodes to the proper of BigTimer, I’ve merely put node.error(msg); and node.error(msg); respectively. The one distinction is one has a crimson bar (error) the opposite a yellow bar (warn). These make a helpful various to utilizing the debug node for testing.

Current additions to the inputs embody on_override and off_override. These are in response to requests to have the ability to change the on and off instances from the Dashboard. Please notice that override data you inject right here (in hours and minute or simply minutes, space-delimited) is misplaced when Node-Pink is restarted or the board rebooted.

Not proven on the images above are two new choices – to kill the output on even days of the month, odd days (or after all each).

For those who make good use of this node – please put a hyperlink to this weblog entry someplace in your writings so individuals will come again right here. Or if the node proves REALLY helpful you would feed my Ebay behavior – there’s a hyperlink on the proper of the weblog.

See the Node-Pink information panel in Node-Pink for up-to-date data.

July 2022 Fast Take a look at

I juat added a brand new timer to a stream and did nothing greater than check outputs 1 and a couple of on the at present OFF timer – and obtained the anticipated outcomes when injecting “auto” then “handbook on” then “handbook off” to a timer prefitted with payloads “on” and “off”. The primary 2 debug outputs appeared on finishing the stream replace, the others on injecting auto, handbook on and handbook off respectively. All different settings have been defaults.

[
    {
        "id": "403d2aae837a4874",
        "type": "tab",
        "label": "bigtimer test",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "e1483686f071ce5d",
        "kind": "bigtimer",
        "z": "403d2aae837a4874",
        "outtopic": "",
        "outpayload1": "",
        "outpayload2": "",
        "title": "Huge Timer",
        "remark": "",
        "lat": 0,
        "lon": 0,
        "starttime": 5001,
        "endtime": 1425,
        "starttime2": 0,
        "endtime2": 0,
        "startoff": 0,
        "endoff": 0,
        "startoff2": 0,
        "endoff2": 0,
        "offs": 0,
        "outtext1": "",
        "outtext2": "",
        "timeout": 1440,
        "solar": true,
        "mon": true,
        "tue": true,
        "wed": true,
        "thu": true,
        "fri": true,
        "sat": true,
        "jan": true,
        "feb": true,
        "mar": true,
        "apr": true,
        "might": true,
        "jun": true,
        "jul": true,
        "aug": true,
        "sep": true,
        "oct": true,
        "nov": true,
        "dec": true,
        "day1": 0,
        "month1": 0,
        "day2": 0,
        "month2": 0,
        "day3": 0,
        "month3": 0,
        "day4": 0,
        "month4": 0,
        "day5": 0,
        "month5": 0,
        "day6": 0,
        "month6": 0,
        "day7": 0,
        "month7": 0,
        "day8": 0,
        "month8": 0,
        "day9": 0,
        "month9": 0,
        "day10": 0,
        "month10": 0,
        "day11": 0,
        "month11": 0,
        "day12": 0,
        "month12": 0,
        "d1": 0,
        "w1": 0,
        "d2": 0,
        "w2": 0,
        "d3": 0,
        "w3": 0,
        "d4": 0,
        "w4": 0,
        "d5": 0,
        "w5": 0,
        "d6": 0,
        "w6": 0,
        "xday1": 0,
        "xmonth1": 0,
        "xday2": 0,
        "xmonth2": 0,
        "xday3": 0,
        "xmonth3": 0,
        "xday4": 0,
        "xmonth4": 0,
        "xday5": 0,
        "xmonth5": 0,
        "xday6": 0,
        "xmonth6": 0,
        "xday7": 0,
        "xmonth7": 0,
        "xday8": 0,
        "xmonth8": 0,
        "xday9": 0,
        "xmonth9": 0,
        "xday10": 0,
        "xmonth10": 0,
        "xday11": 0,
        "xmonth11": 0,
        "xday12": 0,
        "xmonth12": 0,
        "xd1": 0,
        "xw1": 0,
        "xd2": 0,
        "xw2": 0,
        "xd3": 0,
        "xw3": 0,
        "xd4": 0,
        "xw4": 0,
        "xd5": 0,
        "xw5": 0,
        "xd6": 0,
        "xw6": 0,
        "droop": false,
        "random": false,
        "randon1": false,
        "randoff1": false,
        "randon2": false,
        "randoff2": false,
        "repeat": true,
        "atstart": true,
        "odd": false,
        "even": false,
        "x": 1600,
        "y": 220,
        "wires": [
            [
                "b9a7d7728562fa9e"
            ],
            [
                "674e3a0fab0f9036"
            ],
            []
        ]
    },
    {
        "id": "b9a7d7728562fa9e",
        "kind": "debug",
        "z": "403d2aae837a4874",
        "title": "out1",
        "energetic": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "full": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1850,
        "y": 160,
        "wires": []
    },
    {
        "id": "674e3a0fab0f9036",
        "kind": "debug",
        "z": "403d2aae837a4874",
        "title": "out2",
        "energetic": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "full": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1850,
        "y": 260,
        "wires": []
    },
    {
        "id": "2b5f995c17a902ec",
        "kind": "inject",
        "z": "403d2aae837a4874",
        "title": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "as soon as": false,
        "onceDelay": 0.1,
        "subject": "",
        "payload": "auto",
        "payloadType": "str",
        "x": 1430,
        "y": 140,
        "wires": [
            [
                "e1483686f071ce5d"
            ]
        ]
    },
    {
        "id": "3e5bc965ead87fd7",
        "kind": "inject",
        "z": "403d2aae837a4874",
        "title": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "as soon as": false,
        "onceDelay": 0.1,
        "subject": "",
        "payload": "handbook on",
        "payloadType": "str",
        "x": 1430,
        "y": 240,
        "wires": [
            [
                "e1483686f071ce5d"
            ]
        ]
    },
    {
        "id": "a233611e23b794bb",
        "kind": "inject",
        "z": "403d2aae837a4874",
        "title": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "as soon as": false,
        "onceDelay": 0.1,
        "subject": "",
        "payload": "handbook off",
        "payloadType": "str",
        "x": 1430,
        "y": 280,
        "wires": [
            [
                "e1483686f071ce5d"
            ]
        ]
    }
]

Take pleasure in and please do report any points again right here.


For those who like this publish – please share a hyperlink to it by social media, by e-mail with buddies or in your web site.
Extra readers means extra suggestions means extra solutions for all of us. Thanks!

Facebooktwitterpinterestlinkedin