Integrate Flic2 buttons with Hubitat Elevation?

Background:

I recently started experimenting with automation by purchasing a Flic-2 hub and smart buttons. Flic uses BlueToothLE to communicate. There are apps for configuring Flic via Android, iOS or Mac. But so far a Windows app is just an empty promise. They have finally released a windows SDK, but it is beyond my capabilities (and will) to setup the environment and then develop my own app.

There are several integrations built into the Flic system, but most rely on cloud services like IFTTT, Microsoft Flow or Zapier. For my purposes, I do not want to rely on cloud connectivity. I want to control from within my own LAN. It seems my lowest common denominator for Flic is its ability to make HTTP requests.

After much web searching for rules engines and control hubs, I came across Hubitat. It looked promising, so I bought the Elevation hub and have spent many hours experimenting with it.

So far I have figured out how to make an HTTP request from Flic to HE and trigger a Rule-4 app to log the event.

But here is my problem:

Since there is no Windows interface to program the Flic buttons, I can't just copy and paste the Hubitat endpoint URLs. I must manually type them into the Flic app on my Android phone. Considering I have multiple buttons and each button has three functions, that is a lot of endpoints to type in manually. (Yikes!)

I'm thinking rather than have multiple endpoint URLs, can I use a single endpoint URL but append two additional parameters for button ID and single-click, double-click or hold action? That way I can copy/paste the same long URL within the smartphone, but just edit the short, custom parameters at the end.

That single Hubitat rule would have to parse out the custom parameters to determine which rule actions to execute.

So here are my questions:

Is this do-able?

  • Can I append additional parameters to the endpoint URL without breaking it?
  • If so, how do I go about capturing the incoming HTTP request string in order to parse out my parameters?
  • Is this best accomplished with Rule machine, Maker API or some other app?

Any help or pointers to possible solutions are appreciated!

1 Like

If you open your hubs IP address on your phone, it works just like on your computer. Go to the rule and copy the endpoint's http address just like you do on computer. I did exactly that to create HTTP Requests in Tasker app on my phone without retyping.

I can't help with your 3 questions though.

Thanks for the tip! I tried it and it works.

It's a bit time consuming to navigate the app to each endpoint URL via my phone. However I could more quickly copy all the various endpoint strings to a text file via Windows interface, then transfer that file to the phone and do the copy/pastes from that text file.

I'm still curious as to whether the incoming http request can be captured and parsed. We'll see if anybody chimes in on that aspect.

Thanks again!

This is basically what you'll have if you use Maker API instead of RM Endpoints. When I added my Flic buttons, I created a virtual button for each Flic button, and then exposed the virtual buttons to the Maker API. Then, I basically get just one API URL that I need to call each time, and all I have to change for each Flic button is the Device ID, and button action. Also, when configuring your Flic buttons in the app, after you've set up all 3 actions for one button, you can then do "Copy Config" to another button, and then all you need to change is the Device ID in the URLs.

1 Like

It seems like this might be possible, but I've never tried it myself. For example, the RM API allows you to specify Rule Actions to run:

https://docs.hubitat.com/index.php?title=Rule_Machine#Using_Rule_Machine_from_HTTP_requests

Thanks! That looks intriguing... I'll dig in and experiment with it. I'll post back here later on with results (or failures).

Update: After referencing the documentation you pointed out, I was able to set a global variable by inserting a "/setGlobalVariable" command just prior to the "?access_token=" substring in an endpoint URL..

So in order to set a global string variable named "MyGlobalVar" to a value of "Apricots" via the http request, I had to insert the following new string segment

"/setGlobalVariable=MyGlobalVar:Apricots"

So my original endpoint URL:

http://{MyIP}/apps/api/129/trigger?access_token={MyToken}

became:

http://{MyIP}/apps/api/129/trigger/setGlobalVariable=MyGlobalVar:Apricots?access_token={MyToken}

I experimented with trying to pass more than one variable, but that didn't seem to work.

Thanks again for pointing me in the right direction!

Updated 2/21 to remove actual IP addresses and tokens from the examples

Another way I found to more easily program Flic Android on on my phone is to use software called Vysor. It allows me to connect my phone to my desktop and see a representation of the phone's screen on the PC. Then I can use the keyboard to send input to the phone. I can also cut from PC and paste to the phone. $40 for a lifetime license; not bad for all the headaches it prevents!

3 Likes

Adding some feedback here in case anyone opens this thread in the future looking for details on HE+Flic. Here is what I have done (took about 10-15min at most)

On Hubitat

  • Create a Virtual Device (type Button) for each physical Flic button
  • Configure these with just 1 button (rather than default of 5 I believe)
  • Create Maker API application (built-in)
  • Add all virtual buttons I just created to the list of devices this API can control
  • Used the API URLs to figure out URL format, etc.

On Flic Android App (with Flic Hub):

  • Add new Flic button to Flic Hub
  • Configure each action (click, double click, hold) with an "Internet Request"
  • Request type: GET
  • URL: Maker API URL with device ID, command and button number
  • All other buttons you can copy the button config in the Flic app, then just go back and change the device ID in the URLs. I hope this helps.

EDIT: example of Internet Request URLs below (for Flic settings), for each action type, corresponding to the correct command on the Maker API URL:

Click:

http://HUB_IP_ADDRESS/apps/api/APP_ID/devices/1016/push/1?access_token=TOKEN

Double Click:

http://HUB_IP_ADDRESS/apps/api/APP_ID/devices/1016/doubleTap/1?access_token=TOKEN

Hold:

http://HUB_IP_ADDRESS/apps/api/APP_ID/devices/1016/hold/1?access_token=TOKEN

Note: only portion of the URL that whill change is "...devices/DEVICE_ID/COMMAND/..."

The number 1 after "/COMMAND/" is the button number on the virtual device you created with type "button".


This looks like it should be simple but Iā€™m missing something because I cannot get the flic to work with a Magichome dimmer. Can you dumb this down and perhaps include a screen shot

Don't forget to and an RM command

Download the Hubitat app