how to use flags

Started by jimnfl, November 04, 2005, 06:17:53 AM

Previous topic - Next topic

jimnfl

the directions on how to use flags are
vague.  can anyone tell how to use them and
their purpose.

Tuicemen

flags are conditions to be used in
smartmacros they can be used set or cleared.
They can be used to lengthen the number of
conditions a macro checks before running.
you can set/clear a flag any number of ways
even with another macro. Eg If you have one
macro "A" set  flag 1 at the begining of the
macro and clear it at the end. then You can
have another macro "B" check to see if flag
1 is set/cleared thus it tells macro B if
macro A is running or not.
Using flags can become as complicated as
your imagination lets it. :)
Please Read Topic:
General Forum Etiquette
Before you post!

tom j

Quote from: Tuicemen on November 04, 2005, 03:46:28 PM
flags are conditions to be used in
smartmacros they can be used set or cleared.
They can be used to lengthen the number of
conditions a macro checks before running.
you can set/clear a flag any number of ways
even with another macro. Eg If you have one
macro "A" set  flag 1 at the begining of the
macro and clear it at the end. then You can
have another macro "B" check to see if flag
1 is set/cleared thus it tells macro B if
macro A is running or not.
Using flags can become as complicated as
your imagination lets it. :)

Say how about another general example of a flag and there uses. Thanks

Tcj

jatracy

I tried using flags in my multiple motion detector setup. I was setting a flag in a macro each time motion was detected and turning on the lights and clearing the flag when the motion detector sent the OFF command. I also had an else statement look at all the flags to decide to turn the lights off or not. The problem I had, was I was trying to insert a delay in the macro before clearing the flag (as opposed to setting the delay on the motion sensor), but the flag would get cleared as soon as the macro was triggered. I have since stopped using flags and I just setup the motion detectors for the amount of delay I want and check the status of the dummy appliance modules that are on the same HC/UC. I would prefer to use flags, but it works so why break it if it ain't broken!

Tuicemen

#4
I use dummy/phantom modules as well as flags but that for another thread. Heres a simple example of a flag I use to tell my system that I'm working day shift anything which would run during the day if I'm home checks to see if the flag is setor cleared first.Also I can have macro wich will only run if I'm at work by checking to see if this flag is set or not. Macro is triggered by a motion sensor  and has limitations eg: if my wife gets up at this time for some unknow reason!
but for the most part it works flawlessly ;) :D Note: the flag is cleared every night with a timer instead of at the end of the week in case of a false set. ;)
Please Read Topic:
General Forum Etiquette
Before you post!

tom j

Quote from: Tuicemen on May 17, 2006, 10:33:23 AM
I use dummy/phantom modules as well as flags but that for another thread. Heres a simple example of a flag I use to tell my system that I'm working day shift anything which would run during the day if I'm home checks to see if the flag is setor cleared first.Also I can have macro wich will only run if I'm at work by checking to see if this flag is set or not. Macro is triggered by a motion sensor  and has limitations eg: if my wife gets up at this time for some unknow reason!
but for the most part it works flawlessly ;) :D Note: the flag iscleared every night with a timer instead of at the end of the week incase of a false set.

Say this is great thanks!! bought Active home Pro a while back but because of range issues I haven't hooked it up yet. Guess I should download the software and start experimenting still currently using the old Active Home. Just wondering do you know if there are any books that help explain this kind of programing? really would be great if there was it would be a big help. One last thing what's the definition of a flag anyway. Thanks Again!

Tcj

steven r

Quote from: tom j on May 19, 2006, 12:48:04 AM
...Just wondering do you know if there are any books that help explain this kind of programing?...
This forum is the closest thing you'll find to a book. There's a good chance that what you want to do has been done before. If not, someone will give you an idea how. This is what I call "drop & drag" programming. Try it out. Start building a macro and drag each step over. If you have a problem or question, let us know.

Quote from: tom j on May 19, 2006, 12:48:04 AM
...One last thing what's the definition of a flag anyway....
A flag is a setable condition that can be tested later. eg. You could set flag 2 from one macro and later test for it in another macro. You can have your macro take action or not based on the condition of the flag. Hmm... Perhaps not the clearest explanation. Hope it helped, anyway. Best way to learn is start making macros and see what happens.

BVC let's me tell my camera where to go!
:) Murphy is my beta testing pal. He helps me find problems whether I like it or not. :)

Tuicemen

#7
tom j: steven r is right
QuoteThis forum is the closest thing you'll find to a book. There's a good chance that what you want to do has been done before. If not, someone will give you an idea how.
Users on this forum have been able to do things with AHP and the CM15A that even X10 hadn't thought of. Even when they said it couldn't be done we found workarounds to prove otherwise! ;) ;D :D as for the definition of a flag  check here: Definition of a flag found at  the X10 Knowledgebase Wiki
Please Read Topic:
General Forum Etiquette
Before you post!

maddoghoek

Is the current status of a dummy module held in the CM15 or do you need a PC running.  I was using flags to create an on/off switch of my motion detectors.

Tuicemen

#9
Please Read Topic:
General Forum Etiquette
Before you post!

RJMiller

Hi, I am also trying to use flags with phantom modules.

I am using a flag to show if it is a weekday or not.  Since SmartMacros only allow for two conditions I run this macro prior to the macro with the time range in it.  I am trying to decrease the number of phantom modules I have to use.  Somehow things just don't seem to be working.  I check flag 16 to see if set (weekday) and then check the time range then go about my business of taking action.

I use other flags to determine which door has opened...  door switch triggers a macro which sets a flag identifying say... door 1 as the one that is opened.  Then a checkflag macro looks at the flags and runs another macro specific to the flag it sees... flag 1 would be door 1 then action is taken.

For instance...

  Door 1 switch triggers a macro
    run macro checkweekday (set flag 16 appropriately)
    set flag 1
    run checkflag macro

  Checkflag macro
    if outside working hours and flag1 and 16 set (weekdays and door1)
      run door 1 macro

  Door 1 macro
    send email saying someone there after working hours

I can do this with multiple phantom modules but somehow the flag logic isn't working.  Anyone have any ideas?

  RJ


delibaker

RJ, you should be able to use the conditions "Weekday" and "Time Between" to do what you want.  I don't have the email option but I've included a screenshot of what it would look like!  HTH!


Tuicemen

#12
Quote from: RJMiller on October 16, 2006, 06:08:20 PM

  Door 1 switch triggers a macro
    run macro checkweekday (set flag 16 appropriately)
    set flag 1
    run checkflag macro

  Checkflag macro
    if outside working hours and flag1 and 16 set (weekdays and door1)
      run door 1 macro

  Door 1 macro
    send email saying someone there after working hours

I can do this with multiple phantom modules but somehow the flag logic isn't working.  Anyone have any ideas?

  RJ
You need to have your door sensor trigger a macro to set a phantom "ONLY" (no conditions or extra info like flags set etc)!  ;)
Your phantom address then is used in a macro to Set/clear flags
The problem is your security sensors/macros have to run from the PC. Flag macros have to run from the interface! Phantoms can run from either as can regular modules! ;) :D ;D
Hope this Helps!
Please Read Topic:
General Forum Etiquette
Before you post!

KDR

#13
Tuicemen   You are 100% correct and in addition if you have MyHouse and use it for emails in macros you can't use conditions in those macros either. I tested the Day Of Week condition and found it will work if you only select 1 of the days. If you select more then that the condition doesn't apply. And none of the Time conditions work. (Security and Email has the "store in interface" and "run from pc" grayed out.

It takes 3 macros to send an email from a security sensor if there are conditions that need to be met.  Macro 1 is setup for the security sensor status and then triggers macro 2 by way of a dummy module with the same address as macro 2. Macro 2 contains your conditionals and a dummy module which turns on if the conditions are met. Macro 3 which has the same house and unit code as the dummy module in macro 2, turns on at the same time, executing the content in macro 3 which is the send email command. I have spent a bit of time looking at this trying to see if a flag could be used but keep drawing a blank. Can anyone else see a way of using a flag instead of a dummy module?

By the way I don't actually drag and drop an appliance module into a room. I go to Advance Functions in the macro window and just drop in an Appliance Control in the macro body and give it a house and unit code.

QuoteYour phantom address then is used in a macro to Set/clear flags

I can see how this works provided the flags being set are looked at or tested for by a regular macro which is checking conditions and not one of these "run from pc" only modules or dropins. I would think that this is something that will be fixed in some future update version.

Added...
The problem with using dummy modules is that it takes 2 per email. I have my security system set to email me with a specific email message giving me detail of the zone that set off the sensor. Dummy modules = Number of sensors x 2. That could end up using a lot of house codes. 10 for me right now. Maybe another 20 to 30 or more down the road.
Note: "Guests" may read the X10 forum , but you must register to post!

When I'm online you can find me in the Home Automation Chat Room!

Tuicemen

KDR: Hopefully this is only a "temporary work arround" until X10 updates this plug-in ::) ;) :D
Please Read Topic:
General Forum Etiquette
Before you post!