Advertisement
Guest User

ACCEL

a guest
Nov 1st, 2018
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 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. definition (name: "Simulated Acceleration Sensor 4", namespace: "capabilities", author: "SmartThings") {
  16. capability "Acceleration Sensor"
  17.  
  18. command "SetActive"
  19. command "SetInactive"
  20. }
  21.  
  22. simulator {
  23. status "active": "acceleration:active"
  24. status "inactive": "acceleration:inactive"
  25. }
  26.  
  27.  
  28.  
  29. tiles {
  30. standardTile("acceleration", "device.acceleration", width: 2, height: 2) {
  31. state("inactive", label:'${name}', action: "SetActive", icon:"st.motion.acceleration.inactive", backgroundColor:"#cccccc")
  32. state("active", label:'${name}', action: "SetInactive", icon:"st.motion.acceleration.active", backgroundColor:"#00A0DC")
  33. }
  34.  
  35. main "acceleration"
  36. details "acceleration"
  37. }
  38. }
  39.  
  40. def parse(String description) {
  41. def pair = description.split(":")
  42. createEvent(name: pair[0].trim(), value: pair[1].trim())
  43. }
  44.  
  45. def SetActive() {
  46. log.trace "active()"
  47. sendEvent(name: "acceleration", value: "active")
  48. }
  49.  
  50. def SetInactive() {
  51. log.trace "inactive()"
  52. sendEvent(name: "acceleration", value: "inactive")
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement