Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome Programming
 PowerHome Messageboard : PowerHome Programming
Subject Topic: Creating a toggle button Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
fasttimes
Groupie
Groupie


Joined: March 12 2006
Online Status: Offline
Posts: 63
Posted: April 22 2006 at 16:11 | IP Logged Quote fasttimes

I have a ceiling fan connected to an insteon switch (non-dimmmer) and want to create a macro to toggle the current status. Is this possible?

I also want to create a button on the control center that will have an on/off position (down for on, up for off, or using colors instead). I also want the button to reflect the status of the device if the fan is turned on from the switch or another insteon device.

Any suggestions?

Thanks!
Back to Top View fasttimes's Profile Search for other posts by fasttimes
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: April 22 2006 at 18:20 | IP Logged Quote TonyNo

Sure! You can do it on one line with a formula in a macro...

case( ph_getinsteonstat( "FAN" ) when 1 then ph_insteon( "FAN", ifaston, 0) when 2 then ph_insteon( "FAN", ifastoff, 0) )

I don't have on/off Insteon devices, so I'm guessing at faston and off.

For the on/off in the CC, there is a reply in a thread you started here, and also good info here, too.

Edited by TonyNo - April 22 2006 at 18:21
Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
fasttimes
Groupie
Groupie


Joined: March 12 2006
Online Status: Offline
Posts: 63
Posted: April 22 2006 at 20:44 | IP Logged Quote fasttimes

Tony,

Thanks for the reply. That formula works nicely.

Is there a way I can modify that so I can create my own formula and use it everywhere in PH?

For example, I could call something like

myToggle("FAN")

if I had something like the following below?

--------------------------
Function myToggle(ItemID as String)

return
(

case( ph_getinsteonstat( ItemID ) when 1 then ph_insteon( ItemID, ifaston, 0) when 2 then ph_insteon( ItemID, ifastoff, 0) )

)

End Function


Back to Top View fasttimes's Profile Search for other posts by fasttimes
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: April 22 2006 at 21:45 | IP Logged Quote TonyNo

I think the only way to do that would be in a macro that can receive parameters. You would then call it via ph_macroparm(). I do this in my announcement macro.

Your TOGGLE macro would be...

case( ph_getinsteonstat( "[TEMP1]" ) when 1 then ph_insteon( "[TEMP1]", ifaston, 0) when 2 then ph_insteon( "[TEMP1]", ifastoff, 0) )

And you would call it with...

ph_macroparm ( "TOGGLE", "FAN", 0, 0, 0, 0 )
Back to Top View TonyNo's Profile Search for other posts by TonyNo Visit TonyNo's Homepage
 
fasttimes
Groupie
Groupie


Joined: March 12 2006
Online Status: Offline
Posts: 63
Posted: April 23 2006 at 02:41 | IP Logged Quote fasttimes

How do I "create" this macro?

When I paste

case( ph_getinsteonstat( "[TEMP1]" ) when 1 then ph_insteon( "[TEMP1]", ifaston, 0) when 2 then ph_insteon( "[TEMP1]", ifastoff, 0) )

into the formula column of the macro, it evaluates to <nothing>.

When I am creating this macro, what is the "command type"?

Thanks
Back to Top View fasttimes's Profile Search for other posts by fasttimes
 
TonyNo
Moderator Group
Moderator Group
Avatar

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: April 23 2006 at 09:14 | IP Logged Quote TonyNo

Quote:
it evaluates to <nothing>

Correct. That is because TEMP1 is nul. It will only evaluate properly when called with ph_macroparm.

Command type is formula.
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: April 24 2006 at 16:14 | IP Logged Quote dhoward

Just a slight correction I need to make...

The ph_macroparm function passes the parameters using the LOCAL variables instead of the TEMP variables.

So the macro line shoule look like:

case( ph_getinsteonstat( "[LOCAL1]" ) when 1 then ph_insteon( "[LOCAL1]", ifaston, 0) when 2 then ph_insteon( "[LOCAL1]", ifastoff, 0) )

Hope this helps,

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

Joined: December 05 2001
Location: United States
Online Status: Offline
Posts: 2889
Posted: April 24 2006 at 19:25 | IP Logged Quote TonyNo

Doh! I need to pay more attention to detail!
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: April 25 2006 at 22:42 | IP Logged Quote dhoward

Happens to the best of us .
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