Skip to content

Instantly share code, notes, and snippets.

@davidsulpy
Last active October 30, 2015 20:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidsulpy/81eae1ab4426c1ea73f8 to your computer and use it in GitHub Desktop.
Save davidsulpy/81eae1ab4426c1ea73f8 to your computer and use it in GitHub Desktop.
Flowthings Drop
{
"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
}
}
}
}
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