Last active
February 27, 2021 19:02
-
-
Save 625alex/7a36495e93e087dc9b5d745f92f3ba1e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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