mirror of
https://github.com/mtan93/SmartThingsPublic.git
synced 2026-03-30 14:13:06 +01:00
Compare commits
4 Commits
MSA-1539-7
...
MSA-1551-6
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0fddbd93ae | ||
|
|
a9aee8fd96 | ||
|
|
5c015cf678 | ||
|
|
cf1a46e309 |
@@ -0,0 +1,148 @@
|
|||||||
|
metadata {
|
||||||
|
// Automatically generated. Make future change here.
|
||||||
|
definition (name: "MY Zigbee Dimmer255", namespace: "smartthings", author: "SmartThings") {
|
||||||
|
capability "Actuator"
|
||||||
|
capability "Switch"
|
||||||
|
capability "Sensor"
|
||||||
|
capability "Switch Level"
|
||||||
|
capability "Refresh"
|
||||||
|
|
||||||
|
fingerprint profileId: "0104", inClusters: "0000,0003,0006,0008", outClusters: "0019"
|
||||||
|
}
|
||||||
|
|
||||||
|
// simulator metadata
|
||||||
|
simulator {
|
||||||
|
// status messages
|
||||||
|
status "on": "on/off: 1"
|
||||||
|
status "off": "on/off: 0"
|
||||||
|
|
||||||
|
// reply messages
|
||||||
|
reply "zcl on-off on": "on/off: 1"
|
||||||
|
reply "zcl on-off off": "on/off: 0"
|
||||||
|
}
|
||||||
|
|
||||||
|
// UI tile definitions
|
||||||
|
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.switch", inactiveLabel: false, decoration: "flat") {
|
||||||
|
state "default", label:'', action:"refresh.refresh", icon:"st.secondary.refresh"
|
||||||
|
}
|
||||||
|
controlTile("levelSliderControl", "device.level", "slider", height: 1, width: 3, inactiveLabel: false) {
|
||||||
|
state "level", action:"switch level.setLevel"
|
||||||
|
}
|
||||||
|
valueTile("level", "device.level", inactiveLabel: false, decoration: "flat") {
|
||||||
|
state "level", label:'${currentValue} %', unit:"%", backgroundColor:"#ffffff"
|
||||||
|
}
|
||||||
|
|
||||||
|
main "switch"
|
||||||
|
details (["switch","refresh","level","levelSliderControl"])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parse incoming device messages to generate events
|
||||||
|
def parse(String description) {
|
||||||
|
/*if (description?.startsWith("catchall: 0104 000A")) {
|
||||||
|
log.debug "Dropping catchall for SmartPower Outlet"
|
||||||
|
return []
|
||||||
|
}*/
|
||||||
|
log.trace description
|
||||||
|
if (description?.startsWith("catchall:")) {
|
||||||
|
def msg = zigbee.parse(description)
|
||||||
|
log.trace msg
|
||||||
|
log.trace "data: $msg.data"
|
||||||
|
if(msg.command == 0x01){
|
||||||
|
if(msg.clusterId == 0x0006 && msg.data[0] == 0x00 && msg.data[1] == 0x00){
|
||||||
|
def name = "switch"
|
||||||
|
def value = (msg.data[4] != 0 ? "on" : "off")
|
||||||
|
log.debug"name:$name,value:$value"
|
||||||
|
def result = createEvent(name: name, value: value)
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
}else if(msg.command == 0x0b && msg.clusterId == 0x0006){
|
||||||
|
def name = "switch"
|
||||||
|
def value = (msg.data[0] != 0 ? "on" : "off")
|
||||||
|
log.debug"name:$name,value:$value"
|
||||||
|
def result = createEvent(name: name, value: value)
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
}else if(description?.startsWith("read attr")){
|
||||||
|
def descMap = parseDescriptionAsMap(description)
|
||||||
|
log.debug "Read attr: $description"
|
||||||
|
if(descMap.cluster == "0008" && descMap.attrId == "0000"){
|
||||||
|
def name = "level"
|
||||||
|
def value = Integer.parseInt(descMap.value, 16)
|
||||||
|
value = Math.round(value * 100/255)
|
||||||
|
log.debug"name:$name,value:$value"
|
||||||
|
def result = createEvent(name: name, value: value)
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
}/*else {
|
||||||
|
log.debug "parse description: $description"
|
||||||
|
def name = description?.startsWith("on/off: ") ? "switch" : null
|
||||||
|
def value = name == "switch" ? (description?.endsWith(" 1") ? "on" : "off") : null
|
||||||
|
def result = createEvent(name: name, value: value)
|
||||||
|
log.debug "Parse returned ${result?.descriptionText}"
|
||||||
|
return result
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
|
||||||
|
def parseDescriptionAsMap(description) {
|
||||||
|
(description - "read attr - ").split(",").inject([:]) { map, param ->
|
||||||
|
def nameAndValue = param.split(":")
|
||||||
|
map += [(nameAndValue[0].trim()):nameAndValue[1].trim()]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def refresh() {
|
||||||
|
log.debug "refresh()"
|
||||||
|
def cmds = []
|
||||||
|
cmds << "st rattr 0x${device.deviceNetworkId} 1 0x0006 0x0000"
|
||||||
|
cmds << "delay 200"
|
||||||
|
cmds << "st rattr 0x${device.deviceNetworkId} 1 0x0008 0x0000"
|
||||||
|
}
|
||||||
|
|
||||||
|
// Commands to device
|
||||||
|
def on() {
|
||||||
|
log.debug "on()"
|
||||||
|
def cmds = []
|
||||||
|
cmds << "st cmd 0x${device.deviceNetworkId} 1 6 1 {}"
|
||||||
|
cmds << "delay 5000"
|
||||||
|
cmds << "st rattr 0x${device.deviceNetworkId} 1 0x0008 0x0000"
|
||||||
|
}
|
||||||
|
|
||||||
|
def off() {
|
||||||
|
log.debug "off()"
|
||||||
|
def cmds = []
|
||||||
|
cmds << "st cmd 0x${device.deviceNetworkId} 1 6 0 {}"
|
||||||
|
cmds << "delay 5000"
|
||||||
|
cmds << "st rattr 0x${device.deviceNetworkId} 1 0x0008 0x0000"
|
||||||
|
}
|
||||||
|
|
||||||
|
def setLevel(value) {
|
||||||
|
log.trace "setLevel($value)"
|
||||||
|
def cmds = []
|
||||||
|
|
||||||
|
if (value == 0) {
|
||||||
|
sendEvent(name: "switch", value: "off")
|
||||||
|
//cmds << "st cmd 0x${device.deviceNetworkId} 1 6 0 {}"
|
||||||
|
}
|
||||||
|
else if (device.latestValue("switch") == "off") {
|
||||||
|
sendEvent(name: "switch", value: "on")
|
||||||
|
//cmds << "st cmd 0x${device.deviceNetworkId} 1 6 1 {}"
|
||||||
|
|
||||||
|
}
|
||||||
|
//def transitionTime = Math.round(Math.abs(((device.currentValue("level")?:0) as int) - (value as int))*0.3)
|
||||||
|
//def transitionTime2 = hexString(transitionTime>>8)
|
||||||
|
//def transitionTime1 = hexString(transitionTime%256)
|
||||||
|
sendEvent(name: "level", value: value)
|
||||||
|
def level = hexString(Math.round(value * 255/100))
|
||||||
|
cmds << "st cmd 0x${device.deviceNetworkId} 1 8 4 {${level} FFFF}"
|
||||||
|
cmds << "delay 5000"
|
||||||
|
cmds << "st rattr 0x${device.deviceNetworkId} 1 0x0008 0x0000"
|
||||||
|
|
||||||
|
log.debug cmds
|
||||||
|
cmds
|
||||||
|
}
|
||||||
@@ -11,6 +11,9 @@
|
|||||||
* for the specific language governing permissions and limitations under the License.
|
* for the specific language governing permissions and limitations under the License.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
import groovy.transform.Field
|
||||||
|
|
||||||
|
@Field Boolean hasConfiguredHealthCheck = false
|
||||||
|
|
||||||
metadata {
|
metadata {
|
||||||
definition (name: "ZLL Dimmer Bulb", namespace: "smartthings", author: "SmartThings") {
|
definition (name: "ZLL Dimmer Bulb", namespace: "smartthings", author: "SmartThings") {
|
||||||
@@ -21,6 +24,7 @@ metadata {
|
|||||||
capability "Refresh"
|
capability "Refresh"
|
||||||
capability "Switch"
|
capability "Switch"
|
||||||
capability "Switch Level"
|
capability "Switch Level"
|
||||||
|
capability "Health Check"
|
||||||
|
|
||||||
//fingerprint profileId: "C05E", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 1000", outClusters: "0000,0019"
|
//fingerprint profileId: "C05E", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 1000", outClusters: "0000,0019"
|
||||||
fingerprint profileId: "C05E", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 1000", outClusters: "0019"
|
fingerprint profileId: "C05E", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 1000", outClusters: "0019"
|
||||||
@@ -96,7 +100,38 @@ def poll() {
|
|||||||
refresh()
|
refresh()
|
||||||
}
|
}
|
||||||
|
|
||||||
def configure() {
|
/**
|
||||||
log.debug "Configuring Reporting and Bindings."
|
* PING is used by Device-Watch in attempt to reach the Device
|
||||||
zigbee.onOffConfig() + zigbee.levelConfig() + zigbee.onOffRefresh() + zigbee.levelRefresh()
|
* */
|
||||||
|
def ping() {
|
||||||
|
return zigbee.levelRefresh()
|
||||||
|
}
|
||||||
|
|
||||||
|
def healthPoll() {
|
||||||
|
log.debug "healthPoll()"
|
||||||
|
def cmds = refresh()
|
||||||
|
cmds.each{ sendHubCommand(new physicalgraph.device.HubAction(it))}
|
||||||
|
}
|
||||||
|
|
||||||
|
def configureHealthCheck() {
|
||||||
|
Integer hcIntervalMinutes = 12
|
||||||
|
if (!hasConfiguredHealthCheck) {
|
||||||
|
log.debug "Configuring Health Check, Reporting"
|
||||||
|
unschedule("healthPoll")
|
||||||
|
runEvery5Minutes("healthPoll")
|
||||||
|
// Device-Watch allows 2 check-in misses from device
|
||||||
|
sendEvent(name: "checkInterval", value: hcIntervalMinutes * 60, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])
|
||||||
|
hasConfiguredHealthCheck = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def configure() {
|
||||||
|
log.debug "configure()"
|
||||||
|
zigbee.onOffConfig() + zigbee.levelConfig() + zigbee.onOffRefresh() + zigbee.levelRefresh()
|
||||||
|
configureHealthCheck()
|
||||||
|
}
|
||||||
|
|
||||||
|
def updated() {
|
||||||
|
log.debug "updated()"
|
||||||
|
configureHealthCheck()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,9 @@
|
|||||||
* for the specific language governing permissions and limitations under the License.
|
* for the specific language governing permissions and limitations under the License.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
import groovy.transform.Field
|
||||||
|
|
||||||
|
@Field Boolean hasConfiguredHealthCheck = false
|
||||||
|
|
||||||
metadata {
|
metadata {
|
||||||
definition (name: "ZLL White Color Temperature Bulb", namespace: "smartthings", author: "SmartThings") {
|
definition (name: "ZLL White Color Temperature Bulb", namespace: "smartthings", author: "SmartThings") {
|
||||||
@@ -22,6 +25,7 @@ metadata {
|
|||||||
capability "Refresh"
|
capability "Refresh"
|
||||||
capability "Switch"
|
capability "Switch"
|
||||||
capability "Switch Level"
|
capability "Switch Level"
|
||||||
|
capability "Health Check"
|
||||||
|
|
||||||
attribute "colorName", "string"
|
attribute "colorName", "string"
|
||||||
command "setGenericName"
|
command "setGenericName"
|
||||||
@@ -96,9 +100,41 @@ def poll() {
|
|||||||
zigbee.onOffRefresh() + zigbee.levelRefresh() + zigbee.colorTemperatureRefresh()
|
zigbee.onOffRefresh() + zigbee.levelRefresh() + zigbee.colorTemperatureRefresh()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PING is used by Device-Watch in attempt to reach the Device
|
||||||
|
* */
|
||||||
|
def ping() {
|
||||||
|
return zigbee.levelRefresh()
|
||||||
|
}
|
||||||
|
|
||||||
|
def healthPoll() {
|
||||||
|
log.debug "healthPoll()"
|
||||||
|
def cmds = zigbee.onOffRefresh() + zigbee.levelRefresh()
|
||||||
|
cmds.each{ sendHubCommand(new physicalgraph.device.HubAction(it))}
|
||||||
|
}
|
||||||
|
|
||||||
|
def configureHealthCheck() {
|
||||||
|
Integer hcIntervalMinutes = 12
|
||||||
|
if (!hasConfiguredHealthCheck) {
|
||||||
|
log.debug "Configuring Health Check, Reporting"
|
||||||
|
unschedule("healthPoll")
|
||||||
|
runEvery5Minutes("healthPoll")
|
||||||
|
// Device-Watch allows 2 check-in misses from device
|
||||||
|
sendEvent(name: "checkInterval", value: hcIntervalMinutes * 60, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])
|
||||||
|
hasConfiguredHealthCheck = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
def configure() {
|
def configure() {
|
||||||
log.debug "Configuring Reporting and Bindings."
|
log.debug "configure()"
|
||||||
|
configureHealthCheck()
|
||||||
zigbee.onOffConfig() + zigbee.levelConfig() + zigbee.colorTemperatureConfig() + zigbee.onOffRefresh() + zigbee.levelRefresh() + zigbee.colorTemperatureRefresh()
|
zigbee.onOffConfig() + zigbee.levelConfig() + zigbee.colorTemperatureConfig() + zigbee.onOffRefresh() + zigbee.levelRefresh() + zigbee.colorTemperatureRefresh()
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
def updated() {
|
||||||
|
log.debug "updated()"
|
||||||
|
configureHealthCheck()
|
||||||
}
|
}
|
||||||
|
|
||||||
def setColorTemperature(value) {
|
def setColorTemperature(value) {
|
||||||
|
|||||||
Reference in New Issue
Block a user