mirror of
https://github.com/mtan93/SmartThingsPublic.git
synced 2026-04-25 14:23:06 +01:00
Compare commits
1 Commits
MSA-1522-1
...
MSA-1514-1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
56ff11c827 |
@@ -655,10 +655,6 @@ void lowerSetpoint() {
|
|||||||
void alterSetpoint(temp) {
|
void alterSetpoint(temp) {
|
||||||
|
|
||||||
def mode = device.currentValue("thermostatMode")
|
def mode = device.currentValue("thermostatMode")
|
||||||
|
|
||||||
if (mode == "off" || mode == "auto") {
|
|
||||||
log.warn "this mode: $mode does not allow alterSetpoint"
|
|
||||||
} else {
|
|
||||||
def heatingSetpoint = device.currentValue("heatingSetpoint")
|
def heatingSetpoint = device.currentValue("heatingSetpoint")
|
||||||
def coolingSetpoint = device.currentValue("coolingSetpoint")
|
def coolingSetpoint = device.currentValue("coolingSetpoint")
|
||||||
def deviceId = device.deviceNetworkId.split(/\./).last()
|
def deviceId = device.deviceNetworkId.split(/\./).last()
|
||||||
@@ -708,7 +704,6 @@ void alterSetpoint(temp) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
generateStatusEvent()
|
generateStatusEvent()
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def generateStatusEvent() {
|
def generateStatusEvent() {
|
||||||
|
|||||||
@@ -0,0 +1,96 @@
|
|||||||
|
/**
|
||||||
|
* Lights In My Home
|
||||||
|
*
|
||||||
|
* Copyright 2016 Maciej Urbanski
|
||||||
|
*
|
||||||
|
* 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: "Lights In My Home",
|
||||||
|
namespace: "lights-in-my-home",
|
||||||
|
author: "Maciej Urbanski",
|
||||||
|
description: "Controll lights in my home",
|
||||||
|
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",
|
||||||
|
oauth: true)
|
||||||
|
|
||||||
|
|
||||||
|
preferences {
|
||||||
|
preferences {
|
||||||
|
section ("Allow external service to control these things...") {
|
||||||
|
input "switches", "capability.switch", multiple: true, required: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mappings {
|
||||||
|
path("/switches") {
|
||||||
|
action: [
|
||||||
|
GET: "listSwitches"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
path("/switches/:command") {
|
||||||
|
action: [
|
||||||
|
PUT: "updateSwitches"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def installed() {
|
||||||
|
log.debug "Installed with settings: ${settings}"
|
||||||
|
|
||||||
|
initialize()
|
||||||
|
}
|
||||||
|
|
||||||
|
def updated() {
|
||||||
|
log.debug "Updated with settings: ${settings}"
|
||||||
|
|
||||||
|
unsubscribe()
|
||||||
|
initialize()
|
||||||
|
}
|
||||||
|
|
||||||
|
// returns a list like
|
||||||
|
// [[name: "kitchen lamp", value: "off"], [name: "bathroom", value: "on"]]
|
||||||
|
def listSwitches() {
|
||||||
|
def resp = []
|
||||||
|
switches.each {
|
||||||
|
resp << [name: it.displayName, value: it.currentValue("switch")]
|
||||||
|
}
|
||||||
|
return resp
|
||||||
|
}
|
||||||
|
|
||||||
|
void updateSwitches() {
|
||||||
|
// use the built-in request object to get the command parameter
|
||||||
|
def command = params.command
|
||||||
|
|
||||||
|
// all switches have the command
|
||||||
|
// execute the command on all switches
|
||||||
|
// (note we can do this on the array - the command will be invoked on every element
|
||||||
|
switch(command) {
|
||||||
|
case "on":
|
||||||
|
switches.on()
|
||||||
|
break
|
||||||
|
case "off":
|
||||||
|
switches.off()
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
httpError(400, "$command is not a valid command for all switches specified")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def initialize() {
|
||||||
|
// TODO: subscribe to attributes, devices, locations, etc.
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: implement event handlers
|
||||||
@@ -12,13 +12,13 @@
|
|||||||
*
|
*
|
||||||
* It's Too Hot
|
* It's Too Hot
|
||||||
*
|
*
|
||||||
* Author: SmartThings - zahir
|
* Author: SmartThings
|
||||||
*/
|
*/
|
||||||
definition(
|
definition(
|
||||||
name: "It's Too Hot",
|
name: "It's Too Hot",
|
||||||
namespace: "smartthings",
|
namespace: "smartthings",
|
||||||
author: "SmartThings",
|
author: "SmartThings",
|
||||||
description: "Monitor the temperature and when it rises above your setting get a notification and/or turn off underfloor heating.",
|
description: "Monitor the temperature and when it rises above your setting get a notification and/or turn on an A/C unit or fan.",
|
||||||
category: "Convenience",
|
category: "Convenience",
|
||||||
iconUrl: "https://s3.amazonaws.com/smartapp-icons/Meta/its-too-hot.png",
|
iconUrl: "https://s3.amazonaws.com/smartapp-icons/Meta/its-too-hot.png",
|
||||||
iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Meta/its-too-hot@2x.png"
|
iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Meta/its-too-hot@2x.png"
|
||||||
@@ -37,7 +37,7 @@ preferences {
|
|||||||
input "phone1", "phone", title: "Send a Text Message?", required: false
|
input "phone1", "phone", title: "Send a Text Message?", required: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
section("Turn off which A/C or fan...") {
|
section("Turn on which A/C or fan...") {
|
||||||
input "switch1", "capability.switch", required: false
|
input "switch1", "capability.switch", required: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -73,9 +73,9 @@ def temperatureHandler(evt) {
|
|||||||
// TODO: Send "Temperature back to normal" SMS, turn switch off
|
// TODO: Send "Temperature back to normal" SMS, turn switch off
|
||||||
} else {
|
} else {
|
||||||
log.debug "Temperature rose above $tooHot: sending SMS and activating $mySwitch"
|
log.debug "Temperature rose above $tooHot: sending SMS and activating $mySwitch"
|
||||||
def tempScale = location.temperatureScale ?: "C"
|
def tempScale = location.temperatureScale ?: "F"
|
||||||
send("${temperatureSensor1.displayName} is too hot, reporting a temperature of ${evt.value}${evt.unit?:tempScale}")
|
send("${temperatureSensor1.displayName} is too hot, reporting a temperature of ${evt.value}${evt.unit?:tempScale}")
|
||||||
switch1?.off()
|
switch1?.on()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user