The WPLight makes HTTP GET calls to the URL specified during the configuration.
To configure the WPLight simple connect the device to the power and it will pulse, open your smartphone and find it in the available wifi networks. Connect to it to configure.
As you can see in this schema the WPLight calls a web server (WordPress or not) to receive back a command (“light on“). If you’re using WordPress you can install our WordPress IoT plugin to handle WPLight calls and answer properly.
By reading this article you will understand how the answers to the calls are built, and so you will be able to make the WPLight talk with every CMS or external service, like IFTTT.
The WPLight GET calls bring also this three parameters:
action
= dolight (to hook the plugin)chip
= xxxxxxx the number of your WPLight IDpons
= xxxx a random number to make every call a new call
So the calls are like this:
GET /?action=dolight&pons=2215&chip=1662353 HTTP/1.1
Host: www.barattalo.it
The answers must be in plain text with just a 3 parameters command string like this: {1,D,30}
which contains, in this exact order, these data:
- number = an integer value
- mode = “
C
” for alert, “D
” for on/off, “E
” for event monitor - timer = the number of seconds after which it will make another call (minimun value 5)
So if you want to communicate with the light you should configure the light to reach your url and you have to answer with a properly formatted command string.
If the GET
call fails the light is turned off and the WPLight will wait 120 seconds before calling again.
You can’t make the WPLight call faster then once every 5 seconds.
Here there are the three lighting modes described in detail:
Alert mode
In the alert mode the light blinks and the number represents the speed of the blinking. From 1 slow (the light turns on for 2 seconds) to 10 very fast (the light is ononly for 100 msec).
Examples:
{1,C,30}
The WPLight blinks slowely for 30 seconds then it calls back the WordPress plugin to check for a new command.
{5,C,120}
The WPLight blinks quite fastly for 120 seconds then it calls back the WordPress plugin to check for a new command.
On/Off mode
In the on/off mode the light turns on or off based on the number: 0 turns it off, 1 or grater turns it on.
Examples:
{0,D,60}
The WPLight is turned off and after 30 seconds a new call is made to the WordPress plugin to check for a new command (if it is still the same it will remain off).
{1,D,10}
The WPLight is turned on and after 10 seconds a new call is made to check for a new command.
Event monitor mode
In the event monitor mode the WPLight makes the number of blinks specified distributing them randomly in the timer period. This is good for activity monitors which have to show some value to let you understand that something is happening.
The narrow is the period the best is precision.
If the number of event to show is small, blinks will be slow (2 seconds long).
If the number of events to show is too big, blinks will be very fast (100 msec).
Examples:
{23,E,120}
The WPLight performs 23 blinks randomly distributed in 120 seconds.
For this example suppose you want to show the traffic on your site. You can count the pageviews, that is to say that every time you have a pageview you add 1 to your counter. When the WPLight call comes you answer with the counter and then reset it.