NAC Timers

Discussion in 'C-Bus Automation Controllers' started by carlg, Oct 22, 2018.

  1. carlg

    carlg

    Joined:
    Jan 29, 2009
    Messages:
    43
    Likes Received:
    0
    I am a bit stuck on how to add a automatic timer for some squash courts.
    We would of used PluseCBUS group for 1hour, 2 hours, 3 hours etc. is SchedulePlus and then add a button that sees the timer and displays the time remining for the viewer to see
    The NAC dose have the Pulse Cbus Function, but need to be able to show a count down timer as well. But cant find that bit.
    So what we have is a single group 0/112/5 that sets preset levels 10 = 1 Hour, 20 = 2 Hours 30 = 3 Hours etc etc.
    Script is
    value = GetCBusLevel(0, 112, 5) -- Get Level
    if (value == 50) then -- 5 Hour
    PulseCBusLevel(0, 112, 5, 150, 0, 5, 0) -- Left 5Seconds for Testing
    elseif (value == 40) then -- 4 Hour
    PulseCBusLevel(0, 112, 5, 150, 0, 4, 0) -- Left 4 Seconds for Testing
    elseif (value == 30) then -- 3 Hour
    PulseCBusLevel(0, 112, 5, 150, 0, 3, 0) -- Left 3 Seconds for Testing
    elseif (value == 20) then -- 2 Hour
    PulseCBusLevel(0, 112, 5, 150, 0, 2, 0) -- Left 2 Seconds for Testing
    elseif (value == 10) then -- 1 Hour
    PulseCBusLevel(0, 112, 5, 150, 0, 1, 0) -- Left 1 Seconds for Testing
    elseif (value == 0) then -- Cancel Test
    end
    This all works fine. Well not sure how to get the Control Group 0,112,5 to go back to zero when each of the timers expiries.
    also the bit of how to generate the countdown timer, doesn't need to show seconds, just every minute.

    Any help would be appreciated
     
    carlg, Oct 22, 2018
    #1
  2. carlg

    Ashley

    Joined:
    Dec 1, 2005
    Messages:
    1,548
    Likes Received:
    178
    Location:
    Adelaide, Australia
    When you issue the Pulse command store the end time. Then have a script that runs every minute and subtracts the current time from the end time and convert it to minutes.

    Why don't you think that is what the pulse command will do when the timer expires?

    Also, why all the IF statements. Why not just one PulseCBusLevel(0, 112, 5, 150, 0, value * 360, 0)

    I assume you are just trying to create a timer and not actually controlling the lights?

    If so, why bother with the Pulse command at all. Whenever the time value ga changes, just convert it to minutes and save it then set the ga to zero. Have another script that runs every minute and if the count is non zero just decrement it and show the result.
     
    Ashley, Oct 24, 2018
    #2
  3. carlg

    carlg

    Joined:
    Jan 29, 2009
    Messages:
    43
    Likes Received:
    0
    Ashley.
    Thank you for your email, the script is only shown in testing format.
    The timers will once complete will turn the court lights on for the given periods as stated in the PulseCBusLevel (Well when the real values are added)
    the reason for the ifelse statements is that on the visualization the user will be given the control to select the time required for the court. 1,2,3,4,5 Hour intervals.

    Will have a look at your suggested of running another script that will do the subtraction.
     
    carlg, Oct 24, 2018
    #3
  4. carlg

    Ashley

    Joined:
    Dec 1, 2005
    Messages:
    1,548
    Likes Received:
    178
    Location:
    Adelaide, Australia
    If you are controlling the lights create a separate GA to set the time interval. Have an event triggered by that GA so that when it goes non-zero you issue the pulse command, store the end time and reset that ga back to zero.

    Since you are setting the time interval ga to the number of hours (x10 in your example), you don't need all those IF statements because you can calculate the actual pulse time in seconds by multiplying the hours by 360 and use that as the time interval in a single IF statement. That also makes it easy to add more intervals without changing the script.

    Then, as suggested, a second script that runs every minute to update the remaining time.
     
    Ashley, Oct 24, 2018
    #4
  5. carlg

    carlg

    Joined:
    Jan 29, 2009
    Messages:
    43
    Likes Received:
    0
    Ashley.
    Thank you. I will give it a try next week when we are back on site
     
    carlg, Oct 25, 2018
    #5
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.