Created
July 12, 2014 02:45
-
-
Save ogiewon/45fabe1b8199ad7e668d to your computer and use it in GitHub Desktop.
Virtual to Arduino Multiplexer
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
/** | |
* Virtual to Arduino Multiplexer | |
* | |
* Copyright 2014 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. | |
* | |
*/ | |
definition( | |
name: "Virtual to Arduino Multiplexer", | |
namespace: "ogiewon", | |
author: "Daniel Ogorchock", | |
description: "Virtual to Arduino Multiplexer", | |
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") | |
preferences { | |
section("Connect these virtual switches to the Arduino's relays") { | |
input "leftdoor", title: "Left Garage Door Button", "capability.actuator" | |
input "rightdoor", title: "Right Garage Door Button", "capability.actuator" | |
} | |
section("Connect these virtual contact sesnor to the Arduino's sensors") { | |
input "frontdoor", title: "Virtual Contact for Front Door", "capability.contactSensor" | |
input "backdoor", title: "Virtual Contact for Back Door", "capability.contactSensor" | |
input "kitchendoor", title: "Virtual Contact for Kitchen Door", "capability.contactSensor" | |
input "garagesidedoor", title: "Virtual Contact for Garage Side Door", "capability.contactSensor" | |
} | |
section("Which Arduino board to control?") { | |
input "arduino", "capability.contactSensor" | |
//"device.ogiewonarduino" | |
} | |
} | |
def installed() { | |
log.debug "Installed with settings: ${settings}" | |
subscribe() | |
} | |
def updated() { | |
log.debug "Updated with settings: ${settings}" | |
unsubscribe() | |
subscribe() | |
} | |
def subscribe() { | |
subscribe(arduino, "leftDoor.open", leftDoorOpen) | |
subscribe(arduino, "leftDoor.opening", leftDoorOpening) | |
subscribe(arduino, "leftDoor.closed", leftDoorClosed) | |
subscribe(arduino, "leftDoor.closing", leftDoorClosing) | |
subscribe(leftdoor, "garagedoor.pushbutton", leftDoorPushButton) | |
subscribe(arduino, "rightDoor.open", rightDoorOpen) | |
subscribe(arduino, "rightDoor.opening", rightDoorOpening) | |
subscribe(arduino, "rightDoor.closed", rightDoorClosed) | |
subscribe(arduino, "rightDoor.closing", rightDoorClosing) | |
subscribe(rightdoor, "garagedoor.pushbutton", rightDoorPushButton) | |
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, "garagesideDoor.open", garagesideDoorOpen) | |
subscribe(arduino, "garagesideDoor.closed", garagesideDoorClosed) | |
} | |
def leftDoorOpen(evt) | |
{ | |
log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" | |
leftdoor.open() | |
} | |
def leftDoorOpening(evt) | |
{ | |
log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" | |
leftdoor.opening() | |
} | |
def leftDoorClosing(evt) | |
{ | |
log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" | |
leftdoor.closing() | |
} | |
def leftDoorClosed(evt) | |
{ | |
log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" | |
leftdoor.closed() | |
} | |
def leftDoorPushButton(evt) | |
{ | |
log.debug "virtualGarageDoor($evt.name: $evt.value: $evt.deviceId)" | |
arduino.pushLeft() | |
} | |
def rightDoorOpen(evt) | |
{ | |
log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" | |
rightdoor.open() | |
} | |
def rightDoorOpening(evt) | |
{ | |
log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" | |
rightdoor.opening() | |
} | |
def rightDoorClosing(evt) | |
{ | |
log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" | |
rightdoor.closing() | |
} | |
def rightDoorClosed(evt) | |
{ | |
log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" | |
rightdoor.closed() | |
} | |
def rightDoorPushButton(evt) | |
{ | |
log.debug "virtualGarageDoor($evt.name: $evt.value: $evt.deviceId)" | |
arduino.pushRight() | |
} | |
def frontDoorOpen(evt) | |
{ | |
log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" | |
frontdoor.openme() | |
} | |
def frontDoorClosed(evt) | |
{ | |
log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" | |
frontdoor.closeme() | |
} | |
def backDoorOpen(evt) | |
{ | |
log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" | |
backdoor.openme() | |
} | |
def backDoorClosed(evt) | |
{ | |
log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" | |
backdoor.closeme() | |
} | |
def kitchenDoorOpen(evt) | |
{ | |
log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" | |
kitchendoor.openme() | |
} | |
def kitchenDoorClosed(evt) | |
{ | |
log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" | |
kitchendoor.closeme() | |
} | |
def garagesideDoorOpen(evt) | |
{ | |
log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" | |
garagesidedoor.openme() | |
} | |
def garagesideDoorClosed(evt) | |
{ | |
log.debug "arduinoevent($evt.name: $evt.value: $evt.deviceId)" | |
garagesidedoor.closeme() | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment