Inspiration

It is always a tedious and troublesome task when getting started with smart home. Setting up schedules for your lights and switches take a lot of time and is very cumbersome every time you want to make a slight change, as well as including new devices into your schedule. If only there were something that could just learn when I want the lights to be on or off. Something that could just set up my smart home for me. That would truly be a "smart" home.

What it does

My solution to this scheduling problem is a machine learning app that connects to your Samsung SmartThings account and learns how you control all your lights and switches. While learning, the app will start to automate your devices. For example, if you tend to turn on your lights around 10am, then the app will begin turning on your lights at 10am automatically.

Another great feature of the app, is that it's adaptive. So if you change your scheduling habits, the app will figure this out and learn from it. For example, if you decide to turn your lights at 11am instead of 10am, the app will eventually start to turn your lights on at 11am, as it realizes that this is your new habit of controlling your lights.

How I built it

The way this works is whenever an user logs into the app, it initializes the user by creating a database in AWS and triggering an Azure Logic app that sets up the Azure storage and Azure machine learning web service. DynamoDB is meant to contain all the devices' data while Azure storage is used to contain the training data. The Web Service is used to predict the state of each device.

Every hour, a function is triggered to get the current state of every device and save the data. After saving the data, it also asks the predictive web service to set the correct state of each device based on the trained model. If a device has gone through 24 hours of training, then all the data is sent to a Logic App, which is a workflow that combines the new and old data, starts a training job, and then updates the predictive web service.

Specifically, the Azure machine learning studio experiment utilizes a binary classifier to identify whether a device's state should be 1 or 0 (on or off). Furthermore, the training experiment has the ability to distinct between multiple devices per user, so this way only 1 model is needed per user. It keeps up to 3 days of data per device, before replacing the old data with new data. This is how the app becomes adaptive to each user's habits.

Challenges I ran into

This was my first time in machine learning and Azure. But thankfully Azure machine learning studio provided an easy drag and drop interface which made machine learning easy. I could easily try out different algorithms to see which one would give the correct results for my app.

Also, I found out to automate much of the machine learning process, powershell cmdlets were the most effective way to do this. However I didn't know of any way to do this as I am used to HTTP requests. Luckily though, Azure provides Automation Runbooks that can be triggered inside of Logic Apps.

Logic Apps are one of the greatest features about Azure alongside with their ML studio. Before learning about this, I attempted to do everything programmatically. Things got real messy and complicated. Once I found out about this, it made connecting all the services together seamless through a simple GUI interface.

Accomplishments that I'm proud of

I'm pretty satisfied with the way this app came out. It made my smart home actually "Smart" and automated all my lights and switches for me. I tried to make it as complete of a product as possible, and I'm satisfied with the way the app has come out with a simple login interface to get your SmartThings account quickly integrated with machine learning. Normally machine learning is a complex task, but Azure ML studio made it pretty easy to get started, and I'll definitely be using it as my go-to service.

What I learned

From zero to hero, I quickly got introduced to machine learning and a variety of Azure services. I initially started of with the Automated ML UI, which was super. And eventually I dug into Azure ML studio for greater flexibility and control over how my machine learning algorithm would control my smart home devices. I also learned how to quickly integrate the machine learning service with Logic Apps for seamless workflows. In regards to machine learning, I quickly learned from creating a simple number guesser to a full-fledged functioning, self learning smart home app.

What's next for Self Learning Home

I'm currently working on a seamless oAuth integration with SmartThings, a.k.a 1-click "Login with SmartThings" button instead of having to deal the with the all of the access token stuff.

The next step for Self Learning Home is to use machine learning studio to learn other capabilities of smart home devices, such as brightness and color. Additionally, I'll add a feature where the app can utilize data from other trained devices to better improve accuracy of the product.

Built With

Share this project:

Updates