forked from sidjohn1/smartthings
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NetworkMonitor.groovy
97 lines (89 loc) · 3.22 KB
/
NetworkMonitor.groovy
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/**
* Network Monitor
*
* Copyright 2015 Sidney Johnson
* Inspired by notoriousbdg's BatteryMonitor
*
* If you like this app, please support the developer via PayPal: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=XKDRYZ3RUNR9Y
*
* 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.
*
* Version: 1.0 - Initial Version
*/
definition(
name: "Network Monitor",
namespace: "sidjohn1",
author: "Sidney Johnson",
description: "Monitors rssi status",
category: "Green Living",
iconUrl: "http://cdn.device-icons.smartthings.com/Health%20&%20Wellness/health9-icn.png",
iconX2Url: "http://cdn.device-icons.smartthings.com/Health%20&%20Wellness/[email protected]",
iconX3Url: "http://cdn.device-icons.smartthings.com/Health%20&%20Wellness/[email protected]")
preferences {
page name:"pageInfo"
}
def pageInfo() {
return dynamicPage(name: "pageInfo", install: true, uninstall: true) {
section("About") {
paragraph "Network Monitor, Monitors your rssi status and puts all the data in one place."
paragraph "${textVersion()}\n${textCopyright()}"
}
def templist = ""
settings.senors.each() {
try {
templist += "$it.displayName is $it.currentRssi RSSI and $it.currentLqi% Link quality\n"
} catch (e) {
log.trace "Error checking status."
log.trace e
}
}
if (templist) {
section("Your Monitored Sensors...") {
paragraph templist.trim()
}
}
section("Select Sensors to monitor...") {
input "senors", "capability.signalStrength", title: "Select...", multiple: true, required: true, submitOnChange: true
}
}
}
def installed() {
log.trace "Installed with settings: ${settings}"
initialize()
}
def updated() {
log.trace "Updated with settings: ${settings}"
unsubscribe()
initialize()
}
def initialize() {
log.info "Network Monitor ${textVersion()} ${textCopyright()}"
schedule("22 32 6,19 1/1 * ?", sendStatus)
}
def sendStatus() {
log.trace "Checking Network"
sendEvent(linkText:app.label, name:"sendStatus", value:"Checking Network", descriptionText:"Checking Network", eventType:"SOLUTION_EVENT", displayed: true)
settings.senors.each() {
try {
log.trace "$it.displayName is $it.currentRssi RSSI and $it.currentLqi% Link quality"
sendEvent(linkText:app.label, name:"${it.displayName}", value:"${it.currentRssi} RSSI and ${it.currentLqi}% Link quality", descriptionText:"${it.displayName} is ${it.currentRssi} RSSI and ${it.currentLqi}% Link quality", eventType:"SOLUTION_EVENT", displayed: true)
}
catch (e) {
log.trace "Error checking status"
log.trace e
}
}
}
private def textVersion() {
def text = "Version 1.0"
}
private def textCopyright() {
def text = "Copyright © 2015 Sidjohn1"
}