Posted: January 15 2003 at 10:05 | IP Logged
|
|
|
Phil,
The sample PSP files should just be opened in either notepad or wordpad. You can open them in Word as a text file but it's overkill.
The easiest way to create a custom page with just a button to turn F5 On is listed below. The file should be saved to the PowerHome web directory and the sample assumes the filename is "simple.htm".
<html> <head> <title>Simple PowerHome X-10 Button</title> </head> <body> <form action="/ph-cgi/execsendkeys" method=post> <input type="hidden" name="nexturl" value="/simple.htm"> <input type="hidden" name="sendkeys" value="ph_rtne(ph_x10(1,'F',5,0) + ph_x10(1,'F',102,0))"> <input type="submit" value="F5 On"> </form> </body> </html>
I won't go into the various HTML tags, but will detail the PowerHome specific calls. Basically were creating a form with a single button. The form will call an internal PowerHome CGI function called "execsendkeys". This function allows the user to pass two parameters...the "nexturl" to be returned when done and the "sendkeys" formula to be executed. I've declared both these parameters as "hidden" form types. The "nexturl" tells PowerHome that when the button is clicked, I want to reload the same page. The "sendkeys" is a formula that I want PowerHome to perform. In this case, I don't actually want to simulate any keystrokes being pressed so I use the ph_rtne function which will convert numeric data to an empty string. Inside the ph_rtne function are two ph_x10 functions. The first one tells PowerHome to send housecode/unitcode "F5" to X-10 controller 1. The second one tells PowerHome to send housecode/command "F On" to X-10 controller 1. If the ph_x10 command is successful, it will return a 0. If both are successful we'll get 0 + 0 = 0. The ph_rtne will convert the 0 to an empty string which is then passed to the send keys function. Since the string is empty, no keystrokes will actually be simulated but we don't care since we performed the X-10 functionality that we wanted. F5 will be turned on and the browser will reload the same page.
In the above example, we didn't use PSP at all and just had a simple HTML page. We didn't have to use PSP because the page is static, meaning that the way the page is displayed will never change. Now if we wanted to include the time that "Sunset" will occur on our webpage, then that is dynamic, meaning that the web page is changing based upon some condition. In this situation, we would use PSP, which is nothing more than HTML with embedded PowerHome formula functions. These formula functions are enclosed within the "<%" and "%>" tags. When PowerHome serves a PSP page, the page is searched for the PSP tags, the formulas are evaluated, and the results are passed back along with the HTML. Below is our simple HTML button for F5 On slightly enhanced with the time that Sunset will occur that day:
<html> <head> <title>Simple PowerHome X-10 Button</title> </head> <body> <%string(ph_getsuntime(today(),2))%> <form action="/ph-cgi/execsendkeys" method=post> <input type="hidden" name="nexturl" value="/simple.psp"> <input type="hidden" name="sendkeys" value="ph_rtne(ph_x10(1,'F',5,0) + ph_x10(1,'F',102,0))"> <input type="submit" value="F5 On"> </form> </body> </html>
All that is different is a simple function that returns the time that sunrise will occur. To make this work, the file must be named "simple.psp" instead of "simple.htm". You can also see that I changed the "nexturl" to reflect the new filename.
Hope this helps and let me know if you have any other questions.
Dave.
|