Whenever I reach home at night, I encounter a challenge. It's dark and the switch to the light is on the other side of the room. So, every time I have to struggle to find my way to reach the switch to turn on the bulb.
Then there is another challenge, I need to switch the bulb off while going to bed and then navigate my way back to bed.
What:To solve this problem, I had two things in mind:
1. A mobile switch which I can have in my pocket, keep it on bed or paste it on the nearby accessible wall.
2. Easy to install and configure for different users.
How:For solving the first problem Flic Button is used, which is a bluetooth based button which pairs with the phone. It can be pasted on different surfaces, clipped to the trousers/shirts or can be just placed on anywhere. In addition to it, Lifx bulb has been used which can be controlled over wifi network.
The entire system can be setup by a user with no background in technology (unless you want to make changed in the code that I have published). The was enabled by the ease of use the Artik provides and its integration with IFTTT.
To integrate flic button with Artik cloud, Flic button sample code and Artik cloud sample code is used. The code and the setup details are given on the github page.
Steps1. Getting the setup ready
Prerequisites:
- Install Flic app
- Install Lifx App
- Connect your Lifx bulb to app
a. To get started, Clone the github repo and install the application on your android phone. Change your parameters in the code (details on git)
b. Open up the app. It would look like this. Click on Get Flic
c. Grab the flic button
d. Login with your samsung account
[You only need steps 2-3 if you want to create your own device contract on cloud. You can skip these steps if you want to reuse the device which I have already created]
2. Next, create the FlicButton device on https://developer.artik.cloud/. This defines the manifest which is like a contract between the client and the server. We sent the data from Android app which adheres to the manifest created. Device and the manifest are shown in the figure below. Flic offeres single click, double click and hold functionality. So you can see these three boolean fields in the manifest along with a timestamp. IFTTT subscribes to 'State' field, so it needs to be included as well. Essentially State is the same as isSingleClick. It would be true when someone single clicks flic button.
3. Next, create an application from the same developer portal. Settings are shown below. This acts as a service application which the android application can communicate to.
4. Connect the Flic Button device: Now you can connect the flic button device you created or you can use the device which I have already created. To create it:
a. Go to https://artik.cloud/my/devices
b. Click on 'Connect another device'
c. Search for FlicButton device
d. Create device token:
e. Switch on you app, login, connect your flic button and do single click. You will see data on your dashboard like in figure below. You should see 'State' and 'isSingleClick' as green on the dashboard. Also play by doing double click and hold on flic button device.
5. Connect Lifx bulb, Artik cloud with IFTTT:
a. Login on IFTTT and go to channels https://ifttt.com/channels
b. Link your Lifx bulb to IFTTT
c. Search for artik cloud and click on create a new receipe
d. Bind artik cloud as the trigger. If 'state' is true then switch on 'Lifx bulb'
e. Choose 'turn on' as the trigger
f. Choose flic button as the device
g. Use Lifx as the action
h. Choose 'turn lights on' or the best action for your choice
i. Choose the parameters and your lifx bulb. Click on create action
j. Repeat the similar steps with trigger as 'state off'. You are done:
k. You can even activate the scenes when the state changes. Play with it.
Debugging Tips:
1. Test the app. Click on send message and get latest message
2. Check message and error log for device and application on https://developer.artik.cloud/ . Artik allows only 150 requests per day.
3. Check if you are receiving the data on the dashboard on https://artik.cloud/my/data (See the video)
4. Check the logs tab on IFTTT. There was a bug with IFTTT and Artik cloud. I wrote to the developer team of Samsung and they fixed it. So you shouldn't face any issue with that.
5. Install if on android and check the messages
Comments