VoxCommando Forum

General Discussion => General Discussion => Topic started by: garryjw on April 03, 2014, 05:15:29 PM

Title: Does VCSetEventTimer to time of day work?
Post by: garryjw on April 03, 2014, 05:15:29 PM
The help for this says
QuoteThe parameter <Delay/Time> can use a number of different formats:
-  A time of day such as 3:45 or 16:30 or 4:00 PM or 8:00 AM
but
<action actiontype="VC.SetEventTimer" repeat="1" logic="False"><params><param>19:45</param><param>sunset</param></params></action>
gives an error can't parse Time/Delay parameter error.

Any ideas?
Title: Re: Does VCSetEventTimer to time of day work?
Post by: Kalle on April 03, 2014, 05:36:30 PM
I 've test it with VC1.9.1.9 and it works. I think you have forget to create the event which you want to trigger, then VC create this error because the event doesn't exist.

<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 1.9.1.9-->
<commandGroup open="False" name="event timer" enabled="True" prefix="" priority="0" requiredProcess="" description="">
 <command id="1421" name="eventtimer" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
   <action>
     <cmdType>VC.SetEventTimer</cmdType>
     <params>
       <param>22:25</param>
       <param>sunset</param>
     </params>
     <cmdRepeat>1</cmdRepeat>
   </action>
   <event>VC.Rebuild</event>
   <event>VC.Loaded</event>
 </command>
</commandGroup>
Title: Re: Does VCSetEventTimer to time of day work?
Post by: nime5ter on April 03, 2014, 05:40:51 PM
I've tested it with 1.919 as well -- following the 24-hour syntax as described without adding "PM" as Kalle did -- and it is working for me as well.

I've compared my action xml to yours and it's identical apart from the time I used:
<macro>
<action actiontype="VC.SetEventTimer" repeat="1" logic="False"><params><param>15:35</param><param>doit</param></params></action>
</macro>
Title: Re: Does VCSetEventTimer to time of day work?
Post by: Kalle on April 03, 2014, 05:50:40 PM
I can confirm my post above: if you doesn't create the event, it will show the error which you has described.

Title: Re: Does VCSetEventTimer to time of day work?
Post by: jitterjames on April 03, 2014, 06:31:46 PM
It should not throw an error though even if no command uses the event.  The action should work, and tell you how long until the event will fire and then it should fire.  If there is no command that uses it, the event will show up in the history window, it just won't cause a macro to run.

I've tested this with VC1 and VC2 and it works perfectly unless I give it invalid params.

By the way Kalle, it doesn't make sense to use a 24 hour format, and also specify PM.  But VC seems to accept it anyway.

Only thing I can think of is that it doesn't like Garry's locale, but I find it surprising, it should still be able to parse time formats the same as for us.
Title: Re: Does VCSetEventTimer to time of day work?
Post by: Kalle on April 03, 2014, 06:52:02 PM
You're right, AM/PM makes no sense in 24 hour format. Did not thought about, I have it corrected above - sorry.  :bonk
Title: Re: Does VCSetEventTimer to time of day work?
Post by: jitterjames on April 03, 2014, 07:29:12 PM
I think the error is thrown when you try to set a time that is before the current time.  Anything else I try with a time later than "now" seems to work perfectly.  I could improve the handling of this by automatically adding 24:00 hours when the specified time is earlier than "now".

I had intended to do that, but I guess I was waffling about whether or not I should add 12 hours or 24 hours.  If it is 10:00 AM and you say "set the alarm for 9:00", it is not clear if you want it to be at 9:00 PM today or 9:00 AM tomorrow.  A lot of people (including me) use a 12 hour clock even though it is as stoopid as using feet and miles and Fahrenheit.

I'll just set it to add 24 hrs for now.
Title: Re: Does VCSetEventTimer to time of day work?
Post by: garryjw on April 03, 2014, 08:09:50 PM
Hi James and Kalle

Thanks for all the research on this. I am using 24 hour clock and my locale is the United Kingdom. I did have the event I am calling set up.

I think James is spot on with the time being before now my calculation was probably going over midnight.
Title: Re: Does VCSetEventTimer to time of day work?
Post by: ajith on April 06, 2014, 09:40:13 AM
Quote from: jitterjames on April 03, 2014, 07:29:12 PM
I think the error is thrown when you try to set a time that is before the current time.  Anything else I try with a time later than "now" seems to work perfectly.  I could improve the handling of this by automatically adding 24:00 hours when the specified time is earlier than "now".

I had intended to do that, but I guess I was waffling about whether or not I should add 12 hours or 24 hours.  If it is 10:00 AM and you say "set the alarm for 9:00", it is not clear if you want it to be at 9:00 PM today or 9:00 AM tomorrow.  A lot of people (including me) use a 12 hour clock even though it is as stoopid as using feet and miles and Fahrenheit.

I'll just set it to add 24 hrs for now.

I just verified this. I get the error when I set a time (in 24 hr format, without AM/PM, or even in 12 hr format) that is before the current time.
The way I want to use this is to set a timer on VC.Loaded event for 12:30 AM (this is actually 00:30 in 24 hr format) to generate a "TIMER_SHUTDOWN" event. I would then use the TIMER_SHUTDOWN event to shutdown my media center PC automatically. Presently, neither 00:30 nor 12:30 AM works, because both seem to be "before" the current time.

To remove the confusion, can we just stick to the 24 hr format and assume 09:00 means 9 AM and 21:00 means 9 PM?

Title: Re: Does VCSetEventTimer to time of day work?
Post by: jitterjames on April 06, 2014, 09:54:27 AM
Quote from: ajith on April 06, 2014, 09:40:13 AM
To remove the confusion, can we just stick to the 24 hr format and assume 09:00 means 9 AM and 21:00 means 9 PM?
I'm not sure what you mean by this.  Are you suggesting we all use the 24 hour convention when talking on the forum, or are you suggesting that the program assume a 24 hour format?

AFAIK VC will assume a 24 hour format if you don't specify AM or PM and so will I.
Title: Re: Does VCSetEventTimer to time of day work?
Post by: jitterjames on April 06, 2014, 10:02:15 AM
It is a different story when you are creating your commands though.  People will use whatever convention they are comfortable with.  Around here if it is 18:00 and I said "Remind me to walk the dog at ten", I would almost certainly mean 10PM and I would not find it natural to say "Remind me to walk the dog at 22 o'clock".  For the sake of getting my message through to the computer I could be compelled to say "remind me to walk the dog at 10 PM" though.  Everyone is different.
Title: Re: Does VCSetEventTimer to time of day work?
Post by: nime5ter on April 06, 2014, 11:47:17 AM
James,

I have a question about how the time delay format for the set event timer functions.

I know you can set a delay of the form 1h 10m in order to trigger an event 1 hour and 10 minutes from now, for example.

My question is: can the minute delay amount be greater than 60?

The reason I ask is because I was trying to come up with a temporary workaround to accomplish what Ajith is trying to do: setting a timer for 00:30.

I have come up with a time delay solution using a python calculation. Initially I had a problem with the minutes, because depending on the current time my calculation would result in negative minutes. So I came up with the following solution instead, but it means that the set event timer function needs to know that 1h 80m is the same as 2h 20m.

Here's what I came up with. ... Maybe I made this overly complicated. :)

My mission was to avoid needing multiple lines of python code so that I could use just the one Py.ExecString action.

<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 1.9.1.9-->
<command id="276" name="SetShutdownTime" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
 <action>
   <cmdType>PY.ExecString</cmdType>
   <params>
     <param>result=str(23-{dtcustom.HH})+"h "+str(90-{dtcustom.mm})+"m"</param>
   </params>
   <cmdRepeat>1</cmdRepeat>
 </action>
 <action>
   <cmdType>VC.SetEventTimer</cmdType>
   <params>
     <param>{LastResult}</param>
     <param>TIMER_SHUTDOWN</param>
   </params>
   <cmdRepeat>1</cmdRepeat>
 </action>
 <event>VC.Loaded</event>
</command>
Title: Re: Does VCSetEventTimer to time of day work?
Post by: jitterjames on April 06, 2014, 11:48:42 AM
I am a bit confused by your question.  In order to answer it I tried it, and the answer is yes.  But since you got that far, why didn't you just try it yourself?  I guess maybe you are just asking for the sake of others?  I just did a test setting the timer for 1h 90m and in the history window it shows that the timer was set for 2h 30m.
Title: Re: Does VCSetEventTimer to time of day work?
Post by: nime5ter on April 06, 2014, 12:02:46 PM
Ha. I tested it and saw that the math was correct, but didn't think to roll over the result in the history window.

Sorry babe. I have failed you once again. ;)

Here I thought I was being helpful and creative.
Title: Re: Does VCSetEventTimer to time of day work?
Post by: jitterjames on April 06, 2014, 12:17:47 PM
Well, your solution works perfectly, but the next release of VC2 will make it a bit redundant.  Hopefully it will be instructional for others.  It will also come in handy if you want to set an event timer for "2 days from now at 9:45" or something like that.

Also it gave me the chance to point out that the history windows shows you what the event delay has been boiled down to... :D
Title: Re: Does VCSetEventTimer to time of day work?
Post by: ajith on April 06, 2014, 02:12:18 PM
Quote from: jitterjames on April 06, 2014, 09:54:27 AM
I'm not sure what you mean by this.  Are you suggesting we all use the 24 hour convention when talking on the forum, or are you suggesting that the program assume a 24 hour format?

AFAIK VC will assume a 24 hour format if you don't specify AM or PM and so will I.

My reply is a little late, but what I meant was the latter. I'd like the program to have one unambiguous way to specify time. And it shouldn't depend on whether the specified time is in the past, etc., A past time should just mean that the time is specified for the next day, like all alarm clock settings! This way of doing it might be technical, and not conforming to conventional language like "remind me to take the dog out at 10". But once we have that technical, unambiguous way of inputting time, making it understand conventional language could be done as per individual preference using tools like Python Scripting etc.,

Just my 2 paisa!  Just ignore this if it doesn't make sense or too demanding :)

PS: Thanks, nime5ter for the creative solution. :) I am yet to try it out.
Title: Re: Does VCSetEventTimer to time of day work?
Post by: nime5ter on April 06, 2014, 03:13:35 PM
I think it's been a while since you've had time for the VC forum, Ajith, so you may not have noticed that quite a few of the new VC users have made it clear they're not comfortable with things like Python scripting.

It turns out that what makes intuitive sense to a black-box user is rather different than what makes intuitive sense to programmers.  :biglaugh

But it means that it will be less work/stress for James to keep the front end as layperson-oriented as possible and leave the Python workarounds to folks like you.
Title: Re: Does VCSetEventTimer to time of day work?
Post by: jitterjames on April 06, 2014, 03:15:04 PM
It is not too demanding because this is the way it already is.
Title: Re: Does VCSetEventTimer to time of day work?
Post by: ajith on April 06, 2014, 11:26:29 PM
Quote from: nime5ter on April 06, 2014, 03:13:35 PM
I think it's been a while since you've had time for the VC forum, Ajith, so you may not have noticed that quite a few of the new VC users have made it clear they're not comfortable with things like Python scripting.

It turns out that what makes intuitive sense to a black-box user is rather different than what makes intuitive sense to programmers.  :biglaugh

But it means that it will be less work/stress for James to keep the front end as layperson-oriented as possible and leave the Python workarounds to folks like you.

I understand. But the programmer friendly interface was what attracted me to VOX, in the first place! I guess I'm in the minority now. Everyone cannot be pleased at the same time, I guess  :)
Title: Re: Does VCSetEventTimer to time of day work?
Post by: ajith on April 06, 2014, 11:32:23 PM
Quote from: jitterjames on April 06, 2014, 03:15:04 PM
It is not too demanding because this is the way it already is.

Hmm... in that case I'd have thought the SetEventTimer command would accept a time parameter like 00:30 without a workaround, and the event would have fired at 30 min past midnight, no matter what the current time is. What am I missing?
Title: Re: Does VCSetEventTimer to time of day work?
Post by: jitterjames on April 06, 2014, 11:37:29 PM
QuoteEveryone cannot be pleased at the same time, I guess

I don't really see why not.  We can and in many cases do have the best of both worlds.  In any case VC is not and never will be for dummies.  We can try to make it as user friendly as possible but this should not hurt programmers.  I will always put functionality first, and you can basically do anything you want in python if it is not already possible in the core program or a plugin.

Just so we are all clear, going back to the original topic.  There is not, nor has there ever been any ambiguity in the way that times are defined in the VC.SetEventTimer action.  You may use a 24 hour clock or a 12 hour clock as long as you format it correctly.  Both methods are correct and precise.  In the last public release it was simply not set up to automatically add 24 hours if you specified a time that was before the current time.  I have already added this functionality and it will be in the next VC2 update once it gets uploaded.

You should also know, in case you are not aware that the event will not be triggered every day.  It is a one time thing, so if you want it to automatically repeat every day you need to add another call to set the event timer in your triggered command.
Title: Re: Does VCSetEventTimer to time of day work?
Post by: jitterjames on April 06, 2014, 11:40:55 PM
Quote from: ajith on April 06, 2014, 11:32:23 PM
Hmm... in that case I'd have thought the SetEventTimer command would accept a time parameter like 00:30 without a workaround, and the event would have fired at 30 min past midnight, no matter what the current time is. What am I missing?

I don't think you really followed the course of the whole thread, but in particular, after we established what the problem was, I posted this:

http://voxcommando.com/forum/index.php?topic=1484.msg12900#msg12900

The problem was identified, and I said I would fix it, by adding 24 hours if the time was "before now".
Title: Re: Does VCSetEventTimer to time of day work?
Post by: ajith on April 07, 2014, 04:26:37 AM
Quote from: jitterjames on April 06, 2014, 11:40:55 PM
I don't think you really followed the course of the whole thread, but in particular, after we established what the problem was, I posted this:

http://voxcommando.com/forum/index.php?topic=1484.msg12900#msg12900

The problem was identified, and I said I would fix it, by adding 24 hours if the time was "before now".

Oops! I missed the part where you said you meant to fix it!  :-[
Sorry for wasting your time!
Title: Re: Does VCSetEventTimer to time of day work?
Post by: jitterjames on April 07, 2014, 09:06:33 AM
No problem.  It is an easy thing to miss.
Title: Re: Does VCSetEventTimer to time of day work?
Post by: jitterjames on April 07, 2014, 09:08:56 AM
By the way, if you want to trigger an event at the same time every day, then the google calendar plugin is a nice way to do it.  It won't work for sunrise and sunset though since these times change over the course of the year.