mirror of
https://github.com/mtan93/SmartThingsPublic.git
synced 2026-03-10 13:21:52 +00:00
Compare commits
1 Commits
MSA-2114-4
...
MSA-2117-7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c0bdbf6abb |
@@ -1,180 +0,0 @@
|
||||
/**
|
||||
* Copyright 2015 SmartThings
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
metadata {
|
||||
definition (name: "FortrezZ Water Sensor", namespace: "fortrezz", author: "SmartThings") {
|
||||
capability "Water Sensor"
|
||||
capability "Sensor"
|
||||
capability "Battery"
|
||||
capability "Temperature Measurement"
|
||||
|
||||
fingerprint deviceId: "0x2001", inClusters: "0x30,0x9C,0x9D,0x85,0x80,0x72,0x31,0x84,0x86"
|
||||
fingerprint deviceId: "0x2101", inClusters: "0x71,0x70,0x85,0x80,0x72,0x31,0x84,0x86"
|
||||
}
|
||||
|
||||
simulator {
|
||||
status "dry": "command: 7105, payload: 00 00 00 FF 05 FE 00 00"
|
||||
status "wet": "command: 7105, payload: 00 FF 00 FF 05 02 00 00"
|
||||
status "overheated": "command: 7105, payload: 00 00 00 FF 04 02 00 00"
|
||||
status "freezing": "command: 7105, payload: 00 00 00 FF 04 05 00 00"
|
||||
status "normal": "command: 7105, payload: 00 00 00 FF 04 FE 00 00"
|
||||
for (int i = 0; i <= 100; i += 20) {
|
||||
status "battery ${i}%": new physicalgraph.zwave.Zwave().batteryV1.batteryReport(batteryLevel: i).incomingMessage()
|
||||
}
|
||||
}
|
||||
|
||||
tiles(scale: 2) {
|
||||
multiAttributeTile(name:"water", type: "generic", width: 6, height: 4){
|
||||
tileAttribute ("device.water", key: "PRIMARY_CONTROL") {
|
||||
attributeState "dry", label: "Dry", icon:"st.alarm.water.dry", backgroundColor:"#ffffff"
|
||||
attributeState "wet", label: "Wet", icon:"st.alarm.water.wet", backgroundColor:"#53a7c0"
|
||||
}
|
||||
}
|
||||
standardTile("temperatureState", "device.temperature", width: 2, height: 2) {
|
||||
state "normal", icon:"st.alarm.temperature.normal", backgroundColor:"#ffffff"
|
||||
state "freezing", icon:"st.alarm.temperature.freeze", backgroundColor:"#53a7c0"
|
||||
state "overheated", icon:"st.alarm.temperature.overheat", backgroundColor:"#F80000"
|
||||
}
|
||||
valueTile("temperature", "device.temperature", width: 2, height: 2) {
|
||||
state("temperature", label:'${currentValue}°',
|
||||
backgroundColors:[
|
||||
[value: 31, color: "#153591"],
|
||||
[value: 44, color: "#1e9cbb"],
|
||||
[value: 59, color: "#90d2a7"],
|
||||
[value: 74, color: "#44b621"],
|
||||
[value: 84, color: "#f1d801"],
|
||||
[value: 95, color: "#d04e00"],
|
||||
[value: 96, color: "#bc2323"]
|
||||
]
|
||||
)
|
||||
}
|
||||
valueTile("battery", "device.battery", decoration: "flat", inactiveLabel: false, width: 2, height: 2) {
|
||||
state "battery", label:'${currentValue}% battery', unit:""
|
||||
}
|
||||
main (["water", "temperatureState"])
|
||||
details(["water", "temperatureState", "temperature", "battery"])
|
||||
}
|
||||
}
|
||||
|
||||
def parse(String description) {
|
||||
def result = []
|
||||
def parsedZwEvent = zwave.parse(description, [0x30: 1, 0x71: 2, 0x84: 1])
|
||||
|
||||
if(parsedZwEvent) {
|
||||
if(parsedZwEvent.CMD == "8407") {
|
||||
def lastStatus = device.currentState("battery")
|
||||
def ageInMinutes = lastStatus ? (new Date().time - lastStatus.date.time)/60000 : 600
|
||||
log.debug "Battery status was last checked ${ageInMinutes} minutes ago"
|
||||
|
||||
if (ageInMinutes >= 600) {
|
||||
log.debug "Battery status is outdated, requesting battery report"
|
||||
result << new physicalgraph.device.HubAction(zwave.batteryV1.batteryGet().format())
|
||||
}
|
||||
result << new physicalgraph.device.HubAction(zwave.wakeUpV1.wakeUpNoMoreInformation().format())
|
||||
}
|
||||
result << createEvent( zwaveEvent(parsedZwEvent) )
|
||||
}
|
||||
if(!result) result = [ descriptionText: parsedZwEvent, displayed: false ]
|
||||
log.debug "Parse returned ${result}"
|
||||
return result
|
||||
}
|
||||
|
||||
def zwaveEvent(physicalgraph.zwave.commands.wakeupv1.WakeUpNotification cmd)
|
||||
{
|
||||
[descriptionText: "${device.displayName} woke up", isStateChange: false]
|
||||
}
|
||||
|
||||
def zwaveEvent(physicalgraph.zwave.commands.sensorbinaryv1.SensorBinaryReport cmd)
|
||||
{
|
||||
def map = [:]
|
||||
map.name = "water"
|
||||
map.value = cmd.sensorValue ? "wet" : "dry"
|
||||
map.descriptionText = "${device.displayName} is ${map.value}"
|
||||
map
|
||||
}
|
||||
|
||||
def zwaveEvent(physicalgraph.zwave.commands.batteryv1.BatteryReport cmd) {
|
||||
def map = [:]
|
||||
if(cmd.batteryLevel == 0xFF) {
|
||||
map.name = "battery"
|
||||
map.value = 1
|
||||
map.descriptionText = "${device.displayName} has a low battery"
|
||||
map.displayed = true
|
||||
} else {
|
||||
map.name = "battery"
|
||||
map.value = cmd.batteryLevel > 0 ? cmd.batteryLevel.toString() : 1
|
||||
map.unit = "%"
|
||||
map.displayed = false
|
||||
}
|
||||
map
|
||||
}
|
||||
|
||||
def zwaveEvent(physicalgraph.zwave.commands.alarmv2.AlarmReport cmd)
|
||||
{
|
||||
def map = [:]
|
||||
if (cmd.zwaveAlarmType == physicalgraph.zwave.commands.alarmv2.AlarmReport.ZWAVE_ALARM_TYPE_WATER) {
|
||||
map.name = "water"
|
||||
map.value = cmd.alarmLevel ? "wet" : "dry"
|
||||
map.descriptionText = "${device.displayName} is ${map.value}"
|
||||
}
|
||||
if(cmd.zwaveAlarmType == physicalgraph.zwave.commands.alarmv2.AlarmReport.ZWAVE_ALARM_TYPE_HEAT) {
|
||||
map.name = "temperatureState"
|
||||
if(cmd.zwaveAlarmEvent == 1) { map.value = "overheated"}
|
||||
if(cmd.zwaveAlarmEvent == 2) { map.value = "overheated"}
|
||||
if(cmd.zwaveAlarmEvent == 3) { map.value = "changing temperature rapidly"}
|
||||
if(cmd.zwaveAlarmEvent == 4) { map.value = "changing temperature rapidly"}
|
||||
if(cmd.zwaveAlarmEvent == 5) { map.value = "freezing"}
|
||||
if(cmd.zwaveAlarmEvent == 6) { map.value = "freezing"}
|
||||
if(cmd.zwaveAlarmEvent == 254) { map.value = "normal"}
|
||||
map.descriptionText = "${device.displayName} is ${map.value}"
|
||||
}
|
||||
|
||||
map
|
||||
}
|
||||
|
||||
def zwaveEvent(physicalgraph.zwave.commands.sensormultilevelv5.SensorMultilevelReport cmd)
|
||||
{
|
||||
def map = [:]
|
||||
if(cmd.sensorType == 1) {
|
||||
map.name = "temperature"
|
||||
if(cmd.scale == 0) {
|
||||
map.value = getTemperature(cmd.scaledSensorValue)
|
||||
} else {
|
||||
map.value = cmd.scaledSensorValue
|
||||
}
|
||||
map.unit = location.temperatureScale
|
||||
}
|
||||
map
|
||||
}
|
||||
|
||||
def zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicSet cmd)
|
||||
{
|
||||
def map = [:]
|
||||
map.name = "water"
|
||||
map.value = cmd.value ? "wet" : "dry"
|
||||
map.descriptionText = "${device.displayName} is ${map.value}"
|
||||
map
|
||||
}
|
||||
|
||||
def getTemperature(value) {
|
||||
if(location.temperatureScale == "C"){
|
||||
return value
|
||||
} else {
|
||||
return Math.round(celsiusToFahrenheit(value))
|
||||
}
|
||||
}
|
||||
|
||||
def zwaveEvent(physicalgraph.zwave.Command cmd)
|
||||
{
|
||||
log.debug "COMMAND CLASS: $cmd"
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
/**
|
||||
* FortrezZ MIMO2+ B-Side
|
||||
*
|
||||
* Copyright 2016 FortrezZ, LLC
|
||||
*
|
||||
* 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 MIMO2+ B-Side",
|
||||
namespace: "fortrezz",
|
||||
author: "FortrezZ, LLC",
|
||||
description: "Breaks the MIMO2 into two separate devices to allow automation on SIG2 and Relay 2.",
|
||||
category: "Convenience",
|
||||
iconUrl: "http://swiftlet.technology/wp-content/uploads/2016/05/logo-square-200-1.png",
|
||||
iconX2Url: "http://swiftlet.technology/wp-content/uploads/2016/05/logo-square-500.png",
|
||||
iconX3Url: "http://swiftlet.technology/wp-content/uploads/2016/05/logo-square.png",
|
||||
singleInstance: true)
|
||||
|
||||
|
||||
preferences {
|
||||
section("Title") {
|
||||
input(name: "devices", type: "capability.voltageMeasurement", title: "MIMO2 devices", description: null, required: true, submitOnChange: true, multiple: true)
|
||||
}
|
||||
}
|
||||
|
||||
def installed() {
|
||||
log.debug "Installed with settings: ${settings}"
|
||||
|
||||
initialize()
|
||||
}
|
||||
|
||||
def updated() {
|
||||
log.debug "Updated with settings: ${settings}"
|
||||
|
||||
unsubscribe()
|
||||
initialize()
|
||||
}
|
||||
|
||||
def initialize(){
|
||||
log.debug("Devices: ${settings.devices}")
|
||||
settings.devices.each {//deviceId ->
|
||||
subscribe(it, "powered", events)
|
||||
subscribe(it, "switch2", events)
|
||||
subscribe(it, "contact2", events)
|
||||
subscribe(it, "voltage2", events)
|
||||
subscribe(it, "relay2", events)
|
||||
subscribe(it, "anaDig2", events)
|
||||
|
||||
try {
|
||||
def existingDevice = getChildDevice(it.id)
|
||||
if(!existingDevice) {
|
||||
log.debug("Device ID: ${existingDevice}")
|
||||
def childDevice = addChildDevice("fortrezz", "FortrezZ MIMO2+ B-Side", it.id, null, [name: "Device.${it.id}", label: "${it.name} B-Side", completedSetup: true])
|
||||
}
|
||||
} catch (e) {
|
||||
log.error "Error creating device: ${e}"
|
||||
}
|
||||
}
|
||||
|
||||
getChildDevices().each {
|
||||
def test = it
|
||||
def search = settings.devices.find { getChildDevice(it.id).id == test.id }
|
||||
if(!search) {
|
||||
removeChildDevices(test)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def uninstalled() {
|
||||
removeChildDevices(getChildDevices())
|
||||
}
|
||||
|
||||
private removeChildDevices(delete) {
|
||||
delete.each {
|
||||
deleteChildDevice(it.deviceNetworkId)
|
||||
}
|
||||
}
|
||||
|
||||
def on2(child) {
|
||||
log.debug("on2")
|
||||
def ret = child
|
||||
settings.devices.each {//deviceId ->
|
||||
def ch = getChildDevice(it.id)
|
||||
if(child == ch.id) {
|
||||
ret = "${child}, ${it.id}"
|
||||
it.on2()
|
||||
}
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
def off2(child) {
|
||||
log.debug("off2")
|
||||
def ret = child
|
||||
settings.devices.each {//deviceId ->
|
||||
def ch = getChildDevice(it.id)
|
||||
if(child == ch.id) {
|
||||
ret = "${child}, ${it.id}"
|
||||
it.off2()
|
||||
}
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
def refresh2(child) {
|
||||
log.debug("refresh2")
|
||||
def ret = child
|
||||
settings.devices.each {//deviceId ->
|
||||
def ch = getChildDevice(it.id)
|
||||
if(child == ch.id) {
|
||||
ret = "${child}, ${it.id}"
|
||||
it.refresh()
|
||||
}
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
def events(evt) {
|
||||
def ch = getChildDevice(evt.device.id)
|
||||
ch.eventParse(evt);
|
||||
log.debug("${evt.device.id} triggered ${evt.name}")
|
||||
}
|
||||
// TODO: implement event handlers
|
||||
Reference in New Issue
Block a user