xetrok

2 Gang Smart App

Jul 18th, 2018
286
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 2 Gang Switch",
  11. namespace: "",
  12. author: "netsheriff",
  13. description: "This app allows you to bind 2 Virtual On/Off Tiles to the 2 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. }
  28. def installed() {
  29. log.debug "Installed with settings: ${settings}"
  30. subscribe(strip, "switch.on", MainSwitchOnOneHandler)
  31. subscribe(strip, "switch.off", MainSwitchOffOneHandler)
  32. subscribe(strip, "switch1.on", MainSwitchOnOneHandler)
  33. subscribe(strip, "switch1.off", MainSwitchOffOneHandler)
  34. subscribe(strip, "switch2.on", MainSwitchOnTwoHandler)
  35. subscribe(strip, "switch2.off", MainSwitchOffTwoHandler)
  36.  
  37. subscribe(switch1, "switch.on", switchOnOneHandler)
  38. subscribe(switch2, "switch.on", switchOnTwoHandler)
  39. subscribe(switch1, "switch.off", switchOffOneHandler)
  40. subscribe(switch2, "switch.off", switchOffTwoHandler)
  41. }
  42. def updated(settings) {
  43. log.debug "Updated with settings: ${settings}"
  44. unsubscribe()
  45. subscribe(strip, "switch.on", MainSwitchOnOneHandler)
  46. subscribe(strip, "switch.off", MainSwitchOffOneHandler)
  47.  
  48. subscribe(strip, "switch1.on", MainSwitchOnOneHandler)
  49. subscribe(strip, "switch1.off", MainSwitchOffOneHandler)
  50.  
  51. subscribe(strip, "switch2.on", MainSwitchOnTwoHandler)
  52. subscribe(strip, "switch2.off", MainSwitchOffTwoHandler)
  53.  
  54. subscribe(switch1, "switch.on", switchOnOneHandler)
  55. subscribe(switch2, "switch.on", switchOnTwoHandler)
  56.  
  57. subscribe(switch1, "switch.off", switchOffOneHandler)
  58. subscribe(switch2, "switch.off", switchOffTwoHandler)
  59. }
  60. def MainSwitchOnOneHandler(evt) {
  61. log.debug "switch on"
  62. switch1.on()
  63. }
  64. def MainSwitchOffOneHandler(evt) {
  65. log.debug "switch off"
  66. switch1.off()
  67. }
  68. def MainSwitchOnTwoHandler(evt) {
  69. log.debug "switch on"
  70. switch2.on()
  71. }
  72. def MainSwitchOffTwoHandler(evt) {
  73. log.debug "switch off"
  74. switch2.off()
  75. }
  76. def switchOnOneHandler(evt) {
  77. log.debug "switch on1"
  78. strip.on()
  79. }
  80. def switchOnTwoHandler(evt) {
  81. log.debug "switch on2"
  82. strip.on2()
  83. }
  84. def switchOffOneHandler(evt) {
  85. log.debug "switch off1"
  86. strip.off()
  87. }
  88. def switchOffTwoHandler(evt) {
  89. log.debug "switch off2"
  90. strip.off2()
  91. }
RAW Paste Data