mirror of
https://github.com/mtan93/SmartThingsPublic.git
synced 2026-03-18 21:03:39 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fafa4cb01f |
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Fibaro Wall Plug ZW3
|
* Fibaro Wall Plug ZW5
|
||||||
*
|
*
|
||||||
* Copyright 2016 Fibar Group S.A.
|
* Copyright 2016 Fibar Group S.A.
|
||||||
*
|
*
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
metadata {
|
metadata {
|
||||||
definition (name: "Fibaro Wall Plug ZW3", namespace: "fibargroup", author: "Fibar Group S.A.") {
|
definition (name: "Fibaro Wall Plug ZW5", namespace: "fibargroup", author: "Fibar Group S.A.") {
|
||||||
capability "Actuator"
|
capability "Actuator"
|
||||||
capability "Configuration"
|
capability "Configuration"
|
||||||
capability "Energy Meter"
|
capability "Energy Meter"
|
||||||
@@ -22,18 +22,17 @@ metadata {
|
|||||||
capability "Refresh"
|
capability "Refresh"
|
||||||
capability "Sensor"
|
capability "Sensor"
|
||||||
capability "Switch"
|
capability "Switch"
|
||||||
|
|
||||||
|
command "reset"
|
||||||
|
|
||||||
command "reset"
|
fingerprint deviceId: "0x1001", inClusters: "0x5E, 0x22, 0x85, 0x59, 0x70, 0x56, 0x5A, 0x7A, 0x72, 0x32, 0x8E, 0x71, 0x73, 0x98, 0x31, 0x25, 0x86", outClusters: ""
|
||||||
|
|
||||||
fingerprint deviceId: "0x1001", inClusters: "0x72, 0x86, 0x70, 0x85, 0x25, 0x9C, 0x71, 0x73, 0x32, 0x31, 0x7A", outClusters: "0x25" //v 2.2
|
|
||||||
fingerprint deviceId: "0x1000", inClusters: "0x72, 0x86, 0x70, 0x85, 0x8E, 0x25, 0x73, 0x32, 0x31, 0x7A", outClusters: "0x25, 0x31, 0x32" //v2.4+
|
|
||||||
}
|
}
|
||||||
|
|
||||||
simulator {
|
simulator {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tiles(scale: 2) {
|
tiles(scale: 2) {
|
||||||
multiAttributeTile(name:"FGWP", type:"lighting", width:6, height:4) {//with generic type secondary control text is not displayed in Android app
|
multiAttributeTile(name:"FGWP", type:"lighting", width:6, height:4) {//with generic type secondary control text is not displayed in Android app
|
||||||
tileAttribute("device.switch", key:"PRIMARY_CONTROL") {
|
tileAttribute("device.switch", key:"PRIMARY_CONTROL") {
|
||||||
attributeState("on", label: '${name}', action: "switch.off", icon:"st.switches.switch.on", backgroundColor:"#79b821")
|
attributeState("on", label: '${name}', action: "switch.off", icon:"st.switches.switch.on", backgroundColor:"#79b821")
|
||||||
@@ -64,21 +63,88 @@ metadata {
|
|||||||
def parse(String description) {
|
def parse(String description) {
|
||||||
log.debug "Parsing '${description}'"
|
log.debug "Parsing '${description}'"
|
||||||
|
|
||||||
def cmd = zwave.parse(description, [0x25: 1, 0x31: 2, 0x32: 1, 0x72: 1, 0x86: 1])
|
if (description.startsWith("Err 106")) {
|
||||||
|
if (state.sec) {
|
||||||
if (cmd) {
|
result = createEvent(descriptionText:description, displayed:false)
|
||||||
log.debug "Parsed '${cmd}'"
|
} else {
|
||||||
zwaveEvent(cmd)
|
result = createEvent(
|
||||||
|
descriptionText: "FGK failed to complete the network security key exchange. If you are unable to receive data from it, you must remove it from your network and add it again.",
|
||||||
|
eventType: "ALERT",
|
||||||
|
name: "secureInclusion",
|
||||||
|
value: "failed",
|
||||||
|
displayed: true,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} else if (description == "updated") {
|
||||||
|
return null
|
||||||
|
} else {
|
||||||
|
def cmd = zwave.parse(description, [0x25: 1, 0x31: 5, 0x32: 1, 0x5A: 1, 0x71: 3, 0x72: 2, 0x86: 1])
|
||||||
|
|
||||||
|
if (cmd) {
|
||||||
|
log.debug "Parsed '${cmd}'"
|
||||||
|
zwaveEvent(cmd)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def zwaveEvent(physicalgraph.zwave.commands.manufacturerspecificv1.ManufacturerSpecificReport cmd) {
|
//security
|
||||||
|
def zwaveEvent(physicalgraph.zwave.commands.securityv1.SecurityMessageEncapsulation cmd) {
|
||||||
|
def encapsulatedCommand = cmd.encapsulatedCommand([0x25: 1, 0x5A: 1])
|
||||||
|
if (encapsulatedCommand) {
|
||||||
|
return zwaveEvent(encapsulatedCommand)
|
||||||
|
} else {
|
||||||
|
log.warn "Unable to extract encapsulated cmd from $cmd"
|
||||||
|
createEvent(descriptionText: cmd.toString())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//crc16
|
||||||
|
def zwaveEvent(physicalgraph.zwave.commands.crc16encapv1.Crc16Encap cmd)
|
||||||
|
{
|
||||||
|
def versions = [0x31: 5, 0x32: 1, 0x71: 3, 0x72: 2, 0x86: 1]
|
||||||
|
def version = versions[cmd.commandClass as Integer]
|
||||||
|
def ccObj = version ? zwave.commandClass(cmd.commandClass, version) : zwave.commandClass(cmd.commandClass)
|
||||||
|
def encapsulatedCommand = ccObj?.command(cmd.command)?.parse(cmd.data)
|
||||||
|
if (!encapsulatedCommand) {
|
||||||
|
log.debug "Could not extract command from $cmd"
|
||||||
|
} else {
|
||||||
|
zwaveEvent(encapsulatedCommand)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def zwaveEvent(physicalgraph.zwave.commands.meterv1.MeterReport cmd) {
|
||||||
|
if (cmd.scale == 0) {
|
||||||
|
createEvent(name: "energy", value: cmd.scaledMeterValue, unit: "kWh")
|
||||||
|
} else if (cmd.scale == 2) {
|
||||||
|
createEvent(name: "power", value: Math.round(cmd.scaledMeterValue), unit: "W")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def zwaveEvent(physicalgraph.zwave.commands.manufacturerspecificv2.ManufacturerSpecificReport cmd) {
|
||||||
log.debug "manufacturerId: ${cmd.manufacturerId}"
|
log.debug "manufacturerId: ${cmd.manufacturerId}"
|
||||||
log.debug "manufacturerName: ${cmd.manufacturerName}"
|
log.debug "manufacturerName: ${cmd.manufacturerName}"
|
||||||
log.debug "productId: ${cmd.productId}"
|
log.debug "productId: ${cmd.productId}"
|
||||||
log.debug "productTypeId: ${cmd.productTypeId}"
|
log.debug "productTypeId: ${cmd.productTypeId}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def zwaveEvent(physicalgraph.zwave.commands.manufacturerspecificv2.DeviceSpecificReport cmd) {
|
||||||
|
log.debug "deviceIdData: ${cmd.deviceIdData}"
|
||||||
|
log.debug "deviceIdDataFormat: ${cmd.deviceIdDataFormat}"
|
||||||
|
log.debug "deviceIdDataLengthIndicator: ${cmd.deviceIdDataLengthIndicator}"
|
||||||
|
log.debug "deviceIdType: ${cmd.deviceIdType}"
|
||||||
|
|
||||||
|
if (cmd.deviceIdType == 1 && cmd.deviceIdDataFormat == 1) {//serial number in binary format
|
||||||
|
String serialNumber = "h'"
|
||||||
|
|
||||||
|
cmd.deviceIdData.each{ data ->
|
||||||
|
serialNumber += "${String.format("%02X", data)}"
|
||||||
|
}
|
||||||
|
|
||||||
|
updateDataValue("serialNumber", serialNumber)
|
||||||
|
log.debug "${device.displayName} - serial number: ${serialNumber}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
def zwaveEvent(physicalgraph.zwave.commands.versionv1.VersionReport cmd) {
|
def zwaveEvent(physicalgraph.zwave.commands.versionv1.VersionReport cmd) {
|
||||||
updateDataValue("version", "${cmd.applicationVersion}.${cmd.applicationSubVersion}")
|
updateDataValue("version", "${cmd.applicationVersion}.${cmd.applicationSubVersion}")
|
||||||
log.debug "applicationVersion: ${cmd.applicationVersion}"
|
log.debug "applicationVersion: ${cmd.applicationVersion}"
|
||||||
@@ -88,15 +154,7 @@ def zwaveEvent(physicalgraph.zwave.commands.versionv1.VersionReport cmd) {
|
|||||||
log.debug "zWaveProtocolSubVersion: ${cmd.zWaveProtocolSubVersion}"
|
log.debug "zWaveProtocolSubVersion: ${cmd.zWaveProtocolSubVersion}"
|
||||||
}
|
}
|
||||||
|
|
||||||
def zwaveEvent(physicalgraph.zwave.commands.meterv1.MeterReport cmd) {
|
def zwaveEvent(physicalgraph.zwave.commands.sensormultilevelv5.SensorMultilevelReport cmd) {
|
||||||
if (cmd.scale == 0) {
|
|
||||||
createEvent(name: "energy", value: cmd.scaledMeterValue, unit: "kWh")
|
|
||||||
} else if (cmd.scale == 2) {
|
|
||||||
createEvent(name: "power", value: Math.round(cmd.scaledMeterValue), unit: "W")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def zwaveEvent(physicalgraph.zwave.commands.sensormultilevelv2.SensorMultilevelReport cmd) {
|
|
||||||
def map = [ displayed: true ]
|
def map = [ displayed: true ]
|
||||||
if (cmd.sensorType == 4) {
|
if (cmd.sensorType == 4) {
|
||||||
createEvent(name: "power", value: Math.round(cmd.scaledSensorValue), unit: "W")
|
createEvent(name: "power", value: Math.round(cmd.scaledSensorValue), unit: "W")
|
||||||
@@ -107,6 +165,21 @@ def zwaveEvent(physicalgraph.zwave.commands.switchbinaryv1.SwitchBinaryReport cm
|
|||||||
createEvent(name: "switch", value: cmd.value ? "on" : "off", type: "digital")
|
createEvent(name: "switch", value: cmd.value ? "on" : "off", type: "digital")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def zwaveEvent(physicalgraph.zwave.commands.deviceresetlocallyv1.DeviceResetLocallyNotification cmd) {
|
||||||
|
log.info "${device.displayName}: received command: $cmd - device has reset itself"
|
||||||
|
}
|
||||||
|
|
||||||
|
def zwaveEvent(physicalgraph.zwave.commands.notificationv3.NotificationReport cmd)
|
||||||
|
{
|
||||||
|
if (cmd.notificationType == 0x08) {
|
||||||
|
if (cmd.event == 0x06) {
|
||||||
|
createEvent(descriptionText: "Warning: $device.displayName detected over-current", isStateChange: true)
|
||||||
|
} else if (cmd.event == 0x08) {
|
||||||
|
createEvent(descriptionText: "Warning: $device.displayName detected over-load", isStateChange: true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
def zwaveEvent(physicalgraph.zwave.Command cmd) {
|
def zwaveEvent(physicalgraph.zwave.Command cmd) {
|
||||||
log.debug "$device.displayName: Unhandled: $cmd"
|
log.debug "$device.displayName: Unhandled: $cmd"
|
||||||
[:]
|
[:]
|
||||||
@@ -115,57 +188,67 @@ def zwaveEvent(physicalgraph.zwave.Command cmd) {
|
|||||||
// handle commands
|
// handle commands
|
||||||
def configure() {
|
def configure() {
|
||||||
log.debug "Executing 'configure'"
|
log.debug "Executing 'configure'"
|
||||||
|
|
||||||
def cmds = []
|
def cmds = []
|
||||||
|
|
||||||
cmds += zwave.manufacturerSpecificV1.manufacturerSpecificGet()
|
cmds += zwave.manufacturerSpecificV1.manufacturerSpecificGet()
|
||||||
|
cmds += zwave.manufacturerSpecificV2.deviceSpecificGet()
|
||||||
cmds += zwave.versionV1.versionGet()
|
cmds += zwave.versionV1.versionGet()
|
||||||
//this group is associated automatically upon inclusion, but it is not needed
|
cmds += zwave.associationV2.associationSet(groupingIdentifier:1, nodeId:[zwaveHubNodeId])
|
||||||
//group 3 should be set instead
|
|
||||||
cmds += zwave.associationV2.associationRemove(groupingIdentifier:1, nodeId:[zwaveHubNodeId])
|
|
||||||
cmds += zwave.associationV2.associationSet(groupingIdentifier:3, nodeId:[zwaveHubNodeId])
|
|
||||||
cmds += zwave.meterV2.meterGet(scale:0)
|
cmds += zwave.meterV2.meterGet(scale:0)
|
||||||
cmds += zwave.meterV2.meterGet(scale:2)
|
cmds += zwave.meterV2.meterGet(scale:2)
|
||||||
cmds += zwave.switchBinaryV1.switchBinaryGet()
|
cmds += zwave.switchBinaryV1.switchBinaryGet()
|
||||||
|
|
||||||
sequence(cmds, 500)
|
encapSequence(cmds, 500)
|
||||||
}
|
}
|
||||||
|
|
||||||
def refresh() {
|
def refresh() {
|
||||||
log.debug "Executing 'refresh'"
|
log.debug "Executing 'refresh'"
|
||||||
|
|
||||||
def cmds = []
|
def cmds = []
|
||||||
cmds += zwave.meterV2.meterGet(scale:0)
|
cmds += zwave.meterV2.meterGet(scale:0)
|
||||||
cmds += zwave.meterV2.meterGet(scale:2)
|
cmds += zwave.meterV2.meterGet(scale:2)
|
||||||
cmds += zwave.switchBinaryV1.switchBinaryGet()
|
cmds += zwave.switchBinaryV1.switchBinaryGet()
|
||||||
|
|
||||||
sequence(cmds, 500)
|
encapSequence(cmds, 500)
|
||||||
}
|
|
||||||
|
|
||||||
def reset() {
|
|
||||||
log.debug "Executing 'reset'"
|
|
||||||
zwave.meterV2.meterReset().format()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def on() {
|
def on() {
|
||||||
log.debug "Executing 'on'"
|
log.debug "Executing 'on'"
|
||||||
|
encap(zwave.switchBinaryV1.switchBinarySet(switchValue: 0xFF))
|
||||||
def cmds = []
|
|
||||||
cmds += zwave.switchBinaryV1.switchBinarySet(switchValue: 0xFF)
|
|
||||||
cmds += zwave.switchBinaryV1.switchBinaryGet()//for ZW3 version Report is not automatically sent after receiving Set frame
|
|
||||||
|
|
||||||
sequence(cmds)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def off() {
|
def off() {
|
||||||
log.debug "Executing 'off'"
|
log.debug "Executing 'off'"
|
||||||
|
encap(zwave.switchBinaryV1.switchBinarySet(switchValue: 0x00))
|
||||||
def cmds = []
|
|
||||||
cmds += zwave.switchBinaryV1.switchBinarySet(switchValue: 0x00)
|
|
||||||
cmds += zwave.switchBinaryV1.switchBinaryGet()//for ZW3 version Report is not automatically sent after receiving Set frame
|
|
||||||
|
|
||||||
sequence(cmds)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private sequence(commands, delay=200) {
|
def reset() {
|
||||||
delayBetween(commands.collect{ it.format() }, delay)
|
log.debug "Executing 'reset'"
|
||||||
|
encap(zwave.meterV2.meterReset())
|
||||||
|
}
|
||||||
|
|
||||||
|
private secure(physicalgraph.zwave.Command cmd) {
|
||||||
|
zwave.securityV1.securityMessageEncapsulation().encapsulate(cmd).format()
|
||||||
|
}
|
||||||
|
|
||||||
|
private crc16(physicalgraph.zwave.Command cmd) {
|
||||||
|
//zwave.crc16encapV1.crc16Encap().encapsulate(cmd).format()
|
||||||
|
"5601${cmd.format()}0000"
|
||||||
|
}
|
||||||
|
|
||||||
|
private encapSequence(commands, delay=200) {
|
||||||
|
delayBetween(commands.collect{ encap(it) }, delay)
|
||||||
|
}
|
||||||
|
|
||||||
|
private encap(physicalgraph.zwave.Command cmd) {
|
||||||
|
def secureClasses = [0x25, 0x5A, 0x70, 0x85, 0x8E]
|
||||||
|
|
||||||
|
//todo: check if secure inclusion was successful
|
||||||
|
//if not do not send security-encapsulated command
|
||||||
|
if (secureClasses.find{ it == cmd.commandClassId }) {
|
||||||
|
secure(cmd)
|
||||||
|
} else {
|
||||||
|
crc16(cmd)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user