My SmartThings multisensor is a great little piece of technology. It reports, in real time, motion, temperature, and open/close state of my back door. The iOS app is slick, too, but I wanted a way to view it from my computer and have access to historical data.
Enter Dweet and Freeboard from Buglabs.
There's actually no setup required on Dweet (but be sure to check out their nifty demo). It just starts eating data and making it available for use via HTTP/JSON!
To create a SmartApp you neeed to be a SmartThings developer (free and simple process). Then the app is built in the SmartThings web-based IDE, and installed directly to your SmartThings system.
dweet.groovy
file below
A simulator tile of that device should appear.
A developer console will pop up. Check for any red errors.
If there are no errors, your device should have dweeted! You can confirm by visiting http://dweet.io/follow/THE-NAME-YOU-CHOSE-EARLIER and see some JSON like:
{
"contact": "closed",
"degrees": 68,
"unit": "F"
}
The device will continue to dweet when the temperature or contact change.
Let's add the dweeted data to a slick (free!) dashboard from Freeboard.io.
Set up a free account, and walk through the tutorial.
Now make a gauge for the sensor's temperature:
degrees
attribute
datasources["Deck Door"].degrees
You should see the current temperature of your sensor in the gauge.
TODO: Add set up for temp sparkline
TODO: Add set up for open/closed indicator light
This is based on @alexking's implementation.
I simply added a datapoint about the "contact" (open/close) attribute of the sensor.
If you're trying to graph values over time, it would be better to set up an interval in your SmartThings SmartApp rather than subscribing to changes in temperature as they may not come in regularly.
Dweets are public by default, so data about your sensor is public. Not a huge deal since you can easily lock them down.
A more adaptable approach may be to create a generic SmartApp that dweets a devices entire status. I'm working on this next.
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
/**
* Dweet
*
* This is free and unencumbered software released into the public domain.
* http://unlicense.org
*/
preferences {
section("When this thing changes ") {
input "item", "capability.temperatureMeasurement", title : "Temperature Sensors"
}
section("Dweet as...") {
input "handle", "text", title : "Enter a name to dweet from..."
}
}
def installed() {
log.debug "Installed with settings: ${settings}"
initialize()
}
def updated() {
log.debug "Updated with settings: ${settings}"
unsubscribe()
initialize()
}
def initialize() {
// Subscribe for future dweeting
subscribe(item, "temperature", dweet)
subscribe(item, "contact", dweet)
dweet()
}
// Send the dweet
def dweet(evt) {
httpGet([
uri : "http://dweet.io/",
path : "dweet/for/" + handle,
query : [
"contact" : item.currentValue('contact'),
"degrees" : item.currentValue('temperature'),
"unit" : "F"
],
success: { response ->
log.debug "Request was successful, $response"
}
])
}