Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome Programming
 PowerHome Messageboard : PowerHome Programming
Subject Topic: Button to Run Formula... Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
traviskleckner
Senior Member
Senior Member
Avatar

Joined: February 26 2007
Location: United States
Online Status: Offline
Posts: 118
Posted: November 28 2008 at 13:10 | IP Logged Quote traviskleckner

Hello all,

I know that I am just doing something stupid here and
need a little help. I'm working on some custom pages to
control lights from an iPhone/touch.

I'm trying to figure out the best way to set Scenes from
an HTML page (I don't really want to do it all with
groups.)

I've got this:

<form method="post" action="/ph-cgi/formula">
<input type="hidden" name="type" value="5">
<input type="submit" style="height: 50px; width:
150px;font-size:16pt" name="cmd" value="MBR On">
<input type="hidden" name="formula"
value="ph_insteon('MBR-FANLIGHT',17,75)+ph_insteon('MBR-
WALLLIGHTS',17,125)">
<input type="hidden" name="nexturl"
value="/iPhoneLights.html">
</form>

Which works, but always takes me to PH formula page (it
seems to ignore the "nexturl" section.)

That said, is there a better way to do this? Could it
be done with a link url rather than a form?

Edit: While I'm at it...any thoughts on why this
doesn't work:

<a href="/ph-cgi/evalformula?formula=ph_insteon('MBR-
FANLIGHT',17,255)&nexturl=/iPhoneLights.html">Fan Light
On</a>
<a href="/ph-cgi/evalformula?formula=ph_insteon('MBR-
FANLIGHT',19,0)&nexturl=/iPhoneLights.html ">Fan Light
Off</a>

(for whatever reason, it's in the "+". This: <a
href="/ph-cgi/evalformula?formula=ph_insteon ('MBR-
WALLLIGHTS',iOn,255)&nexturl=/iPhoneLights.html ">On</a>
works fine. For some reason I can't run them both.
Grr.)

Thanks in advance!

Edited by traviskleckner - November 28 2008 at 13:19
Back to Top View traviskleckner's Profile Search for other posts by traviskleckner
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: November 30 2008 at 21:54 | IP Logged Quote dhoward

Travis,

In the first "form" method, change the action to "/ph-cgi/evalformula". The ph-cgi/formula will always bring up the PowerHome default formula page and ignores the nexturl parameter.

Concerning your href examples, they should work. As a quick test, I copied and pasted your code into a file with slight modifications for my own system and didnt have a problem.

Code:

<html>
<body>
<a href="/ph-cgi/evalformula?formula=ph_insteon('NOOK',ion,255) &nexturl=/test.html">Nook Light On</a><br>
<a href="/ph-cgi/evalformula?formula=ph_insteon('NOOK',ioff,0)& nexturl=/test.html">Nook Light Off</a>
</body>
</html>


Now, if you're saying you have a problem with trying to add to ph_insteon functions like in your "form" example, then yes, you'll have a problem as the "+" sign is used as an escape character for HTTP GET commands as a space character. You can fix this by instead subtracting the two ph_insteon commands (or multiplying, dividing). You can also escape the "+" symbol so it doesnt get interpreted as a space character with %2b. So the href equivalent of your form would be:

Code:

<a href="/ph-cgi/evalformula?formula=ph_insteon('MBR-FANLIGHT', 17,75) %2b ph_insteon('MBR-WALLLIGHTS',17,125)&nexturl=/iPhoneLights.ht ml">On</a>


Hope this helps,

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

Joined: February 26 2007
Location: United States
Online Status: Offline
Posts: 118
Posted: December 01 2008 at 12:17 | IP Logged Quote traviskleckner

Thanks Dave, that was it. The plus was killing me.
Back to Top View traviskleckner's Profile Search for other posts by traviskleckner
 

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