The IoT Tower Light is a small project I created not so long ago, to be used as a notification system. One of the aims of this challenge, was to incorporate its control in OpenHAB.

 

IoT Tower Light

 

The project is basically a light in which I've replaced the internal circuitry by a Particle Photon and a NeoPixel Ring. Using IFTTT, different animations can be triggered using a smartphone and an internet connection.

 

A dedicated blog post exists on my website, containing wiring and code: Internet of Things Tower Light – Frederick Vandenbosch

 

Here's a build video of the original project, with a demo at the end:

 

 

Modification

 

Because the light currently uses the IFTTT service, it requires an active internet connection. This may not always be the case though, so in order to ensure local control without internet, a new mechanism needs to be added.

 

The protocol of choice for most in this challenge has been MQTT, and it won't be different for this project. I modified the Photon's code to add support for MQTT. This means the Photon will now listen to events from both IFTTT and MQTT, ensuring backwards compatibility with the DO Button app.

 

Screen Shot 2016-07-01 at 20.58.43.png

 

The new, extended code looks like this:

 

 

OpenHAB

 

The integration in OpenHAB is rather straightforward.

 

First, a new numeric item is defined, linked to the MQTT binding. It is configured such that the value of any command received on this item is published to the MQTT broker:

 

Number TowerLight <light> {mqtt=">[piiot:TowerLight:command:*:${command}]"}

 

Next, the item is added to the sitemap. Note that it is using the "switch" definition. The possible numeric values are linked to labels, to have meaningful buttons in the GUI:

 

Switch item=TowerLight label="TowerLight" mappings=[0="Off", 1="Siren", 2="Pulse", 3="Blink"]

 

This results in four buttons, each with a different label, linked to a command. When clicked, the command is passed to the item, which in turn triggers the linked MQTT binding.

 

2016-07-02 09:54:11.981 [INFO ] [smarthome.event.ItemCommandEvent    ] - Item 'TowerLight' received command 1
2016-07-02 09:54:12.006 [INFO ] [marthome.event.ItemStateChangedEvent] - TowerLight changed from 0 to 1
2016-07-02 09:54:14.747 [INFO ] [smarthome.event.ItemCommandEvent    ] - Item 'TowerLight' received command 2
2016-07-02 09:54:14.771 [INFO ] [marthome.event.ItemStateChangedEvent] - TowerLight changed from 1 to 2
2016-07-02 09:54:18.975 [INFO ] [smarthome.event.ItemCommandEvent    ] - Item 'TowerLight' received command 3
2016-07-02 09:54:19.004 [INFO ] [marthome.event.ItemStateChangedEvent] - TowerLight changed from 2 to 3
2016-07-02 09:54:23.115 [INFO ] [smarthome.event.ItemCommandEvent    ] - Item 'TowerLight' received command 0
2016-07-02 09:54:23.138 [INFO ] [marthome.event.ItemStateChangedEvent] - TowerLight changed from 3 to 0

 

In the GUI, the buttons are visualised like this:

Screen Shot 2016-07-01 at 23.05.19.png

 

Because the MQTT broker is on the local network, as opposed to the IFTTT service on the internet, the responsiveness has improved greatly.

 

 

That integration went smoothly, on to the next part!

 


arrow_prev.png

 


Navigate to the next or previous post using the arrows.

arrow_next.png