Home Integration Tutorial
IoT solutions have many moving parts. Devices, connectivity, device management, and data services. So we've taken all of these components, wrapped them all up into one unified environment, and provided them for you to try out. We're going to take a look at one of our core data services, scriptr.
To get started, check out the tutorial on getting the Philips Hue system integrated with wot.io here. Once you have that running, get the path for the Blink Demo from the email you received when signing up, or contact us for help.
Demo one - blink
In this demo, we're going to use scriptr to automatically turn on and off a lightbulb.
In your scriptr account, create a new script and call it
connectedhome/blink. To find out how, please refer to the scriptr documentation. Then type in the following code and save it:
var lights = JSON.parse(request.rawBody).data.lights; // Retrieve the data that we are putting onto the wot.io bus return '["phue","set_light",3,"on",' + !(lights["3"]["state"]["on"]) + ']'; // Send a message that either turns off the light if it is on or vice versa.
Now, run your Philips Hue integration from the previous step, using the path from the email
python hue.py <bridge ip> <wot path>
And that's it! Your light bulb should now turn on and off every few seconds. If you want to adjust the speed, simply change the delay in
Demo two - color change
Let's try another simple script, where the color of the bulb changes. This time, create a script called
connectedhome/changecolor, type in the following code, and save it:
return '["phue","set_light",3,"hue",' + Math.floor((Math.random()*65000)) + ']'; // Send a command to change the light bulb color
Connect with the
hue.py script again, and voila! That's all that it takes to create a production-ready deployment. There's no need to set up any servers or anything else.