Step 12Talking to the stoplight
To do this, you need to formulate web calls to the extremely lightweight "API" the light responds to. In other words, you have to have your script craft a url that looks like an http GET request.
This url looks like:
http://<your stoplights name or IP>:<port>/b?<argument>&<argument>
The arguments are each separated by an & and should be one or more of these:
- a= The "secret" password. Not encrypted in any way, this is only to prevent casual browsers from resetting your light. If this is not right the light will not change, it will just return a web page showing how it would have changed it, had the password been correct. The password should not be any of the other words or subsets of them. i.e. "yell" would be bad because it's a substring of "yellow"
- c= One of: "red","yellow","green" or "beacon" to turn on the corresponding lamp or the auxiliary outlet.
- "error=1" to start the yellow light light blinking
- "error=2" to start the red light blinking (We use this when we really want to call attention to something)
- "error" (without a =1 or =2) to flash all three lights twice as fast as they flash when first powered on.
Except in reality the server is just searching for certain keys words and ignores all the other characters. So that example could also be "http://stoplight.example.com/bsecretredgreen" and work just as well.
We use it in conjunction with a server monitoring package. Every five minutes during the day a script looks at the aggregate results of the things we care most about, and decides what state to set the stoplight to. After hours, a single call turns all the lights off to save power.
| « Previous Step | Download PDFView All Steps | Next Step » |

















































<.script GET src ="http://stoplight:port/bsecretredgreen"/>
is an example of turning red and green on
except get rid of the dot before script(its just so instructables doesnt treat it as a html line)