/** Copyright Sinopé Technologies SVN-365 * 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: "DM2500ZB Sinope Dimmer", namespace: "Sinope Technologies", author: "Sinope Technologies") { capability "Actuator" capability "Configuration" capability "Refresh" capability "Switch" capability "Switch Level" fingerprint profileId: "0104", inClusters: "0000 0003 0004 0005 0006 0008", manufacturer: "Sinope Technologies", model: "DM2500ZB" } 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.level", key: "SLIDER_CONTROL") { attributeState "level", action:"switch level.setLevel" } /** //tileAttribute ("device.level", key: "SLIDER_CONTROL", range: "(0..100)") //{ // attributeState "level", action:"switch level.setLevel" //} **/ } standardTile("refresh", "device.switch", inactiveLabel: false, decoration: "flat", width: 2, height: 2) { state "default", label:"", action:"refresh.refresh", icon:"st.secondary.refresh" } main "switch" details(["switch","refresh"]) } } //-- Parsing --------------------------------------------------------------------------------------------- def parse(String description) { log.debug "description is $description" def cluster = zigbee.parse(description) def event = zigbee.getEvent(description) log.debug "EVENT = $event" if(event) { log.debug "send event : $event" sendEvent(event) } else { log.warn "DID NOT PARSE MESSAGE for description : $description" log.debug zigbee.parseDescriptionAsMap(description) } } def parseDescriptionAsMap(description) { log.debug "parsing MAP ..." (description - "read attr - ").split(",").inject([:]) { map, param -> def nameAndValue = param.split(":") map += [(nameAndValue[0].trim()):nameAndValue[1].trim()] } } //-- On Off Control -------------------------------------------------------------------------------------- def off() { zigbee.off() // + zigbee.readAttribute(0x0008, 0x0000) } def on() { zigbee.on() // + zigbee.readAttribute(0x0008, 0x0000) } //-- Level Control --------------------------------------------------------------------------------------- def setLevel(value) { log.debug "primary value = $value" zigbee.setLevel(value,0) } //-- refresh --------------------------------------------------------------------------------------------- def refresh() { return zigbee.readAttribute(0x0006, 0x0000) + zigbee.readAttribute(0x0008, 0x0000) } //-- configuration --------------------------------------------------------------------------------------- def configure() { log.debug "Configuring Reporting and Bindings." return zigbee.configureReporting(0x0006, 0x0000, 0x10, 0, 599, null) + zigbee.configureReporting(0x0008, 0x0000, 0x20, 3, 602, 0x01) + zigbee.readAttribute(0x0006, 0x0000) + zigbee.readAttribute(0x0008, 0x0000) }