Skip to content

pfink/openhab2-flicbutton

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

91 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

openHAB 2 Flic Button Binding

Build Status codebeat badge Project Status: Moved to https://github.com/openhab/openhab-addons/pull/9234 – The project has been moved to a new location, and the version at that location should be considered authoritative. to openhab/openhab-addons#9234

openHAB 2 binding for fliclib-linux-hci using the java clientlib by Shortcut Labs. When you use this binding, please share your expierences here and create issues at this repository for feature requests and bug reports.

Supported Things

  • flicd-bridge - The bridge representing a running instance of fliclib-linux-hci (flicd) on the server .
  • button - The Flic button (supports Flic 1 buttons as well as Flic 2 buttons)

Discovery

  • There is no automatic discovery for flicd-bridges available.
  • After flicd-bridge is (manually) configured, buttons will be automatically discovered as soon as they're addded with simpleclient via background discovery. If they're already attached to the flicd-bridge before configuring this binding, they can be discovered by triggering an active scan.

Thing Configuration

flicd-bridge

The bridge should be added to a *.things file. Example:

Bridge flicbutton:flicd-bridge:mybridge

The default host is localhost:5551 (this should be sufficient if flicd is running with default settings on the same server as openHAB). If your flicd service is running somewhere else, specify it like this:

Bridge flicbutton:flicd-bridge:mybridge [ hostname="<YOUR_HOSTNAME>",  port="<YOUR_PORT>"]

If flicd is running on a remote host, please do not forget to start it with the parameter -s 0.0.0.0, otherwise it won't be accessible for openHAB (more details on fliclib-linux-hci).

button

There are no configuration parameters for buttons available and normally no textual configuration is necessary as buttons are autodiscovered as soon as the bridge is configured. If you want to use textual configuration anyway, you can do it like this:

Bridge flicbutton:flicd-bridge:mybridge [ hostname="<YOUR_HOSTNAME>",  port="<YOUR_PORT>"] {
    Thing button <MAC_ADDRESS> "<YOUR_LABEL>"
    Thing button <MAC_ADDRESS> "<YOUR_LABEL>"
    ...
}

You can lookup the MAC addresses of your buttons within the inbox of Paper UI. You're free to choose any label you like for your button.

Channels

Getting Started

  1. Setup and run flicd as described in fliclib-linux-hci. Please consider that you need a seperate Bluetooth adapter. Shared usage with other Bluetooth services (e.g. Bluez) is not possible.
  2. Connect your buttons to flicd using the simpleclient as described in fliclib-linux-hci. Flicd has to run in background the whole time, simpleclient can be killed after you successfully tested the button connection.
  3. Add a flicd-bridge via PaperUI or Textual Configuration. Please consider that flicd does only accept connections from localhost by default, to enable remote connections from openHAB you have to use the --server-addr parameter as described in fliclib-linux-hci.
  4. When the bridge is online, buttons newly added via simpleclient will automatically get discovered via background Discovery. To discover buttons that were set up before the Binding setup, please run an active scan.
  5. Profiles are the recommended way to use this binding. But it's also possible to setup Rules, e.g. like this:
    rule "Button rule using the button channel"
    
    when
        Channel "flicbutton:button:1:80-e4-da-71-12-34:button" triggered SHORT_PRESSED
    then
        logInfo("Flic", "Flic 'short pressed' triggered")
    end
    
    rule "Button rule directly using the rawbutton channel"
    
    when
        Channel "flicbutton:button:1:80-e4-da-71-12-34:rawbutton" triggered
    then
        logInfo("Flic", "Flic pressed: " + receivedEvent.event)
    end