2023-11-01 17:11:09 -04:00
2023-11-01 17:11:09 -04:00
2023-11-01 17:11:09 -04:00
2023-11-01 17:11:09 -04:00
2023-11-01 17:11:09 -04:00
2023-03-19 14:28:41 -04:00
2023-11-01 17:11:09 -04:00
2023-11-01 17:11:09 -04:00
2023-11-01 17:11:09 -04:00
2023-11-01 17:11:09 -04:00

flic2hass

A Flic SDK utility to publish all of your Flic buttons to Home Assistant via MQTT as well control the onboard IR module.

Requirements:

  • A Flic Hub
  • A functional MQTT server

Basic Steps

1. Connect to Flic Hub IDE:

2. Create MQTT module:

  • One in the Web IDE, click "Create Module".
  • Give the new module a name. "MQTT" is a good option but anything will work.

3. Insert lib.js:

  • Copy content from lib.js in this repo to lib.js in the flic IDE.
  • Right click the folder in the left pane and select "New File".
  • Name the file lib.js (IT MUST BE NAMED THIS).
  • Copy content from lib.js in this repo to lib.js in the flic IDE.

4. Setup main.js:

  • Copy the following to main.js
require("./lib").start(
 require("buttons"),
 require("ir"),
 "0",
 {
  mqtt: {
   host: "set-this-to-yours",
   username: "set-this-to-yours",
   password: "set-this-to-yours",
  }
 }
)
  • Modify host, username, password with your details.

    If your MQTT server does not require authentication:

  • Delete username & password:

  1. Start the module in the IDE by clicking the green play button, and watch the Console output (it's extremely verbose right now)

    If the module didn't start correctly, try powercycling your Flic Hub and reconnect. Verify the Module saved properly and is running.

  2. Once the module has started and you have verified it is working as expected, turn on the "restart after crash" checkbox to ensure the module is always running after any unexpected crash or hub power cycle.

Additional Configuration

The setup example contains just the bare minimum changes, if you wish to play around with the configuration or need to enable expanded logging see the following complete configuration file.

{
   "mqtt": {
      "host": "", // MQTT Host
      "port": 1883, // MQTT Port
      "client_id": "", // MQTT Identifier
      "username": "", // MQTT Username
      "password": "" // MQTT Password
   },
   "debug": false, // Enable debug logging for all modules
   "ha": {
      "debug": false, // Enable debug logging for just home-assistant related things
      "topics": {
         "homeassistant": "homeassistant", // MQTT Prefix for homeassistant auto-discover
         "flic": "flic", // MQTT Prefix for state values
      }
   },
   "flicBtns": { 
      "disabled": false, // Do not publish button events
      "debug": false // Enable debug logging for button related things
   },
   "flicIR": { 
      "disabled": false, // Do not publish IR events
      "debug": false // Enable debug logging for IR related things
   },
}
S
Description
A BETTER Flic SDK utility to publish all Flic buttons to Home Assistant via MQTT
Readme
1 MiB
0 Stars 1 Watchers 0 Forks
Languages
JavaScript 52%
TypeScript 48%