Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome General
 PowerHome Messageboard : PowerHome General
Subject Topic: Turn off all but certain lights? Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
judetf
Senior Member
Senior Member


Joined: January 23 2008
Online Status: Offline
Posts: 234
Posted: March 20 2008 at 14:34 | IP Logged Quote judetf

Looking for an elegant way to turn off all lights _except_ for two specified lights. I don't want to turn them all off and then turn those two back on: I want them left on if they are on, and left off if they are off.

Ideal is for this to be a global "off" so that if I ever add new lights they'll get turned off, too, without having to reprogram the macro.

Thanks for any thoughts.
jtf
Back to Top View judetf's Profile Search for other posts by judetf
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: March 20 2008 at 19:44 | IP Logged Quote TonyNo

Sorry, but what kind of devices do you have?

If Insteon, you can create a Group that contains the lights you want to turn off, then just issue a Group Off command.

If X10, I think the easy thing to do would be to create a macro that turns each light off.
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: March 20 2008 at 22:46 | IP Logged Quote dhoward

jtf,

It kind of depends on how you want the lights to turn off. If it's ok for them to sequence off one after the other, you could write a macro that queries the database and dynamically builds a list of all but the two lights. You could then loop through the list, turning the lights off one by one. Since it's a database query, you wouldnt need to maintain it unless you wanted to change the lights being excluded...not the ones being included.

If you're wanting the lights to all turn off simulataneously (this is assuming you have Insteon), then the only way to really do it is to create a PLC containing all of the lights except the two.

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


Joined: January 23 2008
Online Status: Offline
Posts: 234
Posted: March 21 2008 at 05:41 | IP Logged Quote judetf

Dave,

That's perfect. I haven't yet played with SQL querying as part of a macro, but that's the exact effect I want. I'm off to see if I can learn how to do that... Thanks.

(Tony, yes, they are Insteon; apologies.)
Back to Top View judetf's Profile Search for other posts by judetf
 
judetf
Senior Member
Senior Member


Joined: January 23 2008
Online Status: Offline
Posts: 234
Posted: March 21 2008 at 07:17 | IP Logged Quote judetf

So perfect!!

Again, Dave's advice worked like a charm. Here's the code:

ph_sqlselect(1, "select ID from insteondevices where ID <> 'GARAGE' and ID <> 'FOYER' and ID <> 'INSTEON PLC'")+
ph_forloopwinc('
     ph_insteon(
           ph_getdata(1,ph_getvar_n(1,1),1)
     ,ioff,0)
',1,ph_getsqlrows(1),1,1)+
ph_sqldestroy(1)

If you care about why: wife and I leave together in the morning. I am programming a "leave home" button for the garage KPL, and want it to turn off any/all lights in the house except for the garage light and the foyer light (which will both turn off later on a timed event).

If you care about why/how the code above works (via my limited SQL/programming skills): I query the insteondevices table for the ID of all devices but the two (plus the PLC). As I understand it, this gets saved into a "data retrieval area." I then loop through each row in that area, and run my ph_insteon ioff command by querying the ID (col 1 from the data area) from the row that represents the count of the loop (ph_getvar_n(1,1) - I'm not sure what/how this function works, but I copied it from somewhere else and, well, it works). The loop runs for the total count of rows returned in the original SQL query.

Voila!
Thanks, Dave, and others whose vast programming skills left breadcrumbs to follow throughout the forums.
jtf
Back to Top View judetf's Profile Search for other posts by judetf
 

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