Flic button


(Jonathan Bisson) #1

I’ve created a device handler for the flic button. Combined the two together, it allows you to receive click, doubleClick and hold events from a real flic button (hardware).

Once the event is inside the smartthing, you could use CoRE (Community’s own Rule Engine) for defining your own rule. (ie: When I click on my flicButton do this, ect)
[RELEASE CANDIDATE] CoRE (Community's own Rule Engine)

Step 1) Get the flic button device handler code here:

Step 2) Install it and configure one button

Step 3) Get the expose rest-api code here:

Step 4) Install and configure it. You should now be able to see your newly created flic button (from step #1) within the buttons section.

Step 5) This app need oAuth support. Click on My SmartApps within from https://graph.api.smartthings.com/ide/apps and choose the new jbisson : Expose REST API, click edit properties (second icon).

Step 6) Under that page, you’ll find an OAuth section. Click and Click Enable OAuth in Smart App. Store the Client ID somewhere, you’ll need it for the next step.

Step 7) Open a new browser tab and go to this address (replace the Cliend Id part with the one you got from step #6) https://graph.api.smartthings.com/oauth/authorize?response_type=code&client_id=<Client ID>&scope=app&redirect_uri=www.blah123.com

Example would be: https://graph.api.smartthings.com/oauth/authorize?response_type=code&client_id=38be8142-3572-407e-8959-34027e545811&scope=app&redirect_uri=www.blah123.com

Step 8) Select your hub from the list and check the device handler flic button you have to give them access and click Authorize at the bottom. You’ll be redirected by a not found page (this is normal). Look in the url, you should see a code portion ie: https://graph.api.smartthings.com/oauth/www.blah123.com?code=s6w514 Note this code, it will be used for the next step.

Step 9) The last step require curl (postman would work as well). Download a copy of curl.exe for windows https://curl.haxx.se/download.html Make sure you download one of the package for your platform. Open a command prompt and type this:
curl -X POST -H "Content-Type: application/x-www-form-urlencoded" -d 'grant_type=authorization_code&code=<Code>&client_id=<ClientId>&client_secret=<ClientSecret>&redirect_uri=www.blah123.com' "https://graph.api.smartthings.com/oauth/token" --header "Content-Type: application/x-www-form-urlencoded"

curl -X POST -H “Content-Type: application/x-www-form-urlencoded” -d ‘grant_type=authorization_code&code=s6fxRf&client_id=a1e36dab-c6f6-4cc4-b234-18cd6c75de9e&client_secret=ded44492-5531-431d-b9fb-7b5a32751d8f&redirect_uri=www.blah123.com’ “https://graph.api.smartthings.com/oauth/token” --header “Content-Type: application/x-www-form-urlencoded”

Make sure to replace the code by the code you got from step #8, your client_id as well as the client_secret. If everything works well, you should get a response that look like this: “access_token”:“99741db6-2859-43ec-ac8c-241a364a5516”,“token_type”:“bearer”,“expires_in”:1576786529,“scope”:“app”}. The access token is really what we need for next step.

Step 10)
Use a browser and go to https://graph.api.smartthings.com/api/smartapps/endpoints?access_token=bcea5b37-1868-4418-a131-3c82a2e9eb91 (make sure you replace with your access token). This will give the url of the installationId (within the uri body section). At this point, you should have a working public end-point that look something like this:
ttps://graph.api.smartthings.com/api/smartapps/installations/<installationId>/ Login in your flic mobile application. For each actions (Click, Double Click, Hold), choose the Internet Request and paste the url for your button (the url will change based on which color you choose in step #1)

The full url should look something like this (for a turquise flic button and click event):

Note that you need to replace the access_token with the one you got form step 9.

  • Usage (REST API on how to invoked it):


<installationId>: InstallationId of your smartApp (use https://graph.api.smartthings.com/api/smartapps/endpoints?access_token=bcea5b37-1868-4418-a131-3c82a2e9eb90 to find it out)

<your_access_token> access token used for authentication (step 9)

<btnColor>  : Color of your button (if using the flic handler integration options are: black, white, turquise, green, yellow)

<btnNumber> : Button number identification used if you have more than one button with the same color 

<action>    : Action name - command name - that will be invoked. (if using the flic handler integration options are: click, doubleClick, hold)

Note that the id’s will be different in your case as well as the access token. In order to validate that you have a working endpoint working, use curl again, open your flic device handler (in your smartphone). You should be able to control your flic button device handler by sending this:
curl -X PUT -H “Content-Type: application/x-www-form-urlencoded” -d ‘’ “https://graph.api.smartthings.com/api/smartapps/installations/a096c1ec-aa3e-41de-b5fa-cc39fabb3865/button/white/0/click?access_token=bcea5b37-1868-4418-a131-3c82a2e9eb90” --header “Content-Type: application/x-www-form-urlencoded” (again, change your installationId and access_token with yours.

Step 11) At this point, you should have an end-to-end working flic button. When you click on it, it should do a request to the expose API, which then notify the flic button device handler for an event. You could use CoRE (Community’s own Rule Engine) for defining your own rule. (ie: When I click on my flicButton do this, ect) [RELEASE CANDIDATE] CoRE (Community's own Rule Engine) If you use CoRE and using the Flic Button device handler, The mapping between action and button numbers are as follow, this will be very usefl if using CoRE smartApps:
Click event: Button#1 -> pushed
Double Click event: Button#2 -> pushed
Hold event Button#3 -> pushed

Step 12) The last step is to link the url to the actual flic hardward device. Launch your flic android app, click on your button and for a specific event (Click, Double Click, Hold event), add an HTTP Internet Request and insert the url on step #5 in the Put section. The url will look like this: https://graph.api.smartthings.com/api/smartapps/installations/<installationId>/button/<btnColor>/<btnNumber>/<action>?access_token=<your_access_token >

The end-to-end should be working now. When you’ll press on the flic button, it will contact your phone or your tablet through bluetooth. The app will invoke the smartthing rest API endpoint. The rest API endpoint will notify the flic button device handler and there, all your rules and logic associated with the flic button will apply.

This give a tons of possibility to trigger all kind of thing related the the flic button.


Flic - Wireless Smart Button
FAQ: Full list of buttons and remotes confirmed to work with SmartThings
Just a Button? 1 button, nothing more fancy?

Cool. :sunglasses:

For those not familiar with core:

(Tim Slagle) #3


Nice, been looking at these buttons for a little while hoping someone would integrate it to smartthings.
Thank you, just ordered a few to test, cant wait, I can see lots of really nice usecases..


Just remember that this is still connecting like a cloud to cloud integration. You still have to pair the flic to a phone or tablet that has Wi-Fi in order for it to be able to talk to SmartThings. And Bluetooth range inside a house will probably be 40 to 50 feet although you may get a little longer. So if you take your phone upstairs while the flic is downstairs the flic may not work while it's out of range.

We have the flics and like them, but we have ours paired to a tablet which acts as a home automation controller and is always kept in the same place.

(Jonathan Bisson) #6


The flic doesn't have any WIFI connectivity so your phone and tablet will act as a gateway to the cloud. I have a tablet that sit near and act as a gateway between bluethooth and wifi.

In an ideal world, flic button should be z-wave so it could talk directly to the hub and/or hub having bluethooth capability directly, but for now, it is what it is. It seems to work very well the way it is....


Ohh, I didnt realized it was cloud to cloud, hopefully bluetooth will be enabled on st hub one day.

Anyone care to make a more detailed instruction on howto install this?

(Brent) #8

Hey thanks so much for this tutorial. I received 4 flics yesterday and they are certainly very neat imo. Unfortunately a lot of this code is quite foreign to me and I was hoping someone could hold my hand on this one and walk me through some steps I am not understanding. I have the basic understanding of installing device handlers and apps using code and I have done so here. As of now I am quite stuck on step 5. I can go into the settings for the Expose Rest Api and I do see OAuth but I really don't quite understand what I am supposed to be doing in this step or how to do it. I have read the tutorial but how does it apply to this app or what changes do I need to make with this app? If someone could elaborate here I would highly appreciate that. Please let me know if I have not provided enough info as well. As of now all I am trying to do is make a smartthing routine fire when I click the flic.



I can't help you with this particular device handler, but while you're waiting to get that figured out if you want to you can just use the IFTTT method.

Flic already has an IFTTT channel, and so does SmartThings. However, the SmartThings channel doesn't include routines. To do that, you need to have a virtual switch that then turns on the routine. You set that up the same way you would set up a virtual switch so the echo could control it, and that's detailed in the following FAQ:

So just in case you want to start using the flic before you get this particular device type handler set up, you could use IFTTT initially and then changeover later (since the device handler method will probably run a little faster). :sunglasses:

(Brent) #10

Thanks much, I will certainly look into this as a temporary solution and report back.

(Jonathan Bisson) #11

@Brenttron @fredrik Yeah, my initial instruction was not that clear.... I tried to put more detail on them, let me know if you are stuck somewhere and you need more help to get going.

(SmartThings enthusiast from Estonia) #12

@jbisson Thanks for updating the instructions. Much clearer now. I managed to get the access_token by using curl, but after trying the public end-point in my browser I get the following message:

{"error":true,"type":"AccessDenied","message":"This request is not authorized by the specified access token"}

Do you have any suggestions how to get past this?

BTW, the curl syntax which eventually gave me the access token was: curl -X POST -d "grant_type=authorization_code&code=CODE&client_id=CLIENTID&client_secret=CLIENTSECRET&redirect_uri=www.blah123.com" https://graph.api.smartthings.com/oauth/token --header "Content-Type: application/x-www-form-urlencoded"

PS. I'm using the UK Hub if that changes anything..

(Jonathan Bisson) #13

@jaaks I'm assuming you are at step 10 correct? Could you tell me which url you are trying to use? It should look like this one:

(SmartThings enthusiast from Estonia) #14

@jbisson Thanks so much for the help. I'm indeed at step 10 and the response I got from step 9 was:

The public end-point I'm trying to reach is: https://graph.api.smartthings.com/api/smartapps/installations/734d15f6-xxxx-xxxx-b855-0a1f0e845858/button/white/0/click?access_token=03c0bf71-xxxx-xxxx-8ed2-28004ca8f6d5

(Jonathan Bisson) #15

@jaaks My bad...there is another step that you needed to do... I'll udpate my steps. But basically, you need to do this:

and this will give you the url for your endpoint (in the uri) section. Just that take link and append the /button section.


The questioner is in the UK. It's likely that the URL will be different.

(SmartThings enthusiast from Estonia) #17

@jbisson Thanks for the updates. These got me one step further, but still the end-point does not appear to be operational.

The new instructions for Step 10 gave me the following:

After that I tried to access the end-point at https://graph-eu01-euwest1.api.smartthings.com:443/api/smartapps/installations/a096c1ec-xxxx-xxxx-b5fa-cc39fabb3865/button/white/0/click?access_token=4b17641d-xxxx-xxxx-88a2-4524e95676cb

However, the response is probably not what it should be:
{"error":true,"type":"SmartAppException","message":"Method Not Allowed"}

(Jonathan Bisson) #18

I forgot I changed the smart app from GET to a PUT so you'll need to use curl to trigger it. The url is good, just need to use a PUT. Try this:
curl -X PUT -H "Content-Type: application/x-www-form-urlencoded" -d '' "https://graph.api.smartthings.com/api/smartapps/installations/a096c1ec-aa3e-41de-b5fa-cc39fabb3865/button/white/0/click?access_token=bcea5b37-1868-4418-a131-3c82a2e9eb90" --header "Content-Type: application/x-www-form-urlencoded"

(SmartThings enthusiast from Estonia) #19

@jbisson That did the trick, thank you! Was quite a journey to get this to work, but it's working perfectly now and the latency seems to be a lot better compared to IFTTT. Thanks again for all the help.

(SmartThings enthusiast from Estonia) #20

One last question though.. How to you get CoRE to detect the click and doubleClick events?

It's working perfectly well with the hold function.

However, CoRE does not seem to detect the push capability of these Flic button device types and the double click does not seem to be a separate event altogether.