BigTimer for Node-Red

This is an old article - For information and the latest on BigTimer - see this blog article.

Having just fixed a bug in big-timer (npm install node-red-contrib-bigtimer) I thought it was time to do a short video.

So this is for users of Node-Red - this demo on a simple Model A Raspberry Pi

Facebooktwittergoogle_pluspinterestlinkedin

43 thoughts on “BigTimer for Node-Red

  1. Hello Peter,
    Just to inform you that you made a little mistake in your Youtube video .
    You wrote : npn install node-red-contrib-bigtimer instead of npM install.....
    However, thank you for your work and your very good blog that i discovered
    last week.
    Jhujube

  2. Really amazing project!!!

    One question... can i use node-red for use with AND CONDITIONS? (THAT IS... if SUNDAY AND temp below 18º AND presence sensor is ON.... POWER ON HEATER)

    1. Of course - just join some functions together. I'm using mine to control my heating with multiple zones per day. I don't use BIGTIMER for that - just a large function - it's Javascript inside the function node. In my case if it is the weekend and after 10pm, set the heating on unless the temperature is already 20c...

      In fact I wrote a thermostat node but ended up doing it another way.

      You can play with this once you have node-red up... node-red-contrib-thermostat - I made that ages ago - but it only has 2 on-off times a day.. it has peak, off-peak and frost... but you're better off using a function node and doing your own code in it... is it just a heater or a full central heating system you're thinking of?

  3. Dear Peter,

    I have a suggestion for improvement. I do not know if you know, since years I have developed a number of so called plugins for EventGhost. One of those is named SunTracker and is in some way comparable with your BigTimer.
    However, there are two features I really think would be valuable to have also in the BigTimer, two more day types. We can call them 'Vacation' and 'Away' (or 'Empty house').
    In SunTracker I can have different settings for those two day types. During 'Vacation' I personally have completely different settings for lights and other stuff then during normal weekends (so Saturday and Sunday settings will not work). Also when 'Away', I have again different needs.
    Let's assume you would have settings for those additional day types. To activate them you could have an additional input accepting the values 0, 1, 2 (0 = Don't bother, 1 = Vacation, 2 = Away).
    In this way you could externally set the mode of your system/house very easily using whatever node signals (like external calendars or home alarm system). You would also be able to manage special holidays (like we just had with Christmas and New Year)

    As I said, just a suggestion,

    Best regards, Walter

    1. Hi Walter

      Well the first flaw there is "you could have an additional input..." - you can't have more than one input in a node-red node.

      However you could of course put 2 bigtimers side by side and feed their outputs to the same place. One would be none-vacation - the other would be vacation etc... actually you could have LOADS of them - and why not - they're free 🙂

      Keep the suggestions coming folks.

  4. Hi, yes, having them in parallel solves it partly, that is how I configured it already for weekdays and weekends, but still, I see a need for two additional day types and that could not be solved using side by side effects. And you would then need something to tell the system which day type to use (a separate input is obviously not possible so instead some unique values like 'N' for normal, 'V' for vacation, 'A' for away ). Since you need to tell the node which day type is active. Or am I missing something?

  5. I would assume that you also have different requirements for home automation in your houses whether it is normal weekdays, weekends, you are away or you are there on vacation (late nights with parties & friends, you don't want lights go off at 23.00)

    When you are in your house in Spain, what about the house back home in Britain? For heating and lights etc, you could lower the temperature, you do not need the lights on that long in the evening or you would like to have them on all night long. Your house in Britain is then in the 'A' mode (away). Your hose in Spain is in normal or vacation mode. When leaving sunshine behind, the reverse will happen, your house in Spain goes into 'A' mode etc

    BR Walter

    1. Oh I definitely use 2 bigtimers for that - so in Spain right now everyhthing is on the B timer. One could put a tickbox to disable the entire timer - but then you can do that just by cutting the connecting lead....

      Heating and lighting - I have for the heating a HOLD function so I can hold things at minimums for X hours or days....

      I see your point.... let me ponder that one.

  6. Of course there is nothing stopping you making those changes - if you look - there's an HTML file and a JS file - it's not rocket science to change them. If you do make a change you need to stop and start node-red for the changes to have an effect.

  7. Hi Pete.

    I have a question in my mind, as I am going to build a Rpi Node-red setup which will not have an access to internet. Will your bigtimer work in that particular situation for dawn and dusk time calculation? if I provide latitude and longitude for that particular location? For time, I have a plan to attach ds 3231 time-module with pi.

    1. Hi there. I don't know - as I used a module to give me the conversions - it may for all I know use an online table - I never intended the timer - or indeed any of my modules to work offline. I guess if you experiment you'll soon find out - just try setting up coordinates and say on at DUSK without any internet connection - you'll see on the node long to go and hence when dusk is - if it is correct - then it does not need an internet connection.

  8. I'm using Bigtimer to control an exterior post light. I have it set to turn on at dusk -30 minutes and go off at 23:00. It reliably turns on at around dusk -30 (around 19:40 here in Virginia). However it goes off at 1:16 the next day regardless of what off time I set (I haven't tried them all). The on time changes a little each day but the off time does not.

    I'm willing to believe I'm doing something wrong but what? Something in Node-Red setup?

    (I record the old and new values at each transition to make it appear as a square wave on a graph)
    +---------------------+-------+
    | timestamp | value |
    +---------------------+-------+
    | 2016-05-11 01:16:11 | 0 |
    | 2016-05-11 01:16:11 | 1 |
    | 2016-05-10 19:41:11 | 1 |
    | 2016-05-10 19:41:11 | 0 |
    | 2016-05-09 19:40:09 | 1 |
    | 2016-05-09 19:40:09 | 0 |
    | 2016-05-08 19:39:08 | 0 |
    | 2016-05-08 19:39:08 | 1 |
    | 2016-05-08 01:16:06 | 0 |
    | 2016-05-08 01:16:06 | 1 |
    | 2016-05-07 19:39:06 | 1 |
    | 2016-05-07 19:39:06 | 0 |
    | 2016-05-07 01:16:05 | 0 |
    | 2016-05-07 01:16:05 | 1 |
    | 2016-05-06 19:38:04 | 1 |
    | 2016-05-06 19:38:04 | 0 |
    +---------------------+-------+

  9. Make sure you are using yesterday's BIG-TIMER (vesion 1.2.2) as I discovered a bug in my latest revision if you were NOT using random timing - now fixed and tested. I have an installation here with several lighting systems working at dusk with a positive or negative offset and then turning off late at night reliably.

    To update an existing setup - merely install again:
    npn install node-red-contrib-bigtimer

    - and restart Node-Red.

  10. I'm having difficulty integrating Bigtimer with imperihome. Manual on/off works but I haven't managed to get auto command/status connected to imperihome. It almost works as expected from NodeRed. The light auto off time is stuck on ~1:16AM regardless of configured off times (I'm at GMT -5), but I can live with that. I have Imperihome configured for DevMultiSwitch with on, off, auto states. I see no output from Bigtimer that ever includes the auto state. I'm looking at the complete msg object from each output. In fact I never see the described state or name items either. The json file says I'm at version 1.2.94 and I just updated yesterday.

    Can anyone give me a start in the right direction?

    John

  11. Hi Peter,

    I'm slightly confused about adding Big Timer to the Node-RED IDE. I've got a Pi Zero (original) with Jessie Raspbian and Node-RED and everything is fine up to that point. When I run sudo npm install node-red-contrib-bigtimer I get the response...

    node-red-contrib-bigtimer@1.2.95 node_modules/node-red-contrib-bigtimer

    ...OK, no error message but I just started playing with Node-RED today so I'm not sure what to expect....

    At this point I thought I'd see Big Timer in my list of things to add to my Flow but it's nowhere to be found (restarted Node-RED IDE and also Pi Zero). I also noticed in your video you have a Scargill section where you find it but I don't have that section. I'm guessing there might be a core Scargill library I need to install first? Or am I doing something else wrong?

    Cheers,
    Brian

    1. Hi Brian -yes you're doing something wrong - I'm just not sure what it is.

      Assuming you are user pi and you have CD'd to .node-red directory

      ie
      cd
      cd .node-red
      npm install node-red-contrib-bigtimer

      Once it's done - stop node red and start it - or reboot if you like... and it'll be there down the left hand side.

      That method of install is how you should install most nodes incidentally - if you do it from the pi directory the node will end up installed in the wrong place.

      1. Hi Pete,

        Thanks - you hit the nail on the head. Damn Pi Terminal defaults to root directory.

        I tried again and I made sure I changed to .node-red then re-ran npm. I did have to restart the Pi Zero though as I have Node-RED set to autostart at boot (seems it only reads the node_modules directory at service start??? Not sure but that fixed things and I've got a Scargill section now. 🙂

        Shame there's not an environment variable or similar so npm could work out where to put things but that often seems to be the way with Linux.

        Anyway, thanks again Node-RED looks like fun. I'll have a play with Big Timer and there's a few other modules I'd like to pull from nodered.org - at least I know where to put them now..

        Cheers,
        Brian

  12. Hi, Pete.
    Is it possible to add time ajusting command to BigTimer?

    Something like msg.payload="StartAt 21:15"?
    It will be very useful possibility to control On/Of time via web or something like pusher/pushover.

  13. Pete, i think i don't understand youe idea quite right. As i see manual override change state of the timer but i'm talking about change of timer settings.
    Can you spend a few time and give me an examle?

  14. Hi, I'm trying to use a switch to action different bigtimers. I check a status, and if it is on, then it should go to the first group of bigtimers alternatively go to the second set.

    However, they all seem to be in action. Is there a best way to do this?

    So far, they all look like they are still in action, or alternatively it sends an OFF which will turn off the light that the first action just switched on.

    I don't want to edit node-red to switch which one is in operation, but to use the API check of the status which is in place.

    Here's a screen shot ... https://flic.kr/p/MzizkS

    Thanks

  15. Great node, Pete.

    What's the best way to get the state of the timer? I get the 1, 0 output for control, but how best can I do a logical test for whether the timer is in Auto mode or not? I can see the status string, but I'm hesitant at string matching for long term reliability.

    I guess what I'm really asking for is a 0 (Forced off), 1 (Forced on) or 2 (Auto) output.

  16. Thanks for writing this. I have a few questions if you don't mind.
    1. Is there a way to add or pass through a topic? It seems to be stripped through your node.
    2. Is there a way I could change the override timeout <8 hrs? I went through bigtimer.js but couldn't figure it out.
    3. What exactly is the timeout option which is set to 1440? I tried to change it thinking it was perhaps a newer version that allows the override timeout to be changed to a different value than 8 hours.

    Thanks again for this, it works great!!

    1. I'd have to check the topic but you might be able to pass through something else you create like msg.myinformation
      You can override the 8 hours which is actually 24 - it is one of the boxes in the setup (in minutes - 1440).

  17. Thank you for the reply. I am fairly new to node-red/pi (Day 3 now) so I'm unsure if I have the technical ability to change the email node I'm using to an alternate msg to be honest.

    I did change the timeout field in the node setup to 5 and deployed but after >5 minutes it still states temp override. Perhaps I'm doing something wrong?

    I really hate to bother you with such a thing but this node does nearly everything I need as opposed to a few others I've used in the last 2 days.

  18. I did figure out the override timeout. While reading the README.md I must have misinterpreted your descrption " Manual override will also be over-ridden by any scheduled change." I assume if I overrode and switched from on to off and then the defined timer on time came it would switch back to auto and turn it on but I'm assuming that was not the intended goal here.

    BTW, I got the 8 hour time out from your README.md included w/ the npm installed module
    "#Override
    The manual override will time-out after 8 hours and go back to auto (just in case you forget to turn something off). Manual override will also be over-ridden by any scheduled change. There is a pause schedule button for convenient longer-term pausing of the schedule."

    Let me know if you do come across a way to pass through the topic but not a deal breaker, thanks again for the great node!! Take the criticism in stride, you can't please everyone all the time.

    1. Let us say that the program turns the light on at 5pm and off at 6pm. At 4pm you turn the light on manually. At 6pm the timer will still turn the light off.

      I will fix the description. Thank you.

  19. Hi pete,
    I have recently installed Bigtimer from 1.4.88 and i have problem. On node red launch i have :

    [bigtimer] SyntaxError : Invalid or unexpected token.
    And after :
    Waiting for missing types to be registered
    - bigtimer

    Do you have any idea about this issue?
    Thanks
    thomas

  20. I'am a lubuntu VM user. it is installed in /home/user/.node-ned in node_modules

    I find a missing "break" in line 351 of bigtimer.js
    It can be the problem ?

    1. Hang on I'll go take a look... ok, it would not hurt to have that line break in - and by all means put it in, stop node-red and start again... but I seriously doubt it as I'm not having any issue - and it will just drop through to the default which isn't doing anything.

      Lubuntu I can't comment on. Don't use it. Sadly we have pretty awful debugging on Node-Red - the error message does not help.

      And no-one else has reported this... the missing token whatever it is would likely stop it loading and hence the later message.

  21. I have worked yesterday and i have found my solution.
    I have installed with "-g" global the 1.4.87 version in /usr/local/lib. When i uninstall/re-install the 1.4.88 version in .node-red folder, it reports 1.4.88 version but the .config.json file used the global version that's why node-red never launch the right version.
    Really thx for your time
    I can now try your node.
    Thank you Pete

Leave a Reply

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