Author |
|
RichardL Senior Member
Joined: December 29 2008 Location: United States
Online Status: Offline Posts: 165
|
Posted: December 21 2009 at 09:16 | IP Logged
|
|
|
Is there a way to remove an existing timed event?
Thanks.
|
Back to Top |
|
|
BeachBum Super User
Joined: April 11 2007 Location: United States
Online Status: Offline Posts: 1880
|
Posted: December 21 2009 at 09:38 | IP Logged
|
|
|
If it was created in a Macro under Command then this will kill it.
PH_DIRECTSQL("DELETE FROM TIMEDEVENTS WHERE FREQUENCY = 0 AND ACTION = 'KITCHEN_OFF'")
Kitchen is the ID of the event.
__________________ Pete - X10 Oldie
|
Back to Top |
|
|
RichardL Senior Member
Joined: December 29 2008 Location: United States
Online Status: Offline Posts: 165
|
Posted: December 21 2009 at 09:57 | IP Logged
|
|
|
Sounds like what I need, but:
1-
I am creating the timed events dynamically, via PH.CreateTimedEvent. This results in an ID something like "__OS_0". The PH.CreateTimedEvent call does not return the newly created ID info.
So one challenge is to obtian the ID of a newly created Timed Event, then use your command to delete it.
2-
I am also unsure as to the meaning of the "Frequency = 0" portion of your command.
Would PH_DIRECTSQL("DELETE FROM TIMEDEVENTS WHERE ACTION = 'KITCHEN_OFF'") work?
Thank you.
|
Back to Top |
|
|
BeachBum Super User
Joined: April 11 2007 Location: United States
Online Status: Offline Posts: 1880
|
Posted: December 21 2009 at 10:21 | IP Logged
|
|
|
I’m by no means a SQL person but I believe it means all occurrences. I don’t have an answer to the dynamic as I have not found a way yet. I believe if you play with this ph_modifytimedevent ( id, active, reftime, flags ) you might be able to kill it.
__________________ Pete - X10 Oldie
|
Back to Top |
|
|
grif091 Super User
Joined: March 26 2008 Location: United States
Online Status: Offline Posts: 1357
|
Posted: December 21 2009 at 10:32 | IP Logged
|
|
|
The ph_createtimedevent1 call permits you to assign the ID. The down side is if you plan to create multiple timed events you need to have a dynamic aspect to the ID as you cannot create duplicate names.
__________________ Lee G
|
Back to Top |
|
|
RichardL Senior Member
Joined: December 29 2008 Location: United States
Online Status: Offline Posts: 165
|
Posted: December 21 2009 at 11:28 | IP Logged
|
|
|
Great stuff. I can create the Timed Event via PH.CreateTimedEvent1, assigning a known ID that won't duplicate.
Then I can delete it via the SQL command.
I will test this and post results.
Question:
In my HELP file I do not see documentation for PH.CreateTimedEvent1, I have PH.CreateTimedEvent. Is it possible that you can post the HELP details, and or let me know why I don't have it...
Thank you.
|
Back to Top |
|
|
BeachBum Super User
Joined: April 11 2007 Location: United States
Online Status: Offline Posts: 1880
|
Posted: December 21 2009 at 11:32 | IP Logged
|
|
|
Which release and version of PH are you running?
__________________ Pete - X10 Oldie
|
Back to Top |
|
|
grif091 Super User
Joined: March 26 2008 Location: United States
Online Status: Offline Posts: 1357
|
Posted: December 21 2009 at 11:39 | IP Logged
|
|
|
Search for ph_createtimedevent1 The parameters should be the same. I am hoping that is just an oversight in updating the Help information. There is normally a one for one correlation between the ph_xxx and ph.xxx functions.
Pete raises a good question. Some of the expanded capability that was added to a particular function call (with the 1 added to the end) was done on version 2.
__________________ Lee G
|
Back to Top |
|
|
RichardL Senior Member
Joined: December 29 2008 Location: United States
Online Status: Offline Posts: 165
|
Posted: December 21 2009 at 11:50 | IP Logged
|
|
|
I am running PH v2.1b.
Maybe my HELP file is old. I'll check when I get home later.
Thanks.
|
Back to Top |
|
|
BeachBum Super User
Joined: April 11 2007 Location: United States
Online Status: Offline Posts: 1880
|
Posted: December 21 2009 at 11:52 | IP Logged
|
|
|
I’m guessing you are V2.1 because of the dynamic id. If so here’s the help.
ph_createtimedevent1 ( id, active, timing, freq, offset, offsetamt, reftime, type, action, boolean )
Argument Description
id The ID you want to use for the Timed Event. Use a blank value to have PowerHome automatically create an ID.
active Use 0 for the Timed Event to be set inactive. Use 1 for the Timed Event to be active.
timing Integer. The Timing value for the Timed Event. Use 0 for Exact, 1 for Sunrise, 2 for Sunset, 3 for Dawn, 4 for Dusk.
freq Long. The frequency the Timed Event will occur in minutes. Use 0 for a One Shot. 1440 is the equivalent to Daily.
offset Integer. The type off offset to apply to the
reftime. Use 0 for None, 1 for Absolute +, 2 for Absolute -, 3 for Random +, 4 for Random -, 5 for Random +/-
offsetamt Integer. The offset amount in minutes to apply to the reftime depending upon the offset type.
reftime A datetime value for when the timed event will execute.
type An integer representing the action type of the timed event. A 0 will create a macro timed event. A 1 will create a Send Keys timed event. A 2 will create a Formula timed event.
action A string denoting the action associated with the timed event. If a macro type of timed event, use the macro id. If a Send Keys type of timed event, then a formula evaluating to a valid Send Keys string. If a Formula type of timed event, then any valid formula.
boolean A string representing the Boolean formula for the Timed Event.
Return value
String. Returns the ID of the Timed Event that was created. Otherwise a string representing the error is returned.
__________________ Pete - X10 Oldie
|
Back to Top |
|
|
RichardL Senior Member
Joined: December 29 2008 Location: United States
Online Status: Offline Posts: 165
|
Posted: December 21 2009 at 12:11 | IP Logged
|
|
|
Wow, this is a big difference vs CreateTimedEvent!
I see the frequency value that was in your SQL statement.
Now to push the envelope further, do you know of the string length limit of an ID?
When I create the IDs, I'll probably use some text followed by a yyyymmddhhmmss to ensure uniqueness...
Thank you.
|
Back to Top |
|
|
RichardL Senior Member
Joined: December 29 2008 Location: United States
Online Status: Offline Posts: 165
|
Posted: December 22 2009 at 09:13 | IP Logged
|
|
|
The CreateTimedEvent1 fields have opened up a different way for me to look at this project.
Now this begs another question: how can I toggle an existing timed event as "enabled/disabled" (or active/inactive)?
Is there a way to modify other fields as well?
Thank you.
|
Back to Top |
|
|
BeachBum Super User
Joined: April 11 2007 Location: United States
Online Status: Offline Posts: 1880
|
Posted: December 22 2009 at 09:18 | IP Logged
|
|
|
Funny you should ask…
ph_modifytimedevent ( id, active, reftime, flags )
Argument Description
id String. The ID of the Timed Event you wish to modify.
active Integer. Use 0 to set the Timed Event inactive. Use 1 to set the Timed Event active. Controlled by the flags parameter.
reftime DateTime. The new reftime for the specified Timed Event. Controlled by the flags parameter.
flags Integer. Determines which parameters are used to update the Timed Event. Add values together. 1 - Recalculate a new StartTime, 2 - Update the Active parameter, 4 - Set a new RefTime and recalculate StartTime
Return value
Integer. Returns 0 if successful. 1 if the Timed Event specified does not exist.
__________________ Pete - X10 Oldie
|
Back to Top |
|
|
RichardL Senior Member
Joined: December 29 2008 Location: United States
Online Status: Offline Posts: 165
|
Posted: December 22 2009 at 09:47 | IP Logged
|
|
|
Awesome!
This really changes everything. I will no longer have to have the code manage performing or not performing a resubmit of the Timed Event every minute. I will simply have a "built-in" timed event that runs every minute, and can toggle it on/off via an overseer program according to conditions.
I got home too late to check why my HELP file doesn't have this, I am using a copy at work that I have with me...
Thank you thank you!
|
Back to Top |
|
|
RichardL Senior Member
Joined: December 29 2008 Location: United States
Online Status: Offline Posts: 165
|
Posted: December 26 2009 at 03:12 | IP Logged
|
|
|
I have looked throughout my install and cannot find any reference to ModifyTimedEvent or CreateTimedEvent1. I am running PH v2.1b.
Upon running the "Check Formula" option under triggers and timed events, I took errors indicating that PH.ModifyTimedEvent was invalid.
I noticed that the website's PH21bSetup.exe is 5MB larger than the one I used for my install about a year ago. Not sure about that one... So I did a full file/folder backup and then took a GHOST image of my PC, then uninstalled and re-installed PH2.1b. Hoping that I missed some form of an update.
The problem persists, and I am now hopefully certain that I am running the latest version.
Now I am totally dead since this project is based around the ability to modify the timed events - which is the way to go.
Any thoughts, ideas?
Thank you!
|
Back to Top |
|
|
grif091 Super User
Joined: March 26 2008 Location: United States
Online Status: Offline Posts: 1357
|
Posted: December 26 2009 at 08:48 | IP Logged
|
|
|
I do not find the ph.xxx equivalent in the help section for the script based timed event calls on my system. I would suggest testing your commands using the ph_xxx version of the function call and when that is working, try the same script command. You could have a parameter problem on the call unrelated to the ph.xxx. If the ph_xxx works and the ph.xxx does not then I would conclude that PH did not implement the ph.xxx variant. That would be unusual.
__________________ Lee G
|
Back to Top |
|
|
BeachBum Super User
Joined: April 11 2007 Location: United States
Online Status: Offline Posts: 1880
|
Posted: December 26 2009 at 11:11 | IP Logged
|
|
|
When you get back home click on help the “About” and verify the “Version” and “DB Version”. In ”C:\Program Files\powerhome” check the size of “ph-help.chm” it should be 496 KB. If any of this doesn’t match then the install is not straight forward. If you do a reinstall rename the old before you start. If you want to keep the settings and database copy the database and the INI file. You may also want to run phupg.exe before you launch PH.
__________________ Pete - X10 Oldie
|
Back to Top |
|
|
grif091 Super User
Joined: March 26 2008 Location: United States
Online Status: Offline Posts: 1357
|
Posted: December 26 2009 at 11:33 | IP Logged
|
|
|
Pete, I have a Help entry for
ph_createtimedevent1
ph_modifytimedevent
I do not have a Help entry for
ph.createtimedevent1
ph.modifytimedevent
Do you have Help entries for ph.createtimedevent1 and ph.modifytimedevent?
__________________ Lee G
|
Back to Top |
|
|
BeachBum Super User
Joined: April 11 2007 Location: United States
Online Status: Offline Posts: 1880
|
Posted: December 26 2009 at 11:40 | IP Logged
|
|
|
Under Miscellaneous I have:
ph_createtimedevent1
ph_modifytimedevent
Edited by BeachBum - December 26 2009 at 11:41
__________________ Pete - X10 Oldie
|
Back to Top |
|
|
BeachBum Super User
Joined: April 11 2007 Location: United States
Online Status: Offline Posts: 1880
|
Posted: December 26 2009 at 11:46 | IP Logged
|
|
|
Lee,
ph.createtimedevent1 ph.modifytimedevent
Have you tried them? Maybe they are left out of the Help section only.
__________________ Pete - X10 Oldie
|
Back to Top |
|
|