Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@danlieberman
Created January 31, 2014 00:05
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 danlieberman/5845fd624eff26f917ab to your computer and use it in GitHub Desktop.
Save danlieberman/5845fd624eff26f917ab to your computer and use it in GitHub Desktop.
SmartThings Status Board Service
/**
* Status Board Service
*/
preferences {
section("Allow application to report on these things...") {
input "temperatureSensors", "capability.temperatureMeasurement", title: "Which Temperature Sensors?", multiple: true, required: false
}
}
mappings {
path( "/jsonTest" ) {
action: [
GET: "jsonOutputTest"
]
}
}
def installed() {
log.debug settings
}
def updated() {
log.debug settings
}
def jsonOutputTest() {
def dataSequenceList = [];
settings["temperatureSensors"]?.collect {
def dataPoints = []
def myEvents = it.events(max: 30)
/*def myEventsSorted = myEvents.sort() { d ->
[ 'h:mm a', 'H:mm' ].findResult { fmt ->
try {
Date.parse( fmt, d ).time
} catch( e ) {}
}
}*/
def myEventsReverse = myEvents.reverse()
myEventsReverse.collect { eventItem ->
if ( eventItem.value != "active" && eventItem.value != "inactive" ) {
//def myTime = eventItem.date.format( "HH:mm:ss" )
def myCalendar = Calendar.getInstance( location.timeZone )
myCalendar.setTimeInMillis( eventItem.date.time )
dataPoints.add( [title: myCalendar.format( "HH:mm:ss"), value: eventItem.value ] )
}
}
def dataSequence = [ title: it.displayName, datapoints: dataPoints ]
dataSequenceList.add( dataSequence )
}
def graphObject = [
graph: [
title: "SmartThings Temperature Sensors",
type: "line",
refreshEveryNSeconds : 150,
yAxis: [minValue: 50, maxValue: 80],
datasequences: dataSequenceList
]
]
return graphObject
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment