Skip to content

Instantly share code, notes, and snippets.

@netsheriff
Created October 9, 2017 01:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save netsheriff/b50361d111b91b87fc640fec28139fc6 to your computer and use it in GitHub Desktop.
Save netsheriff/b50361d111b91b87fc640fec28139fc6 to your computer and use it in GitHub Desktop.
HUI Wall Switch Binder 1.0 for 3 Gang Switch
/**
* HUI Wall Switch Binder original from Andy's SmartApp - shamlessly borrowed by the netsheriff and modded.
* This app allows you to bind 3 Virtual On/Off Tiles to the 3 switchable outlets.
*
* Author: simic with mod by netsheriff
* Date: 05/09/2017
*/
// Automatically generated. Make future change here.
definition(
name: "HUI Wall Switch Binder 1.0 for 3 Gang Switch",
namespace: "",
author: "netsheriff",
description: "This app allows you to bind 3 Virtual On/Off Tiles to the 3 switchable outlets.",
category: "Convenience",
iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png",
iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience%402x.png")
preferences {
section("Which HUI Wall Switch is used?"){
input "strip", "capability.Switch"
}
section("Select a Virtual Switch to bind to Outlet 1"){
input "switch1", "capability.Switch"
}
section("Select a Virtual Switch to bind to Outlet 2"){
input "switch2", "capability.Switch"
}
section("Select a Virtual Switch to bind to Outlet 3"){
input "switch3", "capability.Switch"
}
}
def installed() {
log.debug "Installed with settings: ${settings}"
subscribe(strip, "switch.on", MainSwitchOnOneHandler)
subscribe(strip, "switch.off", MainSwitchOffOneHandler)
subscribe(strip, "switch1.on", MainSwitchOnOneHandler)
subscribe(strip, "switch1.off", MainSwitchOffOneHandler)
subscribe(strip, "switch2.on", MainSwitchOnTwoHandler)
subscribe(strip, "switch2.off", MainSwitchOffTwoHandler)
subscribe(strip, "switch3.on", MainSwitchOnThreeHandler)
subscribe(strip, "switch3.off", MainSwitchOffThreeHandler)
subscribe(switch1, "switch.on", switchOnOneHandler)
subscribe(switch2, "switch.on", switchOnTwoHandler)
subscribe(switch3, "switch.on", switchOnThreeHandler)
subscribe(switch1, "switch.off", switchOffOneHandler)
subscribe(switch2, "switch.off", switchOffTwoHandler)
subscribe(switch3, "switch.off", switchOffThreeHandler)
}
def updated(settings) {
log.debug "Updated with settings: ${settings}"
unsubscribe()
subscribe(strip, "switch.on", MainSwitchOnOneHandler)
subscribe(strip, "switch.off", MainSwitchOffOneHandler)
subscribe(strip, "switch1.on", MainSwitchOnOneHandler)
subscribe(strip, "switch1.off", MainSwitchOffOneHandler)
subscribe(strip, "switch2.on", MainSwitchOnTwoHandler)
subscribe(strip, "switch2.off", MainSwitchOffTwoHandler)
subscribe(strip, "switch3.on", MainSwitchOnThreeHandler)
subscribe(strip, "switch3.off", MainSwitchOffThreeHandler)
subscribe(switch1, "switch.on", switchOnOneHandler)
subscribe(switch2, "switch.on", switchOnTwoHandler)
subscribe(switch3, "switch.on", switchOnThreeHandler)
subscribe(switch1, "switch.off", switchOffOneHandler)
subscribe(switch2, "switch.off", switchOffTwoHandler)
subscribe(switch3, "switch.off", switchOffThreeHandler)
}
def MainSwitchOnOneHandler(evt) {
log.debug "switch on"
switch1.on()
}
def MainSwitchOffOneHandler(evt) {
log.debug "switch off"
switch1.off()
}
def MainSwitchOnTwoHandler(evt) {
log.debug "switch on"
switch2.on()
}
def MainSwitchOffTwoHandler(evt) {
log.debug "switch off"
switch2.off()
}
def MainSwitchOnThreeHandler(evt) {
log.debug "switch on"
switch3.on()
}
def MainSwitchOffThreeHandler(evt) {
log.debug "switch off"
switch3.off()
}
def switchOnOneHandler(evt) {
log.debug "switch on1"
strip.OneOn()
}
def switchOnTwoHandler(evt) {
log.debug "switch on2"
strip.TwoOn()
}
def switchOnThreeHandler(evt) {
log.debug "switch on3"
strip.ThreeOn()
}
def switchOffOneHandler(evt) {
log.debug "switch off1"
strip.OneOff()
}
def switchOffTwoHandler(evt) {
log.debug "switch off2"
strip.TwoOff()
}
def switchOffThreeHandler(evt) {
log.debug "switch off3"
strip.ThreeOff()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment