Skip to content

Instantly share code, notes, and snippets.

@paulwalko
Created July 12, 2016 22:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paulwalko/6034c1ec6a4756f0daa8daf1e477a863 to your computer and use it in GitHub Desktop.
Save paulwalko/6034c1ec6a4756f0daa8daf1e477a863 to your computer and use it in GitHub Desktop.
/**
* ST_Anything_Doors Device Type - ST_Anything_Doors.device.groovy
*
* Copyright 2015 Daniel Ogorchock
*
* 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.
*
* Change History:
*
* Date Who What
* ---- --- ----
* 2015-01-10 Dan Ogorchock Original Creation
*
*
*/
metadata {
definition (name: "ST_Anything", namespace: "ogiewon", author: "Daniel Ogorchock") {
capability "Window Shade"
attribute "pressure", "string"
attribute "supply", "string"
attribute "suction", "string"
attribute "return", "string"
attribute "value", "string"
attribute "heat stage 1", "string"
attribute "heat stage 2", "string"
attribute "compressor", "string"
attribute "fan", "string"
attribute "water", "string"
}
// Preferences
preferences {
input "temphumidSampleRate", "number", title: "Temperature/Humidity Sensors Sampling Interval (seconds)", description: "Sampling Interval (seconds)", defaultValue: 30, required: true, displayDuringSetup: true
}
// Tile Definitions
tiles {
valueTile("temperature1", "device.pressure", width: 1, height: 1, inactiveLabel: false, wordWrap: true) {
state "temperature", label: 'Pressure: ${currentValue}°F', unit:"F",
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("temperature2", "device.supply", width: 1, height: 1, inactiveLabel: false, wordWrap: true) {
state "temperature", label: 'Supply: ${currentValue}°F', unit:"F",
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("temperature3", "device.suction", width: 1, height: 1, inactiveLabel: false, wordWrap: true) {
state "temperature", label: 'Suction: ${currentValue}°F', unit:"F",
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("temperature4", "device.return", width: 1, height: 1, inactiveLabel: false, wordWrap: true) {
state "temperature", label: 'Return: ${currentValue}°F', unit:"F",
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"]
]
}
standardTile("valve", "device.valve", width: 1, height: 1, canChangeIcon: true, canChangeBackground: true) {
state "open", label:"Valve: OFF", icon:"st.contact.contact.open", backgroundColor:"#ffa81e"
state "closed", label:"Valve: ON", icon:"st.contact.contact.closed", backgroundColor:"#79b821"
}
standardTile("heat1", "device.heat1", width: 1, height: 1, canChangeIcon: true, canChangeBackground: true) {
state "open", label:"Heat Stage 1: OFF", icon:"st.contact.contact.open", backgroundColor:"#ffa81e"
state "closed", label:"Heat Stage 1: ON", icon:"st.contact.contact.closed", backgroundColor:"#79b821"
}
standardTile("heat2", "device.heat2", width: 1, height: 1, canChangeIcon: true, canChangeBackground: true) {
state "open", label:"Heat Stage 2: OFF", icon:"st.contact.contact.open", backgroundColor:"#ffa81e"
state "closed", label:"Heat Stage 2: ON", icon:"st.contact.contact.closed", backgroundColor:"#79b821"
}
standardTile("compressor", "device.compressor", width: 1, height: 1, canChangeIcon: true, canChangeBackground: true) {
state "open", label:"Compressor: OFF", icon:"st.contact.contact.open", backgroundColor:"#ffa81e"
state "closed", label:"Compressor: ON", icon:"st.contact.contact.closed", backgroundColor:"#79b821"
}
standardTile("fan", "device.fan", width: 1, height: 1, canChangeIcon: true, canChangeBackground: true) {
state "open", label:"Fan: OFF", icon:"st.contact.contact.open", backgroundColor:"#ffa81e"
state "closed", label:"Fan: ON", icon:"st.contact.contact.closed", backgroundColor:"#79b821"
}
standardTile("water", "device.water", width: 1, height: 1, canChangeIcon: true, canChangeBackground: true) {
state "open", label:"Water: DRY", icon:"st.contact.contact.open", backgroundColor:"#ffa81e"
state "closed", label:"Water: WET", icon:"st.contact.contact.closed", backgroundColor:"#79b821"
}
standardTile("configure", "device.configure", inactiveLabel: false, decoration: "flat") {
state "configure", label:'', action:"configuration.configure", icon:"st.secondary.configure"
}
main (["temperature1", "temperature2", "temperature3", "temperature4", "valve", "heat1", "heat2", "compressor", "fan", "water"])
details (["temperature1", "temperature2", "temperature3", "temperature4", "valve", "heat1", "heat2", "compressor", "fan", "water"])
}
}
// parse events into attributes
def parse(String description) {
//log.debug "Parsing '${description}'"
def msg = zigbee.parse(description)?.text
//log.debug "Parse got '${msg}'"
def parts = msg.split(" ")
def name = parts.length>0?parts[0].trim():null
def value = parts.length>1?parts[1].trim():null
name = value != "ping" ? name : null
if (name == "temperature1") {
name = "pressure"
state.pressure = value.toInteger()
} else if (name == "temperature2") {
name = "supply"
state.airDelta = state.return - value.toInteger()
} else if (name == "temperature3") {
name = "suction"
state.freonDelta = state.pressure - value.toInteger()
} else if (name == "temperature4") {
name = "return"
state.return = value.toInteger();
} else if (name == "heat1") {
name = "heat stage 1"
} else if (name == "heat2") {
name = "heat stage 2"
}
if (value == "open") {
value = 0
} else if (value == "closed") {
value = 1
}
def result = createEvent(name: name, value: value)
def result2 = createEvent(name: "freonDelta", value: state.freonDelta)
def result3 = createEvent(name: "airDelta", value: state.airDelta)
log.debug "Parsing Data ${result}"
log.debug "${name}: ${value}, freonDelta: ${state.freonDelta}, airDelta: ${state.airDelta}"
return [result, result2, result3]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment