mirror of
https://github.com/mtan93/SmartThingsPublic.git
synced 2026-03-09 13:21:53 +00:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cb95adac4a | ||
|
|
c1422438ac | ||
|
|
8ed23f4c7e | ||
|
|
e7e6ea7d56 | ||
|
|
12896f4095 | ||
|
|
ab4e8a892a | ||
|
|
e076818573 | ||
|
|
cd8bbca5ee | ||
|
|
2d060bddfc |
@@ -0,0 +1,262 @@
|
||||
/**
|
||||
* Copyright 2015 Stuart Buchanan
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Zipato/Phileo PH-PSE02-EU Siren
|
||||
*
|
||||
* Author: fuzzysb
|
||||
* Date: 2015-01-05
|
||||
*/
|
||||
preferences {
|
||||
input "defaultSound", "enum", title: "Default Sound to use for the Siren?", options: ["Emergency","FireAlarm","Ambulance","PoliceCar","DoorChime"], required: false, defaultValue: "Emergency"
|
||||
}
|
||||
|
||||
|
||||
metadata {
|
||||
definition (name: "Zipato PH-PSE02-EU", namespace: "fuzzysb", author: "Stuart Buchanan") {
|
||||
capability "Actuator"
|
||||
capability "Alarm"
|
||||
capability "Switch"
|
||||
capability "Configuration"
|
||||
|
||||
command "Emergency"
|
||||
command "FireAlarm"
|
||||
command "Ambulance"
|
||||
command "PoliceCar"
|
||||
command "DoorChime"
|
||||
|
||||
fingerprint deviceId: "0x1005", inClusters: "0x5E,0x71,0x20,0x25,0x85,0x70,0x72,0x86,0x30,0x59,0x73,0x5A,0x98,0x7A"
|
||||
}
|
||||
|
||||
simulator {
|
||||
|
||||
}
|
||||
|
||||
tiles(scale: 2) {
|
||||
multiAttributeTile(name:"alarm", type: "generic", width: 6, height: 4){
|
||||
tileAttribute ("device.alarm", key: "PRIMARY_CONTROL") {
|
||||
attributeState "off", label:'off', action:'alarm.siren', icon:"st.alarm.alarm.alarm", backgroundColor:"#ffffff"
|
||||
attributeState "both", label:'alarm!', action:'alarm.off', icon:"st.alarm.alarm.alarm", backgroundColor:"#e86d13"
|
||||
}
|
||||
}
|
||||
standardTile("Emergency", "device.button", inactiveLabel: false, decoration: "flat", width: 1, height: 1) {
|
||||
state "default", label:'Emergency', action:"Emergency", icon:"st.Weather.weather1"
|
||||
}
|
||||
standardTile("FireAlarm", "device.button", inactiveLabel: false, decoration: "flat", width: 1, height: 1) {
|
||||
state "default", label:'Fire Alarm', action:"FireAlarm", icon:"st.Outdoor.outdoor10"
|
||||
}
|
||||
standardTile("Ambulance", "device.button", inactiveLabel: false, decoration: "flat", width: 1, height: 1) {
|
||||
state "default", label:'Ambulance', action:"Ambulance", icon:"st.Transportation.transportation2"
|
||||
}
|
||||
standardTile("PoliceCar", "device.button", inactiveLabel: false, decoration: "flat", width: 1, height: 1) {
|
||||
state "default", label:'Police Car', action:"PoliceCar", icon:"st.Transportation.transportation8"
|
||||
}
|
||||
standardTile("DoorChime", "device.button", inactiveLabel: false, decoration: "flat", width: 1, height: 1) {
|
||||
state "default", label:'Door Chime', action:"DoorChime", icon:"st.Home.home30"
|
||||
}
|
||||
standardTile("off", "device.button", inactiveLabel: false, decoration: "flat", width: 1, height: 1) {
|
||||
state "default", label:'', action:"alarm.off", icon:"st.secondary.off"
|
||||
}
|
||||
main "alarm"
|
||||
details(["alarm", "Emergency", "FireAlarm", "Ambulance", "PoliceCar", "DoorChime", "off"])
|
||||
}
|
||||
}
|
||||
|
||||
def parse(String description)
|
||||
{
|
||||
def result = null
|
||||
if (description.startsWith("Err 106")) {
|
||||
state.sec = 0
|
||||
result = createEvent( name: "secureInclusion", value: "failed", isStateChange: true,
|
||||
descriptionText: "This sensor failed to complete the network security key exchange. If you are unable to control it via SmartThings, you must remove it from your network and add it again.")
|
||||
} else if (description != "updated") {
|
||||
def cmd = zwave.parse(description, [0x20: 1, 0x25: 1, 0x26: 1, 0x70: 1, 0x80: 1])
|
||||
if (cmd) {
|
||||
result = zwaveEvent(cmd)
|
||||
log.debug "Parse returned ${result?.inspect()}"
|
||||
} else {
|
||||
log.debug("Couldn't zwave.parse '$description'")
|
||||
null
|
||||
}
|
||||
|
||||
}
|
||||
log.debug "Parsed '${description}' to ${result.inspect()}"
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
|
||||
def zwaveEvent(physicalgraph.zwave.commands.securityv1.SecurityMessageEncapsulation cmd) {
|
||||
def encapsulatedCommand = cmd.encapsulatedCommand([0x20: 1, 0x25: 3, 0x26: 3, 0x70: 1, 0x80: 1])
|
||||
state.sec = 1
|
||||
log.debug "encapsulated: ${encapsulatedCommand}"
|
||||
if (encapsulatedCommand) {
|
||||
zwaveEvent(encapsulatedCommand)
|
||||
} else {
|
||||
log.warn "Unable to extract encapsulated cmd from $cmd"
|
||||
createEvent(descriptionText: cmd.toString())
|
||||
}
|
||||
}
|
||||
|
||||
def zwaveEvent(physicalgraph.zwave.commands.securityv1.SecurityCommandsSupportedReport cmd) {
|
||||
response(configure())
|
||||
}
|
||||
|
||||
def zwaveEvent(physicalgraph.zwave.commands.configurationv1.ConfigurationReport cmd) {
|
||||
log.debug "---CONFIGURATION REPORT V2--- ${device.displayName} parameter ${cmd.parameterNumber} with a byte size of ${cmd.size} is set to ${cmd.configurationValue}"
|
||||
}
|
||||
|
||||
def zwaveEvent(physicalgraph.zwave.commands.switchbinaryv1.SwitchBinaryReport cmd)
|
||||
{
|
||||
[name: "switch", value: cmd.value ? "on" : "off", type: "digital", displayed: true, isStateChange: true]
|
||||
}
|
||||
|
||||
def zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicReport cmd) {
|
||||
log.debug "rx $cmd"
|
||||
[
|
||||
createEvent([name: "switch", value: cmd.value ? "on" : "off", displayed: false]),
|
||||
createEvent([name: "alarm", value: cmd.value ? "both" : "off"])
|
||||
]
|
||||
}
|
||||
|
||||
def zwaveEvent(physicalgraph.zwave.commands.sensorbinaryv2.SensorBinaryReport cmd) {
|
||||
createEvent(name:"Alarm", cmd.sensorValue ? "on" : "off")
|
||||
}
|
||||
|
||||
def zwaveEvent(physicalgraph.zwave.commands.notificationv3.NotificationReport cmd) {
|
||||
if (cmd.notificationType == 6 && cmd.event == 22) {
|
||||
log.debug "Playing Door Chime"
|
||||
} else if (cmd.notificationType == 10 && cmd.event == 1) {
|
||||
log.debug "Playing Police Car"
|
||||
} else if (cmd.notificationType == 10 && cmd.event == 3) {
|
||||
log.debug "Playing Ambulance"
|
||||
} else if (cmd.notificationType == 10 && cmd.event == 2) {
|
||||
log.debug "Playing Fire Alarm"
|
||||
} else if (cmd.notificationType == 7 && cmd.event == 1) {
|
||||
log.debug "Playing Emergency"
|
||||
}
|
||||
}
|
||||
|
||||
def zwaveEvent(physicalgraph.zwave.Command cmd) {
|
||||
log.debug "Unhandled: $cmd"
|
||||
createEvent(descriptionText: cmd.toString(), isStateChange: false)
|
||||
}
|
||||
|
||||
def strobe() {
|
||||
on()
|
||||
}
|
||||
|
||||
def siren() {
|
||||
on()
|
||||
}
|
||||
|
||||
def both() {
|
||||
on()
|
||||
}
|
||||
|
||||
|
||||
def on() {
|
||||
log.debug("Sounding Siren")
|
||||
switch ( settings.defaultSound ) {
|
||||
case "Emergency":
|
||||
Emergency()
|
||||
break
|
||||
|
||||
case "FireAlarm":
|
||||
FireAlarm()
|
||||
break
|
||||
|
||||
case "Ambulance":
|
||||
Ambulance()
|
||||
break
|
||||
|
||||
case "PoliceCar":
|
||||
PoliceCar()
|
||||
break
|
||||
|
||||
case "DoorChime":
|
||||
DoorChime()
|
||||
break
|
||||
|
||||
default:
|
||||
Emergency()
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
def off() {
|
||||
log.debug "sending off"
|
||||
[
|
||||
secure(zwave.basicV1.basicSet(value: 0x00)),
|
||||
secure(zwave.basicV1.basicGet())
|
||||
]
|
||||
}
|
||||
|
||||
def Emergency() {
|
||||
log.debug "Sounding Siren With Emergency"
|
||||
[
|
||||
secure(zwave.notificationV3.notificationReport(event: 0x01, notificationType: 0x07)),
|
||||
secure(zwave.basicV1.basicGet())
|
||||
]
|
||||
}
|
||||
|
||||
def FireAlarm() {
|
||||
log.debug "Sounding Siren With Fire Alarm"
|
||||
[
|
||||
secure(zwave.notificationV3.notificationReport(event: 0x02, notificationType: 0x0A)),
|
||||
secure(zwave.basicV1.basicGet())
|
||||
]
|
||||
}
|
||||
|
||||
def Ambulance() {
|
||||
log.debug "Sounding Siren With Ambulance"
|
||||
[
|
||||
secure(zwave.notificationV3.notificationReport(event: 0x03, notificationType: 0x0A)),
|
||||
secure(zwave.basicV1.basicGet())
|
||||
]
|
||||
}
|
||||
|
||||
def PoliceCar() {
|
||||
log.debug "Sounding Siren With Police Car"
|
||||
[
|
||||
secure(zwave.notificationV3.notificationReport(event: 0x01, notificationType: 0x0A)),
|
||||
secure(zwave.basicV1.basicGet())
|
||||
]
|
||||
}
|
||||
|
||||
def DoorChime() {
|
||||
log.debug "Sounding Siren With Door Chime"
|
||||
[
|
||||
secure(zwave.notificationV3.notificationReport(event: 0x16, notificationType: 0x06)),
|
||||
secure(zwave.basicV1.basicGet())
|
||||
]
|
||||
}
|
||||
|
||||
def configure() {
|
||||
log.debug "Resetting Siren Parameters to SmartThings Compatible Defaults"
|
||||
def cmds = []
|
||||
|
||||
cmds << zwave.configurationV1.configurationSet(configurationValue: [0], parameterNumber: 4, size: 1)
|
||||
cmds << zwave.configurationV1.configurationSet(configurationValue: [0], parameterNumber: 29, size: 1)
|
||||
cmds << zwave.configurationV1.configurationSet(configurationValue: [6], parameterNumber: 31, size: 1)
|
||||
|
||||
delayBetween(cmds, 500)
|
||||
}
|
||||
|
||||
private secure(physicalgraph.zwave.Command cmd) {
|
||||
if (state.sec) {
|
||||
log.debug "Sending Secure Command $cmd"
|
||||
zwave.securityV1.securityMessageEncapsulation().encapsulate(cmd).format()
|
||||
} else {
|
||||
log.debug "Sending Insecure Command $cmd"
|
||||
cmd.format()
|
||||
}
|
||||
}
|
||||
@@ -48,8 +48,8 @@ metadata {
|
||||
}
|
||||
|
||||
standardTile("motion", "device.motion") {
|
||||
state("active", label:'motion', icon:"st.motion.motion.active", backgroundColor:"#53a7c0")
|
||||
state("inactive", label:'no motion', icon:"st.motion.motion.inactive", backgroundColor:"#ffffff")
|
||||
state("active", label:'motion', icon:"st.motion.motion.active", backgroundColor:"#53a7c0")
|
||||
}
|
||||
|
||||
standardTile("refresh", "device.refresh", inactiveLabel: false, decoration: "flat") {
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
//DEPRECATED - Using the smartsense-motion-sensor.groovy DTH for this device. Users need to be moved before deleting this DTH
|
||||
|
||||
metadata {
|
||||
definition (name: "SmartSense Motion/Temp Sensor", namespace: "smartthings", author: "SmartThings") {
|
||||
capability "Motion Sensor"
|
||||
@@ -25,10 +27,6 @@ metadata {
|
||||
|
||||
command "enrollResponse"
|
||||
|
||||
fingerprint inClusters: "0000,0001,0003,0402,0500,0020,0B05", outClusters: "0019", manufacturer: "CentraLite", model: "3305-S"
|
||||
fingerprint inClusters: "0000,0001,0003,0402,0500,0020,0B05", outClusters: "0019", manufacturer: "CentraLite", model: "3305"
|
||||
fingerprint inClusters: "0000,0001,0003,0402,0500,0020,0B05", outClusters: "0019", manufacturer: "CentraLite", model: "3325"
|
||||
fingerprint inClusters: "0000,0001,0003,0402,0500,0020,0B05", outClusters: "0019", manufacturer: "CentraLite", model: "3326"
|
||||
}
|
||||
|
||||
simulator {
|
||||
@@ -233,7 +231,7 @@ private Map getBatteryResult(rawValue) {
|
||||
def volts = rawValue / 10
|
||||
def descriptionText
|
||||
|
||||
if (rawValue == 0) {}
|
||||
if (rawValue == 0 || rawValue == 255) {}
|
||||
else {
|
||||
if (volts > 3.5) {
|
||||
result.descriptionText = "${linkText} battery has too much power (${volts} volts)."
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
* for the specific language governing permissions and limitations under the License.
|
||||
*
|
||||
*/
|
||||
//DEPRECATED - Using the smartsense-multi-sensor.groovy DTH for this device. Users need to be moved before deleting this DTH
|
||||
|
||||
metadata {
|
||||
definition (name: "SmartSense Open/Closed Accelerometer Sensor", namespace: "smartthings", author: "SmartThings") {
|
||||
@@ -23,8 +24,7 @@
|
||||
capability "Refresh"
|
||||
capability "Temperature Measurement"
|
||||
command "enrollResponse"
|
||||
fingerprint inClusters: "0000,0001,0003,0402,0500,0020,0B05,FC02", outClusters: "0019", manufacturer: "CentraLite", model: "3320"
|
||||
fingerprint inClusters: "0000,0001,0003,0402,0500,0020,0B05,FC02", outClusters: "0019", manufacturer: "CentraLite", model: "3321"
|
||||
|
||||
}
|
||||
|
||||
simulator {
|
||||
@@ -225,7 +225,8 @@ def getTemperature(value) {
|
||||
|
||||
def volts = rawValue / 10
|
||||
def descriptionText
|
||||
if (volts > 3.5) {
|
||||
if (rawValue == 0 || rawValue == 255) {}
|
||||
else if (volts > 3.5) {
|
||||
result.descriptionText = "${linkText} battery has too much power (${volts} volts)."
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -220,7 +220,8 @@ private Map getBatteryResult(rawValue) {
|
||||
|
||||
def volts = rawValue / 10
|
||||
def descriptionText
|
||||
if (volts > 3.5) {
|
||||
if (rawValue == 0 || rawValue == 255) {}
|
||||
else if (volts > 3.5) {
|
||||
result.descriptionText = "${linkText} battery has too much power (${volts} volts)."
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -196,7 +196,8 @@ private Map getBatteryResult(rawValue) {
|
||||
|
||||
def volts = rawValue / 10
|
||||
def descriptionText
|
||||
if (volts > 3.5) {
|
||||
if (rawValue == 0 || rawValue == 255) {}
|
||||
else if (volts > 3.5) {
|
||||
result.descriptionText = "${linkText} battery has too much power (${volts} volts)."
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -44,7 +44,7 @@ metadata {
|
||||
attributeState "power", label:'${currentValue} W'
|
||||
}
|
||||
}
|
||||
standardTile("refresh", "device.switch", inactiveLabel: false, decoration: "flat", width: 2, height: 2) {
|
||||
standardTile("refresh", "device.refresh", inactiveLabel: false, decoration: "flat", width: 2, height: 2) {
|
||||
state "default", label:"", action:"refresh.refresh", icon:"st.secondary.refresh"
|
||||
}
|
||||
main "switch"
|
||||
|
||||
@@ -39,7 +39,7 @@ metadata {
|
||||
attributeState "level", action:"switch level.setLevel"
|
||||
}
|
||||
}
|
||||
standardTile("refresh", "device.switch", inactiveLabel: false, decoration: "flat", width: 2, height: 2) {
|
||||
standardTile("refresh", "device.refresh", inactiveLabel: false, decoration: "flat", width: 2, height: 2) {
|
||||
state "default", label:"", action:"refresh.refresh", icon:"st.secondary.refresh"
|
||||
}
|
||||
main "switch"
|
||||
|
||||
@@ -63,7 +63,7 @@ metadata {
|
||||
state "turningOn", label:'${name}', action:"switch.off", icon:"st.switches.switch.on", backgroundColor:"#79b821", nextState:"turningOff"
|
||||
state "turningOff", label:'${name}', action:"switch.on", icon:"st.switches.switch.off", backgroundColor:"#ffffff", nextState:"turningOn"
|
||||
}
|
||||
standardTile("refresh", "device.switch", inactiveLabel: false, decoration: "flat") {
|
||||
standardTile("refresh", "device.refresh", inactiveLabel: false, decoration: "flat") {
|
||||
state "default", label:"", action:"refresh.refresh", icon:"st.secondary.refresh"
|
||||
}
|
||||
controlTile("rgbSelector", "device.color", "color", height: 3, width: 3, inactiveLabel: false) {
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
valueTile("battery", "device.battery", inactiveLabel:false, decoration:"flat", width:2, height:2) {
|
||||
state "battery", label:'${currentValue}% battery', unit:""
|
||||
}
|
||||
standardTile("refresh", "device.lock", inactiveLabel:false, decoration:"flat", width:2, height:2) {
|
||||
standardTile("refresh", "device.refresh", inactiveLabel:false, decoration:"flat", width:2, height:2) {
|
||||
state "default", label:'', action:"refresh.refresh", icon:"st.secondary.refresh"
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ metadata {
|
||||
valueTile("colorTemp", "device.colorTemperature", inactiveLabel: false, decoration: "flat", width: 2, height: 2) {
|
||||
state "colorTemperature", label: '${currentValue} K'
|
||||
}
|
||||
standardTile("refresh", "device.switch", inactiveLabel: false, decoration: "flat", width: 2, height: 2) {
|
||||
standardTile("refresh", "device.refresh", inactiveLabel: false, decoration: "flat", width: 2, height: 2) {
|
||||
state "default", label:"", action:"refresh.refresh", icon:"st.secondary.refresh"
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ metadata {
|
||||
attributeState "power", label:'${currentValue} W'
|
||||
}
|
||||
}
|
||||
standardTile("refresh", "device.switch", inactiveLabel: false, decoration: "flat", width: 2, height: 2) {
|
||||
standardTile("refresh", "device.refresh", inactiveLabel: false, decoration: "flat", width: 2, height: 2) {
|
||||
state "default", label:"", action:"refresh.refresh", icon:"st.secondary.refresh"
|
||||
}
|
||||
main "switch"
|
||||
|
||||
@@ -42,7 +42,7 @@ metadata {
|
||||
attributeState "turningOff", label:'${name}', action:"switch.on", icon:"st.switches.light.off", backgroundColor:"#ffffff", nextState:"turningOn"
|
||||
}
|
||||
}
|
||||
standardTile("refresh", "device.switch", inactiveLabel: false, decoration: "flat", width: 2, height: 2) {
|
||||
standardTile("refresh", "device.refresh", inactiveLabel: false, decoration: "flat", width: 2, height: 2) {
|
||||
state "default", label:"", action:"refresh.refresh", icon:"st.secondary.refresh"
|
||||
}
|
||||
main "switch"
|
||||
|
||||
@@ -54,7 +54,7 @@ metadata {
|
||||
}
|
||||
}
|
||||
|
||||
standardTile("refresh", "device.switch", inactiveLabel: false, decoration: "flat", width: 2, height: 2) {
|
||||
standardTile("refresh", "device.refresh", inactiveLabel: false, decoration: "flat", width: 2, height: 2) {
|
||||
state "default", label:"", action:"refresh.refresh", icon:"st.secondary.refresh"
|
||||
}
|
||||
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
/**
|
||||
* Controlled Power Off
|
||||
*
|
||||
* Copyright 2016 Andrew Crow
|
||||
*
|
||||
* 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: "Controlled Power Off",
|
||||
namespace: "acrow311",
|
||||
author: "Andrew Crow",
|
||||
description: "Application used to power off devices that should be allowed to finish their cycle before being shut down such as air conditions and tankless water heaters. Application will monitor electric usage and delay shutdown until usage has returned to inactive state.",
|
||||
category: "My Apps",
|
||||
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",
|
||||
oauth: true)
|
||||
|
||||
|
||||
preferences {
|
||||
section("Shutdown when device not active") {
|
||||
input(name: "meter", type: "capability.powerMeter", title: "When This Power Meter...", required: true, multiple: false, description: null)
|
||||
input(name: "threshold", type: "number", title: "Reports Below...", required: true, description: "In watts, enter integer value")
|
||||
}
|
||||
}
|
||||
|
||||
def installed() {
|
||||
log.debug "Installed with settings: ${settings}"
|
||||
initialize()
|
||||
}
|
||||
|
||||
def updated() {
|
||||
log.debug "Updated with settings: ${settings}"
|
||||
initialize()
|
||||
}
|
||||
|
||||
def initialize() {
|
||||
unsubscribe()
|
||||
subscribe(meter, "power", meterHandler)
|
||||
}
|
||||
|
||||
def meterHandler(evt) {
|
||||
def meterValue = evt.value as double
|
||||
def thresholdValue = threshold as int
|
||||
def switchState = meter.currentValue("switch") == "on" // Get current switch status (on = true)
|
||||
|
||||
if (switchState) { // If the switch is already off, do nothing
|
||||
if (meterValue < thresholdValue) { // If the power consumption is low enough, turn off switch
|
||||
log.info "${meter} reported energy ${meterValue} below ${threshold}. Turning off switch."
|
||||
sendNotificationEvent("${meter} not running, shutting down.")
|
||||
meter.off()
|
||||
} else { // Power consumption too high - device connected to switch in use - do not shutdown.
|
||||
sendNotificationEvent("Power consumption too high to shut off ${meter}. Attempting again in a moment.")
|
||||
log.info "${meter} reported energy ${meterValue} above ${threshold}. Leaving switch on."
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -545,10 +545,15 @@ def updateSensorData() {
|
||||
def occupancy = ""
|
||||
it.capability.each {
|
||||
if (it.type == "temperature") {
|
||||
if (location.temperatureScale == "F") {
|
||||
temperature = Math.round(it.value.toDouble() / 10)
|
||||
if (it.value == "unknown") {
|
||||
temperature = "--"
|
||||
} else {
|
||||
temperature = convertFtoC(it.value.toDouble() / 10)
|
||||
if (location.temperatureScale == "F") {
|
||||
temperature = Math.round(it.value.toDouble() / 10)
|
||||
} else {
|
||||
temperature = convertFtoC(it.value.toDouble() / 10)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else if (it.type == "occupancy") {
|
||||
|
||||
Reference in New Issue
Block a user