Advertisement
Guest User

SHM

a guest
Nov 1st, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.61 KB | None | 0 0
  1. /**
  2. * Copyright 2015 SmartThings
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
  5. * in compliance with the License. You may obtain a copy of the License at:
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
  10. * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
  11. * for the specific language governing permissions and limitations under the License.
  12. *
  13. */
  14. metadata {
  15.  
  16. definition (name: "SHM Switch", namespace: "erocm123", author: "Eric Maycock") {
  17. capability "Switch"
  18. capability "Relay Switch"
  19. capability "Actuator"
  20.  
  21. command "onPhysical"
  22. command "offPhysical"
  23. }
  24.  
  25. tiles(scale: 2) {
  26. multiAttributeTile(name:"switch", type: "lighting", width: 6, height: 4, canChangeIcon: true){
  27. tileAttribute ("device.switch", key: "PRIMARY_CONTROL") {
  28. attributeState "off", label: "Disarmed", icon: "st.switches.light.off", backgroundColor: "#ffffff", nextState:"turningOn"
  29. attributeState "on", label: '${name}', icon: "st.switches.light.on", backgroundColor: "#00a0dc", nextState:"turningOff"
  30. attributeState "turningOff", label:"Armed", action:"switch.on", icon:"st.switches.light.off", backgroundColor:"#ffffff", nextState:"turningOn"
  31. attributeState "turningOn", label:'${name}', action:"switch.off", icon:"st.switches.light.on", backgroundColor:"#00a0dc", nextState:"turningOff"
  32. }
  33. }
  34. main "switch"
  35. details(["switch"])
  36. }
  37. }
  38.  
  39. def parse(String description) {
  40. //def pair = description.split(":")
  41. //createEvent(name: pair[0].trim(), value: pair[1].trim())
  42. }
  43.  
  44. def parse(Map description) {
  45. //def pair = description.split(":")
  46. //createEvent(name: pair[0].trim(), value: pair[1].trim())
  47. def eventMap
  48. if (description.type == null) eventMap = [name:"$description.name", value:"$description.value"]
  49. else eventMap = [name:"$description.name", value:"$description.value", type:"$description.type"]
  50. createEvent(eventMap)
  51. }
  52.  
  53. def on() {
  54. log.debug "$version on()"
  55. sendEvent(name: "switch", value: "on")
  56. }
  57.  
  58. def off() {
  59. log.debug "$version off()"
  60. sendEvent(name: "switch", value: "off")
  61. }
  62.  
  63. def onPhysical() {
  64. log.debug "$version onPhysical()"
  65. sendEvent(name: "switch", value: "on", type: "physical")
  66. }
  67.  
  68. def offPhysical() {
  69. log.debug "$version offPhysical()"
  70. sendEvent(name: "switch", value: "off", type: "physical")
  71. }
  72.  
  73. private getVersion() {
  74. "PUBLISHED"
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement