Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
definition(
name: "SMS Tile",
namespace: "actiontiles",
author: "Thingterfaces LP",
description: "Send SMS when button is pressed.",
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 {
section("When this momentary button is pressed...") {
input "button", "capability.momentary", title: "Which button?", required: true
}
section("Send SMS to...") {
input "message", "text", title: "Message (max 140 characters)", required: true
input "phone1", "phone", title: "Phone Number 1", required: false
input "phone2", "phone", title: "Phone Number 2", required: false
input "phone3", "phone", title: "Phone Number 3", required: false
input "phone4", "phone", title: "Phone Number 4", required: false
input "phone5", "phone", title: "Phone Number 5", required: false
}
}
def installed() {
log.debug "Installed with settings: ${settings}"
initialize()
}
def updated() {
log.debug "Updated with settings: ${settings}"
unsubscribe()
initialize()
}
def initialize() {
subscribe(app, pushHandler)
subscribe(button, "momentary.pushed", pushHandler)
}
def pushHandler(evt) {
(1..5).each{ n ->
def phone = settings["phone$n"]
if (phone) {
log.debug "Sending SMS to $phone"
sendSms(phone, message)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.