<?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[Leviton?]]></title><description><![CDATA[<p dir="auto">So is anyone using their Flic with any Leviton smart switches?  I can't seem to associated any of my 5 outside flood lights controlled by 5 Leviton Smart switches.  Anyone run into that?</p>
]]></description><link>https://community.flic.io/topic/18243/leviton</link><generator>RSS for Node</generator><lastBuildDate>Tue, 14 Apr 2026 09:24:15 GMT</lastBuildDate><atom:link href="https://community.flic.io/topic/18243.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 13 Feb 2023 20:38:19 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Leviton? on Tue, 28 Mar 2023 03:28:56 GMT]]></title><description><![CDATA[<p dir="auto">HI <a class="plugin-mentions-user plugin-mentions-a" href="https://community.flic.io/uid/4680">@superdave67</a> ,</p>
<p dir="auto">I use Flic with Leviton smart switches but I needed to use a custom setup on my Flic hub using the SDK.</p>
<p dir="auto">If you are interested in that approach you can use the sample code below.</p>
<p dir="auto">The <code>const</code> at the top need to be replaced with IDs specific to your setup. I think I can dig up a postman collection on how to get those IDs which I created based on <a href="https://github.com/tlyakhov/python-decora_wifi/tree/master/decora_wifi/models" rel="nofollow ugc">this library</a>. It is on a different computer, but I think I can get access to it in a few days.</p>
<pre><code>// main.js
var buttonManager = require("buttons");
var http = require("http");

const L_DUSTIN_ID = "&lt;LEVITON ID 1&gt;";
const L_CAT_ID = "&lt;LEVITON ID 2&gt;";
const L_MASTER_ID = "&lt;LEVITON ID 3&gt;";
const FLIC_BUTTON_ID = "&lt;FLIC BUTTON ID&gt;";
const ACCESS_KEY = "&lt;LEVITON ACCESS KEY&gt;";
function toggleSwitch(switchId) {
	  console.log("toggling: " + switchId);
	  // Get current Switch Status.
	  http.makeRequest({
			url: "https://my.leviton.com/api/IotSwitches/" + switchId,
		  method: "GET",
		  headers: {"Content-Type": "application/json", "authorization": ACCESS_KEY}		
		}, function(err, res) {
			
			if(res.statusCode != 200) {
				console.log("request status: " + res.statusMessage);
			} else {
				// Toggle the switch
					http.makeRequest({
						url: "https://my.leviton.com/api/IotSwitches/" + switchId,
						method: "PUT",
						headers: {"Content-Type": "application/json", "authorization": ACCESS_KEY},
						content: JSON.stringify({"power": JSON.parse(res.content).power == "ON" ? "OFF": "ON"}),		
				}, function(err, res) {
					
				});
			}
		});
	
}

function handleButton(obj){
  if(obj.isSingleClick) {
		toggleSwitch(L_DUSTIN_ID);
	}
	
	if(obj.isDoubleClick) {
		toggleSwitch(L_CAT_ID);
	}
	
	if(obj.isHold) {
		toggleSwitch(L_MASTER_ID);
	}
}

buttonManager.on("buttonSingleOrDoubleClickOrHold", function(obj) {
	var button = buttonManager.getButton(obj.bdaddr);
	if(button.uuid == FLIC_BUTTON_ID) {
		handleButton(obj)
	}
});

console.log("Started");
</code></pre>
]]></description><link>https://community.flic.io/post/20614</link><guid isPermaLink="true">https://community.flic.io/post/20614</guid><dc:creator><![CDATA[dustingtorres]]></dc:creator><pubDate>Tue, 28 Mar 2023 03:28:56 GMT</pubDate></item></channel></rss>