Jump to content
C4 Forums | Control4

Programming timer duration or scheduler timing


bdonohoe

Recommended Posts

Is it possible to set the duration of a timer based on a variable? Or to change the dates or times a scheduler will run? I'm trying to set up timers or schedules that will run for a duration or on a date I don't know in advance. It seems like timers can only be set to essentially a fixed duration (i.e. one you can hard code). And schedules cannot be modified programmatically at all, as far as I can tell.

Am I missing something? Are either of those things possible? Are there third party drivers that could do it (like the HouseLogix Advanced Routines driver for instance)?

FWIW, I'm trying to have events happen when things get scheduled in a Google Calendar using @alanchow's awesome IFTTT driver. I can easily pass the right information into C4 (start dates, end dates, durations, etc.), but I seem can't do anything with it.

Link to comment
Share on other sites


9 minutes ago, bdonohoe said:

Is it possible to set the duration of a timer based on a variable? Or to change the dates or times a scheduler will run? I'm trying to set up timers or schedules that will run for a duration or on a date I don't know in advance. It seems like timers can only be set to essentially a fixed duration (i.e. one you can hard code). And schedules cannot be modified programmatically at all, as far as I can tell.

Am I missing something? Are either of those things possible? Are there third party drivers that could do it (like the HouseLogix Advanced Routines driver for instance)?

FWIW, I'm trying to have events happen when things get scheduled in a Google Calendar using @alanchow's awesome IFTTT driver. I can easily pass the right information into C4 (start dates, end dates, durations, etc.), but I seem can't do anything with it.

If you are going to use our IFTTT driver to do scheduling via google calendar then use the any events start trigger and push the following

title : SCHEDULE EXECUTED

message : {{Title}}

Then program your Control4 programming to fire off the appropriate programming umbased on the title and message.  Once setup this will now allow you to dynamically use the calendar alone to do scheduling without any further programming from Control4 as long as the google calendar event title matches (case sensitive) the title you programmed into Control's message conditional statement

Link to comment
Share on other sites

Sure, that's the easy part. The problem I'm trying to work around is that neither IFTTT nor Zapier have "event ended" triggers. So I am trying to find a way to have a state expire after a given period of time (where the period is defined by the event duration) or to schedule an expiration event based on the end date of the event.

The only way I've found to do it so far is to use Zapier's "delay" function, to have a single trigger that sends a Pushover message at the start of the event, then waits the requisite amount of time before firing another Pushover message. Unfortunately, Zapier wants $20/month to enable that functionality. I'm all for paying for services, but $20/month is a lot to pay to work around this one deficiency in Control4's programmability.

Link to comment
Share on other sites

Thanks @alanchow. I appreciate your effort to find a workaround. In this case, I am trying to use the data I already have. Events have duration. There is an end time. I shouldn't need an event for when and event starts and an event for when an event ends.

So I guess the answer to my original question is no, you can't program timers based on incoming data, and no, you can't programmatically adjust when schedules run. I'll have to keep working on external solutions instead.

Control4 "programming" sure leaves a lot to be desired. I wish they'd switch to using a scripting language so we could add actual logic. 

Link to comment
Share on other sites

21 minutes ago, bdonohoe said:

Thanks @alanchow. I appreciate your effort to find a workaround. In this case, I am trying to use the data I already have. Events have duration. There is an end time. I shouldn't need an event for when and event starts and an event for when an event ends.

So I guess the answer to my original question is no, you can't program timers based on incoming data, and no, you can't programmatically adjust when schedules run. I'll have to keep working on external solutions instead.

Control4 "programming" sure leaves a lot to be desired. I wish they'd switch to using a scripting language so we could add actual logic. 

You are correct.  You cannot set a timers time dynamically.  Though that does give me an idea.

Link to comment
Share on other sites

Quote

Is it possible to set the duration of a timer based on a variable? Or to change the dates or times a scheduler will run? I'm trying to set up timers or schedules that will run for a duration or on a date I don't know in advance. It seems like timers can only be set to essentially a fixed duration (i.e. one you can hard code). And schedules cannot be modified programmatically at all, as far as I can tell.

Hmm.

Well you CAN change the duration/interval of a timer in C4 programmatically - but you can't directly set it to another variable's value.

So in a 1-2-3 situation, you'd have to program

WHEN variable changes
IF variable is 1
 set timer to 1 minutes
IF variable is 2
 set timer to 2 minutes

Whether that is truly useful depends on the situation

For schedules, you could possibly create a 'generic' schedule that repeats daily (or several) and embed what you want to happen under a true/false variable - and use programming to change that variable. Again. if you're just looking to do a 'few' of these it's not terrible to do - if you're looking at dozens...

 

 

 

2 hours ago, bdonohoe said:

Control4 "programming" sure leaves a lot to be desired

You complain about this regularly. It won't make a difference. What you may be able to do is far beyond what the majority of people that use it can do - including some dealers. Most of what you're looking to do requires something that just isn't for the majority of the target:

2 hours ago, bdonohoe said:

I wish they'd switch to using a scripting language so we could add actual logic

This may help you and a few other power users and a decent chunk of dealers, the problem remains as always that it would kill it for most everyone else.

 

Know that I understand where you're coming from, and that I don't really disagree - but you would fall under such a small niche of people that expecting it to change is not realistic

Link to comment
Share on other sites

17 minutes ago, Cyknight said:

You complain about this regularly. It won't make a difference. What you may be able to do is far beyond what the majority of people that use it can do - including some dealers. Most of what you're looking to do requires something that just isn't for the majority of the target:

This may help you and a few other power users and a decent chunk of dealers, the problem remains as always that it would kill it for most everyone else.

You know what, Cy? It'd be better for both of us if you just ignored my posts from now on. Just don't read them. Move on. Let other people respond who actually want to talk about how to make their systems better instead of just defending the status quo.

Link to comment
Share on other sites

1 hour ago, bdonohoe said:

You know what, Cy? It'd be better for both of us if you just ignored my posts from now on. Just don't read them. Move on. Let other people respond who actually want to talk about how to make their systems better instead of just defending the status quo.

Oh? Still can't take criticism then, or properly formulated arguments. As you wish.

Link to comment
Share on other sites

1 hour ago, Cyknight said:

Oh? Still can't take criticism then, or properly formulated arguments. As you wish.

This isn't about criticism or your inability to form a cogent argument. It's about your attitude that turns every discussion into a fight. I want to come here to talk about Control4 and home automation, and yes, sometimes that will include venting frustrations.

Thank you in advance for no longer responding to my posts.

 

Link to comment
Share on other sites

13 hours ago, bdonohoe said:

This isn't about criticism or your inability to form a cogent argument. It's about your attitude that turns every discussion into a fight. I want to come here to talk about Control4 and home automation, and yes, sometimes that will include venting frustrations.

Thank you in advance for no longer responding to my posts.

 

Couldn't have said it better. He's the primary reason I no longer try to actively participate in this forum - who needs the aggravation. End-users are not Control4's customers - we know that, he knows that. That creates frustrations that do need to be vented, if for no other reason than maybe, just maybe, someone from Control4 will pick it up and run with it.

I don't use IFTTT so I'm not 100% sure what you're trying to accomplish, but you can use a 1-minute timer that repeats until a certain condition is met (such as a variable equal to another variable). I use that to raise the shades in the morning at sunrise or at 6:30AM, whichever is later. The only "gotcha," and it's a big one, would be you need to assure that the condition will be met at some time in the not too distant future, otherwise it'll run forever (aka endless loop).

Link to comment
Share on other sites

… you can use a 1-minute timer that repeats until a certain condition is met (such as a variable equal to another variable). … you need to assure that the condition will be met at some time in the not too distant future, otherwise it'll run forever (aka endless loop).

Ah, that's an interesting idea. The events I'm trying to track can be days long (e.g. when we have house guests for the weekend, I alter the behavior of certain things), but I could run a timer that checks hourly or even just daily. That way even if something went wrong it wouldn't be too taxing.

Now let me see if I can figure out how to tell whether an event is still active… :)

P.S. Zapier tells me "event end" is a trigger on their todo list. No promises, of course, but I've cast my vote in favor.

Link to comment
Share on other sites

1 hour ago, martymohr said:

I use that to raise the shades in the morning at sunrise or at 6:30AM, whichever is later

C4 already allows for this without using timers and 'complex' check variables.

Schedule events at 6:30am and sunrise

on sunrise

IF time is later than 6:30 AM

on 6:30

IF time is daytime

 

Link to comment
Share on other sites

1 hour ago, Cyknight said:

C4 already allows for this without using timers and 'complex' check variables.

Schedule events at 6:30am and sunrise

on sunrise

IF time is later than 6:30 AM

on 6:30

IF time is daytime

Your point? I mean, besides being argumentative and stupid.

1. There is no complex variable checking - I'm simply creating a "do until" loop using the timer (because I want a slow loop) instead of using a macro loop. Now, if C4 would stop the insanity of claiming loops are dangerous it could be handled a lot cleaner, and easier.
2. I have one scheduled event - wake up house - but don't do it unless it's 6:30AM or later. Why would I want to set up two wake up house schedules especially when ...
3. Schedules don't display alphabetically. When will ComposerHE do what just about every other software does? Sure it's a complex rewrite - but complexity should not be the excuse.

You obviously don't understand there are multiple methods of accomplishing the same result. In the absence of a programmer standards manual (which would only be useful in a group environment using ComposerPRO), what is comfortable for the developer (one schedule instead of two) is appropriate. Sure, your method works,  but in my professional opinion, is very amateurish.

If your post was meant to demonstrate your brilliance, you failed. If it was meant to demonstrate my incompetency, you failed miserably there as well. Please stay out of threads where end-users are trying to accomplish a goal made difficult by your beloved Control4!

Link to comment
Share on other sites

2 minutes ago, martymohr said:

Your point? I mean, besides being argumentative and stupid.

Well, my point was to point out an alternative and generally easier to accomplish (or perhaps, easier to wrap one's head around) method of doing what you're doing within the confines of Control4 for most users.

Quote

There is no complex variable checking

'complex' - as in it's in apostrophes.

3 minutes ago, martymohr said:

If your post was meant to demonstrate your brilliance, you failed. If it was meant to demonstrate my incompetency, you failed miserably there as well.

Uhmm - neither. See above.

4 minutes ago, martymohr said:

You obviously don't understand there are multiple methods of accomplishing the same result

Ok...

7 minutes ago, martymohr said:

by your beloved Control4

You really have no idea do you...

 

And I'm supposed to be the high-strung one on here?

 

Link to comment
Share on other sites

33 minutes ago, Cyknight said:

Well, my point was to point out an alternative and generally easier to accomplish (or perhaps, easier to wrap one's head around) method of doing what you're doing within the confines of Control4 for most users.

Only if you assume most end-users cannot handle complex coding.  I don't subscribe to that philosophy.

34 minutes ago, Cyknight said:

'complex' - as in it's in apostrophes.

By apostrophes do you mean quotes? If not, I have no idea what you're trying to say.

35 minutes ago, Cyknight said:

You really have no idea do you..

I have read enough of your posts that I must conclude that's a rhetorical question - obviously I (and other people on this thread) have a very good idea.

36 minutes ago, Cyknight said:

And I'm supposed to be the high-strung one on here?

Perhaps I am - and I should listen to my wife's advice: don't get into arguments with conceited and/or stupid people ... it's a guaranteed non-win.

This thread is about SOLVING A PROBLEM. If you have nothing to contribute, then please do everyone a favor and stay out!

Link to comment
Share on other sites

2 hours ago, martymohr said:

This thread is about SOLVING A PROBLEM. If you have nothing to contribute, then please do everyone a favor and stay out!

Again - I was merely offering an alternative in my reply to your suggestion. No more, no less.

If you prefer to attack me personally for some reason - whatever reason - go nuts.

I'm conceited and stupid?: I'd suggest you take a step back, take a few deep breaths and read over your last two posts. What you do from there is for others to judge.

Link to comment
Share on other sites

2 hours ago, Cyknight said:

Again - I was merely offering an alternative in my reply to your suggestion. No more, no less.

Sorry ... but " C4 already allows for this without using timers and 'complex' check variables" is not the same as merely offering an alternative. It's a direct slam at what I had programmed. Worse yet, you had no idea of what my code looked like!

I suggest you step back, take a few deep breaths and read over ALL your posts.

Link to comment
Share on other sites

4 hours ago, msgreenf said:

Not trying to jump in here but loops are highly discouraged

Can you explain why? Loops are an integral component of any programming language coming in second, in my opinion, to IF ... THEN ... ELSE. Now granted, the absence of a LOOP STRUCTURE in ComposerHE means you need to "roll your own" which we both [should] know is significantly more dangerous; but just because Control4 had created a self-fulfilling prophecy is no reason we shouldn't be using loops. BTW ... you don't need a loop structure to create an endless loop (gosh, I wish they had used "cycle" instead of "loop" - in which case we wouldn't be having this discussion) ... in fact it's quite the opposite.

 

 

Link to comment
Share on other sites

Can you explain why? Loops are an integral component of any programming language coming in second, in my opinion, to IF ... THEN ... ELSE. Now granted, the absence of a LOOP STRUCTURE in ComposerHE means you need to "roll your own" which we both [should] know is significantly more dangerous; but just because Control4 had created a self-fulfilling prophecy is no reason we shouldn't be using loops. BTW ... you don't need a loop structure to create an endless loop (gosh, I wish they had used "cycle" instead of "loop" - in which case we wouldn't be having this discussion) ... in fact it's quite the opposite.

 

 

Loops Tie up your processor and it can't do other things. Where timers run in the background

Sent from my Nexus 5X using Tapatalk

Link to comment
Share on other sites

12 hours ago, martymohr said:

It's a direct slam at what I had programmed. Worse yet, you had no idea of what my code looked like!

You are reading things into what I posted that were never intended - I did not state or meant to imply that what you were doing is 'wrong' in any way. I just offered an alternative method. One I think is easier to implement or at least to understand the working of for most people. Others beside you read this thread. What works or is more 'logical' (perhaps intuitive is a better word) for one is, as you point out, not the same for another.

I'm either more direct in saying what I think is 'wrong' or more obviously sarcastic than what you're trying to 'decipher' from that line of text.

I can think of about three ways you could have used that timer to achieve what you stated "trigger even at 6:30am or sunrise, whichever is later". But that's beside the point, as I wasn't trying to figure out your exact code - I merely offered an alternative that doesn't require a timer or a check beyond what Control4 offers internally without adding further timers and variables. Not so much directed at you specifically, but at the general/potential reader. Because again, other can come across this thread.

I suspect you'll simply choose to not believe me - but there was zero intend of offense meant behind my reply to you using a timer - neither to you personally, or even to the method in general.

 

Link to comment
Share on other sites

9 hours ago, msgreenf said:

Loops Tie up your processor and it can't do other things. Where timers run in the background

Exactly! So don’t take this the wrong way, but either you misread my original comment, or there is a failure to communicate on what exactly a “loop” is. Any time an action is predicated on a future condition being reached (such as 6:30AM), you need to keep repeating the test until you reach that condition. That is a classic definition of a programming loop.

Unless the condition is something that will occur rather rapidly (more on that in a moment); the only prudent route is using a timer as the loop controller (for the very reason you mentioned). The length of time between iterations (timer interval) would be predicated on the degree of accuracy desired, the amount of slack time you’re willing to tolerate, and the estimated time gap between the start and completion of the loop. One should always strive to make the time interval as long as possible to reduce system load.

If it’s a pure iteration loop (do something x number of times) then use a macro as the loop controller. Which brings up the point I was trying to make: having to roll our own loops instead of having a loop STRUCTURE accomplishes the exact opposite of what Control4 claims it achieves by deleting that capability in ComposerHE.

Link to comment
Share on other sites

with a few IF statements, you can change the duration of any time.. as Cyknight has pointed out... as far as doing things on a schedule that you are not aware of at the moment, or that may change.. have you looked at the google calendar driver?  you can program based on events on a gmail calendar with it.. I find that to work great when I want certain things to happen when I have guests staying over.. or I have a party planned

 

Please feel free to attack me for offering a solution to the problem within the current control4 confines :P

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

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