Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome Programming
 PowerHome Messageboard : PowerHome Programming
Subject Topic: Delete a Timed Event Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
grif091
Super User
Super User


Joined: March 26 2008
Location: United States
Online Status: Offline
Posts: 1357
Posted: December 26 2009 at 11:53 | IP Logged Quote grif091

I have not tried them. Never tried running any script. Guess it is time to learn. I hope it is just a Help section problem. Not likely that Dave would not have implemented them in the script format.

__________________
Lee G
Back to Top View grif091's Profile Search for other posts by grif091
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: December 26 2009 at 12:24 | IP Logged Quote dhoward

I just checked the sourcecode and indeed ph.modifytimedevent is not present in the Script interface. I try to keep them synchronized, but sometimes the script library runs a little behind the PH functions .

However, you always have access to the fallback function ph.formula. With this script function, you can run any PH function...just may have to play around with the proper combination of single and double quotes.

Hope this helps,

Dave.
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
RichardL
Senior Member
Senior Member


Joined: December 29 2008
Location: United States
Online Status: Offline
Posts: 165
Posted: December 26 2009 at 16:15 | IP Logged Quote RichardL

Yes, I got it working.

Highlights:

When I coded using the PH.Formula, it works in that there is no PH.ModifyTimedEvent, but there is a PH_ModifyTimedEvent.

I did not use or try the CreateTimedEvent1, so I cannot comment.

There are PH_ModifyTimedEvent, and PH_CreateTimedEvent1 entries in the PH_ HELP file under Miscellaneous, but there are no entries in the overall view (by clicking functions) - that is what threw me.

There are no PH.ModifyTimedEvent, or PH.CreateTimedEvent1 entries in the PH. HELP file anywhere.

My HELP file is dated 12/13/2008 12:41PM, 507,793 bytes.

Just as a related mention: I also have my code using PH.Formula since the PH.CreateTimedEvent function was funky, but PH_CreateTimedEvent was fine - not sure if this is related.

Another observation - when using the "Check Formula" function, there were many times that it errored on line 12, which was my first "PH." function. In this case a PH.UserMessage - which I knew was right. If I restarted PH, did the exact same thing, no code modifications either, it would error on line 44 which in this case was my PH.ModifyTimedEvent (passing line 12).

Guys - I would like to thank you for your help, insight and fast replies.

The more I use PH the more I like it, having support like this really makes it all.   

Thanks and all the best for a great New Year!

We'll be around.

Richard
Back to Top View RichardL's Profile Search for other posts by RichardL
 
RichardL
Senior Member
Senior Member


Joined: December 29 2008
Location: United States
Online Status: Offline
Posts: 165
Posted: December 26 2009 at 22:07 | IP Logged Quote RichardL

Well, I may have jumped the gun. The "Check formula" works, but I get 2 syntax errors in the event log for the PH_ModifyTimedEvent.

The errors basically look like this:
Syntax Error in Formula: ph_formula(~'PH_ModifyTimedEvent(~~~'TE_Sec-Away~~~', intP1, Now, intP3)~')
Syntax Error in Formula: PH_ModifyTimedEvent(~'TE_Sec-Away~', intP1, Now, intP3)

I may just be boneheading the quotes, but I have tried numerous combinations, including making the command a string. I keep getting syntax errors.

Here are code samples of what I have tried:

---
rv = PH.Formula("PH_ModifyTimedEvent(""TE_Sec-Away"", 1, Now, 3)")
---
intP1 = CInt(1)
intP3 = CInt(2)

rv = PH.Formula("PH_ModifyTimedEvent(""TE_Sec-Away"", intP1, Now, intP3)")
---
intP1 = CInt(1)
intP3 = CInt(2)

rv = PH.Formula("PH_ModifyTimedEvent('TE_Sec-Away', intP1, Now, intP3)")
---
intP1 = CInt(1)
intP3 = CInt(2)

strPHF = "PH_ModifyTimedEvent(" & CHR(34) & "TE_Sec-Away" & CHR(34) & ", intP1, Now, intP3)"

rv = PH.Formula(strPHF)
---
intP1 = CInt(1)
intP3 = CInt(2)
strPHF = CHR(34) & "PH_ModifyTimedEvent(" & CHR(34) & "TE_Sec-Away" & CHR(34) & ", intP1, Now, intP3)" & CHR(34)

rv = PH.Formula(strPHF)
---
intP1 = CInt(1)
intP3 = CInt(2)
strTE = "TE_Sec-Away"

rv = PH.Formula("PH_ModifyTimedEvent(strTE, intP1, Now, intP3)")
---
intP1 = CInt(1)
intP3 = CInt(2)
strTE = CHR(34) & "TE_Sec-Away" & CHR(34)

rv = PH.Formula("PH_ModifyTimedEvent(strTE, intP1, Now, intP3)")
---
rv = PH.Formula("PH_ModifyTimedEvent(""TE_Sec-Away"", 1, Date, 3)")
---
rv = PH.Formula("PH_ModifyTimedEvent(""TE_Sec-Away"", 1, DateTime(), 3)")
---
rv = PH.Formula("PH_ModifyTimedEvent(""TE_Sec-Away"", 1, DateTime(Date), 3)")


I'm kinda frustrated, and may be missing something obvious!

Does anyone have a good example of this command? ...and in the PH.Formula. Help!

Thank you.
Back to Top View RichardL's Profile Search for other posts by RichardL
 
RichardL
Senior Member
Senior Member


Joined: December 29 2008
Location: United States
Online Status: Offline
Posts: 165
Posted: December 26 2009 at 22:29 | IP Logged Quote RichardL

PS just a follow up, the examples had a "3" in the 4th parameter - that is wrong, I retested all with a "2".

Thank.
Back to Top View RichardL's Profile Search for other posts by RichardL
 
grif091
Super User
Super User


Joined: March 26 2008
Location: United States
Online Status: Offline
Posts: 1357
Posted: December 26 2009 at 22:35 | IP Logged Quote grif091

I don't have an example of your specific sequence but the syntax for putting a string inside a string is as follows...

ph_evalscript(0," ",'ph.insteongroup("G2X4OUTPUT1PLM",19,0)')

Start the outer string with a single or double quote and the inner string the opposite,

" ' ' "       or
' " " '   

__________________
Lee G
Back to Top View grif091's Profile Search for other posts by grif091
 
RichardL
Senior Member
Senior Member


Joined: December 29 2008
Location: United States
Online Status: Offline
Posts: 165
Posted: December 26 2009 at 23:27 | IP Logged Quote RichardL

Thanks so much for the clear info, and examples. I re-tried all. No progress. Below is what I just did:

---
Command:
rv = PH.Formula("PH_ModifyTimedEvent('TE_SEC-AWAY', CInt(1), Now, CInt(2))")

Event log errors:
Syntax Error in Formula: ph_formula(~'PH_ModifyTimedEvent(~~~'TE_SEC-AWAY~~~', CInt(1), Now, CInt(2))~')
Syntax Error in Formula: PH_ModifyTimedEvent(~'TE_SEC-AWAY~', CInt(1), Now, CInt(2))

---
Command:
rv = PH.Formula('PH_ModifyTimedEvent("TE_SEC-AWAY", CInt(1), Now, CInt(2))')

Error:
Doesn't run at all, a message box appears with a VBScript compilation error #1002.

---
Command:
rv = PH.Formula("PH_ModifyTimedEvent("""TE_SEC-AWAY""", CInt(1), Now, CInt(2))")

Error:
Doesn't run at all, a message box appears with a VBScript compilation error #1006.

---
Command:
rv = PH.Formula("PH_ModifyTimedEvent(""TE_SEC-AWAY"", CInt(1), Now, CInt(2))")

Event log errors:
Syntax Error in Formula: ph_formula(~'PH_ModifyTimedEvent(~"TE_SEC-AWAY~", CInt(1), Now, CInt(2))~')
Syntax Error in Formula: PH_ModifyTimedEvent(~"TE_SEC-AWAY~", CInt(1), Now, CInt(2))

---
Here are some commands that are working:
rv = PH.Formula("PH_GetTEActive(""TE_SEC-AWAY"")")
rv = PH.Formula("PH_GetTETime(""TE_SEC-AWAY"", 1)")
rv = PH.Formula("PH_CreateTimedEvent(2, 'PH_RunScript_0(5, ""C:\PHScripts\TE_MS-DWY_Off.vbs"", ""Main"")', PH_RelativeDateTime(Now, 10))")


Please notice how close the PH_GetTETime command is to the last single/double quote attempt I made. The TETime works the ModifyTimedEvent doesn't...

I am really baffled, and am not sure if it is quotes, or the data in the parameters. This is why I am keeping it real simple: CINT and Now.

Thank you.

Richard
Back to Top View RichardL's Profile Search for other posts by RichardL
 
grif091
Super User
Super User


Joined: March 26 2008
Location: United States
Online Status: Offline
Posts: 1357
Posted: December 26 2009 at 23:51 | IP Logged Quote grif091

This is a working ph_modifytimedevent ...

ph_modifytimedevent("TEX10FLOODSOFF", 2,today(),6)

I'm not sure but since the string inside the ph.formula string is evaluated by PH I don't think you use script constructs inside the string.

This does not work ...

ph_modifytimedevent("TEX10FLOODSOFF", 2,today(),Cint(6))

even though the only difference between the working and nonworking variation is the Cint(6) versus 6.

Maybe the Cint(6) is converted by the script processor to 6 before it is passed to PH but if it is not PH does not handle Cint(6).


__________________
Lee G
Back to Top View grif091's Profile Search for other posts by grif091
 
RichardL
Senior Member
Senior Member


Joined: December 29 2008
Location: United States
Online Status: Offline
Posts: 165
Posted: December 27 2009 at 00:33 | IP Logged Quote RichardL

Yes, that was it!!!

My final command is now:
rv = PH.Formula("PH_ModifyTimedEvent(""TE_SEC-AWAY"", 1, Today(), 2)")

This is exactly how I had it early on, but the date parameter (#3) was off. I tried everything, including the datetime function so the field had a proper "date" type value in it. But I never used "Today()".

I have used "Now" on many other functions and it has been fine.

Also, on some functions I had issues until I did a CDbl conversion right in-line, hence the CInt I tried. Yes, you are right, even with Today() the CInt failed.

Well it looks like "Today()" will be on top of my vocabulary!

Thanks for saving the day!!!

Richard
Back to Top View RichardL's Profile Search for other posts by RichardL
 
RichardL
Senior Member
Senior Member


Joined: December 29 2008
Location: United States
Online Status: Offline
Posts: 165
Posted: June 12 2010 at 01:14 | IP Logged Quote RichardL

I am trying to get my irrigation routine going, and am running into problems (again) with RelativeDateTime.
If I hardcode the routine as seen on the command line "OK", I get no errors.
For almost every other combination, with two left as NG to show, I get syntax errors in the event log (see below).

Looks like I am running into problems with variables...

Any thoughts?

Thank you.


Code begin -----


'           ;intEZFCounter is the valve counter
'           ;VOT is the Valve On Time, right now equals 15 for all valves.

     intT0 = VOT(intEZFCounter)

     strNextTime = PH.RelativeDateTime(Now, CDbl(intT0))
     dtNextTime = CDate(strNextTime)

     rv = PH.UserMessage(strLogLead & "Modifying Timed Event: TE_Irrigation, Enabled, at: " & _
                    strNex tTime & " ---")

' * NG      rv = PH.Formula("PH_ModifyTimedEvent(""TE_IRRIGATION"", 1, PH_RelativeDateTime(Today(), intT0), 4)")
' * NG     rv = PH.Formula("PH_ModifyTimedEvent(""TE_IRRIGATION"", 1, dtNextTime, 4)")
' * OK      rv = PH.Formula("PH_ModifyTimedEvent(""TE_IRRIGATION"", 1, PH_RelativeDateTime(Today(), 15), 4)")

Back to Top View RichardL's Profile Search for other posts by RichardL
 
grif091
Super User
Super User


Joined: March 26 2008
Location: United States
Online Status: Offline
Posts: 1357
Posted: June 12 2010 at 12:39 | IP Logged Quote grif091

The two variants that do not work are trying to use Script variables (intTO, dtNextTime) within the quoted string passed to PH. VB Script is not going to do substitution because the reference is within a quoted string so it looks like and is being treated as data by the Script processor. Once PowerHome starts processing the quoted string the VB Script variables cannot be resolved by PowerHome.   

EDIT: if you wanted to display a message ....

The value of intTO is : intTO

you would want the first intTO to be treated as data and the second intTO as a variable. To accomplish you would code...

"The Value of intTO is : " intTO

so that the intTO inside the quoted string would be treated as data and the one outside the quoted string would be treated as a variable.


Edited by grif091 - June 12 2010 at 13:26


__________________
Lee G
Back to Top View grif091's Profile Search for other posts by grif091
 
RichardL
Senior Member
Senior Member


Joined: December 29 2008
Location: United States
Online Status: Offline
Posts: 165
Posted: June 14 2010 at 09:36 | IP Logged Quote RichardL

Yep - that makes sense. Didn't see that coming.

So I should be OK if the command would read like this:
rv = PH.Formula("PH_ModifyTimedEvent(""TE_IRRIGATION"", 1, PH_RelativeDateTime(Today(), " & CDbl(intT0) & "), 4)")

I will test tonight from home.

If that doesn't work, then I will rework the logic, since I remember that there is no PH.ModifyTimedEvent, is the PH.CreateTimedEvent OK?

Thank you.
Back to Top View RichardL's Profile Search for other posts by RichardL
 
grif091
Super User
Super User


Joined: March 26 2008
Location: United States
Online Status: Offline
Posts: 1357
Posted: June 14 2010 at 10:58 | IP Logged Quote grif091

I don't know if VB Script will like that syntax but you have the idea correct. If that does not work try putting the string together with VB construct first and then pass the result to PH.

stringPH = "xxx xxx xxx" & intTO & "yyy yyy yyy"

rv = ph.formula(stringPH)

Don't know if that syntax will work either but it is another approach. Either way the VB Script variable that you want substituted cannot be within a quoted string.


Edited by grif091 - June 14 2010 at 10:59


__________________
Lee G
Back to Top View grif091's Profile Search for other posts by grif091
 
RichardL
Senior Member
Senior Member


Joined: December 29 2008
Location: United States
Online Status: Offline
Posts: 165
Posted: June 14 2010 at 11:10 | IP Logged Quote RichardL

Exactly. In theory it should work fine. I'll give it a try tonight and post the results.

Thank you!
Back to Top View RichardL's Profile Search for other posts by RichardL
 
RichardL
Senior Member
Senior Member


Joined: December 29 2008
Location: United States
Online Status: Offline
Posts: 165
Posted: July 01 2010 at 10:41 | IP Logged Quote RichardL

Yep the embedding of the variable works. I got around to testing.

I am facing some other funny behavior for the irrigation routine.

If I am running in a routine (TE_Irrigation.vbs), from a timed event called "TE_Irrigation" and in that VBS I do a ModifyTimedEvent of TE_Irrigation, should it work? I have to investigate further, but my suspicion is that maybe a currently running timed event cannot be changed.

Anything known about this?

Thanks,

Richard
Back to Top View RichardL's Profile Search for other posts by RichardL
 
grif091
Super User
Super User


Joined: March 26 2008
Location: United States
Online Status: Offline
Posts: 1357
Posted: July 01 2010 at 22:29 | IP Logged Quote grif091

Are you executing a ph.modifytimedevent.   I don't think that variant exists. This was identified as an oops by Dave some time ago and I think will be available in the next update.

__________________
Lee G
Back to Top View grif091's Profile Search for other posts by grif091
 
RichardL
Senior Member
Senior Member


Joined: December 29 2008
Location: United States
Online Status: Offline
Posts: 165
Posted: July 02 2010 at 11:01 | IP Logged Quote RichardL

Yes, there was some oops'ing with that. The help file didn't have it in it's overall function list, but it is listed under "miscellaneous". Also only a "PH_" function, no "PH.".

The behavior seemed to lend itself to not allowing the timed event to get modified if a script called by that timed event is running...

In the meantime I reworked the logic to have a static timed event that starts, then creates new timed events.

This is in relation to irrigation:

I have TE_Irrigation.vbs start at 2 hours before sunrise, and within the code are duration settings for each valve. That is where I was trying to modify the timed event - for the next valve, until the last. Now I simply have kept the TE_Irrigation event, and create new timed events for the subsequent valves.

Much going on this weekend, but I'll hopefully test soon.

Happy July 4th!!!

Thanks,

Richard
Back to Top View RichardL's Profile Search for other posts by RichardL
 
GadgetGuy
Super User
Super User
Avatar

Joined: June 01 2008
Location: United States
Online Status: Offline
Posts: 942
Posted: October 26 2010 at 08:56 | IP Logged Quote GadgetGuy


I was about to ask how to delete a Timed Event when I found this thread! Love this Forum!!!

But, that said, I am seeing something that doesn't seem right.

When I execute the below with the Verify Formula tool
   PH_DIRECTSQL("DELETE FROM TIMEDEVENTS WHERE FREQUENCY = 0 AND ACTION = 'GD-LITE OFF'")

I get a Return Code of "0" (which supposedly indicates the SQL operation was successful, however, when I go to the Timed Events Window, the event still shows in the queue, and is active.

Shouldn't the Event disappear from the Timed Events window, or is the window just not updated when there is a db table change?




__________________
Ken B - Live every day like it's your last. Eventually, you'll get it right!
Back to Top View GadgetGuy's Profile Search for other posts by GadgetGuy
 
BeachBum
Super User
Super User
Avatar

Joined: April 11 2007
Location: United States
Online Status: Offline
Posts: 1880
Posted: October 26 2010 at 09:21 | IP Logged Quote BeachBum

Ken, I have found it depends how you created the timed event. If you use the pull down in the macro this works but if you use a ph_ it doesn’t.

__________________
Pete - X10 Oldie
Back to Top View BeachBum's Profile Search for other posts by BeachBum
 
GadgetGuy
Super User
Super User
Avatar

Joined: June 01 2008
Location: United States
Online Status: Offline
Posts: 942
Posted: October 26 2010 at 09:53 | IP Logged Quote GadgetGuy

Pete -

I create the Timed Event with a . . .
Code:
/* Schedule Timed Event to turn light back off in 5 minutes */
ph_createtimedevent1 ("GD-LITE OFF",1,0,0,1,5,TODAY(),2, "ph_insteon('OUT GAR LITE',ifastoff,0)","1")

function.

When you say "this works" do you mean that my SQL direct effort fails, or just that the Event Window does not accurately reflect the DELETE effort?

Edited by GadgetGuy - December 15 2010 at 19:15


__________________
Ken B - Live every day like it's your last. Eventually, you'll get it right!
Back to Top View GadgetGuy's Profile Search for other posts by GadgetGuy
 

<< Prev Page of 3 Next >>
  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum