forked from Mark-C-uk/Hubitat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Notify-No-Events
48 lines (41 loc) · 1.16 KB
/
Notify-No-Events
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
definition(
name: "Notify No Events",
namespace: "hubitat",
author: "Bruce Ravenel",
description: "Notify when no event",
category: "Convenience",
iconUrl: "",
iconX2Url: "")
preferences {
page(name: "mainPage")
}
def mainPage() {
dynamicPage(name: "mainPage", title: " ", install: true, uninstall: true) {
section {
input "thisName", "text", title: "Name this notifier", submitOnChange: true
if(thisName) app.updateLabel("$thisName")
input "meters", "capability.powerMeter", title: "Select Power Meters", submitOnChange: true, required: true, multiple: true
input "period", "number", title: "Enter number of minutes to wait", range: "0..*", submitOnChange: true, required: true
input "notify", "capability.notification", title: "Select Notification Device", submitOnChange: true, required: true
}
}
}
def installed() {
initialize()
}
def updated() {
unsubscribe()
unschedule()
initialize()
}
def initialize() {
subscribe(meters, "power", handler)
runIn(period * 60, timeUp)
}
def handler(evt) {
unschedule()
runIn(period * 60, timeUp)
}
def timeUp() {
notify.deviceNotification("No event for $period minutes from $meters")
}