Last active
October 30, 2015 20:10
-
-
Save davidsulpy/81eae1ab4426c1ea73f8 to your computer and use it in GitHub Desktop.
Flowthings Drop
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
{ | |
"sensor": { | |
"type": "map", | |
"value": { | |
"luminiscence": { | |
"type": "integer", | |
"value": 77 | |
}, | |
"ultraviolet": { | |
"type": "integer", | |
"value": 0 | |
}, | |
"temperature": { | |
"type": "float", | |
"value": 25.6 | |
}, | |
"humidity": { | |
"type": "integer", | |
"value": 47 | |
} | |
} | |
}, | |
"water": { | |
"type": "boolean", | |
"value": false | |
}, | |
"switch": { | |
"type": "map", | |
"value": { | |
"led-color": { | |
"type": "map", | |
"value": { | |
"red": { | |
"type": "integer", | |
"value": 27 | |
}, | |
"green": { | |
"type": "integer", | |
"value": 20 | |
}, | |
"blue": { | |
"type": "integer", | |
"value": 27 | |
} | |
} | |
}, | |
"power": { | |
"type": "map", | |
"value": { | |
"volts": { | |
"type": "float", | |
"value": 120.311005 | |
}, | |
"amps": { | |
"type": "integer", | |
"value": 0 | |
}, | |
"watts": { | |
"type": "integer", | |
"value": 0 | |
} | |
} | |
}, | |
"switch": { | |
"type": "boolean", | |
"value": true | |
} | |
} | |
} | |
} |
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
var lightEmoji = ":o: Off"; | |
if (drop.elems.switch.value.switch.value === true) { | |
lightEmoji = ":bulb: On"; | |
} | |
var bodyJS = [ | |
{ key: "Smart Switch :red_circle:", value: drop.elems.switch.value['led-color'].value.red.value }, | |
{ key: "Smart Switch :green_apple:", value: drop.elems.switch.value['led-color'].value.green.value }, | |
{ key: "Smart Switch :large_blue_circle:", value: drop.elems.switch.value['led-color'].value.blue.value }, | |
{ key: "Smart Switch :zap: Volts", value: drop.elems.switch.value.power.value.volts.value }, | |
{ key: "Smart Switch :zap: Amps", value: drop.elems.switch.value.power.value.amps.value }, | |
{ key: "Smart Switch :zap: Watts", value: drop.elems.switch.value.power.value.watts.value }, | |
{ key: "Smart Switch :bulb:", value: lightEmoji } | |
]; | |
return JSON.stringify(bodyJS); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment