WPLight, a deeper look inside the project

Some more informations about the WPLight system

Dicembre 13, 2016

After a week of my WPLight crowdfunding campaign I need to better describe how developers will be able to talk with my Internet of Things lamp.

When I was uploading the project I thought that I need to talk mainly to bloggers, e-commerce owners and non-tech site owners. But most of the discussions I have had last week on WordPress groups was with technology people.

So, here is a deeper view of my WPLight. :)

You don’t know what is WPLight? It’s an IoT device for site owners, it’s a wonderful designed wifi lamp that blinks when something happens in your site. It’s ready to use for WordPress but comes with API for developers to talk with every CMS and every language.

Go and get one! :)

How does the WPLight work

When you configure the WPLoght it starts polling the server to get values to show. The calls are simply http REST api calls to an endpoint build inside the WPLight plugin (using admin ajax URL). For non-WordPress developers you have to build your own endpoint for the calls. Each call is really short and also the answer is small so there is no useless traffic from and to the server, even if we call the server often.

The endpoint answers just with a small string which contains instructions for the WPLight about the number and the mode of the blinks to perform.

Currently it can blink in two different modes:

  1. ALERT MODE
  2. MONITOR MODE

The WPLight in ALERT MODE

Working as an alert means that it blinks with a speed based on the number that the counter represents.
For example: if you have 1 comment to approve, the blinks last 2 seconds. If you have 10 comments to approve it blinks faster, half a second. If you have 50 comments it blinks ever faster. If the number is too much big, it blinks at the fastest time it can.
This blinking mode is good to use the light as an alert, a note, like the number of push notifications you see on the icon of your favorite app.

As shown in the Kickstarter video it can be used in a shop to tell that there is a new order in the e-commerce that need some work. The person who works in the physical shop can’t stay watching PC and emails, but while working in the store he can see the light blinking and so discover that there is something to do online.

The alert mode require the lamp to call the server maximum once every every two minutes, if the server answers always the same number the lamp slow down and calls the server less.

The alert mode results in a costant blink, faster or slower, like this GIF:

The WPLight in MONITOR MODE

The monitor mode is different, it shows events, each time they happens. Think to a monitor for viral events, for example, it makes a blink every time a user shares a post of your blog on Facebook.

This monitor is not really in real-time, because the WPLight can’t be directly reached by your web server, because it hasn’t a static IP and to reach it from outside your wifi network you need NAT and port forwaring on your wifi router and this isn’t really possible for most users.

So the WPLight polls the server more often than in alert mode and distribute a number of light blinks in a small interval. This way, if the windows is enaugh small it seems real time.

To not overload the server the calls are made maximum once in a minute.

I’ll try to explain better with an example: if you have a user session counter that adds 1 when a new user arrives on your website, the endpoint called will pass that counter to the light. The light calls the server every minute or two, when it see that there are, for example, 5 new sessions, it will blink randomly five times in the interval. This will made the monitor work.

I’ve tested the prototype with Google Analytics opened and the result is really good. There is only one minute delay between Analytics and WPLight.

 

Author

PHP expert. Wordpress plugin and theme developer. Father, Maker, Arduino and ESP8266 enthusiast.

Recommended

Bright Link Previews plugin for WordPress

How to add a link preview to all the links of your site

Settembre 23, 2023

Arduino Theremin

Costruire un Theremin con Arduino Nano e due sensori

Marzo 19, 2023

Test sull’utilizzo di ChatGPT nella scrittura di articoli dentro a WordPress

Alcuni appunti sull'utilizzo di ChatGPT, occhio con la matematica.

Gennaio 29, 2023

WP Gutenberg notes

Collection of notes and thoughts on Wordpress Gutenberg blocks development.

Gennaio 9, 2023

Test page for Bright Links plugin

To test the plugin hover your mouse to a link, or tap the link on mobile device.

Dicembre 4, 2022

Updating a metabox after Gutenberg updates

When press on "Update" refresh a custom metabox under gutenberg editor.