Light Droid is a continuation of another lighting project, Auto Luminosity, that I am working on.
This part of the project is using the Particle Photon, a Windows 10 Universal app and an Android app to handle managing different lights and rooms, and a couple smart bulbs from Lifx and now Phillips Hue. As I mentioned in the previous project, as the project progresses, throughout multiple projects, you'll see new hardware used and new software written. This project introduces support for the Phillips Hue, Windows 10, and a couple new scheduling features.
The goal of this project is to make it easier to setup schedules for my lights, like have them turn off or on at a certain time or being able to just turn on the lights before walking into the house; things like that. This phase of the project will handle just that, with additional lighting features, like dimming, color changes, and additional integration for other bulbs coming in the later projects.
Before we can jump into the project, we have some setup we need to take care of in order to have this project function correctly. First, make sure you've gone through the previous project and completed the setup for Lifx. Next, you'll need to have Phillips Hue bulbs.
Note that you don't really need Phillips Hue bulbs, this is just if you would like to integrate with them, if you have Lifx bulbs and you're good with that then you can skip this section.
Once you've setup your Phillips Hue bridge and bulbs, you should take a look at the getting started page for developers. Follow the steps there to create a username (which is referred to as username token throughout this project) and to locate the IP address for your bridge.
Actual ProjectSo jumping into the project, here are the parts that it's split into:
- Web service
- Photon Firmware
- Android app and Windows 10 Universal app
The web service is a REST service to be easily consumed by any platform, you can pass Json objects and most responses are in Json too.
I recommend downloading Visual Studio 2015 Community if you would like to reuse or modify the service in this project: https://www.visualstudio.com/en-us/products/visual-studio-community-vs.aspx
For your convenience, the web service is hosted and publicly available in order for you to get up and going to try out the project, pretty please don't abuse it. URL is within the projects source code.
Windows 10 Universal AppFor the first time, this project includes a Windows 10 Universal app, you can run the app on any platform that runs Windows 10. Also, there is an Android app included. For this walk through we will look at the Windows 10 app.
This project has some basic registration code to setup a user account and Phillips Hue integration for importing your lights (and all previous features are also included), which you can tie to the account.
The very first time you load up the Windows app you should see something like this. (Note: this is running on a Windows Phone, but you could run it on the desktop too.)
You can continue and register an account and then login into the app. (Very much similar to the previous app).
Once you've registered and successfully logged in you should see something similar to the following next screen. Previous projects would just dump you on a blank activity, thought of trying something else so its a little more interesting from previous apps I've done here.
As you can see, I've kept the flow of app the same from the last project. We are really just building on top of it, and you'll see in future projects I continue the same.
IntegrationSo we still need to set a crucial piece, integration with Phillips Hue (more integration coming soon). Let's go into Settings, you should see this screen:
Tap on Phillips Hue, and we can get going with integration. You'll see a couple settings options, one to add in your username token from Phillips Hue and another to enter your bridge's IP address. Below that you should see a button to import your lights from Phillips Hue's API. Tap on Username Token and let's add that token you generated earlier and then tap on Bridge IP Address and enter the IP address you found earlier as well. Note that Phillips Hue does not yet support a Remote REST API, so you will need to be on your local network in order for the import to work.
After you've entered the needed info, tap on Import from Phillips Hue, and if all goes well you should be able to see your lights in the Lights list. So now if you go back to the Main screen of the app and navigate to Lights, should, hopefully, see your list of light bulbs from Phillips Hue (and Lifx if you've been following :) ).
So you've just about made it through the hardest part of the project, good job! Now let's checkout adding a Schedule and additional features we can now use. Below I have selected one of my light bulbs.
Tap on Add Schedule and we can add some schedules to my light bulb. Also you'll notice that you can also toggle the lights.
Adding a Schedule is pretty simple, just select your action (more actions available in future projects) and the time you want that action to occur. You'll notice there are two new times that you can trigger your lights to turn on/off, Sunrise and Sunset. So now you can schedule your lights to turn on automatically at Sunset everyday!
Tap save and you should have a success message. Once you've added your schedules, you can navigate back to the Main screen and go to Schedules and see a list of all the schedules you have created so far.
You'll be able to see what action will happen, to which light bulb or room and at what time; some basic details to get an idea of the schedule. Of course, you tap into one of the schedules and remove the schedule if you no longer want it.
Here's a quick demo of the Schedule feature below:
Phew! That's enough for the Windows 10 app, Now to the super awesome Particle Photon, I know in the last project I mentioned the Dragonboard was pretty awesome, seriously the Photon is an awesome little board.
Particle Photon App/FirmwareNow you're ready for the Photon app! Hopefully you've checked out Particle's web based IDE and played around a bit to get familiar with it.
One quick thing to know about before jumping in, Particle offers an amazing dashboard. I highly recommend checking it out, it was extremely useful in the development of this portion of the project.
The app has a userId that is hard-coded (I know, ewww) but you should change this to your own. You can get this from making the REST call to LoginUser through something like Postman to make the call. Just post a json payload like this to http://lightdroid.cloudapp.net/LightDroidService/Login:
{
"Email": "you@email.com",
"Password": "yourPassword"
}
And your return should be a User Json object with your UserId included.
Here's pretty much all the code for the Photon app, the firmware (along with the full source code) is included in the repo for easy flashing onto your Photon.
It's important to mention that the app has three libraries included:
You should make sure to include them into your own project.
At this point, it should just be as simple as clicking the flash button and deploying the code onto your Photon.
And that's it! Hopefully you're enjoying the project as much as I have been. Here's a quick demo of toggling the light in action:
May the Force be with you!
Comments