Author |
|
fasttimes Groupie
Joined: March 12 2006
Online Status: Offline Posts: 63
|
Posted: April 22 2006 at 16:11 | IP Logged
|
|
|
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 |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: April 22 2006 at 18:20 | IP Logged
|
|
|
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 |
|
|
fasttimes Groupie
Joined: March 12 2006
Online Status: Offline Posts: 63
|
Posted: April 22 2006 at 20:44 | IP Logged
|
|
|
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 |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: April 22 2006 at 21:45 | IP Logged
|
|
|
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 |
|
|
fasttimes Groupie
Joined: March 12 2006
Online Status: Offline Posts: 63
|
Posted: April 23 2006 at 02:41 | IP Logged
|
|
|
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 |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: April 23 2006 at 09:14 | IP Logged
|
|
|
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 |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: April 24 2006 at 16:14 | IP Logged
|
|
|
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 |
|
|
TonyNo Moderator Group
Joined: December 05 2001 Location: United States
Online Status: Offline Posts: 2889
|
Posted: April 24 2006 at 19:25 | IP Logged
|
|
|
Doh! I need to pay more attention to detail!
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: April 25 2006 at 22:42 | IP Logged
|
|
|
Happens to the best of us .
|
Back to Top |
|
|