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

ICP-13694 - removes supporting the Battery capability #45566

Merged
merged 2 commits into from
Sep 29, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ 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 "Battery"
capability "Configuration"
capability "Refresh"
capability "Window Shade"
Expand Down Expand Up @@ -80,7 +79,6 @@ private getCOMMAND_GOTO_LIFT_PERCENTAGE() { 0x05 }
private getATTRIBUTE_POSITION_LIFT() { 0x0008 }
private getATTRIBUTE_CURRENT_LEVEL() { 0x0000 }
private getCOMMAND_MOVE_LEVEL_ONOFF() { 0x04 }
private getBATTERY_PERCENTAGE_REMAINING() { 0x0021 }

private List<Map> collectAttributes(Map descMap) {
List<Map> descMaps = new ArrayList<Map>()
Expand Down Expand Up @@ -117,9 +115,6 @@ def parse(String description) {
def valueInt = Math.round((zigbee.convertHexToInt(descMap.value)) / 255 * 100)

levelEventHandler(valueInt)
} else if (reportsBatteryPercentage() && descMap?.clusterInt == zigbee.POWER_CONFIGURATION_CLUSTER && zigbee.convertHexToInt(descMap?.attrId) == BATTERY_PERCENTAGE_REMAINING && descMap.value) {
def batteryLevel = zigbee.convertHexToInt(descMap.value)
batteryPercentageEventHandler(batteryLevel)
}
}
}
Expand Down Expand Up @@ -152,13 +147,6 @@ def updateFinalState() {
}
}

def batteryPercentageEventHandler(batteryLevel) {
if (batteryLevel != null) {
batteryLevel = Math.min(100, Math.max(0, batteryLevel))
sendEvent([name: "battery", value: batteryLevel, unit: "%", descriptionText: "{{ device.displayName }} battery was {{ value }}%"])
}
}

def supportsLiftPercentage() {
device.getDataValue("manufacturer") != "Feibit Co.Ltd"
}
Expand Down Expand Up @@ -243,17 +231,9 @@ def configure() {
cmds += readDeviceBindingTable()
}

if (reportsBatteryPercentage()) {
cmds += zigbee.configureReporting(zigbee.POWER_CONFIGURATION_CLUSTER, BATTERY_PERCENTAGE_REMAINING, DataType.UINT8, 30, 21600, 0x01)
}

return refresh() + cmds
}

def usesLocalGroupBinding() {
isIkeaKadrilj() || isIkeaFyrtur()
}

private def parseBindingTableMessage(description) {
Integer groupAddr = getGroupAddrFromBindingTable(description)
if (groupAddr) {
Expand All @@ -279,19 +259,7 @@ private List readDeviceBindingTable() {
}

def shouldInvertLiftPercentage() {
return isIkeaKadrilj() || isIkeaFyrtur() || isSomfy()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you can remove this yet because of the Somfy device.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are totally right, thanks for pointing that out.
Fixed.

}

def reportsBatteryPercentage() {
return isIkeaKadrilj() || isIkeaFyrtur()
}

def isIkeaKadrilj() {
device.getDataValue("model") == "KADRILJ roller blind"
}

def isIkeaFyrtur() {
device.getDataValue("model") == "FYRTUR block-out roller blind"
return isSomfy()
}

def isSomfy() {
Expand Down