Jump to content
C4 Forums | Control4

Date/Time math


jfh

Recommended Posts


I don’t know enough about the date math, but one way you could approach this would be to set up a variable for each contact you want to monitor. Then set a daily schedule to run a macro that adds 1 to the variable counts, checks the counts, and does whatever you want to do if count is over 7. Then set each variable to zero whenever the contact closes. 

Link to comment
Share on other sites

3 hours ago, C4 User said:

I don’t know enough about the date math, but one way you could approach this would be to set up a variable for each contact you want to monitor. Then set a daily schedule to run a macro that adds 1 to the variable counts, checks the counts, and does whatever you want to do if count is over 7. Then set each variable to zero whenever the contact closes. 

This is what I use for both daily count downs and count ups.  If you want to display the current value of the variable, you can do so using a thermostat or a unbound test dimmer.  You can also edit the variable (increase decrease) from a TS using the dimmer or extra experience buttons.

Link to comment
Share on other sites

4 hours ago, South Africa C4 user said:

This is what I use for both daily count downs and count ups.  If you want to display the current value of the variable, you can do so using a thermostat or a unbound test dimmer.  You can also edit the variable (increase decrease) from a TS using the dimmer or extra experience buttons.

@South Africa C4 user Can you explain more about how to display variable value using unbound test dimmer? Thank you.

Link to comment
Share on other sites

2 hours ago, C4 User said:

@South Africa C4 user Can you explain more about how to display variable value using unbound test dimmer? Thank you.

There is a test dimmer and test light driver available in the on-line diver database (Free).  It is intended for dealers to use as a demo in showrooms without a physical light bound to the driver  but is very useful for other purposes (such as this, or linking in completely different types of lights such as pool lights via a pool proxy driver).  You can create a room called variables or settings and put a few of these test dimmers (for numeric values between 0 and 100) and test lights (for Boolean variables) in it.1

Lets say you have a variable called KidsMaxVolume which you use to control the maximum volume in your children’s rooms, you can then program against the dimmer so that every time the lighting level changes, the variable KidsMaxVolume is changed to equal the new light level.  If the variable can be changed in some other fashion (and probably also necessary for after a director reboot - I cant recall) then you also need to program against the when variable changes event for KidsMaxVolume such that it sets the light level to equal the variable value.

I moved away from this method to using the free Yatun Temperature display driver for displaying variables.  The latter takes more programming if one wants display and control but is not limited to the lighting screen only!

Link to comment
Share on other sites

10 hours ago, Neo1738 said:

Honestly wouldn't it be easier to set a timer to reset if contact closed and start if opened and if it expires it does xyz action? Instead of a variable that has to check in daily etc.

Yes, but 7 days is a very long timer and I figured I’d lose it on a reboot.

Link to comment
Share on other sites

I would agree - this is something for a simple scheduled event, assuming you don't care about the EXACT amount of time (if you set for 7 days, it could potentially be 6 days and 1 second to exactly 7 days - or use 8 for 7 days and 1 second to 8 days- due to the exact time the contact opens).

Basic: daily scheduled event at 1PM

Variable, number called [whatever]

WHEN scheduled event occurs

IF contact is open, variable [whatever] +1

 

WHEN variable changes, IF variable is equal to or higher than 7

[whatver you'd want to do]

plus add variable = 0

 

Hardly a lot of programming and much more reliable

You could increase accuracy by scheduling a check twice or more a day, just make sure you multiply and adapt the number before triggering the even:

twice a day that same programming, now you check for variable being 14 to get a 6 day 1 second to 6 day 12h range, for 15 to get 6 day 12 h 1 second to 7 days, for 16 to get 7 days 1 second to 7 days 12h etc)

Running a 7 day timer is not something that I'd recommend due to reboot, but also, why would you have the system run a timer for that long, unless you REALLY need to know by the second?

Even then I'd do it different, though it would likely require paid driver.

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.