Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome Programming
 PowerHome Messageboard : PowerHome Programming
Subject Topic: Status based timed event Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
lizaoreo
Groupie
Groupie


Joined: February 11 2013
Location: United States
Online Status: Offline
Posts: 75
Posted: May 14 2013 at 11:28 | IP Logged Quote lizaoreo

I've had PowerHome set up to turn my bedroom light up to
25% or so for a while now around 10 minutes before my
alarm goes off. The problem was, sometimes I would end
up getting up shortly after my wife left for work and
start getting ready (turning the light on myself).
Usually once I'm up, I just turn it all the way up to
100%, so when the timed event kicked off, it would drop
it down to the 25% or so and I'd have to go turn it back
up myself.

So, as a solution, I tried implementing a simple if/then
statement. If the light's not off, turn it on dimmed, if
it's already on, just set it to whatever it already is.
Unfortunately it doesn't seem to be working, any idea
what I'm doing wrong?

if(ph_getinsteonlevelrt("MSTRBDRMLGT") = 0, 80,
ph_getinsteonlevelrt("MSTRBDRMLGT"))
Back to Top View lizaoreo's Profile Search for other posts by lizaoreo
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: May 14 2013 at 12:07 | IP Logged Quote dhoward

lizaoreo,

Your if/then looks syntatically correct. However, unless there is other code that you havent posted, I don't see where it will actually affect the light. The result of the if/then will be either 80 or the current level of the light if its already on and this value will need to be used in another formula or statement to set the light.

Something like:

ph_insteon("MSTRBDRMLGT",ion,if(ph_getinsteonlevelrt("MSTRBD RMLGT") = 0,80,ph_getinsteonlevelrt("MSTRBDRMLGT")))

The above should work but is a little inefficient since you'll query the light status twice (if its already on) and then set the light to its current value.

What I would do is leave your timed event in the state it was previously where it just turned the light on 25% at the specified time and change the "Boolean" field from 1 to:

if(ph_getinsteonlevelrt("MSTRBDRMLGT") = 0,1,0)

The timed event will fire as normal, but the Boolean formula will be executed and will return 1 if the light is off (which will cause your action formula setting the light to 25% to run) and a 0 if the light is already on...which will cause the timed event not to fire.

Hope this helps,

Dave.


Edited by dhoward - May 14 2013 at 12:09
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
lizaoreo
Groupie
Groupie


Joined: February 11 2013
Location: United States
Online Status: Offline
Posts: 75
Posted: May 16 2013 at 13:57 | IP Logged Quote lizaoreo

Right, I had it set up in a macro for the morning like:

Command: Insteon
ID: MSTRBDRMLGT
Value: On
Formula: 80

Then I changed the formula field to what I posted. It was
still working the way it used to which is odd, but I'll go
with your solution, much cleaner :)

Thanks Dave :)
Back to Top View lizaoreo's Profile Search for other posts by lizaoreo
 
lizaoreo
Groupie
Groupie


Joined: February 11 2013
Location: United States
Online Status: Offline
Posts: 75
Posted: May 16 2013 at 13:59 | IP Logged Quote lizaoreo

Oh, right, and now I remember why I did it in the macro,
that macro also turns on one of the kitchen lights so the
den area isn't completely dark when I leave in the morning.
I'll have to tweak with it some more, I may have it assign
a variable, then use the variable to see if the lights on
or not and set it to the current state if it is. Not
really a concern right now since it's light out when I
leave.

Edited by lizaoreo - May 16 2013 at 14:00
Back to Top View lizaoreo's Profile Search for other posts by lizaoreo
 

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