xetrok

3 Gang Smart App

Jul 18th, 2018
861
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2. * HUI Wall Switch Binder original from Andy's SmartApp - shamlessly borrowed by the netsheriff and modded.
  3. * This app allows you to bind 3 Virtual On/Off Tiles to the 3 switchable outlets.
  4. *
  5. * Author: simic with mod by netsheriff
  6. * Date: 05/09/2017
  7. */
  8. // Automatically generated. Make future change here.
  9. definition(
  10. name: "HUI Wall Switch Binder 1.1 for 3 Gang Switch",
  11. namespace: "",
  12. author: "netsheriff",
  13. description: "This app allows you to bind 3 Virtual On/Off Tiles to the 3 switchable outlets.",
  14. category: "Convenience",
  15. iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png",
  16. iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience%402x.png")
  17. preferences {
  18. section("Which HUI Wall Switch is used?"){
  19. input "strip", "capability.Switch"
  20. }
  21. section("Select a Virtual Switch to bind to Outlet 1"){
  22. input "switch1", "capability.Switch"
  23. }
  24. section("Select a Virtual Switch to bind to Outlet 2"){
  25. input "switch2", "capability.Switch"
  26. }
  27. section("Select a Virtual Switch to bind to Outlet 3"){
  28. input "switch3", "capability.Switch"
  29. }
  30. }
  31. def installed() {
  32. log.debug "Installed with settings: ${settings}"
  33. subscribe(strip, "switch.on", MainSwitchOnOneHandler)
  34. subscribe(strip, "switch.off", MainSwitchOffOneHandler)
  35. subscribe(strip, "switch1.on", MainSwitchOnOneHandler)
  36. subscribe(strip, "switch1.off", MainSwitchOffOneHandler)
  37. subscribe(strip, "switch2.on", MainSwitchOnTwoHandler)
  38. subscribe(strip, "switch2.off", MainSwitchOffTwoHandler)
  39. subscribe(strip, "switch3.on", MainSwitchOnThreeHandler)
  40. subscribe(strip, "switch3.off", MainSwitchOffThreeHandler)
  41.  
  42. subscribe(switch1, "switch.on", switchOnOneHandler)
  43. subscribe(switch2, "switch.on", switchOnTwoHandler)
  44. subscribe(switch3, "switch.on", switchOnThreeHandler)
  45. subscribe(switch1, "switch.off", switchOffOneHandler)
  46. subscribe(switch2, "switch.off", switchOffTwoHandler)
  47. subscribe(switch3, "switch.off", switchOffThreeHandler)
  48. }
  49. def updated(settings) {
  50. log.debug "Updated with settings: ${settings}"
  51. unsubscribe()
  52. subscribe(strip, "switch.on", MainSwitchOnOneHandler)
  53. subscribe(strip, "switch.off", MainSwitchOffOneHandler)
  54.  
  55. subscribe(strip, "switch1.on", MainSwitchOnOneHandler)
  56. subscribe(strip, "switch1.off", MainSwitchOffOneHandler)
  57.  
  58. subscribe(strip, "switch2.on", MainSwitchOnTwoHandler)
  59. subscribe(strip, "switch2.off", MainSwitchOffTwoHandler)
  60.  
  61. subscribe(strip, "switch3.on", MainSwitchOnThreeHandler)
  62. subscribe(strip, "switch3.off", MainSwitchOffThreeHandler)
  63.  
  64. subscribe(switch1, "switch.on", switchOnOneHandler)
  65. subscribe(switch2, "switch.on", switchOnTwoHandler)
  66. subscribe(switch3, "switch.on", switchOnThreeHandler)
  67.  
  68. subscribe(switch1, "switch.off", switchOffOneHandler)
  69. subscribe(switch2, "switch.off", switchOffTwoHandler)
  70. subscribe(switch3, "switch.off", switchOffThreeHandler)
  71. }
  72. def MainSwitchOnOneHandler(evt) {
  73. log.debug "switch on"
  74. switch1.on()
  75. }
  76. def MainSwitchOffOneHandler(evt) {
  77. log.debug "switch off"
  78. switch1.off()
  79. }
  80. def MainSwitchOnTwoHandler(evt) {
  81. log.debug "switch on"
  82. switch2.on()
  83. }
  84. def MainSwitchOffTwoHandler(evt) {
  85. log.debug "switch off"
  86. switch2.off()
  87. }
  88. def MainSwitchOnThreeHandler(evt) {
  89. log.debug "switch on"
  90. switch3.on()
  91. }
  92. def MainSwitchOffThreeHandler(evt) {
  93. log.debug "switch off"
  94. switch3.off()
  95. }
  96. def switchOnOneHandler(evt) {
  97. log.debug "switch on1"
  98. strip.on()
  99. }
  100. def switchOnTwoHandler(evt) {
  101. log.debug "switch on2"
  102. strip.on2()
  103. }
  104. def switchOnThreeHandler(evt) {
  105. log.debug "switch on3"
  106. strip.on3()
  107. }
  108. def switchOffOneHandler(evt) {
  109. log.debug "switch off1"
  110. strip.off()
  111. }
  112. def switchOffTwoHandler(evt) {
  113. log.debug "switch off2"
  114. strip.off2()
  115. }
  116. def switchOffThreeHandler(evt) {
  117. log.debug "switch off3"
  118. strip.off3()
  119. }
RAW Paste Data