Flic hub intergration

Hello,

Recent, Shortcutlabs has released a new product, the Flic Hub (Link).
With this device, your phone hasn’t be always home for the flic buttons to interact.

It would be nice, if you can intergrate the buttons inside home assistnt. Like the Flic Smart Button (link) if you have installed the library on a PI.

The configuration would be something like this:

# Example configuration.yaml entry
flic:
  hubs:
    - host: DEVICE_IP_ADDRESS
    - host: DEVICE_IP_ADDRESS

after this, every button connected to the hub, would be a binary sensor like the smart button component and it would interact as a event trigger.

I have made a request on their ideas form: (link)

Thank you

Please please please :slight_smile:

Would be awesome! :slight_smile:

While waiting for this, you could use the HTTP Binary Sensor in HA, and use the Advanced > HTTP Request option in Flic to send HTTP requests to HA for each button press, which will then appear as binary sensor events in HA.

3 Likes

This would indeed be great! So far it is working pretty well with HTTP request and HA’s RESTful API but native integration would be awsome!

The HTTP Request method is a bit over my head and seems like you have to pass your password. Hub integration would be fantastic!

+1 on that

Perhaps a HTTP Request to mqtt bridge? you could specify the hub ip as the only source it accepts connections from for some security.

Being new to this, could somebody please give me an idea about how to do the RESTful interface?

I understand the hub has to send a URL to HA, but I’m not sure how HA would accept it so actions can be initiated…

Thanks!

Once you have enabled the api, the URL can change the state of the home-assistant entity specified in the body of the post.

This is how I toggle an input boolean for each flic button action:

First enable the home-assistant api, and specify your password in configuration.yaml (you’re going to have to expose it in the flic app):

http:
  api_password: yourapipassword

Create an input boolean for each button action - in configuration.yaml:

#flic button 2 (black)
input_boolean:
  flic2_singleclick:
    name: black_flic2_singleclick
    icon: mdi:checkbox-blank-circle
  flic2_doubleclick:
    name: black_flic2_doubleclick
    icon: mdi:checkbox-multiple-blank-circle
  flic2_hold:
    name: black_flic2_hold
    icon: mdi:clock 

In the flic app, specify the URL details for each action (it’s a bit labourious - fortunately you can clone the config if you have multiple buttons). For example, for a single click:

URL:

http://XXX.XXX.X.XXX:8123/api/services/input_boolean/toggle

select:

POST

Content Type:

application/json

Body: (I had to stop my iphone from inserting “smart quotes”)

{“entitiy_id”:“input_boolean.flic2_singleclick”}

HTTP headers
Key:

x-ha-access

Value:

yourapipassword

then press INSERT

2 Likes

I use a event, works nice.

  - alias: Single click
    trigger:
      platform: event
      event_type: flic_click
      event_data:
        button_name: flic
        click_type: single
     action:
     - service: switch.turn_off        
       entity_id: switch.light

Inside the fllic app:

  • post request to host/api/events/flic_click
  • with in the body and Content Type Json: { “button_name”: “flic”, “click_type”: “single” } this is the event data .
  • and ofcourse, for now, with the your password in the header, hopfully, the long life bearer tokens come quick
6 Likes

Thank you arch and janvanhelvoort!

Anyone got a working setup with a Long-Lived Access Token configured?

I’m a bit out of my comfort zone here but I suspect that I need to change ‘x-ha-access’ to something else and use my token that I’ve configured in HA.

I am using hassio and find the Flicd addon works great, I have a combination of Flics using both the Flic Hub and FlicD (for direct HA access).

Does that work even though there is an api password?

Can you use the buttons on the hub without internet access?

Yes, take a look here.
You need to replace ‘x-ha-access’ with ‘Authorization’ and the Value String then need to be ‘Bearer YourToken’.

Any news on Flic Hub intetration? Would love to see this…Currently using a Pi with hassio as my “flic-hub” (feeds mqtt into my main HA-setup on my Synology). Feels slightly buggy sometimes…

1 Like

Would like to see this to :slight_smile: Also with the addition of the IR = Awesome beans

  1. Add to automations.yaml
  	 - alias: "Flic1 hold"
         trigger:
            platform: event
            event_type: flic
            event_data:
              button_name: flic1
              click_type: hold
         action:
          - service: script.turn_on
            entity_id: script.test_script4  # change this name to your's script name
  1. Remember to replace hassio.local in all steps below with homeassistant IP (typically 192.168.x.x). Although some steps may work also without replacing.

  2. Generate token here: http://hassio.local:8123/profile
    Replace all GENERATED_TOKEN below with it.

  3. (Optional) test if it works on curl:

curl -k -X POST -H "Authorization: Bearer GENERATED_TOKEN" -H "Content-Type: application/json" -d '{ "button_name": "flic1", "click_type": "hold" }' http://hassio.local:8123/api/events/flic
  1. Add “internet request” to button via flic app
    use these settings:
		http://hassio.local:8123/api/events/flic
		Content-Type: application/json
		
		header:
		name: Authorization 
		body of header: Bearer GENERATED_TOKEN
		
	
		body:  { "button_name": "flic1", "click_type": "hold" }