SHARE
TWEET

Untitled

a guest Jul 22nd, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  *  Simulated Battery
  3.  *
  4.  *  Copyright 2019 josh
  5.  */
  6. metadata {
  7.     definition (name: "Simulated Battery", namespace: "sharptools-io", author: "josh", cstHandler: true) {
  8.             capability "Battery"
  9.             capability "Sensor"
  10.             capability "Actuator"
  11.             command "setLevel", ["NUMBER"]
  12.     }
  13.  
  14.  
  15.     simulator {
  16.         // TODO: define status and reply messages here
  17.     }
  18.  
  19.     tiles {
  20.         // TODO: define your main and details tiles here
  21.     }
  22. }
  23.  
  24. def installed(){
  25.     setLevel(100)
  26. }
  27.  
  28. // parse events into attributes
  29. def parse(String description) {
  30.     log.debug "Parsing '${description}'"
  31.     // TODO: handle 'battery' attribute
  32.  
  33. }
  34.  
  35. def setLevel(level){
  36.     level = level as int
  37.     log.debug "setLevel ${level}"
  38.     level = Math.max(Math.min(level, 99), 0)
  39.     sendEvent(name: "battery", value: level)
  40. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top