Created
March 11, 2013 14:44
-
-
Save epall/5134732 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
const NIMBITS_EMAIL = "[email protected]" | |
// 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); |
This file contains hidden or 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
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