Skip to content

Instantly share code, notes, and snippets.

@mhsemcheski
Last active May 29, 2016 19:54
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 mhsemcheski/5fc110f40aa95ea91c563fd28f4ae7c9 to your computer and use it in GitHub Desktop.
Save mhsemcheski/5fc110f40aa95ea91c563fd28f4ae7c9 to your computer and use it in GitHub Desktop.
/**
* shm trigger
*
* Copyright 2016 Mike Semcheski
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
* for the specific language governing permissions and limitations under the License.
*
*/
definition(
name: "shm trigger",
namespace: "mhsemcheski",
author: "Mike Semcheski",
description: "trigger routines on shm changes",
category: "Convenience",
iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png",
iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png",
iconX3Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png")
preferences
{
page(name: "configure")
}
def configure()
{
dynamicPage(name: "configure", title: "Configure Routines", install: true, uninstall: true)
{
def actions = location.helloHome?.getPhrases()*.label
if (actions) {
actions.sort()
section("Arm Away Actions") {
log.trace actions
// use the actions as the options for an enum input
input "armAwayAction", "enum", title: "What Happens on Arm Away", options: actions
}
section("Arm Stay Actions") {
log.trace actions
// use the actions as the options for an enum input
input "armStayAction", "enum", title: "What Happens on Arm Stay", options: actions
}
section("Disarm Actions") {
log.trace actions
// use the actions as the options for an enum input
input "disarmAction", "enum", title: "What Happens on Disarm", options: actions
}
}
}
}
def installed() {
log.debug "Installed with settings: ${settings}"
log.debug "Current Mode = ${location.mode}"
log.debug "Current Alarm State = ${location.alarmSystemStatus}"
initialize()
}
def updated() {
log.debug "Updated with settings: ${settings}"
unsubscribe()
initialize()
}
def initialize() {
subscribe (location, "alarmSystemStatus", alarmChange)
}
def alamChange(evt) {
log.debug "evt.name: $evt.value"
if (evt.value == "Arm (away)")
{
location.helloHome?.execute(armAwayAction)
}
if (evt.value == "Arm (stay)")
{
location.helloHome?.execute(armStayAction)
}
if (evt.value == "Disarm")
{
location.helloHome?.execute(disarmAction)
}
}
// TODO: implement event handlers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment