<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Flic Duo Button Identification JS]]></title><description><![CDATA[<p dir="auto">I just spent too long trying to figure this out since the documentation is not up to date and the chatGPT bot is just wrong.</p>
<p dir="auto">Anyways I thought I would share how I am handling my first Flic Duo device to trigger different Home Assistant automations using the different buttons and webhooks . Hopefully this might save other people some time and effort.</p>
<pre><code>main.js

var buttonManager = require("buttons");
var http = require("http");

buttonManager.on("buttonSingleOrDoubleClickOrHold", function(obj) {
	var button = buttonManager.getButton(obj.bdaddr);
	var clickType = obj.isSingleClick ? "click" : obj.isDoubleClick ? "double_click" : "hold";
	var payload = JSON.stringify({
		button_name: button.name,
		click_type: clickType,
	});

	var targetUrl = null;

	if (button.name === "lock") {
		targetUrl = "http://XXX.XXX.XX.XX:8123/api/webhook/flic-lock";
	} else if (button.name === "auto1") {
		targetUrl = "http://XXX.XXX.XX.XX:8123/api/webhook/flic-leavingHome";
	} else if (button.name === "duo1") {
			if (obj.buttonNumber === 0) {
				targetUrl = "http://XXX.XXX.XX.XX:8123/api/webhook/flic-duo1-big";
			} else if (obj.buttonNumber === 1) {
				targetUrl = "http://XXX.XXX.XX.XX:8123/api/webhook/flic-duo1-small";
			}
	}

	if (targetUrl) {
		http.makeRequest({
			url: targetUrl,
			method: "POST",
			headers: {"Content-Type": "application/json"},
			content: payload,
		}, function(err, res) {
			console.log("");
			console.log("Sent to: " + targetUrl);
			console.log("Name: " + button.name);
			console.log("ID (bdaddr): " + button.bdaddr);
			console.log("Serial: " + button.serialNumber);
			console.log("Click Type: " + clickType);
			console.log("uuid: " + button.uuid);
			console.log("key: " + button.key);
			//console.log("Button #: " + obj.buttonNumber);
			console.log("Status: " + res.statusCode);
		});
	}
});

console.log("Script started");
</code></pre>
<p dir="auto"><strong>obj.buttonNumber</strong> returns <strong>0 for the upper bigger button</strong> and <strong>1 for the smaller lower button</strong></p>
<p dir="auto">You can also perform different automations depending on click type using an if statement where you change the keyword click using something like (YAML):</p>
<pre><code>conditions:
  - condition: template
    value_template: "{{ trigger.json.click_type == 'click' }}"
</code></pre>
<p dir="auto">The HA automation webhook trigger YAML looks something like:</p>
<pre><code>triggers:
  - allowed_methods:
      - POST
      - PUT
    local_only: true
    webhook_id: flic-leavingHome
    trigger: webhook
</code></pre>
<p dir="auto">This might not be the best way to go about this but I would be interested to hear suggestions for improvements. Now do add the rest of the new buttons and model the dimensions as a 3D STL file. It would be nice if flic also provided this as well.</p>
]]></description><link>https://community.flic.io/topic/18601/flic-duo-button-identification-js</link><generator>RSS for Node</generator><lastBuildDate>Fri, 11 Sep 2026 07:23:30 GMT</lastBuildDate><atom:link href="https://community.flic.io/topic/18601.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 20 Dec 2025 03:38:26 GMT</pubDate><ttl>60</ttl></channel></rss>