Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome Programming
 PowerHome Messageboard : PowerHome Programming
Subject Topic: Macro to turn off other macros Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
nadler
Super User
Super User


Joined: February 25 2006
Location: United States
Online Status: Offline
Posts: 354
Posted: January 24 2007 at 18:19 | IP Logged Quote nadler

I'd like to run a vacation macro which would disable a bunch of triggers, times events and macros when I run it. When I get home from vacation I would run a second macro to enable the previously disabled macros, triggers and timed events

At this point, I have many PH macros, triggers and timed events. In the past when I went on vacation I checked each trigger, timed event and macro and disabled the ones I didn't want to run. This became tedious. For triggers I changed the status of each unwanted trigger to disable. I had to delete each timed event because there was no way that I could figure out how to disable it and for the macros I checked each box of a particular macro so it won't execute because I couldn't figure out any other way to disable the macros. Some examples of things I don't want PH to do when I'm away is open the blinds in the morning and close them at night and announce the hour and weather at various times.

I did see there is a ph_disabletrigger function but didn't see anything similar to disable timed events. or macros.

Anyone already doing something like this or have any ideas how to do this?

Thanks.
Noel
Back to Top View nadler's Profile Search for other posts by nadler
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: January 24 2007 at 19:44 | IP Logged Quote dhoward

Noel.

The way most people accomplish what you're trying to do is with a global variable. This global variable is called something like VACATION or AWAY and is set to either 1 or 0 when you're on vacation or away. They'll then typically code within their macros a statement that checks the status of the global and either continues or exits based upon it's value. For triggers, you can code the global variable check in the boolean field.

However, I can see where this may not be the most desirable way of doing things. In this case, for triggers, definately use the ph_enabletrigger and ph_disabletrigger. For macros, rather than enabling the skip on each line, just insert a new line at the beginning of each macro. Make the command of this new line "End Macro". Then just enable or disable this single line. Once this line exists, then you could easily enable or disable the line from another macro with a ph_directsql statement. I can show you how to write this if you're interested. Timed Events are the tricky ones. There is no real good way to temporarily disable them. When I need to do the same thing in my own system (and Im not using the global variable method...I just want a timed event to not execute for the next couple of days), I just edit the timed event and modify the date. I would like to come up with a better way, but won't really be able to until I rework the timed events table. The problem is that Timed Events don't have an ID associated with them so it's hard to reference them from within code in order to update them. One day I'll get to it though and I'll make this type of operation easier.

HTH,

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


Joined: February 25 2006
Location: United States
Online Status: Offline
Posts: 354
Posted: January 24 2007 at 20:07 | IP Logged Quote nadler

Dave - all good suggestions. Thanks.

The changing the date of the timed events just never occurred to me. It will certainly work and is easier then deleting and recreating the event (especially when, like me you forgot to write down what you deleted). The global variable 'trick' I use for so many other similar things, it also just didn't occur to me to use it for this purpose.

These will do. Thanks again.
Back to Top View nadler's Profile Search for other posts by nadler
 

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