Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome Programming
 PowerHome Messageboard : PowerHome Programming
Subject Topic: question automation Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
npavkov
Groupie
Groupie


Joined: February 29 2004
Location: United States
Online Status: Offline
Posts: 91
Posted: June 08 2005 at 19:45 | IP Logged Quote npavkov

I have a timed event defined, for example, to turn off my front house lights at say 23:00 (11PM).
I would like to be able to (within a macro) modify the current scheduled timed event (above) to Not turn off the lights at 23:00 tonight (ONLY) instead I want to turn the lights off temporarily (tonight only) at say 2 AM..... Then I still want to return to turning the lights off at normal time the next day (or the next occurance of the timed event).
Whaty would be the best way to accomplish this in a PH macro?????
Back to Top View npavkov's Profile Search for other posts by npavkov
 
onhiatus
Senior Member
Senior Member
Avatar

Joined: May 12 2004
Location: United States
Online Status: Offline
Posts: 279
Posted: June 08 2005 at 19:58 | IP Logged Quote onhiatus

I'd probably use a global variable to store an offset. Then in my lights off routine I'd look at that variable, if it's greater than 0 then set back to 0, then wait that amount of time before turning the lights out.

So, if the offset is always going to be on the hour then use another macro to increment the global by one using some trigger. So for your example of temporarily setting it to 2am, click on a remote button three times to increment the variable to '3' (assuming your increment macro is triggered by the remote).

I'm sure there are a lot of different ways to do this.
Back to Top View onhiatus's Profile Search for other posts by onhiatus Visit onhiatus's Homepage
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: June 08 2005 at 20:16 | IP Logged Quote TonyNo

I do something similar to control my Wake Up macro.

I have a Global Variable called Normal Wake that is usually set to 1. When I don't want that wake up time, I set it to zero. When the Wake Up macro runs, it checks the GV to see if it should fire. I then have a Daily Timed Event that resets the Normal Wake flag back to 1.

You can code your macro to wait for that offset time before turning the light off, then you would just add a daily timed event to set the offset to zero (or just do it after the light is turned off).
Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
npavkov
Groupie
Groupie


Joined: February 29 2004
Location: United States
Online Status: Offline
Posts: 91
Posted: June 08 2005 at 22:26 | IP Logged Quote npavkov

I was hoping to do this ONLY in timed events without upsetting my normal daily timed event.
I guess I could use the "offset" theory, but I was thinking something like:

temporarily disable the normal timed event (or more clearly (SKIP 1 instance of the timed event) , then I could add a one time timed event to turn lights off at later time. After it executed one time, it would go away and the normal daily timed event would then turn off lights normal the next time it executed.

SO I guess what I would like is to temporarily SKIP one instance of the normal timed event????
Back to Top View npavkov's Profile Search for other posts by npavkov
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: June 09 2005 at 08:18 | IP Logged Quote TonyNo

In that case, I believe you need to use SQL to modify the Timed Event table. You would delete the desired event, create a new one (One Shot) with your offset, then recreate the original event.

You could also just change the offset, but you would then have to change it back to zero after the event fired.

Hopefully, Dave may chime in soon with other suggestions.
Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: June 10 2005 at 16:23 | IP Logged Quote dhoward

Nick,

Well, there is no real GOOD way to do it, but it can be done.

First, to make your normal timed event "skip" a day...this can be accomplished by using the ph_directsql function to directly change the starttime. An example of this is:

ph_directsql("update timedevents set starttime = starttime + 1 where action = '4DTV OFF'")

The above example works easily by merely adding 1 to the starttime which will effectively move the starttime ahead 1 full day. The trick here is the "where" clause. Since the timed events table does not have an "ID" field to use as a primary key, you need to have enough fields in the "where" clause to uniquely identify the proper timed event otherwise you'll change more than one. In my example above, I used the action field because this is the only timed event whose action is the "4DTV OFF" macro.

Now making the timed event unique isnt difficult even if you have multiple events calling the same action. Just change the action type to formula and then add enough data to make it unique. In the above example, I could go into the PowerHome Explorer and modify the timed event and change the action type to "formula" and then set the formula to something like:

ph_macro("4DTV OFF") + 1234

This will effectively run the "4DTV OFF" macro which will return 0 and then add 1234 to the result and the result of the formula is always thrown away when executing a timed event. So you play little games to easily make your timed events unique.

The update formula to move the starttime ahead 1 day using the new unique formula is:

ph_directsql("update timedevents set starttime = starttime + 1 where action = 'ph_macro(~"4DTV OFF~") + 1234'")

The second part of your problem to have a new timed event that executes only a single time is accomplished using the ph_createtimedevent function. The ph_createtimedevent function can ONLY create 1 shot timed events. Perfect for what you wish to accomplish. An example is:

ph_createtimedevent(2,'ph_macro("4DTV OFF")',ph_relativedatetime(today(),240))

This will create a one time timed event four hours in the future from when the statement is executed.

Hope this helps and let me know if you need any clarification.

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

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  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