Skip to content

Instantly share code, notes, and snippets.

@joshualyon
Last active June 18, 2018 07:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save joshualyon/22f6e8f7bebd37779e50f5e42d8cc761 to your computer and use it in GitHub Desktop.
Save joshualyon/22f6e8f7bebd37779e50f5e42d8cc761 to your computer and use it in GitHub Desktop.
Device type to accept mapped Smart Home Monitor states for SmartThings
/**
* SHM Mapper
*
* Copyright 2017 Josh Lyon
*
* This Device Type Handler works in unison with the custom SHM Mapper SmartApp to copy Smart Home Monitor statuses to an
* attribute of this Thing. Even though SHM code is available on the SmartThings community, it was never officially approved
* for use in officially published SmartApps.
*
* In order to get around this, the SHM Mapper SmartApp copies SHM status to the attribute of a Thing so that Thing can be
* subscribed to in other official SmartApps. For example, you could use this to display SHM status in SharpTools.
*
* Required SmartApp: https://gist.github.com/joshualyon/fc9b3fe25cda6cbfc42eb281588141d4
*/
metadata {
definition (name: "SHM Mapper", namespace: "joshualyon", author: "Josh Lyon") {
capability "Switch"
capability "Alarm"
attribute "shmState", "string"
command "setShmState", ["string"]
}
simulator {
// TODO: define status and reply messages here
}
tiles {
// TODO: define your main and details tiles here
}
}
// parse events into attributes
def parse(String description) {
log.debug "Parsing '${description}'"
// TODO: handle 'switch' attribute
// TODO: handle 'SHM State' attribute
}
// handle commands
def on() {
log.warn "Method not implemented: 'on'"
// TODO: handle 'on' command
}
def off() {
log.warn "Method not implemented: 'off'"
// TODO: handle 'off' command
}
def setShmState(newState){
log.info "Setting device shmState to: ${newState}"
sendEvent(name: "shmState", value: newState, isStateChange: true)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment