forked from SmartThingsCommunity/SmartThingsPublic
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request SmartThingsCommunity#4154 from SmartThingsCommunit…
…y/staging Rolling up staging to production for deploy
- Loading branch information
Showing
10 changed files
with
297 additions
and
11 deletions.
There are no files selected for viewing
108 changes: 108 additions & 0 deletions
108
...etypes/smartthings/glentronics-connection-module.src/glentronics-connection-module.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
/** | ||
* Copyright 2019 SmartThings | ||
* | ||
* 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. | ||
* | ||
*/ | ||
|
||
metadata { | ||
definition (name: "Glentronics Connection Module", namespace: "smartthings", author: "SmartThings") { | ||
capability "Sensor" | ||
capability "Water Sensor" | ||
capability "Battery" | ||
capability "Power Source" | ||
capability "Health Check" | ||
|
||
fingerprint mfr:"0084", prod:"0093", model:"0114", deviceJoinName: "Glentronics Connection Module" | ||
} | ||
|
||
tiles (scale: 2){ | ||
multiAttributeTile(name: "water", type: "generic", width: 6, height: 4) { | ||
tileAttribute("device.water", key: "PRIMARY_CONTROL") { | ||
attributeState("dry", icon: "st.alarm.water.dry", backgroundColor: "#ffffff") | ||
attributeState("wet", icon: "st.alarm.water.wet", backgroundColor: "#00A0DC") | ||
} | ||
} | ||
valueTile("battery", "device.battery", inactiveLabel: true, decoration: "flat", width: 2, height: 2) { | ||
state "battery", label: 'Backup battery: ${currentValue}%', unit: "" | ||
} | ||
valueTile("powerSource", "device.powerSource", width: 2, height: 1, inactiveLabel: true, decoration: "flat") { | ||
state "powerSource", label: 'Power Source: ${currentValue}', backgroundColor: "#ffffff" | ||
} | ||
main "water" | ||
details(["water", "battery", "powerSource"]) | ||
} | ||
} | ||
|
||
def parse(String description) { | ||
def result | ||
if (description.startsWith("Err")) { | ||
result = createEvent(descriptionText:description, displayed:true) | ||
} else { | ||
def cmd = zwave.parse(description) | ||
if (cmd) { | ||
result = zwaveEvent(cmd) | ||
} | ||
} | ||
log.debug "Parse returned: ${result.inspect()}" | ||
return result | ||
} | ||
|
||
def installed() { | ||
//There's no possibility for initial poll, so to avoid empty fields, assuming everything is functioning correctly | ||
sendEvent(name: "battery", value: 100, unit: "%") | ||
sendEvent(name: "water", value: "dry") | ||
sendEvent(name: "powerSource", value: "mains") | ||
sendEvent(name: "checkInterval", value: 2 * 60 * 60 + 2 * 60, displayed: false, data: [protocol: "zwave", hubHardwareId: device.hub.hardwareID, offlinePingable: "1"]) | ||
} | ||
|
||
def ping() { | ||
response(zwave.versionV1.versionGet().format()) | ||
} | ||
|
||
def getPowerEvent(event) { | ||
if (event == 0x02) { | ||
createEvent(name: "powerSource", value: "battery", descriptionText: "Pump is powered with backup battery") | ||
} else if (event == 0x03) { | ||
createEvent(name: "powerSource", value: "mains", descriptionText: "Pump is powered with AC mains") | ||
} else if (event == 0x0B) { | ||
createEvent(name: "battery", value: 1, unit: "%", descriptionText: "Backup battery critically low") | ||
} else if (event == 0x0D) { | ||
createEvent(name: "battery", value: 100, unit: "%", descriptionText: "Backup battery is fully charged") | ||
} | ||
} | ||
|
||
def getManufacturerSpecificEvent(cmd) { | ||
if (cmd.event == 3) { | ||
if (cmd.eventParameter[0] == 0) { | ||
createEvent(name: "water", value: "dry", descriptionText: "Water alarm has been cleared") | ||
} else if (cmd.eventParameter[0] == 2) { | ||
createEvent(name: "water", value: "wet", descriptionText: "High water alarm") | ||
} | ||
} | ||
} | ||
|
||
def zwaveEvent(physicalgraph.zwave.commands.notificationv3.NotificationReport cmd) { | ||
log.debug "NotificationReport: ${cmd}" | ||
if (cmd.notificationType == 8) { | ||
getPowerEvent(cmd.event) | ||
} else if (cmd.notificationType == 9) { | ||
getManufacturerSpecificEvent(cmd) | ||
} | ||
} | ||
|
||
def zwaveEvent(physicalgraph.zwave.commands.versionv1.VersionReport cmd) { | ||
createEvent(descriptionText: "Device has responded to ping()") | ||
} | ||
|
||
def zwaveEvent(physicalgraph.zwave.Command cmd) { | ||
log.warn "Unhandled command: ${cmd}" | ||
createEvent(descriptionText: "Unhandled event came in") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,4 +13,4 @@ | |
# under the License. | ||
|
||
# Chinese | ||
'''A60 Dim Bulb'''.zh-cn=智能球泡灯 Samsung Connect | ||
'''A60 Dim Bulb'''.zh-cn=智能球泡灯 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
138 changes: 138 additions & 0 deletions
138
devicetypes/smartthings/zigbee-window-shade.src/zigbee-window-shade.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
/** | ||
* | ||
* Copyright 2019 SmartThings | ||
* | ||
* 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. | ||
*/ | ||
import physicalgraph.zigbee.zcl.DataType | ||
|
||
metadata { | ||
definition(name: "ZigBee Window Shade", namespace: "smartthings", author: "SmartThings", ocfDeviceType: "oic.d.blind", mnmn: "SmartThings", vid: "generic-shade") { | ||
capability "Actuator" | ||
capability "Configuration" | ||
capability "Refresh" | ||
capability "Window Shade" | ||
capability "Health Check" | ||
capability "Switch Level" | ||
|
||
command "pause" | ||
|
||
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0102", outClusters: "0019", model: "E2B0-KR000Z0-HA", deviceJoinName: "SOMFY Blind Controller/eZEX" // SY-IoT201-BD | ||
} | ||
|
||
|
||
tiles(scale: 2) { | ||
multiAttributeTile(name:"windowShade", type: "generic", width: 6, height: 4) { | ||
tileAttribute("device.windowShade", key: "PRIMARY_CONTROL") { | ||
attributeState "open", label: 'Open', action: "close", icon: "http://www.ezex.co.kr/img/st/window_open.png", backgroundColor: "#00A0DC", nextState: "closing" | ||
attributeState "closed", label: 'Closed', action: "open", icon: "http://www.ezex.co.kr/img/st/window_close.png", backgroundColor: "#ffffff", nextState: "opening" | ||
attributeState "partially open", label: 'Partially open', action: "close", icon: "http://www.ezex.co.kr/img/st/window_open.png", backgroundColor: "#d45614", nextState: "closing" | ||
attributeState "opening", label: 'Opening', action: "pause", icon: "http://www.ezex.co.kr/img/st/window_open.png", backgroundColor: "#00A0DC", nextState: "partially open" | ||
attributeState "closing", label: 'Closing', action: "pause", icon: "http://www.ezex.co.kr/img/st/window_close.png", backgroundColor: "#ffffff", nextState: "partially open" | ||
} | ||
} | ||
standardTile("contPause", "device.switch", inactiveLabel: false, decoration: "flat", width: 2, height: 2) { | ||
state "pause", label:"", icon:'st.sonos.pause-btn', action:'pause', backgroundColor:"#cccccc" | ||
} | ||
standardTile("refresh", "device.refresh", inactiveLabel: false, decoration: "flat", width: 2, height: 1) { | ||
state "default", label:"", action:"refresh.refresh", icon:"st.secondary.refresh" | ||
} | ||
valueTile("shadeLevel", "device.level", width: 4, height: 1) { | ||
state "level", label: 'Shade is ${currentValue}% up', defaultState: true | ||
} | ||
controlTile("levelSliderControl", "device.level", "slider", width:2, height: 1, inactiveLabel: false) { | ||
state "level", action:"switch level.setLevel" | ||
} | ||
|
||
main "windowShade" | ||
details(["windowShade", "contPause", "shadeLevel", "levelSliderControl", "refresh"]) | ||
} | ||
} | ||
|
||
private getCLUSTER_WINDOW_COVERING() { 0x0102 } | ||
private getATTRIBUTE_POSITION_LIFT() { 0x0008 } | ||
|
||
private List<Map> collectAttributes(Map descMap) { | ||
List<Map> descMaps = new ArrayList<Map>() | ||
|
||
descMaps.add(descMap) | ||
|
||
if (descMap.additionalAttrs) { | ||
descMaps.addAll(descMap.additionalAttrs) | ||
} | ||
|
||
return descMaps | ||
} | ||
|
||
// Parse incoming device messages to generate events | ||
def parse(String description) { | ||
log.debug "description:- ${description}" | ||
if (description?.startsWith("read attr -")) { | ||
Map descMap = zigbee.parseDescriptionAsMap(description) | ||
if (descMap?.clusterInt == CLUSTER_WINDOW_COVERING && descMap.value) { | ||
log.debug "attr: ${descMap?.attrInt}, value: ${descMap?.value}, decValue: ${Integer.parseInt(descMap.value, 16)}, ${device.getDataValue("model")}" | ||
List<Map> descMaps = collectAttributes(descMap) | ||
def liftmap = descMaps.find { it.attrInt == ATTRIBUTE_POSITION_LIFT } | ||
if (liftmap) { | ||
if (liftmap.value == "64") { //open | ||
sendEvent(name: "windowShade", value: "open") | ||
sendEvent(name: "level", value: "100") | ||
} else if (liftmap.value == "00") { //closed | ||
sendEvent(name: "windowShade", value: "closed") | ||
sendEvent(name: "level", value: "0") | ||
} else { | ||
sendEvent(name: "windowShade", value: "partially open") | ||
sendEvent(name: "level", value: zigbee.convertHexToInt(attr.value)) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
def close() { | ||
log.info "close()" | ||
zigbee.command(CLUSTER_WINDOW_COVERING, 0x01) | ||
} | ||
|
||
def open() { | ||
log.info "open()" | ||
zigbee.command(CLUSTER_WINDOW_COVERING, 0x00) | ||
} | ||
|
||
def setLevel(data) { | ||
log.info "setLevel()" | ||
zigbee.command(CLUSTER_WINDOW_COVERING, 0x05, zigbee.convertToHexString(data, 2)) | ||
} | ||
|
||
def pause() { | ||
log.info "pause()" | ||
zigbee.command(CLUSTER_WINDOW_COVERING, 0x02) | ||
} | ||
|
||
/** | ||
* PING is used by Device-Watch in attempt to reach the Device | ||
* */ | ||
def ping() { | ||
return refresh() | ||
} | ||
|
||
def refresh() { | ||
log.info "refresh()" | ||
def cmds = zigbee.readAttribute(CLUSTER_WINDOW_COVERING, ATTRIBUTE_POSITION_LIFT) | ||
return cmds | ||
} | ||
|
||
def configure() { | ||
// Device-Watch allows 2 check-in misses from device + ping (plus 2 min lag time) | ||
log.info "configure()" | ||
sendEvent(name: "checkInterval", value: 2 * 60 * 60 + 2 * 60, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID]) | ||
log.debug "Configuring Reporting and Bindings." | ||
zigbee.configureReporting(CLUSTER_WINDOW_COVERING, ATTRIBUTE_POSITION_LIFT, DataType.UINT8, 0, 600, null) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters