More on Controlling Lights
The Beta machine turned out to have a flaky serial port and the X10 wireless controller was therefore not completely reliable. So I decided to move everything over to Sigma, since it is a newer machine and I trust the power supply not to burn up during the extended testing I have planned for the X10 controls. I fired up Sigma and Beta and telnetted into Beta, getting the Bottlerocket driver and relevent X10 HTML and Perl files. Everything worked fine on Sigma after changing a few file permissions. I then changed Sigma's IP address to 192.168.0.125 so it would be Internet accessible.
My next task was to add a dimming control to the existing X10 controller webpage. In addition to turning the lamp on or off, I wanted to be able to set the light level. I experimented with drop-down lists, but eventually settled on a text box for light level entry. Text boxes are easy to implement in HTML pages and the data can be anything. Drop-downs are limited to the number of entries I was willing to include, and this would be tedious. Because the light level value passed to the Bottlerocket driver must be a number from -12 to +12, the selections would be numberous. Besides that, the selected value would have to be parsed later, and so a consistent number of characters would be needed. All of this had complications I was too lazy to deal with, so I scrapped the drop-down idea even though it is probably better to give the user only valid choices. I also finally figured out the light dimming syntax of the Bottlerocket driver line commands and was ready to go.
The text box I added to the existing X10 controller web page was set to accept just two characters. This limits the valid light level choices to -9 to 12, but I figured this would be an acceptable compromise. I wrote some Perl code to take the text box value (characters) and convert them to integers. You need to do this anyway to formulate a valid Bottlerocket command line, but it has the additional benefit of turning everything that is not a number into 0, which translates into no change in light level by Bottlerocket. I should probably put some limits on it as well; if the converted value is greater than 12, then I should set it equal to 12.
Anyway, this worked. The X10 webpage now presented to the user by Sigma includes radio buttons for Lamp On and Lamp Off, and a text box entry for light level. When executed, my lamp goes on or off, as before. But now, if set to On, the Black Tower work light then dims to the selected level. The level is also saved in a status file so it is presented to the user on first reaching the X10 control webpage.
I have some clean-up and testing to do, but this definitely extends the X10 capability of the Black Tower. Just another small step in the master plan...
My next task was to add a dimming control to the existing X10 controller webpage. In addition to turning the lamp on or off, I wanted to be able to set the light level. I experimented with drop-down lists, but eventually settled on a text box for light level entry. Text boxes are easy to implement in HTML pages and the data can be anything. Drop-downs are limited to the number of entries I was willing to include, and this would be tedious. Because the light level value passed to the Bottlerocket driver must be a number from -12 to +12, the selections would be numberous. Besides that, the selected value would have to be parsed later, and so a consistent number of characters would be needed. All of this had complications I was too lazy to deal with, so I scrapped the drop-down idea even though it is probably better to give the user only valid choices. I also finally figured out the light dimming syntax of the Bottlerocket driver line commands and was ready to go.
The text box I added to the existing X10 controller web page was set to accept just two characters. This limits the valid light level choices to -9 to 12, but I figured this would be an acceptable compromise. I wrote some Perl code to take the text box value (characters) and convert them to integers. You need to do this anyway to formulate a valid Bottlerocket command line, but it has the additional benefit of turning everything that is not a number into 0, which translates into no change in light level by Bottlerocket. I should probably put some limits on it as well; if the converted value is greater than 12, then I should set it equal to 12.
Anyway, this worked. The X10 webpage now presented to the user by Sigma includes radio buttons for Lamp On and Lamp Off, and a text box entry for light level. When executed, my lamp goes on or off, as before. But now, if set to On, the Black Tower work light then dims to the selected level. The level is also saved in a status file so it is presented to the user on first reaching the X10 control webpage.
I have some clean-up and testing to do, but this definitely extends the X10 capability of the Black Tower. Just another small step in the master plan...

0 Comments:
Post a Comment
<< Home