mirror of
https://github.com/mtan93/SmartThingsPublic.git
synced 2026-04-05 06:13:08 +01:00
Initial commit
This commit is contained in:
@@ -0,0 +1,106 @@
|
||||
/**
|
||||
* Quirky-Wink-Eggtray-Device
|
||||
*
|
||||
* Author: todd@wackford.net
|
||||
* Date: 2014-02-22
|
||||
*
|
||||
*****************************************************************
|
||||
* Setup Namespace, acpabilities, attributes and commands
|
||||
*****************************************************************
|
||||
* Namespace: "wackford"
|
||||
*
|
||||
* Capabilities: "polling"
|
||||
* "refresh"
|
||||
*
|
||||
* Custom Attributes: "inventory"
|
||||
* "totalEggs"
|
||||
* "freshEggs"
|
||||
* "oldEggs"
|
||||
* "eggReport"
|
||||
*
|
||||
* Custom Commands: "eggReport"
|
||||
*
|
||||
*****************************************************************
|
||||
* Changes
|
||||
*****************************************************************
|
||||
* Change 1: 2014-02-26
|
||||
* Added egg report
|
||||
* implemented icons/tiles (thanks to Dane)
|
||||
*
|
||||
* Change 2: 2014-03-10
|
||||
* Documented Header
|
||||
*
|
||||
*****************************************************************
|
||||
* Code
|
||||
*****************************************************************
|
||||
*/
|
||||
// for the UI
|
||||
metadata {
|
||||
|
||||
definition(name:"Quirky Wink Eggtray", namespace:"wackford", author:"Todd Wackford") {
|
||||
|
||||
capability "Polling"
|
||||
capability "Refresh"
|
||||
capability "Sensor"
|
||||
|
||||
attribute "inventory", "enum", ["goodEggs","haveBadEgg","noEggs"]
|
||||
attribute "totalEggs", "number"
|
||||
attribute "freshEggs", "number"
|
||||
attribute "oldEggs", "number"
|
||||
|
||||
command "eggReport"
|
||||
}
|
||||
|
||||
tiles {
|
||||
standardTile("inventory", "device.inventory", width: 2, height: 2){
|
||||
state "goodEggs", label : " ", unit : "" , icon:"st.quirky.egg-minder.quirky-egg-device", backgroundColor: "#53a7c0"
|
||||
state "haveBadEgg", label : " ", unit : "" , icon:"st.quirky.egg-minder.quirky-egg-device", backgroundColor: "#FF1919"
|
||||
state "noEggs", label : " ", unit : "" , icon:"st.quirky.egg-minder.quirky-egg-device", backgroundColor: "#ffffff"
|
||||
}
|
||||
standardTile("totalEggs", "device.totalEggs", inactiveLabel: false){
|
||||
state "totalEggs", label : '${currentValue}', unit : "" , icon:"st.quirky.egg-minder.quirky-egg-count", backgroundColor: "#53a7c0"
|
||||
}
|
||||
standardTile("freshEggs", "device.freshEggs", inactiveLabel: false){
|
||||
state "freshEggs", label : '${currentValue}', unit : "" , icon:"st.quirky.egg-minder.quirky-egg-fresh", backgroundColor: "#53a7c0"
|
||||
}
|
||||
standardTile("oldEggs", "device.oldEggs", inactiveLabel: false){
|
||||
state "oldEggs", label : '${currentValue}', unit : "" , icon:"st.quirky.egg-minder.quirky-egg-expired", backgroundColor: "#53a7c0"
|
||||
}
|
||||
standardTile("eggReport", "device.eggReport", inactiveLabel: false, decoration: "flat"){
|
||||
state "eggReport", action: "eggReport", label : ' ', unit : "" , icon:"st.quirky.egg-minder.quirky-egg-report"
|
||||
}
|
||||
standardTile("refresh", "device.refresh", inactiveLabel: false, decoration: "flat") {
|
||||
state "default", action:"refresh.refresh", icon:"st.secondary.refresh"
|
||||
}
|
||||
}
|
||||
|
||||
main(["inventory", "totalEggs", "freshEggs", "oldEggs"])
|
||||
details(["inventory", "eggReport", "refresh", "totalEggs", "freshEggs", "oldEggs"])
|
||||
|
||||
}
|
||||
|
||||
// parse events into attributes
|
||||
def parse(description) {
|
||||
log.debug "parse() - $description"
|
||||
def results = []
|
||||
|
||||
if (description?.name && description?.value)
|
||||
{
|
||||
results << sendEvent(name: "${description?.name}", value: "${description?.value}")
|
||||
}
|
||||
}
|
||||
|
||||
def eggReport() {
|
||||
log.debug "Executing Egg Report"
|
||||
parent.runEggReport(this)
|
||||
}
|
||||
|
||||
def poll() {
|
||||
log.debug "Executing 'poll'"
|
||||
parent.poll(this)
|
||||
}
|
||||
|
||||
def refresh() {
|
||||
log.debug "Executing 'refresh'"
|
||||
parent.poll(this)
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Quirky-Wink-Nimbus-Device.groovy
|
||||
*
|
||||
* Author: todd@wackford.net
|
||||
* Date: 2014-02-22
|
||||
*
|
||||
*****************************************************************
|
||||
* Setup Namespace, acpabilities, attributes and commands
|
||||
*****************************************************************
|
||||
* Namespace: "wackford"
|
||||
*
|
||||
* Capabilities: "polling"
|
||||
* "refresh"
|
||||
*
|
||||
* Custom Attributes: "dial"
|
||||
* "info"
|
||||
*
|
||||
* Custom Commands: "none"
|
||||
*
|
||||
*****************************************************************
|
||||
* Changes
|
||||
*****************************************************************
|
||||
*
|
||||
* Change 1: 2014-03-10
|
||||
* Documented Header
|
||||
*
|
||||
*****************************************************************
|
||||
* Code
|
||||
*****************************************************************
|
||||
*/
|
||||
// for the UI
|
||||
metadata {
|
||||
|
||||
definition(name:"Quirky Wink Nimbus", namespace:"wackford", author:"Todd Wackford") {
|
||||
|
||||
capability "Polling"
|
||||
capability "Refresh"
|
||||
capability "Sensor"
|
||||
|
||||
attribute "dial", "string"
|
||||
attribute "info", "string"
|
||||
}
|
||||
|
||||
tiles {
|
||||
standardTile("dial", "device.dial", width: 2, height: 2){
|
||||
state("dial", label : '${currentValue}', unit : "", icon:"st.custom.quirky.quirky-device" )
|
||||
}
|
||||
valueTile("info", "device.info", inactiveLabel: false, decoration: "flat") {
|
||||
state "info", label:'Dial is displaying ${currentValue}', unit:""
|
||||
}
|
||||
standardTile("refresh", "device.refresh", inactiveLabel: false, decoration: "flat") {
|
||||
state "default", action:"refresh.refresh", icon:"st.secondary.refresh"
|
||||
}
|
||||
}
|
||||
main(["dial"])
|
||||
details(["dial","info","refresh" ])
|
||||
}
|
||||
|
||||
// parse events into attributes
|
||||
def parse(description) {
|
||||
log.debug "parse() - $description"
|
||||
def results = []
|
||||
|
||||
if (description?.name && description?.value)
|
||||
{
|
||||
results << sendEvent(name: "${description?.name}", value: "${description?.value}")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
def poll() {
|
||||
log.debug "Nimbus executing 'pollNimbus'"
|
||||
parent.pollNimbus(this)
|
||||
}
|
||||
|
||||
def refresh() {
|
||||
log.debug "Nimbus executing 'refresh'"
|
||||
parent.pollNimbus(this)
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
/* Quirky-Wink-Porkfolio-Device.groovy
|
||||
*
|
||||
* Author: todd@wackford.net
|
||||
* Date: 2014-02-22
|
||||
*
|
||||
*****************************************************************
|
||||
* Setup Namespace, acpabilities, attributes and commands
|
||||
*****************************************************************
|
||||
* Namespace: "wackford"
|
||||
*
|
||||
* Capabilities: "acceleration"
|
||||
* "battery"
|
||||
* "polling"
|
||||
* "refresh"
|
||||
*
|
||||
* Custom Attributes: "balance"
|
||||
* "goal"
|
||||
*
|
||||
* Custom Commands: "none"
|
||||
*
|
||||
*****************************************************************
|
||||
* Changes
|
||||
*****************************************************************
|
||||
*
|
||||
* Change 1: 2014-03-10
|
||||
* Documented Header
|
||||
*
|
||||
*****************************************************************
|
||||
* Code
|
||||
*****************************************************************
|
||||
*/
|
||||
metadata {
|
||||
|
||||
definition(name:"Quirky Wink Porkfolio", namespace:"wackford", author:"Todd Wackford") {
|
||||
|
||||
capability "Acceleration Sensor"
|
||||
capability "Battery"
|
||||
capability "Polling"
|
||||
capability "Refresh"
|
||||
capability "Sensor"
|
||||
|
||||
attribute "balance", "string"
|
||||
attribute "goal", "string"
|
||||
}
|
||||
|
||||
tiles {
|
||||
standardTile("acceleration", "device.acceleration", width: 2, height: 2, canChangeIcon: true) {
|
||||
state "inactive", label:'pig secure', icon:"st.motion.acceleration.inactive", backgroundColor:"#44b621"
|
||||
state "active", label:'pig alarm', icon:"st.motion.acceleration.active", backgroundColor:"#FF1919"
|
||||
}
|
||||
standardTile("balance", "device.balance", inactiveLabel: false, canChangeIcon: true) {
|
||||
state "balance", label:'${currentValue}', unit:"", icon:"st.Food & Dining.dining18"
|
||||
}
|
||||
standardTile("goal", "device.goal", inactiveLabel: false, decoration: "flat", canChangeIcon: true) {
|
||||
state "goal", label:'${currentValue} goal', unit:"", icon:"st.Weather.weather2"
|
||||
}
|
||||
standardTile("refresh", "device.refresh", inactiveLabel: false, decoration: "flat") {
|
||||
state "default", action:"refresh.refresh", icon:"st.secondary.refresh"
|
||||
}
|
||||
}
|
||||
main(["acceleration", "balance"])
|
||||
details(["acceleration", "balance", "goal", "refresh" ])
|
||||
}
|
||||
|
||||
// parse events into attributes
|
||||
def parse(description) {
|
||||
log.debug "parse() - $description"
|
||||
def results = []
|
||||
|
||||
if (description?.name && description?.value)
|
||||
{
|
||||
results << sendEvent(name: "${description?.name}", value: "${description?.value}")
|
||||
}
|
||||
}
|
||||
|
||||
def poll() {
|
||||
log.debug "Executing 'poll'"
|
||||
parent.poll(this)
|
||||
}
|
||||
|
||||
def refresh() {
|
||||
log.debug "Executing 'refresh'"
|
||||
parent.poll(this)
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
/* Quirky-Wink-Powerstrip-Device.groovy
|
||||
*
|
||||
* Author: todd@wackford.net
|
||||
* Date: 2014-01-28
|
||||
*
|
||||
*****************************************************************
|
||||
* Setup Namespace, acpabilities, attributes and commands
|
||||
*****************************************************************
|
||||
* Namespace: "wackford"
|
||||
*
|
||||
* Capabilities: "switch"
|
||||
* "polling"
|
||||
* "refresh"
|
||||
*
|
||||
* Custom Attributes: "none"
|
||||
*
|
||||
* Custom Commands: "none"
|
||||
*
|
||||
*****************************************************************
|
||||
* Changes
|
||||
*****************************************************************
|
||||
*
|
||||
* Change 1: 2014-03-10
|
||||
* Documented Header
|
||||
*
|
||||
*****************************************************************
|
||||
* Code
|
||||
*****************************************************************
|
||||
*/
|
||||
// for the UI
|
||||
metadata {
|
||||
|
||||
definition(name:"Quirky Wink Powerstrip", namespace:"wackford", author:"Todd Wackford") {
|
||||
|
||||
capability "Switch"
|
||||
capability "Polling"
|
||||
capability "Refresh"
|
||||
capability "Sensor"
|
||||
capability "Actuator"
|
||||
}
|
||||
|
||||
simulator {
|
||||
// TODO: define status and reply messages here
|
||||
}
|
||||
|
||||
tiles {
|
||||
standardTile("switch", "device.switch", width: 2, height: 2, canChangeIcon: true) {
|
||||
state "off", label: '${name}', action: "switch.on", icon: "st.switches.switch.off", backgroundColor: "#ffffff"
|
||||
state "on", label: '${name}', action: "switch.off", icon: "st.switches.switch.on", backgroundColor: "#79b821"
|
||||
}
|
||||
standardTile("refresh", "device.refresh", inactiveLabel: false, decoration: "flat") {
|
||||
state "default", action:"refresh.refresh", icon:"st.secondary.refresh"
|
||||
}
|
||||
}
|
||||
main(["switch"])
|
||||
details(["switch", "refresh" ])
|
||||
}
|
||||
|
||||
|
||||
// parse events into attributes
|
||||
def parse(description) {
|
||||
log.debug "parse() - $description"
|
||||
def results = []
|
||||
|
||||
if (description?.name && description?.value)
|
||||
{
|
||||
results << sendEvent(name: "${description?.name}", value: "${description?.value}")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// handle commands
|
||||
def on() {
|
||||
log.debug "Executing 'on'"
|
||||
log.debug this
|
||||
parent.on(this)
|
||||
}
|
||||
|
||||
def off() {
|
||||
log.debug "Executing 'off'"
|
||||
parent.off(this)
|
||||
}
|
||||
|
||||
def poll() {
|
||||
log.debug "Executing 'poll'"
|
||||
parent.pollOutlet(this)
|
||||
}
|
||||
|
||||
def refresh() {
|
||||
log.debug "Executing 'refresh'"
|
||||
poll()
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
/**
|
||||
* Quirky-Wink-Spotter-Device.groovy
|
||||
*
|
||||
* Author: todd@wackford.net
|
||||
* Date: 2014-02-19
|
||||
*
|
||||
*****************************************************************
|
||||
* Setup Namespace, capabilities, attributes and commands
|
||||
*****************************************************************
|
||||
* Namespace: "wackford"
|
||||
*
|
||||
* Capabilities: "Polling"
|
||||
* "Battery"
|
||||
* "Temperature Measurement"
|
||||
* "Acceleration Sensor"
|
||||
* "Refresh"
|
||||
* "Motion Sensor"
|
||||
* "Relative Humidity Measurement"
|
||||
*
|
||||
* Custom Attributes: "sound"
|
||||
* "light"
|
||||
* "powerSource"
|
||||
*
|
||||
* Custom Commands: "none"
|
||||
*
|
||||
*****************************************************************
|
||||
* Changes
|
||||
*****************************************************************
|
||||
*
|
||||
* Change 1: 2014-03-10
|
||||
* Documented Header
|
||||
*
|
||||
*****************************************************************
|
||||
* Code
|
||||
*****************************************************************
|
||||
*/
|
||||
// for the UI
|
||||
metadata {
|
||||
definition(name:"Quirky Wink Spotter", namespace:"wackford", author:"Todd Wackford") {
|
||||
|
||||
capability "Polling"
|
||||
capability "Battery"
|
||||
capability "Temperature Measurement"
|
||||
capability "Acceleration Sensor"
|
||||
capability "Refresh"
|
||||
capability "Motion Sensor"
|
||||
capability "Relative Humidity Measurement"
|
||||
capability "Sensor"
|
||||
|
||||
attribute "sound", "enum", ["active","inactive"]
|
||||
attribute "light", "enum", ["active","inactive"]
|
||||
attribute "powerSource", "enum", ["powered","battery"]
|
||||
}
|
||||
|
||||
tiles {
|
||||
standardTile("acceleration", "device.acceleration", width: 2, height: 2, canChangeIcon: true) {
|
||||
state "active", label:'active', icon:"st.motion.acceleration.active", backgroundColor:"#53a7c0"
|
||||
state "inactive", label:'inactive', icon:"st.motion.acceleration.inactive", backgroundColor:"#ffffff"
|
||||
}
|
||||
valueTile("temperature", "device.temperature", canChangeIcon: false)
|
||||
{
|
||||
state("temperature", label : '${currentValue}°', unit : "F",
|
||||
backgroundColors:[
|
||||
[value: 31, color: "#153591"],
|
||||
[value: 44, color: "#1e9cbb"],
|
||||
[value: 59, color: "#90d2a7"],
|
||||
[value: 74, color: "#44b621"],
|
||||
[value: 84, color: "#f1d801"],
|
||||
[value: 95, color: "#d04e00"],
|
||||
[value: 96, color: "#bc2323"]
|
||||
]
|
||||
)
|
||||
}
|
||||
valueTile("humidity", "device.humidity", inactiveLabel: false, canChangeIcon: false) {
|
||||
state "humidity", label:'${currentValue}% RH', unit:""
|
||||
}
|
||||
standardTile("sound", "device.sound", inactiveLabel: false) {
|
||||
state "active", label: "noise", unit:"", icon: "st.alarm.beep.beep", backgroundColor: "#53a7c0"
|
||||
state "inactive", label: "quiet", unit:"", icon: "st.alarm.beep.beep", backgroundColor: "#ffffff"
|
||||
}
|
||||
standardTile("light", "device.light", inactiveLabel: false, canChangeIcon: true) {
|
||||
state "active", label: "light", unit:"", icon: "st.illuminance.illuminance.bright", backgroundColor: "#53a7c0"
|
||||
state "inactive", label: "dark", unit:"", icon: "st.illuminance.illuminance.dark", backgroundColor: "#B2B2B2"
|
||||
}
|
||||
valueTile("battery", "device.battery", decoration: "flat", inactiveLabel: false, canChangeIcon: false) {
|
||||
state "battery", label: '${currentValue}% battery'
|
||||
}
|
||||
standardTile("powerSource", "device.powerSource", inactiveLabel: false, canChangeIcon: true) {
|
||||
state "powered", label: "powered", icon: "st.switches.switch.on", backgroundColor: "#79b821"
|
||||
state "battery", label: "battery", icon: "st.switches.switch.on", backgroundColor: "#ffa81e"
|
||||
}
|
||||
standardTile("refresh", "device.temperature", inactiveLabel: false, decoration: "flat") {
|
||||
state "default", action:"refresh.refresh", icon:"st.secondary.refresh"
|
||||
}
|
||||
}
|
||||
main(["acceleration", "temperature", "humidity", "sound", "light", "powerSource"])
|
||||
details(["acceleration", "temperature", "humidity", "sound", "light", "powerSource", "battery", "refresh" ])
|
||||
}
|
||||
|
||||
// parse events into attributes
|
||||
def parse(description) {
|
||||
log.debug "parse() - $description"
|
||||
def results = []
|
||||
|
||||
if (description?.name && description?.value)
|
||||
{
|
||||
results << sendEvent(name: "${description?.name}", value: "${description?.value}")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
def poll() {
|
||||
log.debug "Executing 'poll'"
|
||||
parent.poll(this)
|
||||
}
|
||||
|
||||
def refresh() {
|
||||
log.debug "Executing 'refresh'"
|
||||
parent.poll(this)
|
||||
}
|
||||
228
devicetypes/wackford/tcp-bulb.src/tcp-bulb.groovy
Normal file
228
devicetypes/wackford/tcp-bulb.src/tcp-bulb.groovy
Normal file
@@ -0,0 +1,228 @@
|
||||
/**
|
||||
* TCP Bulb.groovy
|
||||
*
|
||||
* Author: todd@wackford.net
|
||||
* Date: 2014-03-07
|
||||
*
|
||||
*
|
||||
*****************************************************************
|
||||
* Changes
|
||||
*****************************************************************
|
||||
*
|
||||
* Change 1: 2014-03-10
|
||||
* Documented Header
|
||||
*
|
||||
* Change 2: 2014-03-15
|
||||
* Fixed bug where we weren't coming on when changing
|
||||
* levels down.
|
||||
*
|
||||
* Change 3: 2014-04-02 (lieberman)
|
||||
* Changed sendEvent() to createEvent() in parse()
|
||||
*
|
||||
* Change 4: 2014-04-12 (wackford)
|
||||
* Added current power usage tile
|
||||
*
|
||||
* Change 5: 2014-09-14 (wackford)
|
||||
* a. Changed createEvent() to sendEvent() in parse() to
|
||||
* fix tile not updating.
|
||||
* b. Call IP checker for DHCP environments from refresh. Parent
|
||||
* service manager has method to call every 5 minutes too.
|
||||
*
|
||||
* Change 6: 2014-10-17 (wackford)
|
||||
* a. added step size input to settings of device
|
||||
* b. added refresh on udate
|
||||
* c. added uninstallFromChildDevice to handle removing from settings
|
||||
* d. Changed to allow bulb to 100%, was possible to get past logic at 99
|
||||
*
|
||||
* Change 7: 2014-11-09 (wackford)
|
||||
* a. Added bulbpower calcs to device. TCP is broken
|
||||
* b. Changed to set dim level first then on. Much easier on the eys coming from bright.
|
||||
*
|
||||
*****************************************************************
|
||||
* Code
|
||||
*****************************************************************
|
||||
*/
|
||||
// for the UI
|
||||
metadata {
|
||||
definition (name: "TCP Bulb", namespace: "wackford", author: "Todd Wackford") {
|
||||
capability "Switch"
|
||||
capability "Polling"
|
||||
capability "Power Meter"
|
||||
capability "Refresh"
|
||||
capability "Switch Level"
|
||||
|
||||
attribute "stepsize", "string"
|
||||
|
||||
command "levelUp"
|
||||
command "levelDown"
|
||||
command "on"
|
||||
command "off"
|
||||
command "setBulbPower"
|
||||
}
|
||||
|
||||
simulator {
|
||||
// TODO: define status and reply messages here
|
||||
}
|
||||
|
||||
preferences {
|
||||
input "stepsize", "number", title: "Step Size", description: "Dimmer Step Size", defaultValue: 5
|
||||
}
|
||||
|
||||
tiles {
|
||||
standardTile("switch", "device.switch", width: 2, height: 2, canChangeIcon: true) {
|
||||
state "on", label:'${name}', action:"switch.off", icon:"st.switches.switch.on", backgroundColor:"#79b821", nextState:"turningOff"
|
||||
state "off", label:'${name}', action:"switch.on", icon:"st.switches.switch.off", backgroundColor:"#ffffff", nextState:"turningOn"
|
||||
state "turningOn", label:'${name}', action:"switch.off", icon:"st.switches.switch.on", backgroundColor:"#79b821", nextState:"turningOff"
|
||||
state "turningOff", label:'${name}', action:"switch.on", icon:"st.switches.switch.off", backgroundColor:"#ffffff", nextState:"turningOn"
|
||||
}
|
||||
controlTile("levelSliderControl", "device.level", "slider", height: 1, width: 2, inactiveLabel: false) {
|
||||
state "level", action:"switch level.setLevel"
|
||||
}
|
||||
standardTile("refresh", "device.switch", inactiveLabel: false, decoration: "flat") {
|
||||
state "default", label:"", action:"refresh.refresh", icon:"st.secondary.refresh"
|
||||
}
|
||||
valueTile("level", "device.level", inactiveLabel: false, decoration: "flat") {
|
||||
state "level", label: 'Level ${currentValue}%'
|
||||
}
|
||||
standardTile("lUp", "device.switchLevel", inactiveLabel: false,decoration: "flat", canChangeIcon: false) {
|
||||
state "default", action:"levelUp", icon:"st.illuminance.illuminance.bright"
|
||||
}
|
||||
standardTile("lDown", "device.switchLevel", inactiveLabel: false,decoration: "flat", canChangeIcon: false) {
|
||||
state "default", action:"levelDown", icon:"st.illuminance.illuminance.light"
|
||||
}
|
||||
valueTile( "power", "device.power", inactiveLabel: false, decoration: "flat") {
|
||||
state "power", label: '${currentValue} Watts'
|
||||
}
|
||||
|
||||
main(["switch"])
|
||||
details(["switch", "lUp", "lDown", "levelSliderControl", "level" , "power", "refresh" ])
|
||||
}
|
||||
}
|
||||
|
||||
// parse events into attributes
|
||||
def parse(description) {
|
||||
//log.debug "parse() - $description"
|
||||
def results = []
|
||||
|
||||
if ( description == "updated" )
|
||||
return
|
||||
|
||||
if (description?.name && description?.value)
|
||||
{
|
||||
results << createEvent(name: "${description?.name}", value: "${description?.value}")
|
||||
}
|
||||
}
|
||||
|
||||
// handle commands
|
||||
def setBulbPower(value) {
|
||||
state.bulbPower = value
|
||||
log.debug "In child with bulbPower of ${state.bulbPower}"
|
||||
}
|
||||
|
||||
def on() {
|
||||
log.debug "Executing 'on'"
|
||||
sendEvent(name:"switch",value:on)
|
||||
parent.on(this)
|
||||
|
||||
def levelSetting = device.latestValue("level") as Float ?: 1.0
|
||||
def bulbPowerMax = device.latestValue("setBulbPower") as Float
|
||||
def calculatedPower = bulbPowerMax * (levelSetting / 100)
|
||||
sendEvent(name: "power", value: calculatedPower.round(1))
|
||||
|
||||
if (device.latestValue("level") == null) {
|
||||
sendEvent( name: "level", value: 1.0 )
|
||||
}
|
||||
}
|
||||
|
||||
def off() {
|
||||
log.debug "Executing 'off'"
|
||||
sendEvent(name:"switch",value:off)
|
||||
parent.off(this)
|
||||
sendEvent(name: "power", value: 0.0)
|
||||
}
|
||||
|
||||
def levelUp() {
|
||||
def level = device.latestValue("level") as Integer ?: 0
|
||||
def step = state.stepsize as float
|
||||
|
||||
level+= step
|
||||
|
||||
if ( level > 100 )
|
||||
level = 100
|
||||
|
||||
setLevel(level)
|
||||
}
|
||||
|
||||
def levelDown() {
|
||||
def level = device.latestValue("level") as Integer ?: 0
|
||||
def step = state.stepsize as float
|
||||
|
||||
level-= step
|
||||
|
||||
if ( level < 1 )
|
||||
level = 1
|
||||
|
||||
setLevel(level)
|
||||
}
|
||||
|
||||
def setLevel(value) {
|
||||
log.debug "in setLevel with value: ${value}"
|
||||
def level = value as Integer
|
||||
|
||||
sendEvent( name: "level", value: level )
|
||||
sendEvent( name: "switch.setLevel", value:level )
|
||||
parent.setLevel( this, level )
|
||||
|
||||
|
||||
if (( level > 0 ) && ( level <= 100 ))
|
||||
on()
|
||||
else
|
||||
off()
|
||||
|
||||
def levelSetting = level as float
|
||||
def bulbPowerMax = device.latestValue("setBulbPower") as float
|
||||
def calculatedPower = bulbPowerMax * (levelSetting / 100)
|
||||
sendEvent(name: "power", value: calculatedPower.round(1))
|
||||
}
|
||||
|
||||
def poll() {
|
||||
log.debug "Executing poll()"
|
||||
parent.poll(this)
|
||||
}
|
||||
|
||||
def refresh() {
|
||||
log.debug "Executing refresh()"
|
||||
parent.poll(this)
|
||||
}
|
||||
|
||||
def installed() {
|
||||
initialize()
|
||||
}
|
||||
|
||||
def updated() {
|
||||
initialize()
|
||||
refresh()
|
||||
}
|
||||
|
||||
def initialize() {
|
||||
if ( !settings.stepsize )
|
||||
state.stepsize = 10 //set the default stepsize
|
||||
else
|
||||
state.stepsize = settings.stepsize
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
Method :uninstalled(args)
|
||||
(args) :none
|
||||
returns:Nothing
|
||||
ERRORS :No error handling is done
|
||||
|
||||
Purpose:This is standard ST method.
|
||||
Gets called when "remove" is selected in child device "preferences"
|
||||
tile. It also get's called when "deleteChildDevice(child)" is
|
||||
called from parent service manager app.
|
||||
*******************************************************************************/
|
||||
def uninstalled() {
|
||||
log.debug "Executing 'uninstall' in device type"
|
||||
parent.uninstallFromChildDevice(this)
|
||||
}
|
||||
Reference in New Issue
Block a user