Skip to content

Instantly share code, notes, and snippets.

@epall
Created March 11, 2013 14:44
Show Gist options
  • Save epall/5134732 to your computer and use it in GitHub Desktop.
Save epall/5134732 to your computer and use it in GitHub Desktop.
const NIMBITS_EMAIL = "eric@electricimp.com"
// we recommend creating an access key specifically for the point(s) you want
// to write to, instead of using your account secret
const NIMBITS_ACCESS_KEY = "9cb960d95161235a"
const NIMBITS_POINT = "demo1"
function nimbits_submit(value) {
local body = http.urlencode({
point=NIMBITS_POINT,
email=NIMBITS_EMAIL,
key=NIMBITS_ACCESS_KEY,
value=value,
format="double"
})
local req = http.post("http://cloud.nimbits.com/service/currentvalue", {}, body);
req.sendasync(function(res) {
if(res.statuscode == 200) {
server.log("Value "+value+" successfully submitted");
} else {
server.error("Error "+res.statuscode+": "+res.body);
}
});
}
device.on("value", nimbits_submit);
imp.configure("Nimbits demo", [], []);
agent.send("value", 712.123);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment