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 (Click New Device under My Devices page within smartthing website) and fill the required fields and pick the new device handler you installed on step 1
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)
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.
Use a browser and go to https://graph.api.smartthings.com/api/smartapps/endpoints?access_token=bcea5b37-1868-4418-a131-3c82a2e9eb91 If this url doesn’t work, use the one returned step #9 for regional api url (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:
https://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.