/** Copyright Sinopé Technologies SVN-376 * 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. **/ metadata { definition (name: "RM3250ZB Load Controller", namespace: "Sinope Technologies", author: "Sinope Technologies") { capability "Refresh" capability "Switch" capability "Configuration" capability "Actuator" capability "Power Meter" //attribute "voltage", "number" attribute "power", "number" attribute "load", "number" fingerprint profileId: "0104", deviceId: "0002", inClusters: "0000, 0003, 0004, 0005, 0006, 0B04, 0B05, FF01", manufacturer: "Sinope Technologies", model: "RM3250ZB", deviceJoinName: "RM3250ZB" } tiles(scale: 2) { multiAttributeTile(name:"switch", type: "lighting", width: 6, height: 4, canChangeIcon: true) { tileAttribute ("device.switch", key: "PRIMARY_CONTROL") { attributeState "on", label:'${name}', action:"switch.off", icon:"st.switches.light.on", backgroundColor:"#79b821", nextState:"turningOff" attributeState "off", label:'${name}', action:"switch.on", icon:"st.switches.light.off", backgroundColor:"#ffffff", nextState:"turningOn" attributeState "turningOn", label:'${name}', action:"switch.off", icon:"st.switches.light.on", backgroundColor:"#79b821", nextState:"turningOff" attributeState "turningOff", label:'${name}', action:"switch.on", icon:"st.switches.light.off", backgroundColor:"#ffffff", nextState:"turningOn" } tileAttribute ("device.power", key: "SECONDARY_CONTROL") { attributeState "power", label:'actual load: ${currentValue} Watts' } } // value tile (read only) //valueTile("voltage", "device.voltage", decoration: "flat", width: 2, height: 2) { // state "voltage", label:'${currentValue} V' //} // value tile (read only) valueTile("load", "device.load", decoration: "flat", width: 2, height: 2) { state "load", label:'${currentValue} W' } standardTile("refresh", "device.refresh", inactiveLabel: false, decoration: "flat", width: 2, height: 2) { state "default", label:"", action:"refresh.refresh", icon:"st.secondary.refresh" } main "switch" details(["switch", "load", "refresh"]) //details(["switch", "voltage", "load", "refresh"]) } } // Parse incoming device messages to generate events def parse(String description) { log.debug "Description is $description" def event = zigbee.getEvent(description) if (event) { log.debug "Event name is $event.name" if (event.name == "power") { def powerValue powerValue = (event.value as Integer) //TODO: The divisor value needs to be set as part of configuration sendEvent(name: "power", value: powerValue) } else { sendEvent(event) } } else { if (description?.startsWith("read attr -")) { log.debug "Description start with read attr -" def mymap = zigbee.parseDescriptionAsMap(description) if (mymap) { log.debug "Mymap is $mymap" log.debug "Cluster is $mymap.cluster and Attribute is $mymap.attrId" if(mymap.cluster == "FF01" && mymap.attrId == "0060"){ def loadValue loadValue = zigbee.convertHexToInt(mymap.value) //loadValue = loadValue / 10 log.debug "Load connected id $loadValue Watt" def name = "load" def value = loadValue sendEvent(name: "load", value: loadValue) } //log.debug "Cluster is $mymap.cluster" //if ( mymap.attrId =="0505" ) { // log.debug "attribute is $mymap.attrId" // def voltageValue // //voltageValue = (mymap.value as Integer) // voltageValue = zigbee.convertHexToInt(mymap.value) // voltageValue = voltageValue / 10 // log.debug "Voltage is $voltageValue V" //} //} // if(mymap.cluster == "0B04" && mymap.attrId =="0505") { // def voltageValue // voltageValue = (mymap.value as Integer) // log.debug "Voltage is $voltageValue" // } } } } } def off() { return zigbee.off() + "delay 3000" + zigbee.readAttribute(0x0B04, 0x050B) } def on() { return zigbee.on() + "delay 3000" + zigbee.readAttribute(0x0B04, 0x050B) + zigbee.readAttribute(0xFF01, 0x0060) } def refresh() { return zigbee.readAttribute(0x0006, 0x0000) /*+ zigbee.readAttribute(0x0B04, 0x0505)*/ + zigbee.readAttribute(0x0B04, 0x050B) + zigbee.readAttribute(0xFF01, 0x0060) + zigbee.configureReporting(0x0006, 0x0000, 0x10, 0, 599, null) /*+ zigbee.configureReporting(0x0B04, 0x0505, 0x21, 60, 600, 1)*/ + zigbee.configureReporting(0x0B04, 0x050B, 0x29, 60, 599, 0x64) } def configure() { log.debug "Configuring Reporting and Bindings." return zigbee.configureReporting(0x0006, 0x0000, 0x10, 0, 600, null) /*+ zigbee.configureReporting(0x0B04, 0x0505, 0x21, 10, 600, null)*/ + zigbee.configureReporting(0x0B04, 0x050B, 0x29, 60, 599, 0x64) + zigbee.readAttribute(0x0006, 0x0000) + zigbee.readAttribute(0x0B04, 0x050B) /*+ zigbee.readAttribute(0x0B04, 0x0505)*/ + zigbee.readAttribute(0xFF01, 0x0060) }