Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft, but functional child light device handler for new smartthings app #7

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ KNOWN ISSUES
- fan and light child device views are only available in iOS mobile app
- Fan child device view can't change name when using gear icon like you can in Light child device
*/
def version() {return "ver 0.2.170515"}
def version() {return "ver 0.2.18"}
/*
; shorten ver to increase font size
05/15 pull request merge with Stephan and Ranga changes, Changed Comfort Breeze label from "enable" to "breeze"
Expand All @@ -41,7 +41,7 @@ KNOWN ISSUES
*/

metadata {
definition (name: "KOF Zigbee Fan Controller - Fan Speed Child Device", namespace: "dcoffing", author: "Stephan Hackett") {
definition (name: "KOF Zigbee Fan Controller - Fan Speed Child Device", namespace: "dcoffing", author: "Stephan Hackett", mnmn: "SmartThings", vid: "generic-switch", runLocally: true, executeCommandsLocally: true, ocfDeviceType: "oic.d.fan") {
capability "Actuator"
capability "Switch"
capability "Light"
Expand Down Expand Up @@ -83,6 +83,7 @@ def getIcon() {
}

def off() {
log.info "CHILD ${getDataValue('speedVal')} TURNED ON"
parent.off()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
* for the specific language governing permissions and limitations under the License.
*/
def version() {return "ver 0.2.170515a"}
def version() {return "ver 0.2.18a"}
/*
a- added valueTile for rangeValue; forced to use 2x2 or bug in device handler makes font unreadably small
so modified controlTile 4x2 to match up rangeValue tile size, shorten ver to increase font in tile
Expand All @@ -34,12 +34,20 @@
2017 Year
*/
metadata {
definition (name: "KOF Zigbee Fan Controller - Light Child Device", namespace: "dcoffing", author: "Stephan Hackett") {
capability "Actuator"
definition (name: "KOF Zigbee Fan Controller - Light Child Device", namespace: "dcoffing", author: "Stephan Hackett", mnmn: "SmartThings",
ocfDeviceType: "oic.d.light", vid: "generic-rgbw-color-bulb", minHubCoreVersion: '000.021.00001',runLocally: true, executeCommandsLocally: true) {
capability "Actuator"
capability "Configuration"
capability "Refresh"
capability "Sensor"
capability "Switch"
capability "Switch Level"
capability "Polling"
capability "Light"
capability "Sensor"

command "on"
command "off"
command "setLevel"
}

tiles(scale: 2) {
Expand All @@ -54,42 +62,68 @@ metadata {
// attributeState "level", action: "setLevel"
// }
//}

standardTile("switch", "switch", decoration: "flat", width: 6, height: 4, canChangeIcon: true) {
state "off", label:"OFF", action: "on", icon: getIcon()+"light_grey.png", backgroundColor: "#ffffff", nextState: "turningOn"
state "on", label: "ON", action: "off", icon: getIcon()+"lightH.png", backgroundColor: "#00A0DC", nextState: "turningOff"
state "turningOn", label:"TURNING ON", action: "on", icon: getIcon()+"lightI.png", backgroundColor: "#2179b8", nextState: "turningOn"
state "turningOff", label:"TURNING OFF", action:"off", icon: getIcon()+"lightI.png", backgroundColor:"#2179b8", nextState: "turningOff"
multiAttributeTile(name: "switch", type: "lighting", width: 6, height: 4, canChangeIcon: true) {
tileAttribute("device.switch", key: "PRIMARY_CONTROL") {
attributeState "on", label:'${name}', action:"off", icon:"st.switches.light.on", backgroundColor:"#00A0DC", nextState:"turningOff"
attributeState "off", label:'${name}', action:"on", icon:"st.switches.light.off", backgroundColor:"#ffffff", nextState:"turningOn"
attributeState "turningOn", label:'${name}', action:"off", icon:"st.switches.light.on", backgroundColor:"#00A0DC", nextState:"turningOff"
attributeState "turningOff", label:'${name}', action:"on", icon:"st.switches.light.off", backgroundColor:"#ffffff", nextState:"turningOn"
}

tileAttribute ("device.level", key: "SLIDER_CONTROL", width: 4, height: 2) {
attributeState "level", action:"setLevel"
}
}
controlTile ("level", "level", "slider", width: 4, height: 2) {
state "level", action: "setLevel"
}
valueTile("rangeValue", "device.level", width: 2, height: 2) {
state "range", label:'${currentValue}%', defaultState: true

standardTile("refresh", "device.switch", inactiveLabel: false, decoration: "flat", width: 2, height: 2) {
state "default", label: "", action: "refresh.refresh", icon: "st.secondary.refresh"
}
valueTile("version", "version", width: 6, height: 2) {
state "version", label:"\n Light Child \n" + version()+"\n"
}

// controlTile ("level", "level", "slider", width: 4, height: 2) {
// state "level", action: "setLevel"
// }
controlTile("levelSliderControl", "device.level", "slider", width: 6, height: 1) {
state "level", action:"switch level.setLevel"
}

main(["switch"])
details(["switch", "rangeValue", "level", "version"])
details(["switch", "refresh"])
}
}

def getIcon() {
return "https://cdn.rawgit.com/dcoffing/KOF-CeilingFan/master/resources/images/"
}

def on() {
parent.lightOn()
sendEvent(name: "switch", value: "on")
log.debug("Fan light turned on")
parent.childOn(device.deviceNetworkId)
sendEvent(name: "switch", value: "on")
}

def off() {
parent.lightOff()
log.debug("Fan light turned off")
sendEvent(name: "switch", value: "off")
parent.childOff(device.deviceNetworkId)
}

def setLevel(val) {
log.debug("Set level called")
parent.lightLevel(val)
sendEvent(name: "level", value: val)
}


/**
* PING is used by Device-Watch in attempt to reach the Device
* */
def ping() {
log.debug("Ping called")
log.debug(parent.refresh())
return
}


def refresh() {
log.debug("Refresh called")
log.debug(parent.getLevel())
return parent.getLevel()
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
* for the specific language governing permissions and limitations under the License.
*/
def version() {"ver 0.2.170515"} //update as needed
def version() {"ver 0.2.18"} //update as needed


def currVersions(child) { //Let's user know if running the child versions that corresponds to this parent version
if(child=="fan") {return "ver 0.2.170515"} //manually enter the version of the FAN child that matches the parent version above
if(child=="light") {return "ver 0.2.170515a"} //manually enter the version of the LIGHT child that matches the parent version above
if(child=="fan") {return "ver 0.2.18"} //manually enter the version of the FAN child that matches the parent version above
if(child=="light") {return "ver 0.2.18a"} //manually enter the version of the LIGHT child that matches the parent version above
}

/*
Expand Down Expand Up @@ -55,7 +55,8 @@ if(child=="light") {return "ver 0.2.170515a"} //manually enter the version of th
04/19 added version tile to help in troubleshooting with users
*/
metadata {
definition (name: "KOF Zigbee Fan Controller", namespace: "dcoffing", author: "Stephan Hackett, Ranga Pedamallu, Dale Coffing") {
definition (name: "KOF Zigbee Fan Controller", namespace: "dcoffing", author: "Stephan Hackett, Ranga Pedamallu, Dale Coffing", mnmn: "SmartThings", vid: "generic-rgbw-color-bulb", ocfDeviceType: "oic.d.fan") {
/// runLocally: true, executeCommandsLocally: true,
capability "Actuator"
capability "Configuration"
capability "Refresh"
Expand All @@ -78,7 +79,7 @@ metadata {
attribute "LchildCurr", "string" //stores color of version check
attribute "FchildCurr", "string" //stores color of version check

fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0202", outClusters: "0003, 0019", model: "HDC52EastwindFan"
fingerprint profileId: "0104", inClusters: "0000,0003,0004,0005,0006,0008,0202", outClusters: "0003,0019" //, model: "HDC52EastwindFan"
}

preferences {
Expand Down Expand Up @@ -146,7 +147,7 @@ metadata {
}

def parse(String description) {
//log.debug "Parse description $description"
log.debug "Parse description $description"
def event = zigbee.getEvent(description)
if (event) {
log.info "Light event detected on controller: ${event}"
Expand Down Expand Up @@ -250,7 +251,7 @@ def createFanChild() {
}
if (!childDevice && i != 5) {
childDevice = addChildDevice("KOF Zigbee Fan Controller - Fan Speed Child Device", "${device.deviceNetworkId}-0${i}", null,[completedSetup: true,
label: "${device.displayName} ${getFanName()["0${i}"]}", isComponent: true, componentName: "fanMode${i}",
label: "${device.displayName} ${getFanName()["0${i}"]}", isComponent: false, componentName: "fanMode${i}",
componentLabel: "${getFanName()["0${i}"]}", "data":["speedVal":"0${i}","parent version":version()]])
log.info "Creating child fan mode ${childDevice}"
}
Expand Down Expand Up @@ -402,4 +403,4 @@ def getChildVer() {
sendEvent(name:"LchildVer", value: LchildDevice.version())
LchildDevice.version() != currVersions("light")?sendEvent(name:"LchildCurr", value: 1):sendEvent(name:"LchildCurr", value: 2)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
/**
* King Of Fans Zigbee Fan Controller - Light Child Device
*
* Copyright 2017 Stephan Hackett
* in collaboration with Ranga Pedamallu, Dale Coffing
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
* for the specific language governing permissions and limitations under the License.
*/
def version() {return "ver 0.2.18a"}
/*
a- added valueTile for rangeValue; forced to use 2x2 or bug in device handler makes font unreadably small
so modified controlTile 4x2 to match up rangeValue tile size, shorten ver to increase font in tile
05/15 pull request merge with Stephan and Ranga changes, to allow flat look in parent, changed from multiAttribute to Standard/Control Tile functionality
05/10 decoration: "flat" added to tile for consistancy across all childs
05/05 edit Zigbee to proper ZigBee trademark
05/04 clean up display in iOS child version, smaller text and center version
05/03 tweak to icons for ON to match the lighter grey LED look
05/02 replaced blue rays on icon to be grey when TurningOnOff
b- changed light TurningON/OFF icon to light_blue
a- changed light ON icon from light_blue to lightH for Stephan
05/01 added version tile for iOS child device view, light icon ON with blue rays
04/30a move Stephack latest changes over in a copy/paste; change namespace
04/29 larger matching icon; used URL shortcut https://cdn.rawgit.com/ and located to /resources/images/
04/26 moved icons to KOF repo and renamed for final release
04/20 modified version tile
04/19 added version tile to help in troubleshooting with users
2017 Year
*/
metadata {
definition (name: "King of Fans Zigbee Fan - Light Child Device", namespace: "smartthings", ocfDeviceType:"oic.d.light", author: "Stephan Hackett", vid: "generic-dimmer") {
capability "Switch"
capability "Actuator"
capability "Sensor"
capability "Refresh"
capability "Switch Level"

command "off"
command "on"

}

// Zemismart HGZB-42
fingerprint profileId: "C05E", deviceId: "0000", inClusters: "0000, 0003, 0004, 0005, 0006, 0008", outClusters: "0019", manufacturer: "3A Smart Home DE", model: "LXN-2S27LX1.0", deviceJoinName: "ZigBee Smart Switch"
fingerprint profileId: "C05E", deviceId: "0000", inClusters: "0000, 0003, 0004, 0005, 0006, 0008", outClusters: "0019", manufacturer: "FeiBit", model: "FNB56-ZSW02LX2.0", deviceJoinName: "ZigBee Smart Switch"

// Zemismart HGZB-43
fingerprint profileId: "C05E", deviceId: "0000", inClusters: "0000, 0003, 0004, 0005, 0006, 0008", outClusters: "0019", manufacturer: "3A Smart Home DE", model: "LXN-3S27LX1.0", deviceJoinName: "ZigBee Smart Switch"
fingerprint profileId: "C05E", deviceId: "0000", inClusters: "0000, 0003, 0004, 0005, 0006, 0008", outClusters: "0019", manufacturer: "FeiBit", model: "FNB56-ZSW03LX2.0", deviceJoinName: "ZigBee Smart Switch"

tiles(scale: 2) {
standardTile ("switch", "device.switch", width: 2, height: 2, canChangeIcon: true, decoration: "flat") {
state ("off", label: '${name}', action: "on", icon: "st.switches.light.off", backgroundColor: "#ffffff", nextState: "turningOn")
state ("on", label: '${name}', action: "off", icon: "st.switches.light.on", backgroundColor: "#00a0dc", nextState: "turningOff")
state ("turningOff", label: '${name}', action: "on", icon: "st.switches.light.off", backgroundColor: "#ffffff", nextState: "turningOn")
state ("turningOn", label: '${name}', action: "off", icon: "st.switches.light.on", backgroundColor: "#00a0dc", nextState: "turningOff")
}

controlTile("level", "device.level", "slider", range:"(1..9)", height: 2, width: 2, canChangeIcon: true, decoration: "flat", inactiveLabel: false) {
state "level", action: "setLevel"
}

main("switch")
details(["switch", "level"])
}
}

void on() {
log.info "on()"
sendEvent(name: "device.switch", value: "on", displayed: true, isStateChange: true)
sendEvent(name: "switch", value: "on", displayed: true, isStateChange: true)
parent.on(device)


}

void off() {
log.info "off()"
sendEvent(name: "switch", value: "off", displayed: true, isStateChange: true)
sendEvent(name: "device.switch", value: "off", displayed: true, isStateChange: true)

parent.off(device)

}

void refresh() {
log.debug "refresh()"
parent.refresh(device)
parent.childRefresh(device.deviceNetworkId)
}


def createAndSendEvent(map) {
log.debug "child[ ${device.deviceNetworkId} ].createAndSendEvent($map)"
results.each { name, value ->
sendEvent(name: name, value: value)
}
return null
}

def parse(description) {
log.debug "PARSE IN Child: $description"

//def event = zigbee.getEvent(description)
//sendEvent(description)
// return sendEvent(event)


}

def setLevel(value, rate = 10) { parent.setLevel(value, rate, device) }

def poll() {
log.debug "poll()"
parent.poll(device)
}

def ping() {
log.debug "ping()"
parent.ping(device)
}

def installed () {
log.debug "installed() - parent $parent"

sendEvent(name: "checkInterval", value: 5, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])
}

def uninstalled () {
log.debug "uninstalled()"
//parent.delete()
}
Loading