Compare commits

..

1 Commits

6 changed files with 94 additions and 38 deletions

View File

@@ -120,15 +120,6 @@ def configure() {
return cmd
}
def installed() {
initialize()
}
def updated() {
initialize()
}
def initialize() {
sendEvent(name: "numberOfButtons", value: 4)
}

View File

@@ -109,15 +109,6 @@ def configure() {
return cmds
}
def installed() {
initialize()
}
def updated() {
initialize()
}
def initialize() {
sendEvent(name: "numberOfButtons", value: 4)
}

View File

@@ -183,15 +183,6 @@ def updateState(String name, String value) {
device.updateDataValue(name, value)
}
def installed() {
initialize()
}
def updated() {
initialize()
}
def initialize() {
sendEvent(name: "numberOfButtons", value: 3)
}

View File

@@ -57,7 +57,6 @@ def parse(String description) {
private Map parseBasicMessage(description) {
def name = parseName(description)
def results = [:]
if (name != null) {
def value = parseValue(description)
def linkText = getLinkText(device)
@@ -65,7 +64,7 @@ private Map parseBasicMessage(description) {
def handlerName = value
def isStateChange = isStateChange(device, name, value)
results = [
def results = [
name : name,
value : value,
linkText : linkText,
@@ -74,6 +73,8 @@ private Map parseBasicMessage(description) {
isStateChange : isStateChange,
displayed : displayed(description, isStateChange)
]
} else {
results = [:]
}
log.debug "Parse returned $results.descriptionText"
return results

View File

@@ -126,15 +126,6 @@ private hold(button) {
sendEvent(name: "button", value: "held", data: [buttonNumber: button], descriptionText: "$device.displayName button $button was held", isStateChange: true)
}
def installed() {
initialize()
}
def updated() {
initialize()
}
def initialize() {
sendEvent(name: "numberOfButtons", value: 4)
}

View File

@@ -0,0 +1,91 @@
/**
* Switch Sync
*
* Copyright 2016 Kelly Kristek
*
* 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: "Switch Sync",
namespace: "Electricview",
author: "Kelly Kristek",
description: "This is an app that attempts to keep your virtual 3 way switches in sync regardless of where they are iniated from.\r\n",
category: "Convenience",
iconUrl: "http://i230.photobucket.com/albums/ee70/pickyassgamer/switchsyncsmall.png",
iconX2Url: "http://i230.photobucket.com/albums/ee70/pickyassgamer/switchsyncmedium.png",
iconX3Url: "http://i230.photobucket.com/albums/ee70/pickyassgamer/switchsync.png")
preferences {
section("Select Mains Switch") {
input "firstswitch", "capability.switch", required: true
}
section("Select AUX switch") {
input "secondswitch", "capability.switch", required: true
}
}
def installed() {
log.debug "Installed with settings: ${settings}"
initialize()
}
def updated() {
log.debug "Updated with settings: ${settings}"
unsubscribe()
initialize()
}
def initialize() {
subscribe(firstswitch, "switch.on", firstswitchon)
subscribe(firstswitch, "switch.off", firstswitchoff)
subscribe(secondswitch,"switch.on", secondswitchon)
subscribe(secondswitch,"switch.off", secondswitchoff)
}
def firstswitchon(evt){
log.debug "FirstSwitchOn called: $evt"
// Adding an if statement to verify the switch isn't already in the position we desire, to avoid endless loops
if( "off" == secondswitch.currentSwitch) {
secondswitch.on()
}
}
def firstswitchoff(evt){
log.debug "FirstSwitchOff called: $evt"
// Adding an if statement to verify the switch isn't already in the position we desire, to avoid endless loops
if ( "on" == secondswitch.currentSwitch){
secondswitch.off()
}
}
def secondswitchon(evt){
log.debug "SecondSwitchOn called: $evt"
// Adding an if statement to verify the switch isn't already in the position we desire, to avoid endless loops
if ( "off" == firstswitch.currentSwitch){
firstswitch.on()
}
}
def secondswitchoff(evt){
log.debug "SecondSwitchOff called: $evt"
// Adding an if statement to verify the switch isn't already in the position we desire, to avoid endless loops
if ( "on" == firstswitch.currentSwitch){
firstswitch.off()
}
}
// TODO: implement event handlers