mirror of
https://github.com/mtan93/SmartThingsPublic.git
synced 2026-03-09 05:11:52 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b44a03b90e |
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* Author: Fidure
|
||||
* Date: 2014-12-13
|
||||
* Updated: 2016-1-29
|
||||
* Updated: 2015-08-26
|
||||
*/
|
||||
metadata {
|
||||
// Automatically generated. Make future change here.
|
||||
@@ -207,8 +207,7 @@ def parse(String description) {
|
||||
case "0000":
|
||||
map.name = "temperature"
|
||||
map.value = getTemperature(atMap.value)
|
||||
result += createEvent("name":"displayTemperature", "value":
|
||||
getDisplayTemperature(atMap.value))
|
||||
result += createEvent("name":"displayTemperature", "value": getDisplayTemperature(atMap.value))
|
||||
break;
|
||||
case "0005":
|
||||
//log.debug "hex time: ${descMap.value}"
|
||||
@@ -228,7 +227,7 @@ def parse(String description) {
|
||||
case "0012":
|
||||
map.name = "heatingSetpoint"
|
||||
map.value = getDisplayTemperature(atMap.value)
|
||||
updateSetpoint(map.name,map.value)
|
||||
updateSetpoint(map.name,map.value)
|
||||
break;
|
||||
case "001c":
|
||||
map.name = "thermostatMode"
|
||||
@@ -299,7 +298,7 @@ def parseDescriptionAsMap(description) {
|
||||
def size = Long.parseLong(''+ map.get('size'), 16)
|
||||
def index = 12;
|
||||
def len
|
||||
|
||||
|
||||
//log.trace "processing multi attributes"
|
||||
while((index-12) < size) {
|
||||
attrId = flipHexStringEndianness(raw[index..(index+3)])
|
||||
@@ -314,9 +313,9 @@ def parseDescriptionAsMap(description) {
|
||||
list += ['attrId': "$attrId", 'encoding':"$encoding", 'value': "$value"]
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
list += ['attrId': "$attrId", 'encoding': "$encoding", 'value': "$value"]
|
||||
|
||||
|
||||
map.remove('value')
|
||||
map.remove('encoding')
|
||||
map.remove('attrId')
|
||||
@@ -340,9 +339,8 @@ def getDataLengthByType(t)
|
||||
"2a":3, "2b":4, "2c":5, "2d":6, "2e":7, "2f":8, "30":1, "31":2, "38":2, "39":4, "40":8, "e0":4, "e1":4, "e2":4,
|
||||
"e8":2, "e9":2, "ea":4, "f0":8, "f1":16]
|
||||
|
||||
// return number of hex chars if the type is not in the map,
|
||||
// then it's likely a malformed msg and should not be parsed
|
||||
return (map.get(t) ?: 256) * 2
|
||||
// return number of hex chars
|
||||
return map.get(t) * 2
|
||||
}
|
||||
|
||||
|
||||
@@ -379,13 +377,15 @@ def updateSetpoint(attrib, val)
|
||||
|
||||
def value = '--';
|
||||
|
||||
if (("heat" == mode && heat != null) ||
|
||||
("auto" == mode && runningMode == "heat" && heat != null))
|
||||
value = (attrib == "heatingSetpoint")? val : heat;
|
||||
else if (("cool" == mode && cool != null) || ("auto" == mode && runningMode == "cool" && cool != null))
|
||||
value = (attrib == "coolingSetpoint")? val : cool;
|
||||
|
||||
|
||||
if ("heat" == mode && heat != null)
|
||||
value = heat;
|
||||
else if ("cool" == mode && cool != null)
|
||||
value = cool;
|
||||
else if ("auto" == mode && runningMode == "cool" && cool != null)
|
||||
value = cool;
|
||||
else if ("auto" == mode && runningMode == "heat" && heat != null)
|
||||
value = heat;
|
||||
|
||||
sendEvent("name":"displaySetpoint", "value": value)
|
||||
}
|
||||
@@ -565,7 +565,7 @@ def convertToTime(data)
|
||||
def time = Integer.parseInt("$data", 16) as long;
|
||||
time *= 1000;
|
||||
time += 946684800000; // 481418694
|
||||
time -= location.timeZone.getOffset(date.getTime());
|
||||
time -= location.timeZone.getRawOffset() + location.timeZone.getDSTSavings();
|
||||
|
||||
def d = new Date(time);
|
||||
|
||||
@@ -611,14 +611,12 @@ def checkLastTimeSync(delay)
|
||||
if (!lastSync)
|
||||
lastSync = "${new Date(0)}"
|
||||
|
||||
if (!settings.sync_clock)
|
||||
{
|
||||
if (lastSync != new Date(0))
|
||||
{
|
||||
sendEvent("name":"lastTimeSync", "value":"${new Date(0)}")
|
||||
}
|
||||
return []
|
||||
}
|
||||
if (settings.sync_clock ?: false && lastSync != new Date(0))
|
||||
{
|
||||
sendEvent("name":"lastTimeSync", "value":"${new Date(0)}")
|
||||
}
|
||||
|
||||
|
||||
|
||||
long duration = (new Date()).getTime() - (new Date(lastSync)).getTime()
|
||||
|
||||
@@ -651,7 +649,7 @@ def refresh()
|
||||
{
|
||||
log.debug "refresh called"
|
||||
// log.trace "list: " + readAttributesCommand(0x201, [0x1C,0x1E,0x23])
|
||||
|
||||
|
||||
readAttributesCommand(0x201, [0x00,0x11,0x12]) +
|
||||
readAttributesCommand(0x201, [0x1C,0x1E,0x23]) +
|
||||
readAttributesCommand(0x201, [0x24,0x25,0x29]) +
|
||||
@@ -733,7 +731,7 @@ def setThermostatMode(String next) {
|
||||
def val = (getModeMap().find { it.value == next }?.key)?: "00"
|
||||
|
||||
// log.trace "mode changing to $next sending value: $val"
|
||||
|
||||
|
||||
sendEvent("name":"thermostatMode", "value":"$next")
|
||||
["st wattr 0x${device.deviceNetworkId} 1 0x201 0x1C 0x30 {$val}"] +
|
||||
refresh()
|
||||
@@ -807,31 +805,32 @@ def lock()
|
||||
//log.debug "current lock is: ${val}"
|
||||
|
||||
if (val == "00")
|
||||
val = getLockMap().find { it.value == (settings.lock_level ?: "Unlocked") }?.key
|
||||
val = getLockMap().find { it.value == (settings.lock_level ?: "Full") }?.key
|
||||
else
|
||||
val = "00"
|
||||
|
||||
["st wattr 0x${device.deviceNetworkId} 1 0x204 1 0x30 {${val}}",
|
||||
"st rattr 0x${device.deviceNetworkId} 1 0x204 0x01", "delay 500"]
|
||||
"st rattr 0x${device.deviceNetworkId} 1 0x204 0x01"
|
||||
|
||||
}
|
||||
|
||||
|
||||
def setThermostatTime()
|
||||
{
|
||||
|
||||
if (false == (settings.sync_clock ?: false))
|
||||
if ((settings.sync_clock ?: false))
|
||||
{
|
||||
log.debug "sync time is disabled, leaving"
|
||||
return []
|
||||
}
|
||||
|
||||
|
||||
Date date = new Date();
|
||||
String zone = location.timeZone.getRawOffset() + " DST " + location.timeZone.getDSTSavings();
|
||||
|
||||
long millis = date.getTime(); // Millis since Unix epoch
|
||||
millis -= 946684800000; // adjust for ZigBee EPOCH
|
||||
// adjust for time zone and DST offset
|
||||
millis += location.timeZone.getOffset(date.getTime());
|
||||
millis += location.timeZone.getRawOffset() + location.timeZone.getDSTSavings();
|
||||
//convert to seconds
|
||||
millis /= 1000;
|
||||
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
/**
|
||||
* Fortrezz siren test by open and close sensor
|
||||
*
|
||||
* Copyright 2016 Cz
|
||||
*
|
||||
* 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: "Fortrezz siren test by open and close sensor",
|
||||
namespace: "alarm",
|
||||
author: "Cz",
|
||||
description: "alarm",
|
||||
category: "My Apps",
|
||||
iconUrl: "https://static.wixstatic.com/media/15eeff_b050ea350d0f4733aa6a881660a2c49a.png/v1/fill/w_200,h_200,al_c/15eeff_b050ea350d0f4733aa6a881660a2c49a.png",
|
||||
iconX2Url: "https://static.wixstatic.com/media/15eeff_b050ea350d0f4733aa6a881660a2c49a.png/v1/fill/w_200,h_200,al_c/15eeff_b050ea350d0f4733aa6a881660a2c49a.png",
|
||||
iconX3Url: "https://static.wixstatic.com/media/15eeff_b050ea350d0f4733aa6a881660a2c49a.png/v1/fill/w_200,h_200,al_c/15eeff_b050ea350d0f4733aa6a881660a2c49a.png")
|
||||
|
||||
|
||||
preferences {
|
||||
section("Siren by open and close sensor")
|
||||
section("When Multipurpose Sencor do something"){
|
||||
input "theMultipurpose","capability.contactSensor",required:true,title:"which Multipurpose sensor?"
|
||||
}
|
||||
section("Siren or alarm"){
|
||||
input "theAlarm","capability.alarm",required:true,title:"which switch Siren or alarm?"
|
||||
}
|
||||
}
|
||||
|
||||
def installed() {
|
||||
log.debug "Installed with settings: ${settings}"
|
||||
|
||||
initialize()
|
||||
}
|
||||
|
||||
def updated() {
|
||||
log.debug "Updated with settings: ${settings}"
|
||||
|
||||
unsubscribe()
|
||||
initialize()
|
||||
}
|
||||
|
||||
def initialize() {
|
||||
subscribe(theMultipurpose,"contact",contactHandler)
|
||||
}
|
||||
def contactHandler(evt)
|
||||
{
|
||||
if(evt.value=="open")
|
||||
{
|
||||
//theAlarm.strobe()
|
||||
//theAlarm.siren()
|
||||
theAlarm.both()
|
||||
runIn(1,theAlarmoff)
|
||||
}
|
||||
else if(evt.value=="closed")
|
||||
{
|
||||
theAlarm.off()
|
||||
}
|
||||
}
|
||||
|
||||
def theAlarmoff()
|
||||
{
|
||||
theAlarm.off()
|
||||
}
|
||||
// TODO: implement event handlers
|
||||
67
smartapps/lock/lock-test.src/lock-test.groovy
Normal file
67
smartapps/lock/lock-test.src/lock-test.groovy
Normal file
@@ -0,0 +1,67 @@
|
||||
/**
|
||||
* Lock Test
|
||||
*
|
||||
* Copyright 2016 Cz
|
||||
*
|
||||
* 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: "Lock Test",
|
||||
namespace: "Lock",
|
||||
author: "Cz",
|
||||
description: "Lock Test",
|
||||
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")
|
||||
|
||||
|
||||
preferences {
|
||||
section("Turn on when motion detected:") {
|
||||
input "themotion", "capability.contactSensor", required: true, title: "Where?"
|
||||
}
|
||||
section("Turn on the lock") {
|
||||
input "thelock", "capability.lock", required: true,titel:"lock?"
|
||||
}
|
||||
}
|
||||
|
||||
def installed() {
|
||||
log.debug "Installed with settings: ${settings}"
|
||||
|
||||
initialize()
|
||||
}
|
||||
|
||||
def updated() {
|
||||
log.debug "Updated with settings: ${settings}"
|
||||
|
||||
unsubscribe()
|
||||
initialize()
|
||||
}
|
||||
|
||||
def initialize() {
|
||||
// TODO: subscribe to attributes, devices, locations, etc.
|
||||
subscribe(themotion, "contact", motionAction)
|
||||
}
|
||||
|
||||
def motionAction(evt)
|
||||
{
|
||||
if(evt.value=="open")
|
||||
{
|
||||
thelock.unlock()
|
||||
}
|
||||
else if(evt.value=="closed")
|
||||
{
|
||||
thelock.lock()
|
||||
}
|
||||
|
||||
log.debug "thelock:${thelock.lock}"
|
||||
}
|
||||
// TODO: implement event handlers
|
||||
Reference in New Issue
Block a user