Created
February 22, 2016 02:35
-
-
Save kacole2/15785c1749bfa69e777a to your computer and use it in GitHub Desktop.
ST_Anything_Doors_Multiplexer.smartapp.groovy (SmartApp)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* ST_Anything Doors Multiplexer - ST_Anything_Doors_Multiplexer.smartapp.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 | |
* 2015-01-11 Dan Ogorchock Reduced unnecessary chatter to the virtual devices | |
* 2015-01-18 Dan Ogorchock Added support for Virtual Temperature/Humidity Device | |
* | |
*/ | |
definition( | |
name: "ST_Anything Doors Multiplexer", | |
namespace: "ogiewon", | |
author: "Daniel Ogorchock", | |
description: "Connects single Arduino with multiple DoorControl and ContactSensor devices to their virtual device counterparts.", | |
category: "My Apps", | |
iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png", | |
iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/[email protected]", | |
iconX3Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/[email protected]") | |
preferences { | |
section("Select the House Doors (Virtual Contact Sensor devices)") { | |
input "frontdoor", title: "Virtual Contact Sensor for Front Door", "capability.contactSensor" | |
input "backdoor", title: "Virtual Contact Sensor for Back Door", "capability.contactSensor" | |
input "kitchendoor", title: "Virtual Contact Sensor for Kitchen Door", "capability.contactSensor" | |
input "familyRoomRearDoor", title: "Virtual Contact Sensor for Family Room Read Door", "capability.contactSensor" | |
input "familyRoomPatioDoors", title: "Virtual Contact Sensor for Family Room Patio Doors", "capability.contactSensor" | |
} | |
section("Select the House Windows (Virtual Contact Sensor devices)") { | |
input "basementWindows", title: "Virtual Contact Sensor for Basement Windows", "capability.contactSensor" | |
} | |
section("Select the Arduino ST_Anything_Doors device") { | |
input "arduino", "capability.contactSensor" | |
} | |
} | |
def installed() { | |
log.debug "Installed with settings: ${settings}" | |
subscribe() | |
} | |
def updated() { | |
log.debug "Updated with settings: ${settings}" | |
unsubscribe() | |
subscribe() | |
} | |
def subscribe() { | |
subscribe(arduino, "frontDoor.open", frontDoorOpen) | |
subscribe(arduino, "frontDoor.closed", frontDoorClosed) | |
subscribe(arduino, "backDoor.open", backDoorOpen) | |
subscribe(arduino, "backDoor.closed", backDoorClosed) | |
subscribe(arduino, "kitchenDoor.open", kitchenDoorOpen) | |
subscribe(arduino, "kitchenDoor.closed", kitchenDoorClosed) | |
subscribe(arduino, "familyRoomRearDoor.open", familyRoomRearDoorOpen) | |
subscribe(arduino, "familyRoomRearDoor.closed", familyRoomRearDoorClosed) | |
subscribe(arduino, "familyRoomPatioDoors.open", familyRoomPatioDoorsOpen) | |
subscribe(arduino, "familyRoomPatioDoors.closed", familyRoomPatioDoorsClosed) | |
subscribe(arduino, "basementWindows.open", basementWindowsOpen) | |
subscribe(arduino, "basementWindows.closed", basementWindowsClosed) | |
} | |
// --- Front Door --- | |
def frontDoorOpen(evt) | |
{ | |
if (frontdoor.currentValue("contact") != "open") { | |
log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" | |
frontdoor.openme() | |
} | |
} | |
def frontDoorClosed(evt) | |
{ | |
if (frontdoor.currentValue("contact") != "closed") { | |
log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" | |
frontdoor.closeme() | |
} | |
} | |
// --- back Door --- | |
def backDoorOpen(evt) | |
{ | |
if (backdoor.currentValue("contact") != "open") { | |
log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" | |
backdoor.openme() | |
} | |
} | |
def backDoorClosed(evt) | |
{ | |
if (backdoor.currentValue("contact") != "closed") { | |
log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" | |
backdoor.closeme() | |
} | |
} | |
// --- Kitchen Door --- | |
def kitchenDoorOpen(evt) | |
{ | |
if (kitchendoor.currentValue("contact") != "open") { | |
log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" | |
kitchendoor.openme() | |
} | |
} | |
def kitchenDoorClosed(evt) | |
{ | |
if (kitchendoor.currentValue("contact") != "closed") { | |
log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" | |
kitchendoor.closeme() | |
} | |
} | |
// --- Family Room Rear Door --- | |
def familyRoomRearDoorOpen(evt) | |
{ | |
if (familyRoomRearDoor.currentValue("contact") != "open") { | |
log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" | |
familyRoomRearDoor.openme() | |
} | |
} | |
def familyRoomRearDoorClosed(evt) | |
{ | |
if (familyRoomRearDoor.currentValue("contact") != "closed") { | |
log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" | |
familyRoomRearDoor.closeme() | |
} | |
} | |
// --- familyRoomPatioDoors --- | |
def familyRoomPatioDoorsOpen(evt) | |
{ | |
if (familyRoomPatioDoors.currentValue("contact") != "open") { | |
log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" | |
familyRoomPatioDoors.openme() | |
} | |
} | |
def familyRoomPatioDoorsClosed(evt) | |
{ | |
if (familyRoomPatioDoors.currentValue("contact") != "closed") { | |
log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" | |
familyRoomPatioDoors.closeme() | |
} | |
} | |
// --- basementWindows --- | |
def basementWindowsOpen(evt) | |
{ | |
if (basementWindows.currentValue("contact") != "open") { | |
log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" | |
basementWindows.openme() | |
} | |
} | |
def basementWindowsClosed(evt) | |
{ | |
if (basementWindows.currentValue("contact") != "closed") { | |
log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" | |
basementWindows.closeme() | |
} | |
} | |
def initialize() { | |
// TODO: subscribe to attributes, devices, locations, etc. | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment