Created
December 21, 2018 05:21
-
-
Save pauly7300/dc6041b7432a70a3145a7d132c49ce5a to your computer and use it in GitHub Desktop.
alexa local light parser
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (typeof msg.on !== 'undefined') { | |
var cmd = (msg.on ? "on" : "off"); | |
var brightness = -1; | |
// logic for brightness | |
if (msg.on) { | |
if (msg.bri > 0) { | |
brightness = msg.bri; | |
var t = 0; | |
t = Math.floor(brightness * 2.55); | |
if (t == 254) { t = 255; } | |
brightness = t; | |
} | |
} | |
var out = {}; | |
out.state = cmd; | |
if (brightness > 0) { | |
out.brightness = String(brightness); | |
} | |
var msg = {}; | |
msg.payload = out; | |
return [msg,null]; | |
} else { | |
return [null,null]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment