Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Best way to implement a timed action/macro
hey guys,

I'm programming up my CQC install currently and was wondering what was the best approach to the following situation. This part of the install is what I need to be as reliable as possible. I don't want it failing or going AWOL on me at any time.

What I want to implement

This is an example of what I want to occur over a period of 20 mins. Time in minConfusedec are located on the left.

00:00 Switch on mains power
00:10 Turn on projector, receiver, dvd player, lower screen,
00:50 set projector input, set receiver vol, send cmd(numeric '1' and
'Enter') to DVD player (perform some error checks)
01:00 Dim lights to 0%

19:50 Send 'Stop' to DVD player
19:55 Turn off Projector, Receiver, DVD Player, raise screen
19:00 Bring lights up to 100%
20:00 Switch Off Mains Power

My Options?

Now while I have all the hardware end of it set up; I'm left wondering what is the best (read: reliable and efficient) way of implementing this in CQC. I'd like to keep the actions within 1-2 seconds of indicated timings if possible. Will CQC be consistent on this, or would an external hardware timer be required?

1. My current approach is to use the Timer Driver. Is this the correct approach?

Should I use just one countup/countdown timer to schedule all the actions or should I use separate countup/countdown timers for each action?

i.e. is it best to send triggers when a countup timer hits 00:10, 00:50 etc or should I use two countdown timers set to 10 secs and 50 secs respectively and send a trigger when they hit zero.

Any opinions at all on this are welcome as I really want this to be foolproof.


Those types of things are always tough. But one thing of course to consider is that you shouldn't have any fixed delays that you don't need. If you have two way feedback from the devices, there's no need to wait any longer than it takes for them to get to the point you need them to get to. Once you see that they are at the right state, or already in the state you are interested in, you can move on. This can vastly speed up these types of things.

It's fairly easy to just start a triggered event that will just run for the whole time. That's not something normally you'd do but for something like that, human triggered and you being there to the whole time and whatnot, so it can't happen multiple times at once and such, it wouldn't be horrible.

But, the gotcha is getting out of it it you need to. You can even just run it as a local action invoked from a button, but you'd be locked out of the screen and couldn't cancel it.

Ultimately, the slickest way to do it would probably be to use a CML macro, from a triggered event. This macro wouldn't ever block for more than short periods of time, waiting for the next step to finish (where feedback is available) or waiting the indicated time (in short increments if it's more than 5 seconds or so), and watching for a shutdown request (via a variable driver field flag.)

So this way you could start it, have it update another variable field with some status string so that you could see status of the process. It would either do short waits for a field to reach a certain value, or call a local helper method to wait for X seconds, waking up every few seconds to watch for a shutdown request via the variable driver flag.

If it sees the shutdown request, it would just exit and that would stop the event. Otherwise, it would run the whole time. Handle any exceptions in the CML macro and be sure to update the variable driver status field. This way you can reject any attempt to kick off the action twice by looking at the status field and if it's not indicating idle, then it's already running and you don't want to do anything.

Something along those lines. I know that's a fair bit of work. Ultimately I guess we really need to come up with some of 'local sequencer' type of functionality, where a client can run one sequence at a time in the background and it'll move through a defined set of steps at particular times or upon particular criteria being met. But currently you kind of have to do that kind of thing yourself.

Again, normally you'd not want to eat up an even server thread for a long time like that. But, for something like this, it's probably a reasonable compromise. It's not something being started automatically, and I assume there's only one place in the house it could happen at a time. So, just to massively reduce the complexity of trying to do it in a sequence of independently triggered steps, it would probably be acceptable.
Dean Roddey
Explorans limites defectum

I do get the overall jist of where you are coming from. I know that ideally the above 'macro' would not be driven by a timer but more by states of the devices etc. However, I'm finding more and more that the devices just don't offer the level of feedback that is necessary to allow this form of control. For example the Infocus IN76, once switched on, doesn't notify when the lamp is up to full brightness. Neither does the DVD player offer a discrete message when it comes to the end of a DVD. Unfortunately, for me, it doesn't make any distinction between PLAY and MENU feedback messages. Hence, its difficult to truly know what the current state of the player actually is. Effectively this rules out a 'device state' driven 'macro'. I know I use 'macro' here as a built up list of actions to execute as opposed to CQC's own CML macros, which I do intend to delve into later, but I'll need to implement the above installation before I can do this.

I obviously want to do it without any system block outs at all. Am I correct in saying that a Timer Driver timer does not block out at all, apart from the times its actually writing to a field or such ?

Either way, what I need to know is, assuming the Timer Driver is the best method (for me right now) to implement this scenario; Is it best to use individual timers for each action or can I use the one timer to invoke the required actions?

i.e. how reliable is it to have a Count Down/Up Timer send out a trigger on a IsEqual to 00:50 (50 secs) as opposed to the usual send a trigger when it zeros? i.e. is it possible to implement this schedule with just one CDTimer?

So for the current install, for the time being, I'm looking to get a reliable user invoked action set up that will work.

Its not on an auto cycle. i.e. it will be the same 20 minute sequence invoked by a button press, maybe up to 20 times per day. It will be at two locations in the house. i.e. there are two Home Theatre setups that basically can show the same DVD concurrently. (Separate AV devices for each room) Both rooms will be controlled by the one computer which will host the CQC Master, CQC Server and an IV on a touchscreen.

Ive alot to learn.


You can of course have a triggered event as described above that just does a sequence of timed actions. Just get the current time when you come in, do the first step, see how long till the next one is due, sleep that long, do the next step, and so on.
Dean Roddey
Explorans limites defectum

Possibly Related Threads…
Thread Author Replies Views Last Post
  Timed, slow dimming? gReatAutomation 2 972 04-10-2020, 01:36 PM
Last Post: gReatAutomation
  Where's the Action Editor? Deane Johnson 4 1,839 07-30-2019, 02:50 PM
Last Post: Dean Roddey
  Timed Field Change in Lutron HW8 avtexan 11 5,942 08-06-2018, 11:17 AM
Last Post: Dean Roddey
  User Action on ZWave Keypad jkmonroe 18 8,344 04-04-2015, 05:46 AM
Last Post: jkmonroe
  How to put a pause in an Action list? Deane Johnson 10 5,006 11-30-2014, 11:22 AM
Last Post: Dean Roddey
  Action command help lleo 3 2,657 10-08-2014, 11:25 AM
Last Post: Dean Roddey
  VRCOP User Action Configuration potts.mike 30 10,461 05-11-2014, 09:06 PM
Last Post: potts.mike
  Macro to run multiple lights off/on rtarver 5 2,688 09-30-2012, 08:26 PM
Last Post: anogee
  Syntax for variable action khill 8 3,715 03-23-2011, 08:26 PM
Last Post: Dean Roddey
  Widget no Longer a target for action? (Loading Overlays) MavRic 3 2,725 08-11-2010, 08:44 AM
Last Post: MavRic

Forum Jump:

Users browsing this thread: 1 Guest(s)