[
  {
    "path": ".gitattributes",
    "content": "# Auto detect text files and perform LF normalization\n* text=auto\n\n# Custom for Visual Studio\n*.cs     diff=csharp\n\n# Standard to msysgit\n*.doc\t diff=astextplain\n*.DOC\t diff=astextplain\n*.docx diff=astextplain\n*.DOCX diff=astextplain\n*.dot  diff=astextplain\n*.DOT  diff=astextplain\n*.pdf  diff=astextplain\n*.PDF\t diff=astextplain\n*.rtf\t diff=astextplain\n*.RTF\t diff=astextplain\n"
  },
  {
    "path": ".gitignore",
    "content": "Aeon Doorbell/device_type-aeon-doorbell-v0.4\nzooZ-MiniPlug-ZEN07/device_type-zooZ-MiniPlug-ZEN07.groovy"
  },
  {
    "path": ".idea/misc.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n  <component name=\"ProjectRootManager\">\n    <output url=\"file://$PROJECT_DIR$/out\" />\n  </component>\n</project>"
  },
  {
    "path": "Aeon Door and Window Sensor DSB04100-ZWUS/Aeon_Door_and_Window_Sensor-DSB04100-ZWUS.groovy",
    "content": "/**\n *  Copyright 2015 SmartThings and 2016 Robert Vandervoort\n *\n *  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except\n *  in compliance with the License. You may obtain a copy of the License at:\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n *  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed\n *  on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License\n *  for the specific language governing permissions and limitations under the License.\n *\n *  Aeon Labs DSB04100-ZWUS - Z-Wave Door & Window Sensor\n *\n *  Author: SmartThings and Robert Vandervoort\n *  Date: 7-17-2016\n */\n\nmetadata {\n\tdefinition (name: \"Aeon Labs DSB04100-ZWUS - Z-Wave Door & Window Sensor - RV\", namespace: \"robertvandervoort\", author: \"Robert Vandervoort\") {\n\t\tcapability \"Contact Sensor\"\n\t\tcapability \"Tamper Alert\"\n\t\tcapability \"Sensor\"\n\t\tcapability \"Battery\"\n\t\tcapability \"Configuration\"\n\t\t// RAW ID 0 0 0x0701 0 0 0 f 0x5E 0x86 0x72 0x85 0x59 0x73 0x71 0x84 0x30 0x80 0x70 0x98 0x7A 0xEF 0x5A\n\t\tfingerprint deviceId: \"0x0701\", inClusters: \"0x5E,0x86,0x72,0x85,0x59,0x73,0x71,0x84,0x30,0x80,0x70,0x98,0x7A,0xEF,0x5A\"\n\t}\n\n\tsimulator {\n\t\t// status messages\n\t\tstatus \"open\":  \"command: 2001, payload: FF\"\n\t\tstatus \"closed\": \"command: 2001, payload: 00\"\n\t\tstatus \"wake up\": \"command: 8407, payload: \"\n\t\tstatus \"detected\": \"command: 7105, payload:  000000FF07030000\"\n\t\tstatus \"clear\": \"command: 7105, payload:  000000FF07000000\"\n\t}\n\n\ttiles {\n\t\tstandardTile(\"contact\", \"device.contact\", width: 2, height: 2) {\n\t\t\tstate \"open\", label: '${name}', icon: \"st.contact.contact.open\", backgroundColor: \"#ffa81e\"\n\t\t\tstate \"closed\", label: '${name}', icon: \"st.contact.contact.closed\", backgroundColor: \"#79b821\"\n\t\t}\n\t\tstandardTile(\"tamper\", \"device.tamper\", width: 2, height: 2) {\n\t\t\tstate \"detected\", label: '${currentValue}', icon: \"st.motion.acceleration.active\", backgroundColor: \"#ff0000\"\n\t\t\tstate \"clear\", label: '${currentValue}', icon: \"st.motion.acceleration.inactive\", backgroundColor: \"#00ff00\"\n\t\t}\n\t\tvalueTile(\"battery\", \"device.battery\", inactiveLabel: false, decoration: \"flat\") {\n\t\t\tstate \"battery\", label:'${currentValue}% battery', unit:\"\"\n\t\t}\n\t\tmain \"contact\"\n\t\tdetails([\"contact\", \"tamper\", \"battery\"])\n\t}\n}\n\ndef parse(String description) {\n\tdef result = null\n\tif (description.startsWith(\"Err 106\")) {\n\t\tif (state.sec) {\n\t\t\tlog.debug description\n\t\t} else {\n\t\t\tresult = createEvent(\n\t\t\t\tdescriptionText: \"This sensor failed to complete the network security key exchange. If you are unable to control it via SmartThings, you must remove it from your network and add it again.\",\n\t\t\t\teventType: \"ALERT\",\n\t\t\t\tname: \"secureInclusion\",\n\t\t\t\tvalue: \"failed\",\n\t\t\t\tisStateChange: true,\n\t\t\t)\n\t\t}\n\t} else if (description != \"updated\") {\n\t\tdef cmd = zwave.parse(description, [0x20: 1, 0x25: 1, 0x30: 1, 0x31: 5, 0x80: 1, 0x84: 1, 0x71: 3, 0x9C: 1])\n\t\tif (cmd) {\n\t\t\tresult = zwaveEvent(cmd)\n\t\t}\n\t}\n\tlog.debug \"parsed '$description' to $result\"\n\treturn result\n}\n\ndef updated() {\n\tdef cmds = []\n\tif (!state.MSR) {\n\t\tcmds = [\n\t\t\tcommand(zwave.manufacturerSpecificV2.manufacturerSpecificGet()),\n\t\t\t\"delay 1200\",\n\t\t\tzwave.wakeUpV1.wakeUpNoMoreInformation().format()\n\t\t]\n\t} else if (!state.lastbat) {\n\t\tcmds = []\n\t} else {\n\t\tcmds = [zwave.wakeUpV1.wakeUpNoMoreInformation().format()]\n\t}\n\tresponse(cmds)\n}\n\ndef configure() {\n\tcommands([\n\t\tzwave.manufacturerSpecificV2.manufacturerSpecificGet(),\n\t\tzwave.batteryV1.batteryGet()\n\t], 6000)\n}\n\ndef sensorValueEvent(value) {\n\tif (value) {\n\t\tcreateEvent(name: \"contact\", value: \"open\", descriptionText: \"$device.displayName is open\")\n\t} else {\n\t\tcreateEvent(name: \"contact\", value: \"closed\", descriptionText: \"$device.displayName is closed\")\n\t}\n\tresult\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicReport cmd)\n{\n\tsensorValueEvent(cmd.value)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicSet cmd)\n{\n\tsensorValueEvent(cmd.value)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.notificationv3.NotificationReport cmd)\n{\n\tdef result = []\n\tif (cmd.notificationType == 0x07) {\n\t\tif (cmd.event == 0x03) {\n\t\t\tresult << createEvent(name: \"tamper\", value: \"detected\", descriptionText: \"$device.displayName was removed.\", isStateChange: true)\n\t\t\tif(!state.MSR) result << response(command(zwave.manufacturerSpecificV2.manufacturerSpecificGet()))\n\t\t} else if (cmd.event == 0x00) {\n\t\t\tresult << createEvent(name: \"tamper\", value: \"clear\", descriptionText: \"$device.displayName was replaced.\", isStateChange: true)\n\t\t\tif(!state.MSR) result << response(command(zwave.manufacturerSpecificV2.manufacturerSpecificGet()))\n\t\t} else if (cmd.notificationType == 0x06 && cmd.event == 0x16) {\n\t\t\tresult << sensorValueEvent(1)\n\t\t} else if (cmd.notificationType == 0x06 && cmd.event == 0x17) {\n\t\t\tresult << sensorValueEvent(0)\n\t\t}\n\tresult\n\t}\n\tresult\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.wakeupv1.WakeUpNotification cmd)\n{\n\tdef event = createEvent(descriptionText: \"${device.displayName} woke up\", isStateChange: false)\n\tdef cmds = []\n\tif (!state.MSR) {\n\t\tcmds << command(zwave.manufacturerSpecificV2.manufacturerSpecificGet())\n\t\tcmds << \"delay 1200\"\n\t}\n\tif (!state.lastbat || now() - state.lastbat > 53*60*60*1000) {\n\t\tcmds << command(zwave.batteryV1.batteryGet())\n\t} else {\n\t\tcmds << zwave.wakeUpV1.wakeUpNoMoreInformation().format()\n\t}\n\t[event, response(cmds)]\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.batteryv1.BatteryReport cmd) {\n\tdef map = [ name: \"battery\", unit: \"%\" ]\n\tif (cmd.batteryLevel == 0xFF) {\n\t\tmap.value = 1\n\t\tmap.descriptionText = \"${device.displayName} has a low battery\"\n\t\tmap.isStateChange = true\n\t} else {\n\t\tmap.value = cmd.batteryLevel\n\t}\n\tstate.lastbat = now()\n\t[createEvent(map), response(zwave.wakeUpV1.wakeUpNoMoreInformation())]\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.manufacturerspecificv2.ManufacturerSpecificReport cmd) {\n\tdef result = []\n\tdef msr = String.format(\"%04X-%04X-%04X\", cmd.manufacturerId, cmd.productTypeId, cmd.productId)\n\tlog.debug \"msr: $msr\"\n\tupdateDataValue(\"MSR\", msr)\n\tresult << createEvent(descriptionText: \"$device.displayName MSR: $msr\", isStateChange: false)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.securityv1.SecurityMessageEncapsulation cmd) {\n\tdef encapsulatedCommand = cmd.encapsulatedCommand([0x20: 1, 0x25: 1, 0x30: 1, 0x31: 5, 0x80: 1, 0x84: 1, 0x71: 3, 0x9C: 1])\n\t// log.debug \"encapsulated: $encapsulatedCommand\"\n\tif (encapsulatedCommand) {\n\t\tstate.sec = 1\n\t\tzwaveEvent(encapsulatedCommand)\n\t}\n}\n\ndef zwaveEvent(physicalgraph.zwave.Command cmd) {\n\tcreateEvent(descriptionText: \"$device.displayName: $cmd\", displayed: false)\n}\n\nprivate command(physicalgraph.zwave.Command cmd) {\n\tif (state.sec == 1) {\n\t\tzwave.securityV1.securityMessageEncapsulation().encapsulate(cmd).format()\n\t} else {\n\t\tcmd.format()\n\t}\n}\n\nprivate commands(commands, delay=200) {\n\tdelayBetween(commands.collect{ command(it) }, delay)\n}"
  },
  {
    "path": "Aeon Doorbell/aeon-doorbell-v04.groovy",
    "content": "/*\n * V 0.4 of Aeon Doorbell code 10/4/2017\n *  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except\n *  in compliance with the License. You may obtain a copy of the License at:\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n *  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed\n *  on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License\n *  for the specific language governing permissions and limitations under the License.\n *\n *\tChangelog:\n *\tv 0.1 - initial push of device type, ability to change ring tone, volume and number of rings, basic set reporting\n * for use as a switch to trigger stuff, and ability to trigger as an alarm\n *\tv 0.2 - added separate preference for alarm triggering so a different ringtone can be used for alarm VS doorbell. created\n *\tseparate test buttons for doorbell and alarm\n *\tv 0.3 - added firmware version and checksum reporting as part of the config command, modifed the way the battery check works, may need to redress it later\n *  v 0.4 - added motion activation capability when doorbell or alerm is rung. you can use this to trigger smart home monitor by adding the doorbell as a motion\n *  sensor and have this trigger a siren or another doorbell's alrm tone for multi doorbell houses\n */\n\nmetadata {\n    definition (name: \"Aeon Doorbell - RV v0.4\", namespace: \"robertvandervoort\", author: \"Robert Vandervoort\") {\n        capability \"Actuator\"\n        capability \"Alarm\"\n        capability \"Battery\"\n        capability \"Switch\"\n        capability \"Configuration\"\n        capability \"Refresh\"\n        capability \"Music Player\"\n        capability \"Motion Sensor\"\n\n        command \"atest\"\n        command \"btest\"\n        command \"getbatt\"\n        command \"setRingtone\"\n\n        fingerprint deviceId: \"0x1005\", inClusters: \"0x5E,0x98\"\n    }\n    // simulator metadata\n\n    simulator {\n        /*status \"battery good\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n                zwave.configurationV1.configurationReport(\n                parameterNumber: 42, configurationValue: 0\n                )\n            ).incomingMessage()\n        status \"low battery alert\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n                zwave.configurationV1.configurationReport(\n                parameterNumber: 42, configurationValue: 255\n                )\n            ).incomingMessage()\n        */\n        reply \"9881002001FF,9881002002\": \"command: 9881, payload: 002003FF\"\n        reply \"988100200100,9881002002\": \"command: 9881, payload: 00200300\"\n        reply \"9881002001FF,delay 3000,988100200100,9881002002\": \"command: 9881, payload: 00200300\"\n    }\n    // tile definitions\n    tiles (scale: 2) {\n        multiAttributeTile(name:\"alarm\", type:\"generic\", width:6, height:4, canChangeIcon: true, canChangeBackground: true) {\n            tileAttribute(\"device.alarm\", key: \"PRIMARY_CONTROL\") {\n                attributeState \"off\", label:'OFF', action:'alarm.on', icon:\"st.alarm.alarm.alarm\", backgroundColor:\"#ffffff\"\n                attributeState \"on\", label:'RINGING', action:'alarm.off', icon:\"st.alarm.alarm.alarm\", backgroundColor:\"#e86d13\"\n            }\n        }\n        standardTile(\"btest\", \"device.alarm\", inactiveLabel: false, width: 2, height: 2)\t{\n            state \"default\", label:'bell', action:\"btest\", icon:\"st.Electronics.electronics14\"\n        }\n        standardTile(\"atest\", \"device.alarm\", inactiveLabel: false, width: 2, height: 2)\t{\n            state \"default\", label:'alarm', action:\"atest\", icon:\"st.Electronics.electronics14\"\n        }\n        standardTile(\"off\", \"device.alarm\", inactiveLabel: false, width: 2, height: 2) {\n            state \"default\", label:'', action:\"off\", icon:\"st.secondary.off\"\n        }\n        valueTile(\"battery\", \"device.battery\", decoration: \"flat\", width: 2, height: 2) {\n            state \"battery\", label:'Battery', action:\"getbatt\", backgroundColors:[\n                    [value: 0, color: \"#FF0000\"],\n                    [value: 100, color: \"#00FF00\"]\n            ]\n        }\n        standardTile(\"configure\", \"device.configure\", inactiveLabel: false, decoration: \"flat\", width: 2, height: 2) {\n            state \"configure\", label:'', action:\"configuration.configure\", icon:\"st.secondary.configure\"\n        }\n        standardTile(\"refresh\", \"device.power\", inactiveLabel: false, decoration: \"flat\", width: 2, height: 2) {\n            state \"default\", label:'', action:\"refresh.refresh\", icon:\"st.secondary.refresh\"\n        }\n        valueTile(\"testSoundLabel\", \"device.battery\", width: 2, height: 2, inactiveLabel: false, decoration: \"flat\") {\n            state \"battery\", label:'Test Sound:', unit:\"\"\n        }\n        controlTile(\"testSoundSlider\", \"device.playTrack\", \"slider\", width: 4, height: 2, inactiveLabel: false, range:\"(1..99)\") {\n            state \"testSound\", action:\"playTrack\", backgroundColor: \"#1e9cbb\"\n        }\n        standardTile(\"motion\",\"device.motion\", width: 2, height: 2) {\n           \tstate \"active\",label:'motion',icon:\"st.motion.motion.active\",backgroundColor:\"#53a7c0\"\n            state \"inactive\",label:'no motion',icon:\"st.motion.motion.inactive\",backgroundColor:\"#ffffff\"\n\t\t}\n        main \"alarm\"\n        details([\"alarm\",\"btest\",\"atest\",\"off\",\"testSoundLabel\",\"testSoundSlider\",\"battery\",\"setRingtone\",\"setVolume\",\"refresh\",\"motion\",\"configure\"])\n    }\n\n    preferences {\n        input \"debugOutput\", \"boolean\",\n                title: \"Enable debug logging?\",\n                defaultValue: false,\n                displayDuringSetup: true\n        input \"prefRingtone\", \"integer\",\n                title: \"Doorbell tone:\",\n                description: \"Pick the ringtone, 1-100\",\n                defaultValue: 1,\n                range: \"1..100\",\n                required: false,\n                displayduringSetup: true\n        input \"prefAlarmtone\", \"integer\",\n                title: \"Alarm tone:\",\n                description: \"Pick the alarm tone, 1-100\",\n                defaultValue: 6,\n                range: \"1..100\",\n                required: false,\n                displayduringSetup: true\n        input \"prefVolume\", \"integer\",\n                title: \"Doorbell volume:\",\n                description: \"Set the volume of the doorbell\",\n                defaultValue: 10,\n                range: \"0..10\",\n                required: false,\n                displayduringSetup: true\n        input \"prefNumrings\", \"integer\",\n                title: \"Ring repetitions:\",\n                description: \"How many times to ring per push of the doorbell\",\n                defaultValue: 1,\n                range: \"1..100\",\n                required: false,\n                displayduringSetup: true\n\t\tinput \"motionEnabled\", \"boolean\",\n        \t\ttitle: \"Motion event on ring?\",\n                description: \"Generate motion for triggering other doorbells or alarm\",\n                defaultValue: false,\n                required: false,\n                displayduringSetup: true\n    }\n}\n\ndef updated()\n{\n    state.debug = (\"true\" == debugOutput)\n    if (state.sec && !isConfigured()) {\n        // in case we miss the SCSR\n        response(configure())\n\n    }\n}\n\ndef parse(String description)\n{\n    def result = null\n    if (description.startsWith(\"Err 106\")) {\n        state.sec = 0\n        result = createEvent( name: \"secureInclusion\", value: \"failed\", isStateChange: true,\n                descriptionText: \"This sensor failed to complete the network security key exchange. If you are unable to control it via SmartThings, you must remove it from your network and add it again.\")\n    } else if (description != \"updated\") {\n        def cmd = zwave.parse(description, [0x25: 1, 0x26: 1, 0x27: 1, 0x32: 3, 0x33: 3, 0x59: 1, 0x70: 1, 0x72: 2, 0x73: 1, 0x7A: 2, 0x82: 1, 0x85: 2, 0x86: 1])\n        if (cmd) {\n            result = zwaveEvent(cmd)\n        }\n    }\n    if (state.debug) log.debug \"Parsed '${description}' to ${result.inspect()}\"\n    return result\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.securityv1.SecurityMessageEncapsulation cmd) {\n    def encapsulatedCommand = cmd.encapsulatedCommand([0x25: 1, 0x26: 1, 0x27: 1, 0x32: 3, 0x33: 3, 0x59: 1, 0x70: 1, 0x72: 2, 0x73: 1, 0x7A: 2, 0x82: 1, 0x85: 2, 0x86: 1])\n    state.sec = 1\n    // if (state.debug) log.debug \"encapsulated: ${encapsulatedCommand}\"\n    if (encapsulatedCommand) {\n        zwaveEvent(encapsulatedCommand)\n    } else {\n        log.warn \"Unable to extract encapsulated cmd from $cmd\"\n        createEvent(descriptionText: cmd.toString())\n    }\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.securityv1.SecurityCommandsSupportedReport cmd) {\n    response(configure())\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.powerlevelv1.PowerlevelTestNodeReport cmd) {\n    if (state.debug) log.debug \"===Power level test node report received=== ${device.displayName}: statusOfOperation: ${cmd.statusOfOperation} testFrameCount: ${cmd.testFrameCount} testNodeid: ${cmd.testNodeid}\"\n    def request = [\n            physicalgraph.zwave.commands.powerlevelv1.PowerlevelGet()\n    ]\n    response(commands(request))\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.versionv1.VersionCommandClassReport cmd) {\n    if (state.debug) log.debug \"---COMMAND CLASS VERSION REPORT V1--- ${device.displayName} has command class version: ${cmd.commandClassVersion} - payload: ${cmd.payload}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.versionv1.VersionReport cmd) {\n    def fw = \"${cmd.applicationVersion}.${cmd.applicationSubVersion}\"\n    updateDataValue(\"fw\", fw)\n    if (state.debug) log.debug \"---VERSION REPORT V1--- ${device.displayName} is running firmware version: $fw, Z-Wave version: ${cmd.zWaveProtocolVersion}.${cmd.zWaveProtocolSubVersion}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.firmwareupdatemdv2.FirmwareMdReport cmd) {\n    if (state.debug) log.debug \"---FIRMWARE MD REPORT V2--- ${device.displayName} has Checksum of ${cmd.checksum} firmwareId: ${cmd.firmwareId}, manufacturerId: ${cmd.firmwareId}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.configurationv2.ConfigurationReport cmd) {\n    if (state.debug) log.debug \"---CONFIGURATION REPORT V2--- ${device.displayName} parameter ${cmd.parameterNumber} with a byte size of ${cmd.size} is set to ${cmd.configurationValue}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.configurationv1.ConfigurationReport cmd) {\n    if (state.debug) log.debug \"---CONFIGURATION REPORT V1--- ${device.displayName} parameter ${cmd.parameterNumber} with a byte size of ${cmd.size} is set to ${cmd.configurationValue}\"\n    def map = [ name: \"battery\", value: 100]\n    if (cmd.parameterNumber == 42) {\n        if (cmd.configurationValue == [255]) {\n            map.value = 0\n            map.descriptionText = \"${device.displayName} remote battery is low\"\n            if (state.debug) log.debug \"${device.displayName} remote battery is low\"\n            map.isStateChange = true\n        } else {\n            map.value = 100\n            map.descriptionText = \"${device.displayName} remote battery is good\"\n            if (state.debug) log.debug \"${device.displayName} remote battery is good\"\n            map.isStateChange = true\n        }\n    }\n    createEvent(map)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.associationv2.AssociationReport cmd) {\n    cmd.nodeId.each({log.debug \"AssociationReport: '${cmd}', hub: '$zwaveHubNodeId' reports nodeId: '$it' is associated in group: '${cmd.groupingIdentifier}'\"})\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.hailv1.Hail cmd) {\n    if (state.debug) log.debug \"Hail received: ${cmd}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicReport cmd) {\n    if (state.debug) log.debug \"doorbell value:${cmd.value}\";\n    sendEvent(name: \"switch\", value: cmd.value ? \"on\" : \"off\", type: \"physical\", displayed: true, isStateChange: true, descriptiontext: \"doorbell\");\n    sendEvent(name: \"alarm\", value: cmd.value ? \"on\" : \"off\", type: \"physical\", displayed: true, isStateChange: true);\n    if (motionEnabled == \"true\") {\n    \tif (cmd.value == 255) {\n    \t\tsendEvent(name: \"motion\", value: \"active\", displayed: true, isStateChange: true)\n    \t} else {\n    \tsendEvent(name: \"motion\", value: \"inactive\", displayed: true, isStateChange: true)\n    \t}\n\t}\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicSet cmd) {\n    if (state.debug) log.debug cmd\n    createEvent(name: \"alarm\", value: cmd.value ? \"on\" : \"off\", type: \"physical\", displayed: true, isStateChange: true)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.switchbinaryv1.SwitchBinaryReport cmd) {\n    if (state.debug) log.debug cmd\n    createEvent(name: \"alarm\", value: cmd.value ? \"on\" : \"off\", type: \"digital\", displayed: true, isStateChange: true)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.switchbinaryv1.SwitchBinarySet cmd) {\n    if (state.debug) log.debug cmd\n    createEvent(name: \"alarm\", value: cmd.value ? \"on\" : \"off\", type: \"digital\", displayed: true, isStateChange: true)\n}\n\ndef zwaveEvent(physicalgraph.zwave.Command cmd) {\n    if (state.debug) log.debug \"Unhandled: $cmd sent to ${device.displayName}\"\n    createEvent(descriptionText: cmd.toString(), isStateChange: false)\n}\n\ndef getbatt() {\n    if (state.debug) log.debug \"Getting battery level for remote control on ${device.displayName}\"\n    def request = [\n            zwave.configurationV1.configurationGet(parameterNumber: 42)\n    ]\n    commands(request)\n}\n\ndef btest() {\n    if (state.debug) log.debug \"Testing doorbell ring ${prefRingtone} on ${device.displayName}\"\n    on()\n}\n\ndef atest() {\n    if (state.debug) log.debug \"Testing alarm sound ${prefAlarmtone} on ${device.displayName}\"\n    both()\n}\n\ndef playTrack(track) {\n    disableNotifications()\n    def request = [\n            zwave.configurationV1.configurationSet(parameterNumber: 6, size: 1, scaledConfigurationValue: track.toInteger())\n    ]\n    commands(request)\n}\n\ndef disableNotifications() {\n    state.notification = false\n}\n\ndef setRingtone(track) {\n    def request = [\n            zwave.configurationV1.configurationSet(parameterNumber: 5, size: 1, scaledConfigurationValue: track)\n    ]\n    commands(request)\n}\n\ndef strobe() {\n    if (state.debug) log.debug \"Strobe command received\"\n    on()\n}\n\ndef siren() {\n    if (state.debug) log.debug \"Siren command received\"\n    on()\n}\n\ndef both() {\n    if (state.debug) log.debug \"Alarm test command received\"\n\n    def request = [\n            zwave.configurationV1.configurationSet(parameterNumber: 6, size: 1, scaledConfigurationValue: prefAlarmtone.toInteger())\n    ]\n    commands(request)\n}\n\ndef on() {\n    if (state.debug) log.debug \"Ringing ${device.displayName}\"\n    def request = [\n            zwave.basicV1.basicSet(value: 0xFF)\n    ]\n    commands(request)\n    if (state.notification) {\n        sendEvent(name: \"switch\", value: \"on\", type: \"physical\", displayed: true, isStateChange: true)\n        if (state.debug) log.debug \"${device.displayName} has been rung from button.\"\n    } else {\n        if (state.debug) log.debug \"${device.displayName} has been rung from playTrack.\"\n    }\n}\n\ndef off() {\n    if (state.debug) log.debug \"turning off ${device.displayName}\"\n    def request = [\n            zwave.basicV1.basicSet(value: 0x00),\n            zwave.basicV1.basicGet()\n    ]\n    commands(request)\n    if (state.notification) sendEvent(name: \"switch\", value: \"off\", type: \"physical\", displayed: true, isStateChange: true)\n    state.notification = true\n}\n\ndef refresh() {\n    if (state.debug) log.debug \"refresh request sent to ${device.displayName}\"\n    def request = [\n            zwave.basicV1.basicGet(),\n            zwave.switchBinaryV1.switchBinaryGet()\n    ]\n    commands(request)\n}\n\ndef configure() {\n    if (state.debug) {\n\t\tlog.debug \"settings: ${settings.inspect()}, state: ${state.inspect()}\"\n        if (state.sec) {\n            log.debug \"secure configuration being sent to ${device.displayName}\"\n        }\n        else\n        if (state.debug) log.debug \"configuration being sent to ${device.displayName}\"\n    }\n    if (!state.prefRingtone) state.prefRingtone = 1\n    if (!state.prefAlarmtone) state.prefAlarmtone = 6\n    if (!state.prefVolume) state.prefVolume = 10\n    if (!state.prefNumrings) state.prefNumrings = 1\n    log.debug \"settings: ${settings.inspect()}, state: ${state.inspect()}\"\n\n    def request = [\n            //associate with group 1 and remove any group 2 association\n            //zwave.associationV1.associationRemove(groupingIdentifier:2, nodeId:zwaveHubNodeId),\n            //zwave.associationV1.associationSet(groupingIdentifier:1, nodeId:zwaveHubNodeId),\n            zwave.associationV1.associationGet(groupingIdentifier:1),\n            zwave.associationV1.associationGet(groupingIdentifier:2),\n\n            // Get Version information\n            zwave.versionV1.versionGet(),\n            zwave.firmwareUpdateMdV2.firmwareMdGet(),\n\n            // Enable to send notifications to associated devices (Group 1) (0=nothing, 1=hail CC, 2=basic CC report)\n            zwave.configurationV1.configurationSet(parameterNumber: 80, size: 1, scaledConfigurationValue: 2),\n            zwave.configurationV1.configurationGet(parameterNumber: 80),\n\n            // send low battery notifications\n            zwave.configurationV1.configurationSet(parameterNumber: 81, size: 1, scaledConfigurationValue: 1),\n            zwave.configurationV1.configurationGet(parameterNumber: 81),\n\n            // Set the repetitions for playing doorbell ringtone\n            zwave.configurationV1.configurationSet(parameterNumber: 2, size: 1, scaledConfigurationValue: prefNumrings.toInteger()),\n            zwave.configurationV1.configurationGet(parameterNumber: 2),\n\n            // Set the default doorbell ringtone\n            zwave.configurationV1.configurationSet(parameterNumber: 5, size: 1, scaledConfigurationValue: prefRingtone.toInteger()),\n            zwave.configurationV1.configurationGet(parameterNumber: 5),\n\n            // Set the volume of ringtone\n            zwave.configurationV1.configurationSet(parameterNumber: 8, size: 1, scaledConfigurationValue: prefVolume.toInteger()),\n            zwave.configurationV1.configurationGet(parameterNumber: 8),\n\n            // define +- button function\n            zwave.configurationV1.configurationSet(parameterNumber: 10, size: 1, scaledConfigurationValue: 0),\n            zwave.configurationV1.configurationGet(parameterNumber: 10),\n            zwave.configurationV1.configurationSet(parameterNumber: 11, size: 1, scaledConfigurationValue: 0),\n            zwave.configurationV1.configurationGet(parameterNumber: 11),\n            //\tGet last known remote battery health\n            zwave.configurationV1.configurationGet(parameterNumber: 42)\n    ]\n    commands(request)\n}\n\nprivate setConfigured() {\n    updateDataValue(\"configured\", \"true\")\n}\n\nprivate isConfigured() {\n    getDataValue(\"configured\") == \"true\"\n}\n\nprivate command(physicalgraph.zwave.Command cmd) {\n    if (state.sec) {\n        zwave.securityV1.securityMessageEncapsulation().encapsulate(cmd).format()\n    } else {\n        cmd.format()\n    }\n}\n\nprivate commands(commands, delay=500) {\n    delayBetween(commands.collect{ command(it) }, delay)\n}\n"
  },
  {
    "path": "Aeon Doorbell/device_type-aeon-doorbell-v0.1",
    "content": "/*\n * V 0.1 of Aeon Doorbell code 11/24/2015\n *  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except\n *  in compliance with the License. You may obtain a copy of the License at:\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n *  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed\n *  on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License\n *  for the specific language governing permissions and limitations under the License.\n *\n */\n\n metadata {\n\tdefinition (name: \"Aeon Doorbell - RV v0.1\", namespace: \"robertvandervoort\", author: \"Robert Vandervoort\") {\n\t\tcapability \"Actuator\"\n\t\tcapability \"Alarm\"\n\t\tcapability \"Switch\"\n \t\tcapability \"Configuration\"\n\t\tcapability \"Refresh\"\n\n\t\tcommand \"test\"\n\n\t\tfingerprint deviceId: \"0x1005\", inClusters: \"0x5E,0x98\"\n\t}\n\t// simulator metadata\n\t\n\tsimulator {\n\t\tfor (int i in [0, 5, 10, 15, 50, 99, 100]) {\n\t\t\tstatus \"battery ${i}%\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().batteryV1.batteryReport(\n                batteryLevel: i\n                )\n\t\t\t).incomingMessage()\n\t\t}\n\t\tstatus \"low battery alert\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().batteryV1.batteryReport(\n            \tbatteryLevel: 255\n            \t)\n\t\t).incomingMessage()\n\t\treply \"9881002001FF,9881002002\": \"command: 9881, payload: 002003FF\"\n\t\treply \"988100200100,9881002002\": \"command: 9881, payload: 00200300\"\n\t\treply \"9881002001FF,delay 3000,988100200100,9881002002\": \"command: 9881, payload: 00200300\"\n\t}\n\n\t// tile definitions\n\ttiles (scale: 2) {\n    \tmultiAttributeTile(name:\"alarm\", type:\"generic\", width:6, height:4, canChangeIcon: true) {\n\t\t\ttileAttribute(\"device.alarm\", key: \"PRIMARY_CONTROL\") {\n            \tattributeState \"off\", label:'off', action:'alarm.siren', icon:\"st.alarm.alarm.alarm\", backgroundColor:\"#ffffff\"\n\t\t\t\tattributeState \"on\", label:'alarm!', action:'alarm.off', icon:\"st.alarm.alarm.alarm\", backgroundColor:\"#e86d13\"\n            }\n\t\t}\n\t\tstandardTile(\"test\", \"device.alarm\", inactiveLabel: false, decoration: \"flat\", width: 2, height: 2)\t{\n\t\t\tstate \"default\", label:'', action:\"test\", icon:\"st.secondary.test\"\n\t\t}\n\t\tstandardTile(\"off\", \"device.alarm\", inactiveLabel: false, decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'', action:\"off\", icon:\"st.secondary.off\"\n\t\t}\n\t\tvalueTile(\"battery\", \"device.battery\", decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"battery\", label:'${currentValue}% battery', unit:\"\"\n\t\t}\n\t\tstandardTile(\"configure\", \"device.configure\", inactiveLabel: false, decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"configure\", label:'', action:\"configuration.configure\", icon:\"st.secondary.configure\"\n\t\t}\n\t\tstandardTile(\"refresh\", \"device.power\", inactiveLabel: false, decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'', action:\"refresh.refresh\", icon:\"st.secondary.refresh\"\n\t\t}\n\t\tmain \"alarm\"\n\t\tdetails([\"alarm\",\"test\",\"off\",\"battery\",\"setRingtone\",\"setVolume\",\"refresh\",\"configure\"])\n\t}\n\t\n    preferences { \n\t\tinput \"debugOutput\", \"boolean\", \n\t\t\ttitle: \"Enable debug logging?\",\n\t\t\tdefaultValue: false,\n\t\t\tdisplayDuringSetup: true\n\t\tinput \"prefRingtone\", \"integer\",\n        \ttitle: \"Doorbell tone:\",\n            description: \"Pick the ringtone, 1-100\",\n            defaultValue: 1,\n            range: \"1..100\",\n            required: false,\n            displayduringSetup: true\n\t\tinput \"prefVolume\", \"integer\",\n        \ttitle: \"Doorbell volume:\",\n            description: \"Set the volume of the doorbell\",\n            defaultValue: 10,\n            range: \"1..10\",\n            required: false,\n            displayduringSetup: true\n\t\tinput \"prefNumrings\", \"integer\",\n        \ttitle: \"Ring repetitions:\",\n            description: \"How many times to ring per push of the doorbell\",\n            defaultValue: 1,\n            range: \"1..100\",\n            required: false,\n            displayduringSetup: true\n\t}\n}\n\ndef updated()\n{\n\tstate.debug = (\"true\" == debugOutput)\n\tif (state.sec && !isConfigured()) {\n\t\t// in case we miss the SCSR\n\t\tresponse(configure())\n\t\t\n\t}\n}\n\ndef parse(String description)\n{\n\tdef result = null\n\tif (description.startsWith(\"Err 106\")) {\n\t\tstate.sec = 0\n\t\tresult = createEvent( name: \"secureInclusion\", value: \"failed\", isStateChange: true,\n\t\t\tdescriptionText: \"This sensor failed to complete the network security key exchange. If you are unable to control it via SmartThings, you must remove it from your network and add it again.\")\n\t} else if (description != \"updated\") {\n\t\tdef cmd = zwave.parse(description, [0x25: 1, 0x26: 1, 0x27: 1, 0x32: 3, 0x33: 3, 0x59: 1, 0x70: 1, 0x72: 2, 0x73: 1, 0x82: 1, 0x85: 2, 0x86: 2])\n\t\tif (cmd) {\n\t\t\tresult = zwaveEvent(cmd)\n\t\t}\n\t}\n\t// if (state.debug) log.debug \"Parsed '${description}' to ${result.inspect()}\"\n\treturn result\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.securityv1.SecurityMessageEncapsulation cmd) {\n\tdef encapsulatedCommand = cmd.encapsulatedCommand([0x25: 1, 0x26: 1, 0x27: 1, 0x32: 3, 0x33: 3, 0x59: 1, 0x70: 1, 0x72: 2, 0x73: 1, 0x82: 1, 0x85: 2, 0x86: 2])\n\tstate.sec = 1\n\tif (state.debug) log.debug \"encapsulated: ${encapsulatedCommand}\"\n\tif (encapsulatedCommand) {\n\t\tzwaveEvent(encapsulatedCommand)\n\t} else {\n\t\tlog.warn \"Unable to extract encapsulated cmd from $cmd\"\n\t\tcreateEvent(descriptionText: cmd.toString())\n\t}\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.securityv1.SecurityCommandsSupportedReport cmd) {\n\tresponse(configure())\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.powerlevelv1.PowerlevelTestNodeReport cmd) {\n\tif (state.debug) log.debug \"===Power level test node report received=== ${device.displayName}: statusOfOperation: ${cmd.statusOfOperation} testFrameCount: ${cmd.testFrameCount} testNodeid: ${cmd.testNodeid}\"\n\tdef request = [\n        physicalgraph.zwave.commands.powerlevelv1.PowerlevelGet()\n    ]\n    response(commands(request))\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.configurationv2.ConfigurationReport cmd) {\n    if (state.debug) log.debug \"---CONFIGURATION REPORT V2--- ${device.displayName} parameter ${cmd.parameterNumber} with a byte size of ${cmd.size} is set to ${cmd.configurationValue}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.configurationv1.ConfigurationReport cmd) {\n    if (state.debug) log.debug \"---CONFIGURATION REPORT V1--- ${device.displayName} parameter ${cmd.parameterNumber} with a byte size of ${cmd.size} is set to ${cmd.configurationValue}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.associationv2.AssociationReport cmd) {\n    cmd.nodeId.each({log.debug \"AssociationReport: '${cmd}', hub: '$zwaveHubNodeId' reports nodeId: '$it' is associated in group: '${cmd.groupingIdentifier}'\"})\n    [:]\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.hailv1.Hail cmd) {\n\tif (state.debug) log.debug \"Hail received: ${cmd}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicReport cmd)\n{\n\tif (state.debug) log.debug \"doorbell value:${cmd.value}\"\n    [\n    \tcreateEvent([name: \"switch\", value: cmd.value ? \"on\" : \"off\", type: \"physical\", displayed: true, isStateChange: true]),\n    \tcreateEvent([name: \"alarm\", value: cmd.value ? \"on\" : \"off\", type: \"physical\", displayed: true, isStateChange: true])\n    ]\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicSet cmd) \n{\n\tif (state.debug) log.debug cmd\n    [name: \"alarm\", value: cmd.value ? \"on\" : \"off\", type: \"physical\", displayed: true, isStateChange: true]\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.switchbinaryv1.SwitchBinaryReport cmd)\n{\n\tif (state.debug) log.debug cmd\n\t[name: \"alarm\", value: cmd.value ? \"on\" : \"off\", type: \"digital\", displayed: true, isStateChange: true]\n}\n\t\ndef zwaveEvent(physicalgraph.zwave.commands.switchbinaryv1.SwitchBinarySet cmd)\n{\n\tif (state.debug) log.debug cmd\n    [name: \"alarm\", value: cmd.value ? \"on\" : \"off\", type: \"digital\", displayed: true, isStateChange: true]\n}\n\ndef zwaveEvent(physicalgraph.zwave.Command cmd) {\n\tif (state.debug) log.debug \"Unhandled: $cmd sent to ${device.displayName}\"\n    createEvent(descriptionText: cmd.toString(), isStateChange: false)\n}\n\ndef test() {\n\tif (state.debug) log.debug \"Ringing ${device.displayName}\"\n\tdef request = [\n\t\tzwave.basicV1.basicSet(value: 0xFF),\n        zwave.basicV1.basicGet()\n\t]\n    commands(request)\n}\n\ndef strobe() {\n\tif (state.debug) log.debug \"Strobe command received\"\n\ton()\n}\n\ndef siren() {\n\tif (state.debug) log.debug \"Siren command received\"\n\ton()\n}\n\ndef both() {\n\tif (state.debug) log.debug \"Both command received\"\n\ton()\n}\n\ndef on() {\n\tif (state.debug) log.debug \"Ringing ${device.displayName}\"\n\tdef request = [\n\t\tzwave.basicV1.basicSet(value: 0xFF),\n        zwave.basicV1.basicGet()\n\t]\n    commands(request)\n}\n\ndef off() {\n\tif (state.debug) log.debug \"turning off ${device.displayName}\"\n\tdef request = [\n\t\tzwave.basicV1.basicSet(value: 0x00),\n        zwave.basicV1.basicGet()\n\t]\n    commands(request)\n}\n\ndef refresh() {\n\tif (state.debug) log.debug \"refresh request sent to ${device.displayName}\"\n\tdef request = [\n        zwave.basicV1.basicGet(),\n\t\tzwave.switchBinaryV1.switchBinaryGet()\n\t]\n    commands(request)\n}\n\ndef configure() {\n\tif (state.debug) {\n    \tif (state.sec) {\n        \tlog.debug \"secure configuration being sent to ${device.displayName}\"\n            }\n        else\n        \tif (state.debug) log.debug \"configuration being sent to ${device.displayName}\"\n\t\t}\n\tif (!state.prefRingtone) state.prefRingtone = 1\n\tif (!state.prefVolume) state.prefVolume = 10\n\tif (!state.prefNumrings) state.prefNumrings = 1\n\tlog.debug \"settings: ${settings.inspect()}, state: ${state.inspect()}\"\n    \n    def request = [\n    \t//associate with group 1 and remove any group 2 association\n        zwave.associationV1.associationRemove(groupingIdentifier:2, nodeId:zwaveHubNodeId),\n        zwave.associationV1.associationSet(groupingIdentifier:1, nodeId:zwaveHubNodeId),\n        zwave.associationV1.associationGet(groupingIdentifier:1),\n        zwave.associationV1.associationGet(groupingIdentifier:2),\n        \n    \t// Enable to send notifications to associated devices (Group 1) (0=nothing, 1=hail CC, 2=basic CC report)\n        zwave.configurationV1.configurationSet(parameterNumber: 80, size: 1, scaledConfigurationValue: 2),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 80),\n        \n        // send low battery notifications\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 81, size: 1, scaledConfigurationValue: 1),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 81),\n\t\t\n\t\t// Set the repetitions for playing doorbell ringtone\n        zwave.configurationV1.configurationSet(parameterNumber: 2, size: 1, scaledConfigurationValue: prefNumrings.toInteger()),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 2),\n        \n        // Set the default doorbell ringtone\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 5, size: 1, scaledConfigurationValue: prefRingtone.toInteger()),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 5),\n        \n\t\t// Set the volume of ringtone\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 8, size: 1, scaledConfigurationValue: prefVolume.toInteger()),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 8),\n        \n\t\t// define +- button function\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 10, size: 1, scaledConfigurationValue: 0),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 10),\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 11, size: 1, scaledConfigurationValue: 0),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 11)\n    ]\n\tcommands(request)\n}\n\nprivate setConfigured() {\n\tupdateDataValue(\"configured\", \"true\")\n}\n\nprivate isConfigured() {\n\tgetDataValue(\"configured\") == \"true\"\n}\n\nprivate command(physicalgraph.zwave.Command cmd) {\n\tif (state.sec) {\n\t\tzwave.securityV1.securityMessageEncapsulation().encapsulate(cmd).format()\n\t} else {\n\t\tcmd.format()\n\t}\n}\n\nprivate commands(commands, delay=500) {\n\tdelayBetween(commands.collect{ command(it) }, delay)\n}"
  },
  {
    "path": "Aeon Doorbell/device_type-aeon-doorbell-v0.2",
    "content": "/*\n * V 0.2 of Aeon Doorbell code 11/24/2015\n *  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except\n *  in compliance with the License. You may obtain a copy of the License at:\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n *  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed\n *  on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License\n *  for the specific language governing permissions and limitations under the License.\n *\n *\tChangelog:\n *\tv 0.1 - initial push of device type, ability to change ring tone, volume and number of rings, basic set reporting\n * for use as a switch to trigger stuff, and ability to trigger as an alarm\n *\tv 0.2 - added separate preference for alarm triggering so a different ringtone can be used for alarm VS doorbell. created\n *\tseparate test buttons for doorbell and alarm, battery tile now gets last known remote battery state and displays red or green for bad / good\n */\n\n metadata {\n\tdefinition (name: \"Aeon Doorbell - RV v0.2\", namespace: \"robertvandervoort\", author: \"Robert Vandervoort\") {\n\t\tcapability \"Actuator\"\n\t\tcapability \"Alarm\"\n        capability \"Battery\"\n\t\tcapability \"Switch\"\n \t\tcapability \"Configuration\"\n\t\tcapability \"Refresh\"\n\n\t\tcommand \"atest\"\n        command \"btest\"\n        command \"getbatt\"\n\n\t\tfingerprint deviceId: \"0x1005\", inClusters: \"0x5E,0x98\"\n\t}\n\t// simulator metadata\n\t\n\tsimulator {\n    \t/*status \"battery good\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tzwave.configurationV1.configurationReport(\n                parameterNumber: 42, configurationValue: 0\n                )\n\t\t\t).incomingMessage()         \n\t\tstatus \"low battery alert\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tzwave.configurationV1.configurationReport(\n            \tparameterNumber: 42, configurationValue: 255\n            \t)\n\t\t\t).incomingMessage()\n        */\n\t\treply \"9881002001FF,9881002002\": \"command: 9881, payload: 002003FF\"\n\t\treply \"988100200100,9881002002\": \"command: 9881, payload: 00200300\"\n\t\treply \"9881002001FF,delay 3000,988100200100,9881002002\": \"command: 9881, payload: 00200300\"\n\t}\n\t// tile definitions\n\ttiles (scale: 2) {\n    \tmultiAttributeTile(name:\"alarm\", type:\"generic\", width:6, height:4, canChangeIcon: true, canChangeBackground: true) {\n\t\t\ttileAttribute(\"device.alarm\", key: \"PRIMARY_CONTROL\") {\n            \tattributeState \"off\", label:'OFF', action:'alarm.on', icon:\"st.alarm.alarm.alarm\", backgroundColor:\"#ffffff\"\n\t\t\t\tattributeState \"on\", label:'RINGING', action:'alarm.off', icon:\"st.alarm.alarm.alarm\", backgroundColor:\"#e86d13\"\n            }\n\t\t}\n\t\tstandardTile(\"btest\", \"device.alarm\", inactiveLabel: false, width: 2, height: 2)\t{\n\t\t\tstate \"default\", label:'bell', action:\"btest\", icon:\"st.Electronics.electronics14\"\n\t\t}\n        standardTile(\"atest\", \"device.alarm\", inactiveLabel: false, width: 2, height: 2)\t{\n\t\t\tstate \"default\", label:'alarm', action:\"atest\", icon:\"st.Electronics.electronics14\"\n\t\t}\n\t\tstandardTile(\"off\", \"device.alarm\", inactiveLabel: false, width: 2, height: 2) {\n\t\t\tstate \"default\", label:'', action:\"off\", icon:\"st.secondary.off\"\n\t\t}\n\t\tvalueTile(\"battery\", \"device.battery\", decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"battery\", label:'Battery', action:\"getbatt\", backgroundColors:[\n                \t[value: 0, color: \"#FF0000\"],\n                    [value: 100, color: \"#00FF00\"]\n\t\t\t\t]\n\t\t}\n\t\tstandardTile(\"configure\", \"device.configure\", inactiveLabel: false, decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"configure\", label:'', action:\"configuration.configure\", icon:\"st.secondary.configure\"\n\t\t}\n\t\tstandardTile(\"refresh\", \"device.power\", inactiveLabel: false, decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'', action:\"refresh.refresh\", icon:\"st.secondary.refresh\"\n\t\t}\n\t\tmain \"alarm\"\n\t\tdetails([\"alarm\",\"btest\",\"atest\",\"off\",\"battery\",\"setRingtone\",\"setVolume\",\"refresh\",\"configure\"])\n\t}\n\t\n    preferences { \n\t\tinput \"debugOutput\", \"boolean\", \n\t\t\ttitle: \"Enable debug logging?\",\n\t\t\tdefaultValue: false,\n\t\t\tdisplayDuringSetup: true\n\t\tinput \"prefRingtone\", \"integer\",\n        \ttitle: \"Doorbell tone:\",\n            description: \"Pick the ringtone, 1-100\",\n            defaultValue: 1,\n            range: \"1..100\",\n            required: false,\n            displayduringSetup: true\n\t\tinput \"prefAlarmtone\", \"integer\",\n        \ttitle: \"Alarm tone:\",\n            description: \"Pick the alarm tone, 1-100\",\n            defaultValue: 6,\n            range: \"1..100\",\n            required: false,\n            displayduringSetup: true\n\t\tinput \"prefVolume\", \"integer\",\n        \ttitle: \"Doorbell volume:\",\n            description: \"Set the volume of the doorbell\",\n            defaultValue: 10,\n            range: \"1..10\",\n            required: false,\n            displayduringSetup: true\n\t\tinput \"prefNumrings\", \"integer\",\n        \ttitle: \"Ring repetitions:\",\n            description: \"How many times to ring per push of the doorbell\",\n            defaultValue: 1,\n            range: \"1..100\",\n            required: false,\n            displayduringSetup: true\n\t}\n}\n\ndef updated()\n{\n\tstate.debug = (\"true\" == debugOutput)\n\tif (state.sec && !isConfigured()) {\n\t\t// in case we miss the SCSR\n\t\tresponse(configure())\n\t\t\n\t}\n}\n\ndef parse(String description)\n{\n\tdef result = null\n\tif (description.startsWith(\"Err 106\")) {\n\t\tstate.sec = 0\n\t\tresult = createEvent( name: \"secureInclusion\", value: \"failed\", isStateChange: true,\n\t\t\tdescriptionText: \"This sensor failed to complete the network security key exchange. If you are unable to control it via SmartThings, you must remove it from your network and add it again.\")\n\t} else if (description != \"updated\") {\n\t\tdef cmd = zwave.parse(description, [0x25: 1, 0x26: 1, 0x27: 1, 0x32: 3, 0x33: 3, 0x59: 1, 0x70: 1, 0x72: 2, 0x73: 1, 0x82: 1, 0x85: 2, 0x86: 2])\n\t\tif (cmd) {\n\t\t\tresult = zwaveEvent(cmd)\n\t\t}\n\t}\n\t// if (state.debug) log.debug \"Parsed '${description}' to ${result.inspect()}\"\n\treturn result\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.securityv1.SecurityMessageEncapsulation cmd) {\n\tdef encapsulatedCommand = cmd.encapsulatedCommand([0x25: 1, 0x26: 1, 0x27: 1, 0x32: 3, 0x33: 3, 0x59: 1, 0x70: 1, 0x72: 2, 0x73: 1, 0x82: 1, 0x85: 2, 0x86: 2])\n\tstate.sec = 1\n\tif (state.debug) log.debug \"encapsulated: ${encapsulatedCommand}\"\n\tif (encapsulatedCommand) {\n\t\tzwaveEvent(encapsulatedCommand)\n\t} else {\n\t\tlog.warn \"Unable to extract encapsulated cmd from $cmd\"\n\t\tcreateEvent(descriptionText: cmd.toString())\n\t}\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.securityv1.SecurityCommandsSupportedReport cmd) {\n\tresponse(configure())\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.powerlevelv1.PowerlevelTestNodeReport cmd) {\n\tif (state.debug) log.debug \"===Power level test node report received=== ${device.displayName}: statusOfOperation: ${cmd.statusOfOperation} testFrameCount: ${cmd.testFrameCount} testNodeid: ${cmd.testNodeid}\"\n\tdef request = [\n        physicalgraph.zwave.commands.powerlevelv1.PowerlevelGet()\n    ]\n    response(commands(request))\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.configurationv2.ConfigurationReport cmd) {\n    if (state.debug) log.debug \"---CONFIGURATION REPORT V2--- ${device.displayName} parameter ${cmd.parameterNumber} with a byte size of ${cmd.size} is set to ${cmd.configurationValue}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.configurationv1.ConfigurationReport cmd) {\n    if (state.debug) log.debug \"---CONFIGURATION REPORT V1--- ${device.displayName} parameter ${cmd.parameterNumber} with a byte size of ${cmd.size} is set to ${cmd.configurationValue}\"\n    def map = [ name: \"battery\"]\n\tif (cmd.parameterNumber == 42 && cmd.configurationValue == 0xFF) {\n\t\tmap.value = 0\n\t\tmap.descriptionText = \"${device.displayName} remote battery is low\"\n\t\tif (state.debug) log.debug \"${device.displayName} remote battery is low\"\n        map.isStateChange = true\n\t} else {\n\t\tmap.value = 100\n        map.descriptionText = \"${device.displayName} remote battery is good\"\n\t\tif (state.debug) log.debug \"${device.displayName} remote battery is good\"\n        map.isStateChange = true\n\t}\n\tcreateEvent(map)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.associationv2.AssociationReport cmd) {\n    cmd.nodeId.each({log.debug \"AssociationReport: '${cmd}', hub: '$zwaveHubNodeId' reports nodeId: '$it' is associated in group: '${cmd.groupingIdentifier}'\"})\n    [:]\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.hailv1.Hail cmd) {\n\tif (state.debug) log.debug \"Hail received: ${cmd}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicReport cmd)\n{\n\tif (state.debug) log.debug \"doorbell value:${cmd.value}\"\n    [\n    \tcreateEvent([name: \"switch\", value: cmd.value ? \"on\" : \"off\", type: \"physical\", displayed: true, isStateChange: true]),\n    \tcreateEvent([name: \"alarm\", value: cmd.value ? \"on\" : \"off\", type: \"physical\", displayed: true, isStateChange: true])\n    ]\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicSet cmd) \n{\n\tif (state.debug) log.debug cmd\n    [name: \"alarm\", value: cmd.value ? \"on\" : \"off\", type: \"physical\", displayed: true, isStateChange: true]\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.switchbinaryv1.SwitchBinaryReport cmd)\n{\n\tif (state.debug) log.debug cmd\n\t[name: \"alarm\", value: cmd.value ? \"on\" : \"off\", type: \"digital\", displayed: true, isStateChange: true]\n}\n\t\ndef zwaveEvent(physicalgraph.zwave.commands.switchbinaryv1.SwitchBinarySet cmd)\n{\n\tif (state.debug) log.debug cmd\n    [name: \"alarm\", value: cmd.value ? \"on\" : \"off\", type: \"digital\", displayed: true, isStateChange: true]\n}\n\ndef zwaveEvent(physicalgraph.zwave.Command cmd) {\n\tif (state.debug) log.debug \"Unhandled: $cmd sent to ${device.displayName}\"\n    createEvent(descriptionText: cmd.toString(), isStateChange: false)\n}\n\ndef getbatt() {\n\tif (state.debug) log.debug \"Getting battery level for remote control on ${device.displayName}\"\n\tdef request = [\n        zwave.configurationV1.configurationGet(parameterNumber: 42)\n    ]\n    commands(request)\n}\n\ndef btest() {\n\tif (state.debug) log.debug \"Testing doorbell ring ${prefRingtone} on ${device.displayName}\"\n\ton()\n}\n\ndef atest() {\n\tif (state.debug) log.debug \"Testing alarm sound ${prefAlarmtone} on ${device.displayName}\"\n\tboth()\n}\n\ndef strobe() {\n\tif (state.debug) log.debug \"Strobe command received\"\n\ton()\n}\n\ndef siren() {\n\tif (state.debug) log.debug \"Siren command received\"\n\ton()\n}\n\ndef both() {\n\tif (state.debug) log.debug \"Alarm test command received\"\n\tdef request = [\n        zwave.configurationV1.configurationSet(parameterNumber: 6, size: 1, scaledConfigurationValue: prefAlarmtone.toInteger())\n    ]\n    commands(request)\n}\n\ndef on() {\n\tif (state.debug) log.debug \"Ringing ${device.displayName}\"\n\tdef request = [\n\t\tzwave.basicV1.basicSet(value: 0xFF)\n\t]\n    commands(request)\n}\n\ndef off() {\n\tif (state.debug) log.debug \"turning off ${device.displayName}\"\n\tdef request = [\n\t\tzwave.basicV1.basicSet(value: 0x00),\n        zwave.basicV1.basicGet()\n\t]\n    commands(request)\n}\n\ndef refresh() {\n\tif (state.debug) log.debug \"refresh request sent to ${device.displayName}\"\n\tdef request = [\n        zwave.basicV1.basicGet(),\n\t\tzwave.switchBinaryV1.switchBinaryGet()\n\t]\n    commands(request)\n}\n\ndef configure() {\n\tif (state.debug) {\n    \tif (state.sec) {\n        \tlog.debug \"secure configuration being sent to ${device.displayName}\"\n            }\n        else\n        \tif (state.debug) log.debug \"configuration being sent to ${device.displayName}\"\n\t\t}\n\tif (!state.prefRingtone) state.prefRingtone = 1\n    if (!state.prefRingtone) state.prefAlarmtone = 1\n\tif (!state.prefVolume) state.prefVolume = 10\n\tif (!state.prefNumrings) state.prefNumrings = 1\n\tlog.debug \"settings: ${settings.inspect()}, state: ${state.inspect()}\"\n    \n    def request = [\n    \t//associate with group 1 and remove any group 2 association\n        //zwave.associationV1.associationRemove(groupingIdentifier:2, nodeId:zwaveHubNodeId),\n        //zwave.associationV1.associationSet(groupingIdentifier:1, nodeId:zwaveHubNodeId),\n        zwave.associationV1.associationGet(groupingIdentifier:1),\n        zwave.associationV1.associationGet(groupingIdentifier:2),\n        \n    \t// Enable to send notifications to associated devices (Group 1) (0=nothing, 1=hail CC, 2=basic CC report)\n        zwave.configurationV1.configurationSet(parameterNumber: 80, size: 1, scaledConfigurationValue: 2),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 80),\n        \n        // send low battery notifications\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 81, size: 1, scaledConfigurationValue: 1),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 81),\n\t\t\n\t\t// Set the repetitions for playing doorbell ringtone\n        zwave.configurationV1.configurationSet(parameterNumber: 2, size: 1, scaledConfigurationValue: prefNumrings.toInteger()),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 2),\n        \n        // Set the default doorbell ringtone\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 5, size: 1, scaledConfigurationValue: prefRingtone.toInteger()),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 5),\n        \n\t\t// Set the volume of ringtone\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 8, size: 1, scaledConfigurationValue: prefVolume.toInteger()),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 8),\n        \n\t\t// define +- button function\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 10, size: 1, scaledConfigurationValue: 0),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 10),\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 11, size: 1, scaledConfigurationValue: 0),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 11)\n    ]\n\tcommands(request)\n}\n\nprivate setConfigured() {\n\tupdateDataValue(\"configured\", \"true\")\n}\n\nprivate isConfigured() {\n\tgetDataValue(\"configured\") == \"true\"\n}\n\nprivate command(physicalgraph.zwave.Command cmd) {\n\tif (state.sec) {\n\t\tzwave.securityV1.securityMessageEncapsulation().encapsulate(cmd).format()\n\t} else {\n\t\tcmd.format()\n\t}\n}\n\nprivate commands(commands, delay=500) {\n\tdelayBetween(commands.collect{ command(it) }, delay)\n}"
  },
  {
    "path": "Aeon Doorbell/device_type-aeon-doorbell-v0.3",
    "content": "/*\n * V 0.3 of Aeon Doorbell code 11/24/2015\n *  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except\n *  in compliance with the License. You may obtain a copy of the License at:\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n *  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed\n *  on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License\n *  for the specific language governing permissions and limitations under the License.\n *\n *\tChangelog:\n *\tv 0.1 - initial push of device type, ability to change ring tone, volume and number of rings, basic set reporting\n * for use as a switch to trigger stuff, and ability to trigger as an alarm\n *\tv 0.2 - added separate preference for alarm triggering so a different ringtone can be used for alarm VS doorbell. created\n *\tseparate test buttons for doorbell and alarm\n *\tv 0.3 - added firmware version and checksum reporting as part of the config command, modifed the way the battery check works, may need to redress it later\n */\n\n metadata {\n\tdefinition (name: \"Aeon Doorbell - RV v0.3\", namespace: \"robertvandervoort\", author: \"Robert Vandervoort\") {\n\t\tcapability \"Actuator\"\n\t\tcapability \"Alarm\"\n        capability \"Battery\"\n\t\tcapability \"Switch\"\n \t\tcapability \"Configuration\"\n\t\tcapability \"Refresh\"\n\n\t\tcommand \"atest\"\n        command \"btest\"\n        command \"getbatt\"\n\n\t\tfingerprint deviceId: \"0x1005\", inClusters: \"0x5E,0x98\"\n\t}\n\t// simulator metadata\n\t\n\tsimulator {\n    \t/*status \"battery good\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tzwave.configurationV1.configurationReport(\n                parameterNumber: 42, configurationValue: 0\n                )\n\t\t\t).incomingMessage()         \n\t\tstatus \"low battery alert\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tzwave.configurationV1.configurationReport(\n            \tparameterNumber: 42, configurationValue: 255\n            \t)\n\t\t\t).incomingMessage()\n        */\n\t\treply \"9881002001FF,9881002002\": \"command: 9881, payload: 002003FF\"\n\t\treply \"988100200100,9881002002\": \"command: 9881, payload: 00200300\"\n\t\treply \"9881002001FF,delay 3000,988100200100,9881002002\": \"command: 9881, payload: 00200300\"\n\t}\n\t// tile definitions\n\ttiles (scale: 2) {\n    \tmultiAttributeTile(name:\"alarm\", type:\"generic\", width:6, height:4, canChangeIcon: true, canChangeBackground: true) {\n\t\t\ttileAttribute(\"device.alarm\", key: \"PRIMARY_CONTROL\") {\n            \tattributeState \"off\", label:'OFF', action:'alarm.on', icon:\"st.alarm.alarm.alarm\", backgroundColor:\"#ffffff\"\n\t\t\t\tattributeState \"on\", label:'RINGING', action:'alarm.off', icon:\"st.alarm.alarm.alarm\", backgroundColor:\"#e86d13\"\n            }\n\t\t}\n\t\tstandardTile(\"btest\", \"device.alarm\", inactiveLabel: false, width: 2, height: 2)\t{\n\t\t\tstate \"default\", label:'bell', action:\"btest\", icon:\"st.Electronics.electronics14\"\n\t\t}\n        standardTile(\"atest\", \"device.alarm\", inactiveLabel: false, width: 2, height: 2)\t{\n\t\t\tstate \"default\", label:'alarm', action:\"atest\", icon:\"st.Electronics.electronics14\"\n\t\t}\n\t\tstandardTile(\"off\", \"device.alarm\", inactiveLabel: false, width: 2, height: 2) {\n\t\t\tstate \"default\", label:'', action:\"off\", icon:\"st.secondary.off\"\n\t\t}\n\t\tvalueTile(\"battery\", \"device.battery\", decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"battery\", label:'Battery', action:\"getbatt\", backgroundColors:[\n                \t[value: 0, color: \"#FF0000\"],\n                    [value: 100, color: \"#00FF00\"]\n\t\t\t\t]\n\t\t}\n\t\tstandardTile(\"configure\", \"device.configure\", inactiveLabel: false, decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"configure\", label:'', action:\"configuration.configure\", icon:\"st.secondary.configure\"\n\t\t}\n\t\tstandardTile(\"refresh\", \"device.power\", inactiveLabel: false, decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'', action:\"refresh.refresh\", icon:\"st.secondary.refresh\"\n\t\t}\n\t\tmain \"alarm\"\n\t\tdetails([\"alarm\",\"btest\",\"atest\",\"off\",\"battery\",\"setRingtone\",\"setVolume\",\"refresh\",\"configure\"])\n\t}\n\t\n    preferences { \n\t\tinput \"debugOutput\", \"boolean\", \n\t\t\ttitle: \"Enable debug logging?\",\n\t\t\tdefaultValue: false,\n\t\t\tdisplayDuringSetup: true\n\t\tinput \"prefRingtone\", \"integer\",\n        \ttitle: \"Doorbell tone:\",\n            description: \"Pick the ringtone, 1-100\",\n            defaultValue: 1,\n            range: \"1..100\",\n            required: false,\n            displayduringSetup: true\n\t\tinput \"prefAlarmtone\", \"integer\",\n        \ttitle: \"Alarm tone:\",\n            description: \"Pick the alarm tone, 1-100\",\n            defaultValue: 6,\n            range: \"1..100\",\n            required: false,\n            displayduringSetup: true\n\t\tinput \"prefVolume\", \"integer\",\n        \ttitle: \"Doorbell volume:\",\n            description: \"Set the volume of the doorbell\",\n            defaultValue: 10,\n            range: \"1..10\",\n            required: false,\n            displayduringSetup: true\n\t\tinput \"prefNumrings\", \"integer\",\n        \ttitle: \"Ring repetitions:\",\n            description: \"How many times to ring per push of the doorbell\",\n            defaultValue: 1,\n            range: \"1..100\",\n            required: false,\n            displayduringSetup: true\n\t}\n}\n\ndef updated()\n{\n\tstate.debug = (\"true\" == debugOutput)\n\tif (state.sec && !isConfigured()) {\n\t\t// in case we miss the SCSR\n\t\tresponse(configure())\n\t\t\n\t}\n}\n\ndef parse(String description)\n{\n\tdef result = null\n\tif (description.startsWith(\"Err 106\")) {\n\t\tstate.sec = 0\n\t\tresult = createEvent( name: \"secureInclusion\", value: \"failed\", isStateChange: true,\n\t\t\tdescriptionText: \"This sensor failed to complete the network security key exchange. If you are unable to control it via SmartThings, you must remove it from your network and add it again.\")\n\t} else if (description != \"updated\") {\n\t\tdef cmd = zwave.parse(description, [0x25: 1, 0x26: 1, 0x27: 1, 0x32: 3, 0x33: 3, 0x59: 1, 0x70: 1, 0x72: 2, 0x73: 1, 0x7A: 2, 0x82: 1, 0x85: 2, 0x86: 1])\n\t\tif (cmd) {\n\t\t\tresult = zwaveEvent(cmd)\n\t\t}\n\t}\n\t// if (state.debug) log.debug \"Parsed '${description}' to ${result.inspect()}\"\n\treturn result\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.securityv1.SecurityMessageEncapsulation cmd) {\n\tdef encapsulatedCommand = cmd.encapsulatedCommand([0x25: 1, 0x26: 1, 0x27: 1, 0x32: 3, 0x33: 3, 0x59: 1, 0x70: 1, 0x72: 2, 0x73: 1, 0x7A: 2, 0x82: 1, 0x85: 2, 0x86: 1])\n\tstate.sec = 1\n\t// if (state.debug) log.debug \"encapsulated: ${encapsulatedCommand}\"\n\tif (encapsulatedCommand) {\n\t\tzwaveEvent(encapsulatedCommand)\n\t} else {\n\t\tlog.warn \"Unable to extract encapsulated cmd from $cmd\"\n\t\tcreateEvent(descriptionText: cmd.toString())\n\t}\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.securityv1.SecurityCommandsSupportedReport cmd) {\n\tresponse(configure())\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.powerlevelv1.PowerlevelTestNodeReport cmd) {\n\tif (state.debug) log.debug \"===Power level test node report received=== ${device.displayName}: statusOfOperation: ${cmd.statusOfOperation} testFrameCount: ${cmd.testFrameCount} testNodeid: ${cmd.testNodeid}\"\n\tdef request = [\n        physicalgraph.zwave.commands.powerlevelv1.PowerlevelGet()\n    ]\n    response(commands(request))\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.versionv1.VersionCommandClassReport cmd) {\n\tif (state.debug) log.debug \"---COMMAND CLASS VERSION REPORT V1--- ${device.displayName} has command class version: ${cmd.commandClassVersion} - payload: ${cmd.payload}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.versionv1.VersionReport cmd) {\n\tdef fw = \"${cmd.applicationVersion}.${cmd.applicationSubVersion}\"\n\tupdateDataValue(\"fw\", fw)\n\tif (state.debug) log.debug \"---VERSION REPORT V1--- ${device.displayName} is running firmware version: $fw, Z-Wave version: ${cmd.zWaveProtocolVersion}.${cmd.zWaveProtocolSubVersion}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.firmwareupdatemdv2.FirmwareMdReport cmd) {\n\tif (state.debug) log.debug \"---FIRMWARE MD REPORT V2--- ${device.displayName} has Checksum of ${cmd.checksum} firmwareId: ${cmd.firmwareId}, manufacturerId: ${cmd.firmwareId}\"\n}    \n\ndef zwaveEvent(physicalgraph.zwave.commands.configurationv2.ConfigurationReport cmd) {\n    if (state.debug) log.debug \"---CONFIGURATION REPORT V2--- ${device.displayName} parameter ${cmd.parameterNumber} with a byte size of ${cmd.size} is set to ${cmd.configurationValue}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.configurationv1.ConfigurationReport cmd) {\n    if (state.debug) log.debug \"---CONFIGURATION REPORT V1--- ${device.displayName} parameter ${cmd.parameterNumber} with a byte size of ${cmd.size} is set to ${cmd.configurationValue}\"\n    def map = [ name: \"battery\"]\n\tif (cmd.parameterNumber == 42) {\n    \tif (cmd.configurationValue == [255]) {\n\t\t\tmap.value = 0\n\t\t\tmap.descriptionText = \"${device.displayName} remote battery is low\"\n\t\t\tif (state.debug) log.debug \"${device.displayName} remote battery is low\"\n        \tmap.isStateChange = true\n\t\t} else {\n\t\t\tmap.value = 100\n        \tmap.descriptionText = \"${device.displayName} remote battery is good\"\n\t\t\tif (state.debug) log.debug \"${device.displayName} remote battery is good\"\n        \tmap.isStateChange = true\n\t\t}\n\t}\n    createEvent(map)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.associationv2.AssociationReport cmd) {\n    cmd.nodeId.each({log.debug \"AssociationReport: '${cmd}', hub: '$zwaveHubNodeId' reports nodeId: '$it' is associated in group: '${cmd.groupingIdentifier}'\"})\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.hailv1.Hail cmd) {\n\tif (state.debug) log.debug \"Hail received: ${cmd}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicReport cmd)\n{\n\tif (state.debug) log.debug \"doorbell value:${cmd.value}\"\n    [\n    \tcreateEvent([name: \"switch\", value: cmd.value ? \"on\" : \"off\", type: \"physical\", displayed: true, isStateChange: true]),\n    \tcreateEvent([name: \"alarm\", value: cmd.value ? \"on\" : \"off\", type: \"physical\", displayed: true, isStateChange: true])\n    ]\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicSet cmd) \n{\n\tif (state.debug) log.debug cmd\n    [name: \"alarm\", value: cmd.value ? \"on\" : \"off\", type: \"physical\", displayed: true, isStateChange: true]\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.switchbinaryv1.SwitchBinaryReport cmd)\n{\n\tif (state.debug) log.debug cmd\n\t[name: \"alarm\", value: cmd.value ? \"on\" : \"off\", type: \"digital\", displayed: true, isStateChange: true]\n}\n\t\ndef zwaveEvent(physicalgraph.zwave.commands.switchbinaryv1.SwitchBinarySet cmd)\n{\n\tif (state.debug) log.debug cmd\n    [name: \"alarm\", value: cmd.value ? \"on\" : \"off\", type: \"digital\", displayed: true, isStateChange: true]\n}\n\ndef zwaveEvent(physicalgraph.zwave.Command cmd) {\n\tif (state.debug) log.debug \"Unhandled: $cmd sent to ${device.displayName}\"\n    createEvent(descriptionText: cmd.toString(), isStateChange: false)\n}\n\ndef getbatt() {\n\tif (state.debug) log.debug \"Getting battery level for remote control on ${device.displayName}\"\n\tdef request = [\n        zwave.configurationV1.configurationGet(parameterNumber: 42)\n    ]\n    commands(request)\n}\n\ndef btest() {\n\tif (state.debug) log.debug \"Testing doorbell ring ${prefRingtone} on ${device.displayName}\"\n\ton()\n}\n\ndef atest() {\n\tif (state.debug) log.debug \"Testing alarm sound ${prefAlarmtone} on ${device.displayName}\"\n\tboth()\n}\n\ndef strobe() {\n\tif (state.debug) log.debug \"Strobe command received\"\n\ton()\n}\n\ndef siren() {\n\tif (state.debug) log.debug \"Siren command received\"\n\ton()\n}\n\ndef both() {\n\tif (state.debug) log.debug \"Alarm test command received\"\n\tdef request = [\n        zwave.configurationV1.configurationSet(parameterNumber: 6, size: 1, scaledConfigurationValue: prefAlarmtone.toInteger())\n    ]\n    commands(request)\n}\n\ndef on() {\n\tif (state.debug) log.debug \"Ringing ${device.displayName}\"\n\tdef request = [\n\t\tzwave.basicV1.basicSet(value: 0xFF)\n\t]\n    commands(request)\n}\n\ndef off() {\n\tif (state.debug) log.debug \"turning off ${device.displayName}\"\n\tdef request = [\n\t\tzwave.basicV1.basicSet(value: 0x00),\n        zwave.basicV1.basicGet()\n\t]\n    commands(request)\n}\n\ndef refresh() {\n\tif (state.debug) log.debug \"refresh request sent to ${device.displayName}\"\n\tdef request = [\n        zwave.basicV1.basicGet(),\n\t\tzwave.switchBinaryV1.switchBinaryGet()\n\t]\n    commands(request)\n}\n\ndef configure() {\n\tif (state.debug) {\n    \tif (state.sec) {\n        \tlog.debug \"secure configuration being sent to ${device.displayName}\"\n            }\n        else\n        \tif (state.debug) log.debug \"configuration being sent to ${device.displayName}\"\n\t\t}\n\tif (!state.prefRingtone) state.prefRingtone = 1\n    if (!state.prefRingtone) state.prefAlarmtone = 1\n\tif (!state.prefVolume) state.prefVolume = 10\n\tif (!state.prefNumrings) state.prefNumrings = 1\n\tlog.debug \"settings: ${settings.inspect()}, state: ${state.inspect()}\"\n    \n    def request = [\n    \t//associate with group 1 and remove any group 2 association\n        //zwave.associationV1.associationRemove(groupingIdentifier:2, nodeId:zwaveHubNodeId),\n        //zwave.associationV1.associationSet(groupingIdentifier:1, nodeId:zwaveHubNodeId),\n        zwave.associationV1.associationGet(groupingIdentifier:1),\n        zwave.associationV1.associationGet(groupingIdentifier:2),\n        \n        // Get Version information\n        zwave.versionV1.versionGet(),\n        zwave.firmwareUpdateMdV2.firmwareMdGet(),\n        \n    \t// Enable to send notifications to associated devices (Group 1) (0=nothing, 1=hail CC, 2=basic CC report)\n        zwave.configurationV1.configurationSet(parameterNumber: 80, size: 1, scaledConfigurationValue: 2),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 80),\n        \n        // send low battery notifications\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 81, size: 1, scaledConfigurationValue: 1),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 81),\n\t\t\n\t\t// Set the repetitions for playing doorbell ringtone\n        zwave.configurationV1.configurationSet(parameterNumber: 2, size: 1, scaledConfigurationValue: prefNumrings.toInteger()),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 2),\n        \n        // Set the default doorbell ringtone\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 5, size: 1, scaledConfigurationValue: prefRingtone.toInteger()),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 5),\n        \n\t\t// Set the volume of ringtone\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 8, size: 1, scaledConfigurationValue: prefVolume.toInteger()),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 8),\n        \n\t\t// define +- button function\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 10, size: 1, scaledConfigurationValue: 0),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 10),\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 11, size: 1, scaledConfigurationValue: 0),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 11),\n        //\tGet last known remote battery health\n        zwave.configurationV1.configurationGet(parameterNumber: 42)\n    ]\n\tcommands(request)\n}\n\nprivate setConfigured() {\n\tupdateDataValue(\"configured\", \"true\")\n}\n\nprivate isConfigured() {\n\tgetDataValue(\"configured\") == \"true\"\n}\n\nprivate command(physicalgraph.zwave.Command cmd) {\n\tif (state.sec) {\n\t\tzwave.securityV1.securityMessageEncapsulation().encapsulate(cmd).format()\n\t} else {\n\t\tcmd.format()\n\t}\n}\n\nprivate commands(commands, delay=500) {\n\tdelayBetween(commands.collect{ command(it) }, delay)\n}"
  },
  {
    "path": "Aeon Garage Door/device_type-aeon-garage-door-v0.1",
    "content": "/*\n * V 0.1 of Aeon Garage Door code 12/15/2015\n *  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except\n *  in compliance with the License. You may obtain a copy of the License at:\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n *  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed\n *  on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License\n *  for the specific language governing permissions and limitations under the License.\n *\n * some code used from various SmartThings device type and metering code from ElasticDev\n *\n * change log:\n * v 0.1\n*/\n\n metadata {\n\tdefinition (name: \"Aeon Garage Door - RV v0.1\", namespace: \"robertvandervoort\", author: \"Robert Vandervoort\") {\n\t\tcapability \"Alarm\" // 0x71 Notification v4\n\t\tcapability \"Battery\"\n\t\tcapability \"Switch\" // 0x25 Switch Binary v1\n\t\tcapability \"Configuration\" // 0x70 Configuration v1\n\t\tcapability \"Actuator\"\n\t\tcapability \"Door Control\"\n\t\tcapability \"Garage Door Control\"\n\t\tcapability \"Contact Sensor\"\n\t\tcapability \"Refresh\"\n\t\tcapability \"Sensor\"\n\t\t\n\t\tcommand \"calibrate\"\n\t\t\n\t\t/*\n\t\t0x22 Application Status v1\n\t\t0x5E Zwave Gen 5 v2\n\t\t0x85 Association v2\n\t\t0x59 Association Grp Info v1\n\t\t0x72 Manufacturer Specific v2\n\t\t0x86 Version v1\n\t\t0x7A Firmware Update Md v2\n\t\t0x73 Powerlevel v1\n\t\t0x98 Security v1\n\t\t0x66 BARRIER_OPERATOR v1\n\t\t0xEF Mark v1\n\t\t0x5A Device Reset Locally v1\n\t\t0x82 Hail v1\n\t\t*/\n\t\t\n\t\t// Raw description\n\t\t// 0 0 0x4007 0 0 0 10 0x5E 0x25 0x70 0x85 0x59 0x72 0x86 0x7A 0x73 0x98 0x66  0xEF 0x22 0x5A 0x82 \n\t\tfingerprint deviceId: \"0x10\", inClusters: \"0x98\"\n\t\tfingerprint inClusters: \"0x5E, 0x25, 0x70, 0x85, 0x59, 0x72, 0x86, 0x7A, 0x73, 0x98, 0x66, 0x71, 0xEF, 0x22, 0x5A\", outClusters: \"0x82\"\n\t}\n\t// simulator metadata\n\tsimulator {\n\t\tstatus \"on\":  \"command: 2003, payload: FF\"\n\t\tstatus \"off\": \"command: 2003, payload: 00\"\n\n\t\t// reply messages\n\t\treply \"2001FF,delay 100,2502\": \"command: 2503, payload: FF\"\n\t\treply \"200100,delay 100,2502\": \"command: 2503, payload: 00\"\n\n\t}\n\n\t// tile definitions\n\ttiles (scale: 2) {\n    \tmultiAttributeTile(name:\"main\", type:\"generic\", width:6, height:4, canChangeIcon: true) {\n\t\t\ttileAttribute(\"device.door\", key: \"PRIMARY_CONTROL\") {\n\t\t\t\tattributeState \"unknown\", label:'${name}', action:\"refresh.refresh\", icon:\"st.doors.garage.garage-open\", backgroundColor:\"#ffa81e\"\n\t\t\t\tattributeState \"closed\", label:'${name}', action:\"door control.open\", icon:\"st.doors.garage.garage-closed\", backgroundColor:\"#79b821\", nextState:\"opening\"\n\t\t\t\tattributeState \"open\", label:'${name}', action:\"door control.close\", icon:\"st.doors.garage.garage-open\", backgroundColor:\"#ffa81e\", nextState:\"closing\"\n\t\t\t\tattributeState \"opening\", label:'${name}', icon:\"st.doors.garage.garage-opening\", backgroundColor:\"#ffe71e\"\n\t\t\t\tattributeState \"closing\", label:'${name}', icon:\"st.doors.garage.garage-closing\", backgroundColor:\"#ffe71e\"\n            }\n\t\t}\n\t\tstandardTile(\"open\", \"device.door\", inactiveLabel: false, decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'open', action:\"door control.open\", icon:\"st.doors.garage.garage-opening\"\n\t\t}\n\t\tstandardTile(\"close\", \"device.door\", inactiveLabel: false, decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'close', action:\"door control.close\", icon:\"st.doors.garage.garage-closing\"\n\t\t}\n\t\tstandardTile(\"configure\", \"device.door\", inactiveLabel: false, decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"configure\", label:'', action:\"configuration.configure\", icon:\"st.secondary.configure\"\n\t\t}\n\t\tstandardTile(\"refresh\", \"device.door\", inactiveLabel: false, decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'', action:\"refresh\", icon:\"st.secondary.refresh\"\n\t\t}\n\t\tmain \"main\"\n\t\tdetails([\"main\",\"open\",\"close\",\"refresh\",\"configure\"])\n\t}\n\t\n    preferences { \n\t\tinput \"debugOutput\", \"boolean\", \n\t\ttitle: \"Enable debug logging?\",\n\t\tdefaultValue: false,\n\t\tdisplayDuringSetup: true\n\t}\n}\n\ndef updated()\n{\n\tstate.debug = (\"true\" == debugOutput)\n\tif (state.sec && !isConfigured()) {\n\t\t// in case we miss the SCSR\n\t\tresponse(configure())\n\t}\n}\n\nimport physicalgraph.zwave.commands.barrieroperatorv1.*\n\ndef parse(String description)\n{\n\tdef result = null\n\tif (description.startsWith(\"Err 106\")) {\n\t\tstate.sec = 0\n\t\tresult = createEvent( name: \"secureInclusion\", value: \"failed\", isStateChange: true,\n\t\t\tdescriptionText: \"This sensor failed to complete the network security key exchange. If you are unable to control it via SmartThings, you must remove it from your network and add it again.\")\n\t} else if (description != \"updated\") {\n\t\tdef cmd = zwave.parse(description, [0x5E: 2, 0x25: 1, 0x70: 1, 0x85: 2, 0x59: 1, 0x72: 2, 0x86: 1, 0x7A: 2, 0x73: 1, 0x98: 1, 0x66: 1, 0x71: 4, 0xEF: 1, 0x22: 1, 0x5A: 1])\n\t\tif (cmd) {\n\t\t\tresult = zwaveEvent(cmd)\n\t\t}\n\t}\n\t// if (state.debug) log.debug \"Parsed '${description}' to ${result.inspect()}\"\n\treturn result\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.securityv1.SecurityMessageEncapsulation cmd) {\n\tdef encapsulatedCommand = cmd.encapsulatedCommand([0x5E: 2, 0x25: 1, 0x70: 1, 0x85: 2, 0x59: 1, 0x72: 2, 0x86: 1, 0x7A: 2, 0x73: 1, 0x98: 1, 0x66: 1, 0x71: 4, 0xEF: 1, 0x22: 1, 0x5A: 1])\n\tstate.sec = 1\n\t// if (state.debug) log.debug \"encapsulated: ${encapsulatedCommand}\"\n\tif (encapsulatedCommand) {\n\t\tzwaveEvent(encapsulatedCommand)\n\t} else {\n\t\tlog.warn \"Unable to extract encapsulated cmd from $cmd\"\n\t\tcreateEvent(descriptionText: cmd.toString())\n\t}\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.securityv1.SecurityCommandsSupportedReport cmd) {\n\tresponse(configure())\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.powerlevelv1.PowerlevelTestNodeReport cmd) {\n\tif (state.debug) log.debug \"===Power level test node report received=== ${device.displayName}: statusOfOperation: ${cmd.statusOfOperation} testFrameCount: ${cmd.testFrameCount} testNodeid: ${cmd.testNodeid}\"\n\tdef request = [\n        physicalgraph.zwave.commands.powerlevelv1.PowerlevelGet()\n    ]\n    response(commands(request))\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.versionv1.VersionCommandClassReport cmd) {\n\tif (state.debug) log.debug \"---COMMAND CLASS VERSION REPORT V1--- ${device.displayName} has command class version: ${cmd.commandClassVersion} - payload: ${cmd.payload}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.versionv1.VersionReport cmd) {\n\tdef fw = \"${cmd.applicationVersion}.${cmd.applicationSubVersion}\"\n\tupdateDataValue(\"fw\", fw)\n\tif (state.debug) log.debug \"---VERSION REPORT V1--- ${device.displayName} is running firmware version: $fw, Z-Wave version: ${cmd.zWaveProtocolVersion}.${cmd.zWaveProtocolSubVersion}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.firmwareupdatemdv2.FirmwareMdReport cmd) {\n\tif (state.debug) log.debug \"---FIRMWARE MD REPORT V2--- ${device.displayName} has Checksum of ${cmd.checksum} firmwareId: ${cmd.firmwareId}, manufacturerId: ${cmd.firmwareId}\"\n}    \n\ndef zwaveEvent(physicalgraph.zwave.commands.associationv2.AssociationReport cmd) {\n    cmd.nodeId.each({log.debug \"AssociationReport: '${cmd}', hub: '$zwaveHubNodeId' reports nodeId: '$it' is associated in group: '${cmd.groupingIdentifier}'\"})\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.hailv1.Hail cmd) {\n\tif (state.debug) log.debug \"Hail received: ${cmd}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.manufacturerspecificv2.ManufacturerSpecificReport cmd) {\n\tdef result = []\n\n\tdef msr = String.format(\"%04X-%04X-%04X\", cmd.manufacturerId, cmd.productTypeId, cmd.productId)\n\tlog.debug \"msr: $msr\"\n\tupdateDataValue(\"MSR\", msr)\n\n\tresult << createEvent(descriptionText: \"$device.displayName MSR: $msr\", isStateChange: false)\n\tresult\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.applicationstatusv1.ApplicationBusy cmd) {\n\tdef msg = cmd.status == 0 ? \"try again later\" :\n\t          cmd.status == 1 ? \"try again in $cmd.waitTime seconds\" :\n\t          cmd.status == 2 ? \"request queued\" : \"sorry\"\n\tcreateEvent(displayed: true, descriptionText: \"$device.displayName is busy, $msg\")\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.applicationstatusv1.ApplicationRejectedRequest cmd) {\n\tcreateEvent(displayed: true, descriptionText: \"$device.displayName rejected the last request\")\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.configurationv2.ConfigurationReport cmd) {\n    if (state.debug) log.debug \"---CONFIGURATION REPORT V2--- ${device.displayName} parameter ${cmd.parameterNumber} with a byte size of ${cmd.size} is set to ${cmd.configurationValue}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.configurationv1.ConfigurationReport cmd) {\n    if (state.debug) log.debug \"---CONFIGURATION REPORT V1--- ${device.displayName} parameter ${cmd.parameterNumber} with a byte size of ${cmd.size} is set to ${cmd.configurationValue}\"\n}\n\ndef zwaveEvent(BarrierOperatorReport cmd) {\n\tdef result = []\n\tdef map = [ name: \"door\" ]\n\tswitch (cmd.barrierState) {\n\t\tcase BarrierOperatorReport.BARRIER_STATE_CLOSED:\n\t\t\tmap.descriptionText = \"$device.displayName door is closed\"\n            map.value = \"closed\"\n\t\t\tresult << createEvent(name: \"contact\", value: \"closed\", displayed: false)\n\t\t\tbreak\n\t\tcase BarrierOperatorReport.BARRIER_STATE_UNKNOWN_POSITION_MOVING_TO_CLOSE:\n\t\t\tmap.descriptionText = \"$device.displayName door is closing\"\n            map.value = \"closing\"\n\t\t\tbreak\n\t\tcase BarrierOperatorReport.BARRIER_STATE_UNKNOWN_POSITION_STOPPED:\n\t\t\tmap.descriptionText = \"$device.displayName door state is unknown\"\n\t\t\tmap.value = \"unknown\"\n\t\t\tbreak\n\t\tcase BarrierOperatorReport.BARRIER_STATE_UNKNOWN_POSITION_MOVING_TO_OPEN:\n\t\t\tmap.descriptionText = \"$device.displayName door is opening\"\n            map.value = \"opening\"\n\t\t\tresult << createEvent(name: \"contact\", value: \"open\", displayed: false)\n\t\t\tbreak\n\t\tcase BarrierOperatorReport.BARRIER_STATE_OPEN:\n\t\t\tmap.descriptionText = \"$device.displayName door is open\"\n            map.value = \"open\"\n\t\t\tresult << createEvent(name: \"contact\", value: \"open\", displayed: false)\n\t\t\tbreak\n\t}\n    if (state.debug) log.debug \"---BARRIER OPERATOR REPORT--- ${map.descriptionText}\"\n\tresult + createEvent(map)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.notificationv3.NotificationReport cmd) {\n\tdef result = []\n\tdef map = [:]\n\tif (cmd.notificationType == 6) {\n\t\tmap.displayed = true\n\t\tswitch(cmd.event) {\n\t\t\tcase 0x40:\n\t\t\t\tif (cmd.eventParameter[0]) {\n\t\t\t\t\tmap.descriptionText = \"$device.displayName performing initialization process\"\n\t\t\t\t} else {\n\t\t\t\t\tmap.descriptionText = \"$device.displayName initialization process complete\"\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\tcase 0x41:\n\t\t\t\tmap.descriptionText = \"$device.displayName door operation force has been exceeded\"\n\t\t\t\tbreak\n\t\t\tcase 0x42:\n\t\t\t\tmap.descriptionText = \"$device.displayName motor has exceeded operational time limit\"\n\t\t\t\tbreak\n\t\t\tcase 0x43:\n\t\t\t\tmap.descriptionText = \"$device.displayName has exceeded physical mechanical limits\"\n\t\t\t\tbreak\n\t\t\tcase 0x44:\n\t\t\t\tmap.descriptionText = \"$device.displayName unable to perform requested operation (UL requirement)\"\n\t\t\t\tbreak\n\t\t\tcase 0x45:\n\t\t\t\tmap.descriptionText = \"$device.displayName remote operation disabled (UL requirement)\"\n\t\t\t\tbreak\n\t\t\tcase 0x46:\n\t\t\t\tmap.descriptionText = \"$device.displayName failed to perform operation due to device malfunction\"\n\t\t\t\tbreak\n\t\t\tcase 0x47:\n\t\t\t\tif (cmd.eventParameter[0]) {\n\t\t\t\t\tmap.descriptionText = \"$device.displayName vacation mode enabled\"\n\t\t\t\t} else {\n\t\t\t\t\tmap.descriptionText = \"$device.displayName vacation mode disabled\"\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\tcase 0x48:\n\t\t\t\tif (cmd.eventParameter[0]) {\n\t\t\t\t\tmap.descriptionText = \"$device.displayName safety beam obstructed\"\n\t\t\t\t} else {\n\t\t\t\t\tmap.descriptionText = \"$device.displayName safety beam obstruction cleared\"\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\tcase 0x49:\n\t\t\t\tif (cmd.eventParameter[0]) {\n\t\t\t\t\tmap.descriptionText = \"$device.displayName door sensor ${cmd.eventParameter[0]} not detected\"\n\t\t\t\t} else {\n\t\t\t\t\tmap.descriptionText = \"$device.displayName door sensor not detected\"\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\tcase 0x4A:\n\t\t\t\tif (cmd.eventParameter[0]) {\n\t\t\t\t\tmap.descriptionText = \"$device.displayName door sensor ${cmd.eventParameter[0]} has a low battery\"\n\t\t\t\t} else {\n\t\t\t\t\tmap.descriptionText = \"$device.displayName door sensor has a low battery\"\n\t\t\t\t}\n\t\t\t\tresult << createEvent(name: \"battery\", value: 1, unit: \"%\", descriptionText: map.descriptionText)\n\t\t\t\tbreak\n\t\t\tcase 0x4B:\n\t\t\t\tmap.descriptionText = \"$device.displayName detected a short in wall station wires\"\n\t\t\t\tbreak\n\t\t\tcase 0x4C:\n\t\t\t\tmap.descriptionText = \"$device.displayName is associated with non-Z-Wave remote control\"\n\t\t\t\tbreak\n\t\t\tdefault:\n\t\t\t\tmap.descriptionText = \"$device.displayName: access control alarm $cmd.event\"\n\t\t\t\tmap.displayed = false\n\t\t\t\tbreak\n\t\t}\n\t} else if (cmd.notificationType == 7) {\n\t\tswitch (cmd.event) {\n\t\t\tcase 1:\n\t\t\tcase 2:\n\t\t\t\tmap.descriptionText = \"$device.displayName detected intrusion\"\n\t\t\t\tbreak\n\t\t\tcase 3:\n\t\t\t\tmap.descriptionText = \"$device.displayName tampering detected: product cover removed\"\n\t\t\t\tbreak\n\t\t\tcase 4:\n\t\t\t\tmap.descriptionText = \"$device.displayName tampering detected: incorrect code\"\n\t\t\t\tbreak\n\t\t\tcase 7:\n\t\t\tcase 8:\n\t\t\t\tmap.descriptionText = \"$device.displayName detected motion\"\n\t\t\t\tbreak\n\t\t\tdefault:\n\t\t\t\tmap.descriptionText = \"$device.displayName: security alarm $cmd.event\"\n\t\t\t\tmap.displayed = false\n\t\t}\n\t} else if (cmd.notificationType){\n\t\tmap.descriptionText = \"$device.displayName: alarm type $cmd.notificationType event $cmd.event\"\n\t} else {\n\t\tmap.descriptionText = \"$device.displayName: alarm $cmd.v1AlarmType is ${cmd.v1AlarmLevel == 255 ? 'active' : cmd.v1AlarmLevel ?: 'inactive'}\"\n\t}\n\tresult ? [createEvent(map), *result] : createEvent(map)\n\tif (state.debug) log.debug result\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicReport cmd)\n{\n\t[name: \"switch\", value: cmd.value ? \"on\" : \"off\", type: \"physical\", displayed: true, isStateChange: true]\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicSet cmd) \n{\n    [name: \"switch\", value: cmd.value ? \"on\" : \"off\", type: \"physical\", displayed: true, isStateChange: true]\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.switchbinaryv1.SwitchBinaryReport cmd)\n{\n\t[name: \"switch\", value: cmd.value ? \"on\" : \"off\", type: \"digital\", displayed: true, isStateChange: true]\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.switchbinaryv1.SwitchBinarySet cmd)\n{\n    [name: \"switch\", value: cmd.value ? \"on\" : \"off\", type: \"digital\", displayed: true, isStateChange: true]\n}\n\ndef zwaveEvent(physicalgraph.zwave.Command cmd) {\n\tif (state.debug) log.debug \"Unhandled: $cmd\"\n    createEvent(descriptionText: cmd.toString(), isStateChange: false)\n}\n\ndef on() {\n\tdef request = [\n\t\tzwave.basicV1.basicSet(value: 0xFF),\n\t    zwave.basicV1.basicGet(),\n\t\tzwave.switchBinaryV1.switchBinaryGet()\n\t]\n    commands(request)\n}\n\ndef off() {\n\tdef request = [\n\t\tzwave.basicV1.basicSet(value: 0x00),\n        zwave.basicV1.basicGet(),\n\t\tzwave.switchBinaryV1.switchBinaryGet()\n\t]\n    commands(request)\n}\n\ndef open() {\n\tdef request = [\n\t\tzwave.barrierOperatorV1.barrierOperatorSet(requestedBarrierState: BarrierOperatorSet.REQUESTED_BARRIER_STATE_OPEN)\n\t]\n    commands(request)\n}\n\ndef close() {\n\tdef request = [\n\t\tzwave.barrierOperatorV1.barrierOperatorSet(requestedBarrierState: BarrierOperatorSet.REQUESTED_BARRIER_STATE_CLOSE)\n\t]\n    commands(request)\n}\n\ndef refresh() {\n\tdef request = [\n\t\t// get battery state\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 42),\n        zwave.basicV1.basicGet(),\n\t\tzwave.switchBinaryV1.switchBinaryGet(),\n        zwave.barrierOperatorV1.barrierOperatorGet()\n\t]\n    commands(request)\n}\n\ndef configure() {\n    if (state.debug) log.debug \"settings: ${settings.inspect()}, state: ${state.inspect()}, zwaveHubNodeId: ${zwaveHubNodeId}}\"\n\tdef request = [\n\t\t//associate with group 1 and 2\n        //zwave.associationV1.associationSet(groupingIdentifier:1, nodeId:zwaveHubNodeId),\n        //zwave.associationV1.associationSet(groupingIdentifier:2, nodeId:zwaveHubNodeId),\n        zwave.associationV1.associationGet(groupingIdentifier:1),\n        zwave.associationV1.associationGet(groupingIdentifier:2),\n\n\t\t// Get Version information\n        zwave.versionV1.versionGet(),\n        zwave.firmwareUpdateMdV2.firmwareMdGet(),\n\t\t\n\t\t// Enable to send notifications to associated devices (Group 1) when the state of Micro Switch’s load changed (0=nothing, 1=hail CC, 2=basic CC report)\n        zwave.configurationV1.configurationSet(parameterNumber: 80, size: 1, configurationValue: [2]),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 80),\n\t\t\n\t\t//set startup tone\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 32, size: 1, configurationValue: [1]),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 32),\n        \n\t\t//get number of alarm tone\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 36),\n        \n\t\t// Set blink, sound, volume of opening action\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 37, size: 4, configurationValue: [5,1,1,1]),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 37),\n        \n\t\t// set blink, sound, volume of closing action\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 38, size: 4, configurationValue: [10,2,1,1]),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 38),\n        \n\t\t// set blink, sound, volume of unknown state\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 39, size: 4, configurationValue: [1,3,1,0]),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 39),\t\t\n\n\t\t// set blink, sound, volume of CLOSED state\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 40, size: 4, configurationValue: [1,3,1,0]),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 40),\n\n\t\t// get battery state\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 42),\t\t\n\n\t\t// Can use the zwaveHubNodeId variable to add the hub to the device's associations:\n\t\tzwave.associationV1.associationSet(groupingIdentifier:2, nodeId:zwaveHubNodeId)\n    ]\n\tcommands(request)\n}\n\nprivate setConfigured() {\n\tupdateDataValue(\"configured\", \"true\")\n}\n\nprivate isConfigured() {\n\tgetDataValue(\"configured\") == \"true\"\n}\n\nprivate command(physicalgraph.zwave.Command cmd) {\n\tif (state.sec) {\n\t\tzwave.securityV1.securityMessageEncapsulation().encapsulate(cmd).format()\n\t} else {\n\t\tcmd.format()\n\t}\n}\n\nprivate commands(commands, delay=500) {\n\tdelayBetween(commands.collect{ command(it) }, delay)\n}\n"
  },
  {
    "path": "Aeon Multisensor 6/device_type-aeon-multisensor6-v1.1",
    "content": "/**\n * V 1.1 of Multisensor 6 code\n *\tknown issues : preferences do not seem to affect configuration, secure pairing is the most tested method at the moment. when clicking the action button on *  the sensor, click two times quickly to pair secured. Still not seeing anything other than 0 for ultraviolet. Also, temp and humidity seem to be off about 6 *\tdegrees warmer and 7 percent humidity lower than actual, though your sensor may vary.\n \n *  Original code for gen5 Copyright 2015 SmartThings, modified for use on gen 6 by Robert Vandervoort\n *\n *  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except\n *  in compliance with the License. You may obtain a copy of the License at:\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n *  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed\n *  on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License\n *  for the specific language governing permissions and limitations under the License.\n *\n */\nmetadata {\n\tdefinition (name: \"Aeon Multisensor 6\", namespace: \"robertvandervoort\", author: \"Robert Vandervoort\") {\n\t\tcapability \"Motion Sensor\"\n\t\tcapability \"Temperature Measurement\"\n\t\tcapability \"Relative Humidity Measurement\"\n\t\tcapability \"Illuminance Measurement\"\n\t\tcapability \"Configuration\"\n\t\tcapability \"Sensor\"\n\t\tcapability \"Battery\"\n\t\tfingerprint deviceId: \"0x2101\", inClusters: \"0x5E,0x86,0x72,0x59,0x85,0x73,0x71,0x84,0x80,0x30,0x31,0x70,0x7A,0xEF,0x5A,0x98,0x7A\"\n\t\t}\n\tsimulator {\n\t\tstatus \"no motion\" : \"command: 9881, payload: 00300300\"\n\t\tstatus \"motion\"    : \"command: 9881, payload: 003003FF\"\n        status \"no vibration\" : \" command: 9881, payload: 0071050000000007030000\"\n        status \"vibration\" : \"command: 9881, payload: 007105000000FF07030000\"\n        \n        for (int i = 0; i <= 100; i += 20) {\n\t\t\tstatus \"temperature ${i}F\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().sensorMultilevelV2.sensorMultilevelReport(\n                \tscaledSensorValue: i,\n                    precision: 1,\n                    sensorType: 1,\n                    scale: 1\n\t\t\t\t)\n\t\t\t).incomingMessage()\n\t\t}\n\t\tfor (int i = 0; i <= 100; i += 20) {\n\t\t\tstatus \"RH ${i}%\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().sensorMultilevelV2.sensorMultilevelReport(\n                \tscaledSensorValue: i,\n                    sensorType: 5\n            \t)\n\t\t\t).incomingMessage()\n\t\t}\n\t\tfor (int i in [0, 20, 89, 100, 200, 500, 1000]) {\n\t\t\tstatus \"illuminance ${i} lux\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().sensorMultilevelV2.sensorMultilevelReport(\n                scaledSensorValue: i,\n                sensorType: 3\n                )\n\t\t\t).incomingMessage()\n\t\t}\n\t\tfor (int i = 0; i <= 11; i += 1) {\n\t\t\tstatus \"ultraviolet ${i}\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().sensorMultilevelV2.sensorMultilevelReport(\n                scaledSensorValue: i,\n                sensorType: 27\n                )\n\t\t\t).incomingMessage()\n\t\t}\n\t\tfor (int i in [0, 5, 10, 15, 50, 99, 100]) {\n\t\t\tstatus \"battery ${i}%\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().batteryV1.batteryReport(\n                batteryLevel: i\n                )\n\t\t\t).incomingMessage()\n\t\t}\n\t\tstatus \"low battery alert\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().batteryV1.batteryReport(\n            \tbatteryLevel: 255\n            \t)\n\t\t\t).incomingMessage()\n\t\tstatus \"wake up\": \"command: 8407, payload:\"\n\t}\n\ttiles {\n\t\tstandardTile(\"motion\",\"device.motion\") {\n            \tstate \"active\",label:'motion',icon:\"st.motion.motion.active\",backgroundColor:\"#53a7c0\"\n                state \"inactive\",label:'no motion',icon:\"st.motion.motion.inactive\",backgroundColor:\"#ffffff\"\n\t\t\t}\n\t\tvalueTile(\"temperature\",\"device.temperature\",inactiveLabel: false) {\n            \tstate \"temperature\",label:'${currentValue}°',backgroundColors:[\n                \t[value: 32, color: \"#153591\"],\n                    [value: 44, color: \"#1e9cbb\"],\n                    [value: 59, color: \"#90d2a7\"],\n\t\t\t\t\t[value: 74, color: \"#44b621\"],\n\t\t\t\t\t[value: 84, color: \"#f1d801\"],\n\t\t\t\t\t[value: 92, color: \"#d04e00\"],\n\t\t\t\t\t[value: 98, color: \"#bc2323\"]\n\t\t\t\t]\n\t\t\t}\n\t\tvalueTile(\n        \t\"humidity\",\"device.humidity\",inactiveLabel: false) {\n            \tstate \"humidity\",label:'RH ${currentValue} %',unit:\"\"\n\t\t\t}\n\t\tvalueTile(\n        \t\"illuminance\",\"device.illuminance\",inactiveLabel: false) {\n            \tstate \"luminosity\",label:'${currentValue} ${unit}',unit:\"lux\"\n\t\t\t}\n\t\tvalueTile(\n        \t\"ultraviolet\",\"device.ultraviolet\",inactiveLabel: false) {\n\t\t\t\tstate \"ultraviolet\",label:'UV ${currentValue} ${unit}',unit:\"\"\n\t\t\t}\n\t\tstandardTile(\n        \t\"vibration\",\"device.vibration\") {\n\t\t\t\tstate \"active\",label:'vibration',icon:\"st.motion.motion.active\",backgroundColor:\"#ff0000\"\n                state \"inactive\",label:'calm',icon:\"st.motion.motion.inactive\",backgroundColor:\"#00ff00\"\n\t\t\t}\n\t\tvalueTile(\n\t\t\t\"battery\", \"device.battery\", inactiveLabel: false, decoration: \"flat\") {\n\t\t\tstate \"battery\", label:'${currentValue}% battery', unit:\"\"\n\t\t}\n\t\tstandardTile(\n        \t\"configureAfterSecure\",\"device.configure\",inactiveLabel: false,decoration: \"flat\") {\n\t\t\t\tstate \"configure\",label:'',action:\"configureAfterSecure\",icon:\"st.secondary.configure\"\n\t\t\t}\n\t\tmain([\n        \t\"motion\",\"temperature\",\"humidity\",\"illuminance\",\"ultraviolet\"\n            ])\n\t\tdetails([\n        \t\"motion\",\"temperature\",\"humidity\",\"illuminance\",\"ultraviolet\",\"battery\",\"configureAfterSecure\"\n            ])\n\t}\n    preferences {\n\t\tinput \"tempoffset\",\n\t\t\t\"number\",\n\t\t\ttitle: \"Temperature offset\",\n            description: \"negative values reduce the monitored value positive ones add to it\",\n            defaultValue: 0,\n            required: false,\n            displayDuringSetup: false\n\t\tinput \"humidityoffset\",\n        \t\"number\",\n            title: \"Humidity offset\",\n            description: \"negative values reduce the monitored value positive ones add to it\",\n\t\t\tdefaultValue: 0,\n\t\t\trequired: false,\n            displayDuringSetup: false\n\t\tinput \"luminanceoffset\",\n          \t\"number\",\n            title: \"Luminance offset\",\n            description: \"negative values reduce the monitored value positive ones add to it\",\n            defaultValue: 0,\n            required: false,\n\t        displayDuringSetup: false\n\t\tinput \"ultravioletoffset\",\n          \t\"number\",\n            title: \"Ultraviolet offset\",\n            description: \"negative values reduce the monitored value positive ones add to it\",\n            defaultValue: 0,\n\t        required: false,\n\t\t\tdisplayDuringSetup: false\n\t\tinput \"PIRsensitivity\",\n\t        \"number\",\n    \t    title: \"PIR motion sensitivity\",\n\t\t\tdescription: \"A value from 0-127 low to high sensitivity\",\n\t\t\tdefaultValue: 64,\n\t\t\trequired: true,\n\t\t\tdisplayDuringSetup: true\n\t\tinput \"ReportingInterval\",\n        \t\"number\",\n            title: \"Report data every X seconds\",\n            description: \"A value in seconds, default is 60 / 8 minutes\",\n            defaultValue: 4,\n            required: true,\n            displayDuringSetup: true\n\t}\n}\n\ndef parse(String description) {\n\tdef result = null\n    if (description == \"updated\") {\n        result = null\n\t\t}\n\telse {\n       \tdef cmd = zwave.parse(description, [0x31: 5, 0x30: 2, 0x84: 1])\n\t\tif (cmd) {\n       \t\tresult = zwaveEvent(cmd)\n\t\t}\n\t}\n\tlog.debug \"Parsed '${description}' to ${result.inspect()}\"\n\treturn result\n}\ndef zwaveEvent(physicalgraph.zwave.commands.wakeupv1.WakeUpNotification cmd)\n{\n\tdef result = [createEvent(descriptionText: \"${device.displayName} woke up\", isStateChange: false)]\n\n\tif (!isConfigured()) {\n\t\t// we're still in the process of configuring a newly joined device\n\t\tlog.debug(\"not sending wakeUpNoMoreInformation yet\")\n        result += response(configureAfterSecure())\n\t} else {\n\t\tresult += response(zwave.wakeUpV1.wakeUpNoMoreInformation())\n\t}\n\tresult\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.securityv1.SecurityMessageEncapsulation cmd) {\n\tdef encapsulatedCommand = cmd.encapsulatedCommand([0x31: 5, 0x30: 2, 0x84: 1])\n\tlog.debug \"encapsulated: ${encapsulatedCommand}\"\n\tif (encapsulatedCommand) {\n\t\tzwaveEvent(encapsulatedCommand)\n\t} else {\n\t\tlog.warn \"Unable to extract encapsulated cmd from $cmd\"\n\t\tcreateEvent(descriptionText: cmd.toString())\n\t}\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.securityv1.SecurityCommandsSupportedReport cmd) {\n    log.debug \"Received SecurityCommandsSupportedReport\"\n\tresponse(configureAfterSecure())\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.batteryv1.BatteryReport cmd) {\n\tdef map = [ name: \"battery\", unit: \"%\" ]\n\tif (cmd.batteryLevel == 0xFF) {\n\t\tmap.value = 1\n\t\tmap.descriptionText = \"${device.displayName} battery is low\"\n\t\tmap.isStateChange = true\n\t} else {\n\t\tmap.value = cmd.batteryLevel\n\t}\n\tstate.lastbatt = new Date().time\n\tcreateEvent(map)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.sensormultilevelv5.SensorMultilevelReport cmd)\n{\n\tdef map = [:]\n\tswitch (cmd.sensorType) {\n\t\tcase 1:\n\t\t\tmap.name = \"temperature\"\n\t\t\tdef cmdScale = cmd.scale == 1 ? \"F\" : \"C\"\n\t\t\tmap.value = convertTemperatureIfNeeded(cmd.scaledSensorValue, cmdScale, cmd.precision)\n\t\t\tmap.unit = getTemperatureScale()\n\t\t\tbreak;\n\t\tcase 3:\n\t\t\tmap.name = \"illuminance\"\n\t\t\tmap.value = cmd.scaledSensorValue.toInteger()\n\t\t\tmap.unit = \"lux\"\n\t\t\tbreak;\n        case 5:\n\t\t\tmap.name = \"humidity\"\n\t\t\tmap.value = cmd.scaledSensorValue.toInteger()\n\t\t\tmap.unit = \"%\"\n\t\t\tbreak;\n\t\tcase 27:\n        \tmap.name = \"ultraviolet\"\n            map.value = cmd.scaledSensorValue.toInteger()\n            map.unit = \"\"\n            break;\n\t\tdefault:\n\t\t\tmap.descriptionText = cmd.toString()\n\t}\n\tcreateEvent(map)\n}\n\ndef motionEvent(value) {\n\tdef map = [name: \"motion\"]\n\tif (value == 255) {\n\t\tmap.value = \"active\"\n\t\tmap.descriptionText = \"$device.displayName detected motion\"\n\t} else {\n\t\tmap.value = \"inactive\"\n\t\tmap.descriptionText = \"$device.displayName motion has stopped\"\n\t}\n\tcreateEvent(map)\n}\ndef vibrationEvent(value) {\n\tdef map = [name: \"vibration\"]\n\tif (value == 255) {\n\t\tmap.value = \"active\"\n\t\tmap.descriptionText = \"$device.displayName detected vibration\"\n\t} else { \n\t\tlog.debug \"-------------Vibration inactive------------------\"\n\t\tmap.value = \"inactive\"\n\t\tmap.descriptionText = \"$device.displayName vibration has stopped\"\n\t}\n\tcreateEvent(map)\n}\ndef zwaveEvent(physicalgraph.zwave.commands.sensorbinaryv2.SensorBinaryReport cmd) {\n\tmotionEvent(cmd.sensorValue)\n}\n\n\ndef zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicSet cmd) {\n\tlog.debug \"Basic Set 255 triggered motion event\"\n\tmotionEvent(cmd.value)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.notificationv3.NotificationReport cmd) {\n\tif (cmd.notificationType == 7 && cmd.event == 8) {\n\t\tlog.debug \"notification type 7 event 8 triggered motion event\"\n\t\tmotionEvent(cmd.notificationStatus)\n\t} else if (cmd.notificationType == 7 && cmd.event == 0) {\n\t\tlog.debug \"notification type 7 event 0 motion and vibration cleared\"\n\t\tmotionEvent(cmd.notificationStatus)\n\t\tvibrationEvent(cmd.notificationStatus)\n\t} else if (cmd.notificationType == 7 && cmd.event == 3) {\n\t\tlog.debug \"notification type 7 event 3 triggered vibration event\"\n\t\tvibrationEvent(cmd.notificationStatus)\n\t} else {\n\t\tcreateEvent(descriptionText: cmd.toString(), isStateChange: false)\n\t}\n}\n\ndef zwaveEvent(physicalgraph.zwave.Command cmd) {\n\tcreateEvent(descriptionText: cmd.toString(), isStateChange: false)\n}\n\ndef configureAfterSecure() {\n\tlog.debug \"configureAfterSecure()\"\n    //log.debug \"PIRsensitivity: $PIRsensitivity, Reporting Interval: $ReportingInterval, Temp offset: $tempoffset, Humidity offset: $humidityoffset, Luminance offset: $luminanceoffset, UV offset: $ultravioletoffset\"\n\n\tdef PIRsens = 64\n\tif (PIRsensitivity) {\n\t\tPIRsens=PIRsensitivity.toInteger()\n\t}\n\tdef ReportingInt = 4\n\tif (ReportingInterval) {\n\t\tReportingInt=ReportingInterval.toInteger()\n\t}\n\tdef tempoff = 0\n\tif (tempoffset) {\n\t\ttempoff=tempoffset.toInteger()\n\t}\n\tdef humidityoff = 0\n\tif (humidityoffset) {\n\t\thumidityoff=humidityoffset.toInteger()\n\t}\n\tdef luminanceoff = 0\n\tif (luminanceoffset) {\n\t\tluminanceoff=luminanceoffset.toInteger()\n\t}\n\tdef ultravioletoff = 0\n\tif (ultravioletoffset) {\n\t\tultravioletoff=ultravioletoffset.toInteger()\n\t}\n    //log.debug \"PIRsens: $PIRsens, ReportingInt: $ReportingInt, Tempoffset: $tempoff, Humidityoff: $humidityoff, Luminanceoff: $luminanceoff, UVoff: $ultravioletoff\"\n\tdef request = [\n\t\t// send temperature, humidity, illuminance, ultraviolet and battery\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x65, size: 4, scaledConfigurationValue: 128|64|32|16|1),\n\t\t// configure frequency of reporting \n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x6F,size: 4, scaledConfigurationValue: ReportingInt),\n\t\t// configure PIR sensitivity\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x06,size: 1, scaledConfigurationValue: PIRsens),\n\t\t// send battery every 20 hours\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x66, size: 4, scaledConfigurationValue: 1),\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x70, size: 4, scaledConfigurationValue: 20*60*60),\n        // send no-motion report 60 seconds after motion stops\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x03, size: 2, scaledConfigurationValue: 60),\n\t\t// enable motion sensor\n        zwave.configurationV1.configurationSet(parameterNumber: 0x04, size: 1, scaledConfigurationValue: 0),\n\t\t// send binary sensor report instead of basic set for motion\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x05, size: 1, scaledConfigurationValue: 2),\n\t\t// Enable the function of vibration sensor\n        zwave.configurationV1.configurationSet(parameterNumber: 0x07, size: 1, scaledConfigurationValue: 1),\n\t\t// disable notification-style motion events\n\t\tzwave.notificationV3.notificationSet(notificationType: 7, notificationStatus: 0),\n        // configure temp offset\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0xC9, size: 2, scaledConfigurationValue: tempoff),\n        // configure humidity offset\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0xCA, size: 2, scaledConfigurationValue: humidityoff),\n        // configure luminance offset\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0xCB, size: 2, scaledConfigurationValue: luminanceoff),\n        // configure ultraviolet offset\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0xCC, size: 2, scaledConfigurationValue: ultravioletoff), \n\n\t\tzwave.batteryV1.batteryGet(),\n\t\tzwave.sensorBinaryV2.sensorBinaryGet(),\n        \n\t\t// Can use the zwaveHubNodeId variable to add the hub to the device's associations:\n\t\tzwave.associationV1.associationSet(groupingIdentifier:2, nodeId:zwaveHubNodeId)\n    ]\n\t\n    setConfigured()\n    //log.debug request\n    secureSequence(request) + [\"delay 20000\", zwave.wakeUpV1.wakeUpNoMoreInformation().format()]\n}\n\ndef configure() {\n    //[\"delay 30000\"] + secure(zwave.securityV1.securityCommandsSupportedGet())\n    log.debug \"configure()\"\n   \tdef reportIntervalSecs = 4;\n    \tif (reportInterval) {\n\t\treportIntervalSecs = reportInterval.toInteger()\n\t\t}\n\tdelayBetween([\n\t\t// send temperature, humidity, illuminance, ultraviolet and battery every 8 minutes or as defined by preference\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x65, size: 4, scaledConfigurationValue: 128|64|32|16|1).format(),\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x6F, size: 4, scaledConfigurationValue: reportIntervalSecs).format(),\n\n\t\t// send battery every 20 hours\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x66, size: 4, scaledConfigurationValue: 1).format(),\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x70, size: 4, scaledConfigurationValue: 20*60*60).format(),\n\n        // send no-motion report 60 seconds after motion stops\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x03, size: 2, scaledConfigurationValue: 60).format(),\n\n\t\t// enable motion sensor\n        zwave.configurationV1.configurationSet(parameterNumber: 0x04, size: 1, scaledConfigurationValue: 0).format(),\n\n\t\t// send binary sensor report instead of basic set for motion\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x05, size: 1, scaledConfigurationValue: 2).format(),\n\n\t\t// configure PIR sensitivity for multisensor 6 min to max 0-127 default 64\n        zwave.configurationV1.configurationSet(parameterNumber: 0x06, size: 1, scaledConfigurationValue: 64).format(),\n\n\t\t// Enable the function of vibration sensor\n        zwave.configurationV1.configurationSet(parameterNumber: 0x07, size: 1, scaledConfigurationValue: 1).format(),\n\n\t\t// disable notification-style motion events\n\t\tzwave.notificationV3.notificationSet(notificationType: 7, notificationStatus: 0).format(),\n        \n        // configure temp offset\n        zwave.configurationV1.configurationSet(parameterNumber: 0xC9, size: 2, scaledConfigurationValue: 20).format(),\n        \n        // configure humidity offset\n        zwave.configurationV1.configurationSet(parameterNumber: 0xCA, size: 2, scaledConfigurationValue: 20).format(),\n        \n        // configure luminance offset\n        zwave.configurationV1.configurationSet(parameterNumber: 0xCB, size: 2, scaledConfigurationValue: 0).format(),\n        \n        // configure ultraviolet offset\n        zwave.configurationV1.configurationSet(parameterNumber: 0xCC, size: 2, scaledConfigurationValue: 5).format(),\n        \n\t\tzwave.batteryV1.batteryGet(),\n\t\tzwave.sensorBinaryV2.sensorBinaryGet(),\n\t\t\n        // Can use the zwaveHubNodeId variable to add the hub to the device's associations:\n\t\tzwave.associationV1.associationSet(groupingIdentifier:2, nodeId:zwaveHubNodeId)\n    ])\t\n    setConfigured()\n\tzwave.wakeUpV1.wakeUpNoMoreInformation().format()\n}\n\ndef setConfigured() {\n\tdevice.updateDataValue(\"configured\", \"true\")\n}\n\ndef isConfigured() {\n\tBoolean configured = device.getDataValue([\"configured\"]) as Boolean\n\t\n\treturn configured\n}\n\nprivate secure(physicalgraph.zwave.Command cmd) {\n\tzwave.securityV1.securityMessageEncapsulation().encapsulate(cmd).format()\n}\n\nprivate secureSequence(commands, delay=200) {\n\tdelayBetween(commands.collect{ secure(it) }, delay)\n}\n\ndef updated() {\n\tlog.debug \"updated()\"\n    log.debug \"PIRsensitivity: $PIRsensitivity, Reporting Interval: $ReportingInterval, Temp offset: $tempoffset, Humidity offset: $humidityoffset, Luminance offset: $luminanceoffset, UV offset: $ultravioletoffset\"\n    configureAfterSecure()\n}"
  },
  {
    "path": "Aeon Multisensor 6/device_type-aeon-multisensor6-v1.2",
    "content": "/**\n * V 1.2 of Multisensor 6 code\n *\tknown issues : preferences do not seem to affect configuration,\n *\tNot seeing anything other than 0 for ultraviolet.\n *\ttemp and humidity seem to be off about 6 *\tdegrees warmer and 7 percent humidity lower than actual\n *\tFIXED: battery tile added, vibration tile removed and touch capability and tile added and status updates are working, thanks TIM YUHL for the code review and sanity check!\n \n *  Original code for gen5 Copyright 2015 SmartThings, modified for use on gen 6 by Robert Vandervoort\n *\n *  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except\n *  in compliance with the License. You may obtain a copy of the License at:\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n *  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed\n *  on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License\n *  for the specific language governing permissions and limitations under the License.\n *\n */\nmetadata {\n\tdefinition (name: \"Aeon Multisensor 6\", namespace: \"robertvandervoort\", author: \"Robert Vandervoort\") {\n\t\tcapability \"Motion Sensor\"\n\t\tcapability \"Touch Sensor\"\n\t\tcapability \"Temperature Measurement\"\n\t\tcapability \"Relative Humidity Measurement\"\n\t\tcapability \"Illuminance Measurement\"\n\t\tcapability \"Ultraviolet Index\" \n\t\tcapability \"Configuration\"\n\t\tcapability \"Sensor\"\n\t\tcapability \"Battery\"\n\t\tfingerprint deviceId: \"0x2101\", inClusters: \"0x5E,0x86,0x72,0x59,0x85,0x73,0x71,0x84,0x80,0x30,0x31,0x70,0x7A,0xEF,0x5A,0x98,0x7A\"\n\t\t}\n\tsimulator {\n\t\tstatus \"no motion\" : \"command: 9881, payload: 00300300\"\n\t\tstatus \"motion\"    : \"command: 9881, payload: 003003FF\"\n        status \"no touch\" : \" command: 9881, payload: 0071050000000007030000\"\n        status \"touch\" : \"command: 9881, payload: 007105000000FF07030000\"\n        \n        for (int i = 0; i <= 100; i += 20) {\n\t\t\tstatus \"temperature ${i}F\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().sensorMultilevelV2.sensorMultilevelReport(\n                \tscaledSensorValue: i,\n                    precision: 1,\n                    sensorType: 1,\n                    scale: 1\n\t\t\t\t)\n\t\t\t).incomingMessage()\n\t\t}\n\t\tfor (int i = 0; i <= 100; i += 20) {\n\t\t\tstatus \"RH ${i}%\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().sensorMultilevelV2.sensorMultilevelReport(\n                \tscaledSensorValue: i,\n                    sensorType: 5\n            \t)\n\t\t\t).incomingMessage()\n\t\t}\n\t\tfor (int i in [0, 20, 89, 100, 200, 500, 1000]) {\n\t\t\tstatus \"illuminance ${i} lux\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().sensorMultilevelV2.sensorMultilevelReport(\n                scaledSensorValue: i,\n                sensorType: 3\n                )\n\t\t\t).incomingMessage()\n\t\t}\n\t\tfor (int i = 0; i <= 11; i += 1) {\n\t\t\tstatus \"ultraviolet ${i}\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().sensorMultilevelV2.sensorMultilevelReport(\n                scaledSensorValue: i,\n                sensorType: 27\n                )\n\t\t\t).incomingMessage()\n\t\t}\n\t\tfor (int i in [0, 5, 10, 15, 50, 99, 100]) {\n\t\t\tstatus \"battery ${i}%\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().batteryV1.batteryReport(\n                batteryLevel: i\n                )\n\t\t\t).incomingMessage()\n\t\t}\n\t\tstatus \"low battery alert\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().batteryV1.batteryReport(\n            \tbatteryLevel: 255\n            \t)\n\t\t\t).incomingMessage()\n\t\tstatus \"wake up\": \"command: 8407, payload:\"\n\t}\n\ttiles {\n\t\tstandardTile(\"motion\",\"device.motion\") {\n            \tstate \"active\",label:'motion',icon:\"st.motion.motion.active\",backgroundColor:\"#53a7c0\"\n                state \"inactive\",label:'no motion',icon:\"st.motion.motion.inactive\",backgroundColor:\"#ffffff\"\n\t\t\t}\n\t\tvalueTile(\"temperature\",\"device.temperature\",inactiveLabel: false) {\n            \tstate \"temperature\",label:'${currentValue}°',backgroundColors:[\n                \t[value: 32, color: \"#153591\"],\n                    [value: 44, color: \"#1e9cbb\"],\n                    [value: 59, color: \"#90d2a7\"],\n\t\t\t\t\t[value: 74, color: \"#44b621\"],\n\t\t\t\t\t[value: 84, color: \"#f1d801\"],\n\t\t\t\t\t[value: 92, color: \"#d04e00\"],\n\t\t\t\t\t[value: 98, color: \"#bc2323\"]\n\t\t\t\t]\n\t\t\t}\n\t\tvalueTile(\n        \t\"humidity\",\"device.humidity\",inactiveLabel: false) {\n            \tstate \"humidity\",label:'RH ${currentValue} %',unit:\"\"\n\t\t\t}\n\t\tvalueTile(\n        \t\"illuminance\",\"device.illuminance\",inactiveLabel: false) {\n            \tstate \"luminosity\",label:'${currentValue} ${unit}', unit:\"lux\", backgroundColors:[\n                \t[value: 0, color: \"#000000\"],\n                    [value: 47, color: \"#1A1A0A\"],\n                    [value: 94, color: \"#333314\"],\n\t\t\t\t\t[value: 141, color: \"#4C4C1F\"],\n\t\t\t\t\t[value: 188, color: \"#666629\"],\n\t\t\t\t\t[value: 235, color: \"#808033\"],\n\t\t\t\t\t[value: 282, color: \"#99993D\"],\n\t\t\t\t\t[value: 329, color: \"#B2B247\"],\n\t\t\t\t\t[value: 376, color: \"#CCCC52\"],\n\t\t\t\t\t[value: 423, color: \"#E6E65C\"],\n\t\t\t\t\t[value: 470, color: \"#FFFF66\"],\n\t\t\t\t\t[value: 517, color: \"#FFFF75\"],\n                    [value: 564, color: \"#FFFF85\"],\n                    [value: 611, color: \"#FFFF94\"],\n                    [value: 658, color: \"#FFFFA3\"],\n                    [value: 705, color: \"#FFFFB2\"],\n                    [value: 752, color: \"#FFFFC2\"],\n                    [value: 799, color: \"#FFFFD1\"],\n                    [value: 846, color: \"#FFFFE0\"],\n                    [value: 900, color: \"#FFFFF0\"],\n                    [value: 1000, color: \"#FFFFFF\"]\n\t\t\t\t]\n\t\t\t}\n\t\tvalueTile(\n        \t\"ultraviolet\",\"device.ultraviolet\",inactiveLabel: false) {\n\t\t\t\tstate \"ultraviolet\",label:'${currentValue} UV',unit:\"UV\"\n\t\t\t}\n\t\tstandardTile(\n        \t\"touch\",\"device.touch\") {\n\t\t\t\tstate \"touched\",label:'touched',icon:\"st.motion.motion.active\",backgroundColor:\"#ff0000\"\n                state \"inactive\",label:'calm',icon:\"st.motion.motion.inactive\",backgroundColor:\"#00ff00\"\n\t\t\t}\n\t\tvalueTile(\n\t\t\t\"battery\", \"device.battery\", inactiveLabel: false, decoration: \"flat\") {\n\t\t\tstate \"battery\", label:'${currentValue}% battery', unit:\"\"\n\t\t}\n\t\tstandardTile(\n        \t\"configure\",\"device.configure\",inactiveLabel: false,decoration: \"flat\") {\n\t\t\t\tstate \"configure\",label:'',action:\"configure\",icon:\"st.secondary.configure\"\n\t\t\t}\n\t\tmain([\n        \t\"motion\",\"touch\",\"temperature\",\"humidity\",\"illuminance\",\"ultraviolet\"\n            ])\n\t\tdetails([\n        \t\"motion\",\"touch\",\"temperature\",\"humidity\",\"illuminance\",\"ultraviolet\",\"battery\",\"configureAfterSecure\"\n            ])\n\t}\n    preferences {\n\t\tinput \"tempoffset\",\n\t\t\t\"number\",\n\t\t\ttitle: \"Temperature offset\",\n            description: \"negative values reduce the monitored value positive ones add to it\",\n            range: \"..\",\n\t\t\tdefaultValue: 0,\n            required: false,\n            displayDuringSetup: false\n\t\tinput \"humidityoffset\",\n        \t\"number\",\n            title: \"Humidity offset\",\n            description: \"negative values reduce the monitored value positive ones add to it\",\n\t\t\trange: \"..\",\n\t\t\tdefaultValue: 0,\n\t\t\trequired: false,\n            displayDuringSetup: false\n\t\tinput \"luminanceoffset\",\n          \t\"number\",\n            title: \"Luminance offset\",\n            description: \"negative values reduce the monitored value positive ones add to it\",\n            range: \"..\",\n\t\t\tdefaultValue: 0,\n            required: false,\n\t        displayDuringSetup: false\n\t\tinput \"ultravioletoffset\",\n          \t\"number\",\n            title: \"Ultraviolet offset\",\n            description: \"negative values reduce the monitored value positive ones add to it\",\n            range: \"..\",\n\t\t\tdefaultValue: 0,\n\t        required: false,\n\t\t\tdisplayDuringSetup: false\n\t\tinput \"PIRsensitivity\",\n\t        \"number\",\n    \t    title: \"PIR motion sensitivity\",\n\t\t\tdescription: \"A value from 0-5, from disabled to high sensitivity\",\n\t\t\tdefaultValue: 1,\n\t\t\trequired: true,\n\t\t\tdisplayDuringSetup: true\n\t\tinput \"ReportingInterval\",\n        \t\"number\",\n            title: \"Report data interval\",\n            description: \"A value in seconds for mains power, you can't go shorter than 3600 on battery power.\",\n            defaultValue: 60,\n            required: true,\n            displayDuringSetup: true\n\t}\n}\n\ndef parse(String description) {\n\tdef result = null\n    if (description == \"updated\") {\n        result = null\n\t\t}\n\telse {\n       \tdef cmd = zwave.parse(description, [0x31: 5, 0x30: 2, 0x84: 1])\n\t\tif (cmd) {\n       \t\tresult = zwaveEvent(cmd)\n\t\t}\n\t}\n\tlog.debug \"Parsed '${description}' to ${result.inspect()}\"\n\treturn result\n}\ndef zwaveEvent(physicalgraph.zwave.commands.wakeupv1.WakeUpNotification cmd)\n{\n\tdef result = [createEvent(descriptionText: \"${device.displayName} woke up\", isStateChange: false)]\n\n\tif (!isConfigured()) {\n\t\t// we're still in the process of configuring a newly joined device\n\t\tlog.debug(\"not sending wakeUpNoMoreInformation yet\")\n        result += response(configureAfterSecure())\n\t} else {\n\t\tresult += response(zwave.wakeUpV1.wakeUpNoMoreInformation())\n\t}\n\tresult\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.securityv1.SecurityMessageEncapsulation cmd) {\n\tdef encapsulatedCommand = cmd.encapsulatedCommand([0x31: 5, 0x30: 2, 0x84: 1])\n\tlog.debug \"encapsulated: ${encapsulatedCommand}\"\n\tif (encapsulatedCommand) {\n\t\tzwaveEvent(encapsulatedCommand)\n\t} else {\n\t\tlog.warn \"Unable to extract encapsulated cmd from $cmd\"\n\t\tcreateEvent(descriptionText: cmd.toString())\n\t}\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.securityv1.SecurityCommandsSupportedReport cmd) {\n    log.debug \"Received SecurityCommandsSupportedReport\"\n\tresponse(configureAfterSecure())\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.batteryv1.BatteryReport cmd) {\n\tdef map = [ name: \"battery\", unit: \"%\" ]\n\tif (cmd.batteryLevel == 0xFF) {\n\t\tmap.value = 1\n\t\tmap.descriptionText = \"${device.displayName} battery is low\"\n\t\tmap.isStateChange = true\n\t} else {\n\t\tmap.value = cmd.batteryLevel\n\t}\n\tstate.lastbatt = new Date().time\n\tcreateEvent(map)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.sensormultilevelv5.SensorMultilevelReport cmd)\n{\n\tdef map = [:]\n\tswitch (cmd.sensorType) {\n\t\tcase 1:\n\t\t\tmap.name = \"temperature\"\n\t\t\tdef cmdScale = cmd.scale == 1 ? \"F\" : \"C\"\n\t\t\tmap.value = convertTemperatureIfNeeded(cmd.scaledSensorValue, cmdScale, cmd.precision)\n\t\t\tmap.unit = getTemperatureScale()\n\t\t\tbreak;\n\t\tcase 3:\n\t\t\tmap.name = \"illuminance\"\n\t\t\tmap.value = cmd.scaledSensorValue.toInteger()\n\t\t\tmap.unit = \"lux\"\n\t\t\tbreak;\n        case 5:\n\t\t\tmap.name = \"humidity\"\n\t\t\tmap.value = cmd.scaledSensorValue.toInteger()\n\t\t\tmap.unit = \"%\"\n\t\t\tbreak;\n\t\tcase 27:\n        \tmap.name = \"ultraviolet\"\n            map.value = cmd.scaledSensorValue.toInteger()\n            map.unit = \"\"\n            break;\n\t\tdefault:\n\t\t\tmap.descriptionText = cmd.toString()\n\t}\n\tcreateEvent(map)\n}\n\ndef motionEvent(value) {\n\tdef map = [name: \"motion\"]\n\tif (value == 255) {\n\t\tmap.value = \"active\"\n\t\tmap.descriptionText = \"$device.displayName detected motion\"\n\t} else {\n\t\tmap.value = \"inactive\"\n\t\tmap.descriptionText = \"$device.displayName motion has stopped\"\n\t}\n\tcreateEvent(map)\n}\ndef touchEvent(value) {\n\tdef map = [name: \"touch\"]\n\tif (value == 255) {\n    \tlog.debug \"-------------touched------------------\"\n\t\tmap.value = \"touched\"\n\t\tmap.descriptionText = \"$device.displayName detected touch\"\n\t} else { \n\t\tlog.debug \"-------------touch inactive-----------\"\n\t\tmap.value = \"inactive\"\n\t\tmap.descriptionText = \"$device.displayName touch has stopped\"\n\t}\n\tcreateEvent(map)\n}\ndef zwaveEvent(physicalgraph.zwave.commands.sensorbinaryv2.SensorBinaryReport cmd) {\n\tmotionEvent(cmd.sensorValue)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicSet cmd) {\n\tlog.debug \"Basic Set 255 triggered motion event\"\n\tmotionEvent(cmd.value)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.notificationv3.NotificationReport cmd) {\n\tif (cmd.notificationType == 7 && cmd.event == 8) {\n\t\tlog.debug \"notification type 7 event 8 triggered motion event\"\n\t\tmotionEvent(cmd.notificationStatus)\n\t} else if (cmd.notificationType == 7 && cmd.event == 0) {\n\t\tlog.debug \"notification type 7 event 0 motion and touch cleared\"\n\t\tmotionEvent(0)\n\t\ttouchEvent(0)\n\t} else if (cmd.notificationType == 7 && cmd.event == 3) {\n\t\tlog.debug \"notification type 7 event 3 triggered touch event\"\n\t\ttouchEvent(cmd.notificationStatus)\n\t} else {\n\t\tcreateEvent(descriptionText: cmd.toString(), isStateChange: false)\n\t}\n}\n\ndef zwaveEvent(physicalgraph.zwave.Command cmd) {\n\tcreateEvent(descriptionText: cmd.toString(), isStateChange: false)\n}\n\ndef configureAfterSecure() {\n\tlog.debug \"configureAfterSecure()\"\n    //log.debug \"PIRsensitivity: $PIRsensitivity, Reporting Interval: $ReportingInterval, Temp offset: $tempoffset, Humidity offset: $humidityoffset, Luminance offset: $luminanceoffset, UV offset: $ultravioletoffset\"\n\n\tdef PIRsens = 1\n\tif (PIRsensitivity) {\n\t\tPIRsens=PIRsensitivity.toInteger()\n\t}\n\tdef ReportingInt = 60\n\tif (ReportingInterval) {\n\t\tReportingInt=ReportingInterval.toInteger()\n\t}\n\tdef tempoff = 0\n\tif (tempoffset) {\n\t\tif(tempoffset < 0) {\n\t\t\ttempoff=(255-tempoffset.tointeger())\n\t\t}\n\t\tif(tempoffset > 0) {\n\t\t\ttempoff=(0+tempoffset.tointeger())\n\t\t}\n\t}\n\tdef humidityoff = 0\n\tif (humidityoffset) {\n\t\thumidityoff=humidityoffset.toInteger()\n\t}\n\tdef luminanceoff = 0\n\tif (luminanceoffset) {\n\t\tluminanceoff=luminanceoffset.toInteger()\n\t}\n\tdef ultravioletoff = 0\n\tif (ultravioletoffset) {\n\t\tultravioletoff=ultravioletoffset.toInteger()\n\t}\n    //log.debug \"PIRsens: $PIRsens, ReportingInt: $ReportingInt, Tempoffset: $tempoff, Humidityoff: $humidityoff, Luminanceoff: $luminanceoff, UVoff: $ultravioletoff\"\n\tdef request = [\n\t\t// send temperature, humidity, illuminance, ultraviolet and battery\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x65, size: 4, scaledConfigurationValue: 128|64|32|16),\n\t\t// configure frequency of reporting \n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x6F,size: 4, scaledConfigurationValue: ReportingInt),\n\t\t// send battery every 20 hours\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x66, size: 4, scaledConfigurationValue: 1),\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x70, size: 4, scaledConfigurationValue: 20*60*60),\n        // send no-motion report 20 seconds after motion stops\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x03, size: 2, scaledConfigurationValue: 20),\n\t\t// enable motion sensor and set sensitivity\n        zwave.configurationV1.configurationSet(parameterNumber: 0x04, size: 1, scaledConfigurationValue: PIRsens),\n\t\t// send binary sensor report for motion\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x05, size: 1, scaledConfigurationValue: 2),\n\t\t// Enable the function of touch sensor\n        // zwave.configurationV1.configurationSet(parameterNumber: 0x07, size: 1, scaledConfigurationValue: 1),\n\t\t// disable notification-style motion events\n\t\tzwave.notificationV3.notificationSet(notificationType: 7, notificationStatus: 0),\n        // configure temp offset\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0xC9, size: 2, scaledConfigurationValue: tempoff),\n        // configure humidity offset\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0xCA, size: 2, scaledConfigurationValue: humidityoff),\n        // configure luminance offset\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0xCB, size: 2, scaledConfigurationValue: luminanceoff),\n        // configure ultraviolet offset\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0xCC, size: 2, scaledConfigurationValue: ultravioletoff), \n\n\t\tzwave.batteryV1.batteryGet(),\n\t\tzwave.sensorBinaryV2.sensorBinaryGet(),\n        \n\t\t// Can use the zwaveHubNodeId variable to add the hub to the device's associations:\n\t\tzwave.associationV1.associationSet(groupingIdentifier:2, nodeId:zwaveHubNodeId)\n    ]\n\t\n    setConfigured()\n    //log.debug request\n    secureSequence(request) + [\"delay 20000\", zwave.wakeUpV1.wakeUpNoMoreInformation().format()]\n}\n\ndef configure() {\n    //[\"delay 20000\"] + secure(zwave.securityV1.securityCommandsSupportedGet())\n    log.debug \"configure()\"\n\n\tdef PIRsens = 1\n\tif (PIRsensitivity) {\n\t\tPIRsens=PIRsensitivity.toInteger()\n\t}\n\tdef ReportingInt = 60\n\tif (ReportingInterval) {\n\t\tReportingInt=ReportingInterval.toInteger()\n\t}\n\tdef tempoff = 0\n\tif (tempoffset) {\n\t\tif(tempoffset < 0) {\n\t\t\ttempoff=(255-tempoffset.tointeger())\n\t\t}\n\t\tif(tempoffset > 0) {\n\t\t\ttempoff=(0+tempoffset.tointeger())\n\t\t}\n\t}\n\tdef humidityoff = 0\n\tif (humidityoffset) {\n\t\thumidityoff=humidityoffset.toInteger()\n\t}\n\tdef luminanceoff = 0\n\tif (luminanceoffset) {\n\t\tluminanceoff=luminanceoffset.toInteger()\n\t}\n\tdef ultravioletoff = 0\n\tif (ultravioletoffset) {\n\t\tultravioletoff=ultravioletoffset.toInteger()\n\t}\n    log.debug \"PIRsens: $PIRsens, ReportingInt: $ReportingInt, Tempoffset: $tempoff, Humidityoff: $humidityoff, Luminanceoff: $luminanceoff, UVoff: $ultravioletoff\"\n\n\tdelayBetween([\n\t\t// send temperature, humidity, illuminance, ultraviolet and battery every 60 minutes or seconds depending on power state\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x65, size: 4, scaledConfigurationValue: 128|64|32|16).format(),\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x6F, size: 4, scaledConfigurationValue: ReportingInt).format(),\n\n\t\t// send battery every 20 hours\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x66, size: 4, scaledConfigurationValue: 1).format(),\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x70, size: 4, scaledConfigurationValue: 20*60*60).format(),\n\n        // send no-motion report 20 seconds after motion stops\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x03, size: 2, scaledConfigurationValue: 20).format(),\n\n\t\t// enable motion sensor and set min sensitivity\n        zwave.configurationV1.configurationSet(parameterNumber: 0x04, size: 1, scaledConfigurationValue: PIRsens).format(),\n\n\t\t// send binary sensor report for motion\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x05, size: 1, scaledConfigurationValue: 2).format(),\n\n\t\t// Enable the function of touch sensor\n        //zwave.configurationV1.configurationSet(parameterNumber: 0x07, size: 1, scaledConfigurationValue: 1).format(),\n\n\t\t// disable notification-style motion events\n\t\tzwave.notificationV3.notificationSet(notificationType: 7, notificationStatus: 0).format(),\n        \n        // configure temp offset\n        zwave.configurationV1.configurationSet(parameterNumber: 0xC9, size: 2, scaledConfigurationValue: tempoff).format(),\n        \n        // configure humidity offset\n        zwave.configurationV1.configurationSet(parameterNumber: 0xCA, size: 2, scaledConfigurationValue: humidityoff).format(),\n        \n        // configure luminance offset\n        zwave.configurationV1.configurationSet(parameterNumber: 0xCB, size: 2, scaledConfigurationValue: luminanceoff).format(),\n        \n        // configure ultraviolet offset\n        zwave.configurationV1.configurationSet(parameterNumber: 0xCC, size: 2, scaledConfigurationValue: ultravioletoff).format(),\n        \n\t\tzwave.batteryV1.batteryGet(),\n\t\tzwave.sensorBinaryV2.sensorBinaryGet(),\n\t\t\n        // Can use the zwaveHubNodeId variable to add the hub to the device's associations:\n\t\tzwave.associationV1.associationSet(groupingIdentifier:2, nodeId:zwaveHubNodeId)\n    ])\t\n    setConfigured()\n\tzwave.wakeUpV1.wakeUpNoMoreInformation().format()\n}\n\ndef setConfigured() {\n\tdevice.updateDataValue(\"configured\", \"true\")\n}\n\ndef isConfigured() {\n\tBoolean configured = device.getDataValue([\"configured\"]) as Boolean\n\t\n\treturn configured\n}\n\nprivate secure(physicalgraph.zwave.Command cmd) {\n\tzwave.securityV1.securityMessageEncapsulation().encapsulate(cmd).format()\n}\n\nprivate secureSequence(commands, delay=200) {\n\tdelayBetween(commands.collect{ secure(it) }, delay)\n}\ndef updated() {\n\tlog.debug \"updated()\"\n    log.debug \"PIRsensitivity: $PIRsensitivity, Reporting Interval: $ReportingInterval, Temp offset: $tempoffset, Humidity offset: $humidityoffset, Luminance offset: $luminanceoffset, UV offset: $ultravioletoffset\"\n    configure()\n}"
  },
  {
    "path": "Aeon Multisensor 6/device_type-aeon-multisensor6-v1.3",
    "content": "/**\n * V 1.3 of Multisensor 6 code 9/14/2015\n *  Original code for gen5 Copyright 2015 SmartThings, modified for use on Multisensor 6 by Robert Vandervoort 6/19/2015\n * \n *  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except\n *  in compliance with the License. You may obtain a copy of the License at:\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n *  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed\n *  on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License\n *  for the specific language governing permissions and limitations under the License.\n *\n */\nmetadata {\n\tdefinition (name: \"rv Aeon Multisensor 6\", namespace: \"robertvandervoort\", author: \"Robert Vandervoort\") {\n\t\tcapability \"Motion Sensor\"\n\t\tcapability \"Touch Sensor\"\n\t\tcapability \"Temperature Measurement\"\n\t\tcapability \"Relative Humidity Measurement\"\n\t\tcapability \"Illuminance Measurement\"\n\t\tcapability \"Ultraviolet Index\" \n\t\tcapability \"Configuration\"\n\t\tcapability \"Sensor\"\n\t\tcapability \"Battery\"\n\t\t\n\t\tattribute \"tamper\", \"enum\", [\"detected\", \"clear\"]\n\t\t// CC supported 94, 134, 114, 132, 89, 133, 115, 113, 128, 48, 49, 112, 152, 122\n\t\tfingerprint deviceId: \"0x2101\", inClusters: \"0x5E,0x86,0x72,0x59,0x85,0x73,0x71,0x84,0x80,0x30,0x31,0x70,0xEF,0x5A,0x98,0x7A\"\n\t\t}\n\tsimulator {\n\t\tstatus \"no motion\" : \"command: 9881, payload: 00300300\"\n\t\tstatus \"motion\"    : \"command: 9881, payload: 003003FF\"\n        status \"clear\" : \" command: 9881, payload: 0071050000000007030000\"\n        status \"tamper\" : \"command: 9881, payload: 007105000000FF07030000\"\n        \n        for (int i = 0; i <= 100; i += 20) {\n\t\t\tstatus \"temperature ${i}F\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().sensorMultilevelV2.sensorMultilevelReport(\n                \tscaledSensorValue: i,\n                    precision: 1,\n                    sensorType: 1,\n                    scale: 1\n\t\t\t\t)\n\t\t\t).incomingMessage()\n\t\t}\n\t\tfor (int i = 0; i <= 100; i += 20) {\n\t\t\tstatus \"RH ${i}%\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().sensorMultilevelV2.sensorMultilevelReport(\n                \tscaledSensorValue: i,\n                    sensorType: 5\n            \t)\n\t\t\t).incomingMessage()\n\t\t}\n\t\tfor (int i in [0, 20, 89, 100, 200, 500, 1000]) {\n\t\t\tstatus \"illuminance ${i} lux\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().sensorMultilevelV2.sensorMultilevelReport(\n                scaledSensorValue: i,\n                sensorType: 3\n                )\n\t\t\t).incomingMessage()\n\t\t}\n\t\tfor (int i = 0; i <= 11; i += 1) {\n\t\t\tstatus \"ultravioletultravioletIndex ${i}\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().sensorMultilevelV2.sensorMultilevelReport(\n                scaledSensorValue: i,\n                sensorType: 27\n                )\n\t\t\t).incomingMessage()\n\t\t}\n\t\tfor (int i in [0, 5, 10, 15, 50, 99, 100]) {\n\t\t\tstatus \"battery ${i}%\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().batteryV1.batteryReport(\n                batteryLevel: i\n                )\n\t\t\t).incomingMessage()\n\t\t}\n\t\tstatus \"low battery alert\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().batteryV1.batteryReport(\n            \tbatteryLevel: 255\n            \t)\n\t\t\t).incomingMessage()\n\t\tstatus \"wake up\": \"command: 8407, payload:\"\n\t}\n\ttiles {\n\t\tstandardTile(\"motion\",\"device.motion\") {\n            \tstate \"active\",label:'motion',icon:\"st.motion.motion.active\",backgroundColor:\"#53a7c0\"\n                state \"inactive\",label:'no motion',icon:\"st.motion.motion.inactive\",backgroundColor:\"#ffffff\"\n\t\t\t}\n\t\tvalueTile(\"temperature\",\"device.temperature\",inactiveLabel: false) {\n            \tstate \"temperature\",label:'${currentValue}°',backgroundColors:[\n                \t[value: 32, color: \"#153591\"],\n                    [value: 44, color: \"#1e9cbb\"],\n                    [value: 59, color: \"#90d2a7\"],\n\t\t\t\t\t[value: 74, color: \"#44b621\"],\n\t\t\t\t\t[value: 84, color: \"#f1d801\"],\n\t\t\t\t\t[value: 92, color: \"#d04e00\"],\n\t\t\t\t\t[value: 98, color: \"#bc2323\"]\n\t\t\t\t]\n\t\t\t}\n\t\tvalueTile(\n        \t\"humidity\",\"device.humidity\",inactiveLabel: false) {\n            \tstate \"humidity\",label:'RH ${currentValue} %',unit:\"\"\n\t\t\t}\n\t\tvalueTile(\n        \t\"illuminance\",\"device.illuminance\",inactiveLabel: false) {\n            \tstate \"luminosity\",label:'${currentValue} ${unit}', unit:\"lux\", backgroundColors:[\n                \t[value: 0, color: \"#000000\"],\n                    [value: 47, color: \"#1A1A0A\"],\n                    [value: 94, color: \"#333314\"],\n\t\t\t\t\t[value: 141, color: \"#4C4C1F\"],\n\t\t\t\t\t[value: 188, color: \"#666629\"],\n\t\t\t\t\t[value: 235, color: \"#808033\"],\n\t\t\t\t\t[value: 282, color: \"#99993D\"],\n\t\t\t\t\t[value: 329, color: \"#B2B247\"],\n\t\t\t\t\t[value: 376, color: \"#CCCC52\"],\n\t\t\t\t\t[value: 423, color: \"#E6E65C\"],\n\t\t\t\t\t[value: 470, color: \"#FFFF66\"],\n\t\t\t\t\t[value: 517, color: \"#FFFF75\"],\n                    [value: 564, color: \"#FFFF85\"],\n                    [value: 611, color: \"#FFFF94\"],\n                    [value: 658, color: \"#FFFFA3\"],\n                    [value: 705, color: \"#FFFFB2\"],\n                    [value: 752, color: \"#FFFFC2\"],\n                    [value: 799, color: \"#FFFFD1\"],\n                    [value: 846, color: \"#FFFFE0\"],\n                    [value: 900, color: \"#FFFFF0\"],\n                    [value: 1000, color: \"#FFFFFF\"]\n\t\t\t\t]\n\t\t\t}\n\t\tvalueTile(\n        \t\"ultravioletIndex\",\"device.ultravioletIndex\",inactiveLabel: false) {\n\t\t\t\tstate \"ultravioletIndex\",label:'${currentValue} UV INDEX',unit:\"\"\n\t\t\t}\n\t\tstandardTile(\n        \t\"tamper\",\"device.tamper\") {\n\t\t\t\tstate \"tamper\",label:'tamper',icon:\"st.motion.motion.active\",backgroundColor:\"#ff0000\"\n                state \"clear\",label:'clear',icon:\"st.motion.motion.inactive\",backgroundColor:\"#00ff00\"\n\t\t\t}\n\t\tvalueTile(\n\t\t\t\"battery\", \"device.battery\", inactiveLabel: false, decoration: \"flat\") {\n\t\t\tstate \"battery\", label:'${currentValue}% battery', unit:\"\"\n\t\t}\n\t\tstandardTile(\n        \t\"configure\",\"device.configure\",inactiveLabel: false, decoration: \"flat\") {\n\t\t\t\tstate \"configure\", label:'insecure config', action:\"configure\", icon:\"st.secondary.tools\"\n\t\t\t}\n        standardTile(\n        \t\"configureAfterSecure\", \"device.configure\", inactiveLabel: false, decoration: \"flat\") {\n\t\t\t\tstate \"configure\", label:'secure config', action:\"configureAfterSecure\", icon:\"st.secondary.tools\"\n\t\t\t}\n\t\tmain([\n        \t\"motion\",\"tamper\",\"temperature\",\"humidity\",\"illuminance\",\"ultravioletIndex\"\n            ])\n\t\tdetails([\n        \t\"motion\",\"tamper\",\"temperature\",\"humidity\",\"illuminance\",\"ultravioletIndex\",\"battery\",\"configure\",\"configureAfterSecure\"\n            ])\n\t}\n    preferences {\n\t\tinput \"tempoffset\",\n\t\t\t\"number\",\n\t\t\ttitle: \"Temperature offset\",\n            description: \"negative values reduce the monitored value positive ones add to it\",\n            range: \"..\",\n\t\t\tdefaultValue: 0,\n            required: false,\n            displayDuringSetup: false\n\t\tinput \"humidityoffset\",\n        \t\"number\",\n            title: \"Humidity offset\",\n            description: \"negative values reduce the monitored value positive ones add to it\",\n\t\t\trange: \"..\",\n\t\t\tdefaultValue: 0,\n\t\t\trequired: false,\n            displayDuringSetup: false\n\t\tinput \"luminanceoffset\",\n          \t\"number\",\n            title: \"Luminance offset\",\n            description: \"negative values reduce the monitored value positive ones add to it\",\n            range: \"..\",\n\t\t\tdefaultValue: 0,\n            required: false,\n\t        displayDuringSetup: false\n\t\tinput \"ultravioletoffset\",\n          \t\"number\",\n            title: \"Ultraviolet offset\",\n            description: \"negative values reduce the monitored value positive ones add to it\",\n            range: \"..\",\n\t\t\tdefaultValue: 0,\n\t        required: false,\n\t\t\tdisplayDuringSetup: false\n\t\tinput \"PIRsensitivity\",\n\t        \"number\",\n    \t    title: \"PIR motion sensitivity\",\n\t\t\tdescription: \"A value from 0-5, from disabled to high sensitivity\",\n\t\t\tdefaultValue: 1,\n\t\t\trequired: true,\n\t\t\tdisplayDuringSetup: true\n\t\tinput \"ReportingInterval\",\n        \t\"number\",\n            title: \"Report data interval\",\n            description: \"A value in seconds.\",\n            defaultValue: 300,\n            required: true,\n            displayDuringSetup: true\n\t}\n}\n\ndef parse(String description) {\n\tdef result = null\n    if (description == \"updated\") {\n        result = null\n\t\t}\n\telse {\n       \tdef cmd = zwave.parse(description, [0x31: 5, 0x30: 2, 0x84: 1])\n\t\tif (cmd) {\n       \t\tresult = zwaveEvent(cmd)\n\t\t}\n\t}\n\tlog.debug \"Parsed '${description}' to ${result.inspect()}\"\n\treturn result\n}\ndef zwaveEvent(physicalgraph.zwave.commands.wakeupv1.WakeUpNotification cmd)\n{\n\tdef result = [createEvent(descriptionText: \"${device.displayName} woke up\", isStateChange: false)]\n\n\tif (!isConfigured()) {\n\t\t// we're still in the process of configuring a newly joined device\n\t\tlog.debug(\"have not sent config yet - not sending wakeUpNoMoreInformation yet\")\n        result += response(configureAfterSecure())\n        result += response(configure())\n\t} else {\n\t\tresult += response(zwave.wakeUpV1.wakeUpNoMoreInformation())\n\t}\n\tresult\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.securityv1.SecurityMessageEncapsulation cmd) {\n\tdef encapsulatedCommand = cmd.encapsulatedCommand([0x31: 5, 0x30: 2, 0x84: 1])\n\tlog.debug \"encapsulated: ${encapsulatedCommand}\"\n\tif (encapsulatedCommand) {\n\t\tzwaveEvent(encapsulatedCommand)\n\t} else {\n\t\tlog.warn \"Unable to extract encapsulated cmd from $cmd\"\n\t\tcreateEvent(descriptionText: cmd.toString())\n\t}\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.securityv1.SecurityCommandsSupportedReport cmd) {\n    log.debug \"Received SecurityCommandsSupportedReport\"\n\t// response(configureAfterSecure())\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.batteryv1.BatteryReport cmd) {\n\tdef map = [ name: \"battery\", unit: \"%\" ]\n\tif (cmd.batteryLevel == 0xFF) {\n\t\tmap.value = 1\n\t\tmap.descriptionText = \"${device.displayName} battery is low\"\n\t\tmap.isStateChange = true\n\t} else {\n\t\tmap.value = cmd.batteryLevel\n\t}\n\tstate.lastbatt = new Date().time\n\tcreateEvent(map)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.sensormultilevelv5.SensorMultilevelReport cmd)\n{\n\tdef map = [:]\n\tswitch (cmd.sensorType) {\n\t\tcase 1:\n\t\t\tmap.name = \"temperature\"\n\t\t\tdef cmdScale = cmd.scale == 1 ? \"F\" : \"C\"\n\t\t\tmap.value = convertTemperatureIfNeeded(cmd.scaledSensorValue, cmdScale, cmd.precision)\n\t\t\tmap.unit = getTemperatureScale()\n\t\t\tbreak;\n\t\tcase 3:\n\t\t\tmap.name = \"illuminance\"\n\t\t\tmap.value = cmd.scaledSensorValue.toInteger()\n\t\t\tmap.unit = \"lux\"\n\t\t\tbreak;\n        case 5:\n\t\t\tmap.name = \"humidity\"\n\t\t\tmap.value = cmd.scaledSensorValue.toInteger()\n\t\t\tmap.unit = \"%\"\n\t\t\tbreak;\n\t\tcase 27:\n        \tmap.name = \"ultravioletIndex\"\n            map.value = cmd.scaledSensorValue.toInteger()\n            map.unit = \"\"\n            break;\n\t\tdefault:\n\t\t\tmap.descriptionText = cmd.toString()\n\t}\n\tcreateEvent(map)\n}\n\ndef motionEvent(value) {\n\tdef map = [name: \"motion\"]\n\tif (value) {\n\t\tmap.value = \"active\"\n\t\tmap.descriptionText = \"$device.displayName detected motion\"\n\t} else {\n\t\tmap.value = \"inactive\"\n\t\tmap.descriptionText = \"$device.displayName motion has stopped\"\n\t}\n\tcreateEvent(map)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.sensorbinaryv2.SensorBinaryReport cmd) {\n\t// setConfigured()\n\tmotionEvent(cmd.sensorValue)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicSet cmd) {\n\tmotionEvent(cmd.value)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.notificationv3.NotificationReport cmd) {\n\tdef result = []\n\tif (cmd.notificationType == 7) {\n\t\tswitch (cmd.event) {\n\t\t\tcase 0:\n\t\t\t\tresult << motionEvent(0)\n\t\t\t\tresult << createEvent(name: \"tamper\", value: \"clear\", descriptionText: \"$device.displayName tamper cleared\")\n\t\t\t\tbreak\n\t\t\tcase 3:\n\t\t\t\tresult << createEvent(name: \"tamper\", value: \"detected\", descriptionText: \"$device.displayName was moved\")\n\t\t\t\tbreak\n\t\t\tcase 7:\n\t\t\t\tresult << motionEvent(1)\n\t\t\t\tbreak\n\t\t}\n\t} else {\n\t\tresult << createEvent(descriptionText: cmd.toString(), isStateChange: false)\n\t}\n\tresult\n}\n\ndef zwaveEvent(physicalgraph.zwave.Command cmd) {\n\tcreateEvent(descriptionText: cmd.toString(), isStateChange: false)\n}\n\ndef configureAfterSecure() {\n\tlog.debug \"configureAfterSecure\"\n    log.debug \"PIRsensitivity: $PIRsensitivity, Reporting Interval: $ReportingInterval, Temp offset: $tempoffset, Humidity offset: $humidityoffset, Luminance offset: $luminanceoffset, UV offset: $ultravioletoffset\"\n\n\tdef PIRsens = 1\n\tif (PIRsensitivity) {\n\t\tPIRsens=PIRsensitivity.toInteger()\n\t}\n\tdef ReportingInt = 300\n\tif (ReportingInterval) {\n\t\tReportingInt=ReportingInterval.toInteger()\n\t}\n\tdef tempoff = 0\n\tif (tempoffset) {\n\t\tif(tempoffset < 0) {\n\t\t\ttempoff=(255-tempoffset)\n\t\t}\n\t\tif(tempoffset > 0) {\n\t\t\ttempoff=(0+tempoffset)\n\t\t}\n\t}\n\tdef humidityoff = 0\n\tif (humidityoffset) {\n\t\thumidityoff=humidityoffset.toInteger()\n\t}\n\tdef luminanceoff = 0\n\tif (luminanceoffset) {\n\t\tluminanceoff=luminanceoffset.toInteger()\n\t}\n\tdef ultravioletoff = 0\n\tif (ultravioletoffset) {\n\t\tultravioletoff=ultravioletoffset.toInteger()\n\t}\n    //log.debug \"PIRsens: $PIRsens, ReportingInt: $ReportingInt, Tempoffset: $tempoff, Humidityoff: $humidityoff, Luminanceoff: $luminanceoff, UVoff: $ultravioletoff\"\n\tdef request = [\n\t\t// set wakeup interval to 5 mins\n\t\tzwave.wakeUpV1.wakeUpIntervalSet(seconds:300, nodeid:zwaveHubNodeId),\n\t\t// send temperature, humidity, illuminance, ultraviolet based on reporting interval preference default 5 mins\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x65, size: 4, scaledConfigurationValue: 128|64|32|16),\n\t\t// configure frequency of reporting \n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x6F,size: 4, scaledConfigurationValue: ReportingInt),\n\t\t// send battery every 20 hours\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x66, size: 4, scaledConfigurationValue: 1),\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x70, size: 4, scaledConfigurationValue: 20*60*60),\n        // send no-motion report 20 seconds after motion stops\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x03, size: 2, scaledConfigurationValue: 20),\n\t\t// enable motion sensor and set sensitivity\n        zwave.configurationV1.configurationSet(parameterNumber: 0x04, size: 1, scaledConfigurationValue: PIRsens),\n\t\t// send binary sensor report for motion\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x05, size: 1, scaledConfigurationValue: 2),\n\t\t// Enable the function of touch sensor\n        // zwave.configurationV1.configurationSet(parameterNumber: 0x07, size: 1, scaledConfigurationValue: 1),\n\t\t// disable notification-style motion events\n\t\tzwave.notificationV3.notificationSet(notificationType: 7, notificationStatus: 0),\n        // configure temp offset\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0xC9, size: 2, scaledConfigurationValue: tempoff),\n        // configure humidity offset\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0xCA, size: 2, scaledConfigurationValue: humidityoff),\n        // configure luminance offset\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0xCB, size: 2, scaledConfigurationValue: luminanceoff),\n        // configure ultraviolet offset\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0xCC, size: 2, scaledConfigurationValue: ultravioletoff), \n\n\t\tzwave.batteryV1.batteryGet(),\n\t\tzwave.sensorBinaryV2.sensorBinaryGet(),\n        \n\t\t// Can use the zwaveHubNodeId variable to add the hub to the device's associations:\n\t\tzwave.associationV1.associationSet(groupingIdentifier:2, nodeId:zwaveHubNodeId)\n    ]\n\t\n    //log.debug request\n    secureSequence(request) + [\"delay 20000\", zwave.wakeUpV1.wakeUpNoMoreInformation().format()]\n\tsetConfigured()\n}\n\ndef configure() {\n    //[\"delay 20000\"] + secure(zwave.securityV1.securityCommandsSupportedGet())\n    log.debug \"configure\"\n\tlog.debug \"PIRsensitivity: $PIRsensitivity, Reporting Interval: $ReportingInterval, Temp offset: $tempoffset, Humidity offset: $humidityoffset, Luminance offset: $luminanceoffset, UV offset: $ultravioletoffset\"\n\n\tdef PIRsens = 1\n\tif (PIRsensitivity) {\n\t\tPIRsens=PIRsensitivity.toInteger()\n\t}\n\tdef ReportingInt = 300\n\tif (ReportingInterval) {\n\t\tReportingInt=ReportingInterval.toInteger()\n\t}\n\tdef tempoff = 0\n\tif (tempoffset) {\n\t\tif(tempoffset < 0) {\n\t\t\ttempoff=(255-tempoffset)\n\t\t}\n\t\tif(tempoffset > 0) {\n\t\t\ttempoff=(0+tempoffset)\n\t\t}\n\t}\n\tdef humidityoff = 0\n\tif (humidityoffset) {\n\t\thumidityoff=humidityoffset.toInteger()\n\t}\n\tdef luminanceoff = 0\n\tif (luminanceoffset) {\n\t\tluminanceoff=luminanceoffset.toInteger()\n\t}\n\tdef ultravioletoff = 0\n\tif (ultravioletoffset) {\n\t\tultravioletoff=ultravioletoffset.toInteger()\n\t}\n    log.debug \"PIRsens: $PIRsens, ReportingInt: $ReportingInt, Tempoffset: $tempoff, Humidityoff: $humidityoff, Luminanceoff: $luminanceoff, UVoff: $ultravioletoff\"\n\n\tdelayBetween([\n\t\t// set wakeup interval to 5 minutes\n\t\tzwave.wakeUpV1.wakeUpIntervalSet(seconds:300, nodeid:zwaveHubNodeId).format(),\n\t\t// send temperature, humidity, illuminance, ultraviolet based on reporting interval preference default 5 mins\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x65, size: 4, scaledConfigurationValue: 128|64|32|16).format(),\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x6F, size: 4, scaledConfigurationValue: ReportingInt).format(),\n\n\t\t// send battery every 20 hours\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x66, size: 4, scaledConfigurationValue: 1).format(),\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x70, size: 4, scaledConfigurationValue: 20*60*60).format(),\n\n        // send no-motion report 20 seconds after motion stops\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x03, size: 2, scaledConfigurationValue: 20).format(),\n\n\t\t// enable motion sensor and set min sensitivity\n        zwave.configurationV1.configurationSet(parameterNumber: 0x04, size: 1, scaledConfigurationValue: PIRsens).format(),\n\n\t\t// send binary sensor report for motion\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x05, size: 1, scaledConfigurationValue: 2).format(),\n\n\t\t// Enable the function of touch sensor\n        //zwave.configurationV1.configurationSet(parameterNumber: 0x07, size: 1, scaledConfigurationValue: 1).format(),\n\n\t\t// disable notification-style motion events\n\t\tzwave.notificationV3.notificationSet(notificationType: 7, notificationStatus: 0).format(),\n        \n        // configure temp offset\n        zwave.configurationV1.configurationSet(parameterNumber: 0xC9, size: 2, scaledConfigurationValue: tempoff).format(),\n        \n        // configure humidity offset\n        zwave.configurationV1.configurationSet(parameterNumber: 0xCA, size: 2, scaledConfigurationValue: humidityoff).format(),\n        \n        // configure luminance offset\n        zwave.configurationV1.configurationSet(parameterNumber: 0xCB, size: 2, scaledConfigurationValue: luminanceoff).format(),\n        \n        // configure ultraviolet offset\n        zwave.configurationV1.configurationSet(parameterNumber: 0xCC, size: 2, scaledConfigurationValue: ultravioletoff).format(),\n        \n\t\tzwave.batteryV1.batteryGet(),\n\t\tzwave.sensorBinaryV2.sensorBinaryGet(),\n\t\t\n        // Can use the zwaveHubNodeId variable to add the hub to the device's associations:\n\t\tzwave.associationV1.associationSet(groupingIdentifier:2, nodeId:zwaveHubNodeId)\n    ])\t\n\tzwave.wakeUpV1.wakeUpNoMoreInformation().format()\n\tsetConfigured()\n}\n\ndef setConfigured() {\n\tdevice.updateDataValue(\"configured\", \"true\")\n}\n\ndef isConfigured() {\n\tBoolean configured = device.getDataValue([\"configured\"]) as Boolean\t\n\treturn configured\n}\n\nprivate secure(physicalgraph.zwave.Command cmd) {\n\tzwave.securityV1.securityMessageEncapsulation().encapsulate(cmd).format()\n}\n\nprivate secureSequence(commands, delay=200) {\n\tdelayBetween(commands.collect{ secure(it) }, delay)\n}\ndef updated() {\n\tlog.debug \"updated()\"\n    log.debug \"PIRsensitivity: $PIRsensitivity, Reporting Interval: $ReportingInterval, Temp offset: $tempoffset, Humidity offset: $humidityoffset, Luminance offset: $luminanceoffset, UV offset: $ultravioletoffset\"\n    //configure()\n}"
  },
  {
    "path": "Aeon Multisensor 6/device_type-aeon-multisensor6-v1.4",
    "content": "/*\n * V 1.4 of Multisensor 6 code 9/14/2015\n * Uses some original code from @Duncan Aeon Multisensor 6 code for secure configuration, Copyright 2015 SmartThings, modified for setting\n * preferences around configuration and the reporting of tampering and ultraviolet index, and reconfiguration after pairing.\n * Robert Vandervoort 6/19/2015 - 9/20/2015\n *\n *  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except\n *  in compliance with the License. You may obtain a copy of the License at:\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n *  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed\n *  on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License\n *  for the specific language governing permissions and limitations under the License.\n * \n * INSTRUCTIONS: Pair device to SmartThings by double tapping the inclusion button. Allow it to join with SmartThings device type. After\n * adding, go to device entry in the website, edit it, change type to Aeon Multisensor 6 - RV, open device in SmartThings app, edit\n * edit preferences to your liking but do not save yet, short press action button on sensor one time and the light should go blue, hit save\n * in the app, a couple seconds later the light should go out (you can verify in live logging that it says it woke up and settings were sent\n * over).. Now on device screen, short press the action button one more time and hit secure configure button on the app screen... Your sensor\n * should now follow your polling interval, but will go no lower than 5 minute intervals unless a large enough change happens to warrant it.\n * motion activates immediately and clears after 20 seconds. tamper activates immediately and also clears after 20 seconds. Currently tamper\n * is just used for logging and as an indicator on the screen. If requests for functionality outside of that are required please message me.\n */\n\n metadata {\n\tdefinition (name: \"Aeon Multisensor 6 - RV\", namespace: \"robertvandervoort\", author: \"Robert Vandervoort\") {\n\t\tcapability \"Motion Sensor\"\n\t\tcapability \"Temperature Measurement\"\n\t\tcapability \"Relative Humidity Measurement\"\n\t\tcapability \"Illuminance Measurement\"\n\t\tcapability \"Ultraviolet Index\" \n\t\tcapability \"Configuration\"\n\t\tcapability \"Sensor\"\n\t\tcapability \"Battery\"\n\t\t\n\t\t// CCs supported - 94, 134, 114, 132, 89, 133, 115, 113, 128, 48, 49, 112, 152, 122\n\t\tattribute \"tamper\", \"enum\", [\"detected\", \"clear\"]\n\t\tfingerprint deviceId: \"0x2101\", inClusters: \"0x5E,0x86,0x72,0x59,0x85,0x73,0x71,0x84,0x80,0x30,0x31,0x70,0xEF,0x5A,0x98,0x7A\"\n\t\t}\n\tsimulator {\n\t\tstatus \"no motion\" : \"command: 9881, payload: 00300300\"\n\t\tstatus \"motion\"    : \"command: 9881, payload: 003003FF\"\n        status \"clear\" : \" command: 9881, payload: 0071050000000007030000\"\n        status \"tamper\" : \"command: 9881, payload: 007105000000FF07030000\"\n        \n        for (int i = 0; i <= 100; i += 20) {\n\t\t\tstatus \"temperature ${i}F\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().sensorMultilevelV2.sensorMultilevelReport(\n                \tscaledSensorValue: i,\n                    precision: 1,\n                    sensorType: 1,\n                    scale: 1\n\t\t\t\t)\n\t\t\t).incomingMessage()\n\t\t}\n\t\tfor (int i = 0; i <= 100; i += 20) {\n\t\t\tstatus \"RH ${i}%\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().sensorMultilevelV2.sensorMultilevelReport(\n                \tscaledSensorValue: i,\n                    sensorType: 5\n            \t)\n\t\t\t).incomingMessage()\n\t\t}\n\t\tfor (int i in [0, 1, 2, 8, 12, 16, 20, 24, 30, 64, 82, 100, 200, 500, 1000]) {\n\t\t\tstatus \"illuminance ${i} lux\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().sensorMultilevelV2.sensorMultilevelReport(\n                scaledSensorValue: i,\n                sensorType: 3\n                )\n\t\t\t).incomingMessage()\n\t\t}\n\t\tfor (int i = 0; i <= 11; i += 1) {\n\t\t\tstatus \"ultravioletultravioletIndex ${i}\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().sensorMultilevelV2.sensorMultilevelReport(\n                scaledSensorValue: i,\n                sensorType: 27\n                )\n\t\t\t).incomingMessage()\n\t\t}\n\t\tfor (int i in [0, 5, 10, 15, 50, 99, 100]) {\n\t\t\tstatus \"battery ${i}%\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().batteryV1.batteryReport(\n                batteryLevel: i\n                )\n\t\t\t).incomingMessage()\n\t\t}\n\t\tstatus \"low battery alert\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().batteryV1.batteryReport(\n            \tbatteryLevel: 255\n            \t)\n\t\t\t).incomingMessage()\n\t\tstatus \"wake up\": \"command: 8407, payload:\"\n\t}\n\ttiles {\n\t\tstandardTile(\"motion\",\"device.motion\") {\n            \tstate \"active\",label:'motion',icon:\"st.motion.motion.active\",backgroundColor:\"#53a7c0\"\n                state \"inactive\",label:'no motion',icon:\"st.motion.motion.inactive\",backgroundColor:\"#ffffff\"\n\t\t\t}\n\t\tvalueTile(\"temperature\",\"device.temperature\") {\n            \tstate \"temperature\",label:'${currentValue}°',backgroundColors:[\n                \t[value: 32, color: \"#153591\"],\n                    [value: 44, color: \"#1e9cbb\"],\n                    [value: 59, color: \"#90d2a7\"],\n\t\t\t\t\t[value: 74, color: \"#44b621\"],\n\t\t\t\t\t[value: 84, color: \"#f1d801\"],\n\t\t\t\t\t[value: 92, color: \"#d04e00\"],\n\t\t\t\t\t[value: 98, color: \"#bc2323\"]\n\t\t\t\t]\n\t\t\t}\n\t\tvalueTile(\n        \t\"humidity\",\"device.humidity\") {\n            \tstate \"humidity\",label:'RH ${currentValue} %',unit:\"\"\n\t\t\t}\n\t\tvalueTile(\n        \t\"illuminance\",\"device.illuminance\") {\n            \tstate \"luminosity\",label:'${currentValue} ${unit}', unit:\"lux\", backgroundColors:[\n                \t[value: 0, color: \"#000000\"],\n                    [value: 1, color: \"#060053\"],\n                    [value: 3, color: \"#3E3900\"],\n                    [value: 12, color: \"#8E8400\"],\n\t\t\t\t\t[value: 24, color: \"#C5C08B\"],\n\t\t\t\t\t[value: 36, color: \"#DAD7B6\"],\n\t\t\t\t\t[value: 128, color: \"#F3F2E9\"],\n                    [value: 1000, color: \"#FFFFFF\"]\n\t\t\t\t]\n\t\t\t}\n\t\tvalueTile(\n        \t\"ultravioletIndex\",\"device.ultravioletIndex\") {\n\t\t\t\tstate \"ultravioletIndex\",label:'${currentValue} UV INDEX',unit:\"\"\n\t\t\t}\n\t\tstandardTile(\n        \t\"tamper\",\"device.tamper\") {\n\t\t\t\tstate \"tamper\",label:'tamper',icon:\"st.motion.motion.active\",backgroundColor:\"#ff0000\"\n                state \"clear\",label:'clear',icon:\"st.motion.motion.inactive\",backgroundColor:\"#00ff00\"\n\t\t\t}\n\t\tvalueTile(\n\t\t\t\"battery\", \"device.battery\", decoration: \"flat\") {\n\t\t\tstate \"battery\", label:'${currentValue}% battery', unit:\"\"\n\t\t}\n\t\tstandardTile(\n        \t\"configure\",\"device.configure\", decoration: \"flat\") {\n\t\t\t\tstate \"configure\", label:'config', action:\"configure\", icon:\"st.secondary.tools\"\n\t\t\t}\n\t\tmain([\n        \t\"temperature\",\"humidity\",\"illuminance\",\"motion\",\"tamper\",\"ultravioletIndex\"\n            ])\n\t\tdetails([\n        \t\"temperature\",\"humidity\",\"illuminance\",\"motion\",\"tamper\",\"ultravioletIndex\",\"battery\",\"configure\"\n            ])\n\t}\n\t\n    preferences {\n\t\tinput \"tempoffset\",\n\t\t\t\"number\",\n\t\t\ttitle: \"Temperature offset\",\n            description: \"negative values reduce the monitored value positive ones add to it\",\n            range: \"..\",\n\t\t\tdefaultValue: 0,\n            required: false,\n            displayDuringSetup: false\n\t\tinput \"humidityoffset\",\n        \t\"number\",\n            title: \"Humidity offset\",\n            description: \"negative values reduce the monitored value positive ones add to it\",\n\t\t\trange: \"..\",\n\t\t\tdefaultValue: 0,\n\t\t\trequired: false,\n            displayDuringSetup: false\n\t\tinput \"luminanceoffset\",\n          \t\"number\",\n            title: \"Luminance offset\",\n            description: \"negative values reduce the monitored value positive ones add to it\",\n            range: \"..\",\n\t\t\tdefaultValue: 0,\n            required: false,\n\t        displayDuringSetup: false\n\t\tinput \"ultravioletoffset\",\n          \t\"number\",\n            title: \"Ultraviolet offset\",\n            description: \"negative values reduce the monitored value positive ones add to it\",\n            range: \"..\",\n\t\t\tdefaultValue: 0,\n\t        required: false,\n\t\t\tdisplayDuringSetup: false\n\t\tinput \"PIRsensitivity\",\n\t        \"number\",\n    \t    title: \"PIR motion sensitivity\",\n\t\t\tdescription: \"A value from 0-5, from disabled to high sensitivity\",\n\t\t\tdefaultValue: 1,\n\t\t\trequired: true,\n\t\t\tdisplayDuringSetup: true\n\t\tinput \"ReportingInterval\",\n        \t\"number\",\n            title: \"Report data interval\",\n            description: \"A value in seconds.\",\n            defaultValue: 300,\n            required: true,\n            displayDuringSetup: true\n\t}\n}\n\ndef updated()\n{\n\tif (state.sec && !isConfigured()) {\n\t\t// in case we miss the SCSR\n\t\tresponse(configure())\n\t}\n}\n\ndef parse(String description)\n{\n\tdef result = null\n\tif (description.startsWith(\"Err 106\")) {\n\t\tstate.sec = 0\n\t\tresult = createEvent( name: \"secureInclusion\", value: \"failed\", isStateChange: true,\n\t\t\tdescriptionText: \"This sensor failed to complete the network security key exchange. If you are unable to control it via SmartThings, you must remove it from your network and add it again.\")\n\t} else if (description != \"updated\") {\n\t\tdef cmd = zwave.parse(description, [0x31: 5, 0x30: 2, 0x84: 1])\n\t\tif (cmd) {\n\t\t\tresult = zwaveEvent(cmd)\n\t\t}\n\t}\n\tlog.debug \"Parsed '${description}' to ${result.inspect()}\"\n\treturn result\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.wakeupv1.WakeUpNotification cmd)\n{\n\tdef result = [createEvent(descriptionText: \"${device.displayName} woke up\", isStateChange: false)]\n\n\tif (!isConfigured()) {\n\t\t// we're still in the process of configuring a newly joined device\n\t\tlog.debug(\"late configure\")\n\t\tresult += response(configure())\n\t} else {\n\t\tresult += response(zwave.wakeUpV1.wakeUpNoMoreInformation())\n\t}\n\tresult\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.securityv1.SecurityMessageEncapsulation cmd) {\n\tdef encapsulatedCommand = cmd.encapsulatedCommand([0x31: 5, 0x30: 2, 0x84: 1])\n\tstate.sec = 1\n\tlog.debug \"encapsulated: ${encapsulatedCommand}\"\n\tif (encapsulatedCommand) {\n\t\tzwaveEvent(encapsulatedCommand)\n\t} else {\n\t\tlog.warn \"Unable to extract encapsulated cmd from $cmd\"\n\t\tcreateEvent(descriptionText: cmd.toString())\n\t}\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.securityv1.SecurityCommandsSupportedReport cmd) {\n\tresponse(configure())\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.batteryv1.BatteryReport cmd) {\n\tdef map = [ name: \"battery\", unit: \"%\" ]\n\tif (cmd.batteryLevel == 0xFF) {\n\t\tmap.value = 1\n\t\tmap.descriptionText = \"${device.displayName} battery is low\"\n\t\tmap.isStateChange = true\n\t} else {\n\t\tmap.value = cmd.batteryLevel\n\t}\n\tstate.lastbatt = now()\n\tcreateEvent(map)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.sensormultilevelv5.SensorMultilevelReport cmd)\n{\n\tdef map = [:]\n\tswitch (cmd.sensorType) {\n\t\tcase 1:\n\t\t\tmap.name = \"temperature\"\n\t\t\tdef cmdScale = cmd.scale == 1 ? \"F\" : \"C\"\n\t\t\tmap.value = convertTemperatureIfNeeded(cmd.scaledSensorValue, cmdScale, cmd.precision)\n\t\t\tmap.unit = getTemperatureScale()\n\t\t\tbreak;\n\t\tcase 3:\n\t\t\tmap.name = \"illuminance\"\n\t\t\tmap.value = cmd.scaledSensorValue.toInteger()\n\t\t\tmap.unit = \"lux\"\n\t\t\tbreak;\n        case 5:\n\t\t\tmap.name = \"humidity\"\n\t\t\tmap.value = cmd.scaledSensorValue.toInteger()\n\t\t\tmap.unit = \"%\"\n\t\t\tbreak;\n\t\tcase 27:\n        \tmap.name = \"ultravioletIndex\"\n            map.value = cmd.scaledSensorValue.toInteger()\n            map.unit = \"\"\n            break;\n\t\tdefault:\n\t\t\tmap.descriptionText = cmd.toString()\n\t}\n\tcreateEvent(map)\n}\n\ndef motionEvent(value) {\n\tdef map = [name: \"motion\"]\n\tif (value) {\n\t\tmap.value = \"active\"\n\t\tmap.descriptionText = \"$device.displayName detected motion\"\n\t} else {\n\t\tmap.value = \"inactive\"\n\t\tmap.descriptionText = \"$device.displayName motion has stopped\"\n\t}\n\tcreateEvent(map)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.sensorbinaryv2.SensorBinaryReport cmd) {\n\tsetConfigured()\n\tmotionEvent(cmd.sensorValue)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicSet cmd) {\n\tmotionEvent(cmd.value)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.notificationv3.NotificationReport cmd) {\n\tdef result = []\n\tif (cmd.notificationType == 7) {\n\t\tswitch (cmd.event) {\n\t\t\tcase 0:\n\t\t\t\tresult << motionEvent(0)\n\t\t\t\tresult << createEvent(name: \"tamper\", value: \"clear\", descriptionText: \"$device.displayName tamper cleared\")\n\t\t\t\tbreak\n\t\t\tcase 3:\n\t\t\t\tresult << createEvent(name: \"tamper\", value: \"detected\", descriptionText: \"$device.displayName was moved\")\n\t\t\t\tbreak\n\t\t\tcase 7:\n\t\t\t\tresult << motionEvent(1)\n\t\t\t\tbreak\n\t\t}\n\t} else {\n\t\tresult << createEvent(descriptionText: cmd.toString(), isStateChange: false)\n\t}\n\tresult\n}\n\ndef zwaveEvent(physicalgraph.zwave.Command cmd) {\n\tcreateEvent(descriptionText: cmd.toString(), isStateChange: false)\n}\n\ndef configure() {\n\t// This sensor joins as a secure device if you double-click the button to include it\n\t//if (device.device.rawDescription =~ /98/ && !state.sec) {\n\t//\tlog.debug \"Multi 6 not sending configure until secure\"\n\t//\treturn []\n\t//}\n\tlog.debug \"--Sending configuration command to Multisensor 6--\"\n    //log.debug \"Prefernces settings: PIRsensitivity: $PIRsensitivity, Reporting Interval: $ReportingInterval, Temp offset: $tempoffset, Humidity offset: $humidityoffset, Luminance offset: $luminanceoffset, UV offset: $ultravioletoffset\"\n\t\n\tdef PIRsens = 1\n\tif (PIRsensitivity) {\n\t\tPIRsens=PIRsensitivity.toInteger()\n\t}\n\tdef ReportingInt = 300\n\tif (ReportingInterval) {\n\t\tReportingInt=ReportingInterval.toInteger()\n\t}\n\tdef tempoff = 0\n\tif (tempoffset) {\n\t\tif(tempoffset < 0) {\n\t\t\ttempoff=(255-tempoffset)\n\t\t}\n\t\tif(tempoffset > 0) {\n\t\t\ttempoff=(0+tempoffset)\n\t\t}\n\t}\n\tdef humidityoff = 0\n\tif (humidityoffset) {\n\t\tif(humidityoffset < 0) {\n\t\t\thumidityoff=(255-humidityoffset)\n\t\t}\n\t\tif(humidityoffset > 0) {\n\t\t\thumidityoff=(0+humidityoffset)\n\t\t}\n\t}\n\tdef luminanceoff = 0\n\tif (luminanceoffset) {\n\t\tif(luminanceoffset < 0) {\n\t\t\tluminanceoff=(255-luminanceoffset)\n\t\t}\n\t\tif(luminanceoffset > 0) {\n\t\t\tluminanceoff=(0+luminanceoffset)\n\t\t}\n\t}\n\tdef ultravioletoff = 0\n\tif (ultravioletoffset) {\n\t\tif(ultravioletoffset < 0) {\n\t\t\tultravioletoff=(255-ultravioletoffset)\n\t\t}\n\t\tif(ultravioletoffset > 0) {\n\t\t\tultravioletoff=(0 + ultravioletoffset)\n\t\t}\n\t}\n    //log.debug \"Setting - PIRsens: $PIRsens, ReportingInt: $ReportingInt, Tempoffset: $tempoff, Humidityoff: $humidityoff, Luminanceoff: $luminanceoff, UVoff: $ultravioletoff\"\n\tdef request = [\n\t\t// set wakeup interval to 5 mins\n\t\tzwave.wakeUpV1.wakeUpIntervalSet(seconds:300, nodeid:zwaveHubNodeId),\n\t\t\n\t\t// send temperature, humidity, illuminance, ultraviolet based on reporting interval preference default 5 mins\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x65, size: 4, scaledConfigurationValue: 128|64|32|16),\n\t\t\n\t\t// configure frequency of reporting \n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x6F,size: 4, scaledConfigurationValue: ReportingInt),\n\t\t\n\t\t// send battery every 20 hours\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x66, size: 4, scaledConfigurationValue: 1),\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x70, size: 4, scaledConfigurationValue: 20*60*60),\n\t\t\n        // send no-motion report 20 seconds after motion stops\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x03, size: 2, scaledConfigurationValue: 20),\n\t\t\n\t\t// enable motion sensor and set sensitivity\n        zwave.configurationV1.configurationSet(parameterNumber: 0x04, size: 1, scaledConfigurationValue: PIRsens),\n\t\t\n\t\t// send binary sensor report for motion\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x05, size: 1, scaledConfigurationValue: 2),\n\t\t\n\t\t// Enable the function of touch sensor\n        zwave.configurationV1.configurationSet(parameterNumber: 0x07, size: 1, scaledConfigurationValue: 1),\n\t\t\n\t\t// disable notification-style motion events\n\t\t// zwave.notificationV3.notificationSet(notificationType: 7, notificationStatus: 0),\n\t\t\n        // configure temp offset\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0xC9, size: 1, scaledConfigurationValue: tempoff),\n\t\t\n        // configure humidity offset\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0xCA, size: 1, scaledConfigurationValue: humidityoff),\n\t\t\n        // configure luminance offset\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0xCB, size: 2, scaledConfigurationValue: luminanceoff),\n\t\t\n        // configure ultraviolet offset\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0xCC, size: 1, scaledConfigurationValue: ultravioletoff), \n\n\t\tzwave.batteryV1.batteryGet(),\n\t\tzwave.sensorBinaryV2.sensorBinaryGet(),\n        \n\t\t// Can use the zwaveHubNodeId variable to add the hub to the device's associations:\n\t\tzwave.associationV1.associationSet(groupingIdentifier:2, nodeId:zwaveHubNodeId)\n    ]\n\tcommands(request) + [\"delay 20000\", zwave.wakeUpV1.wakeUpNoMoreInformation().format()]\n}\n\nprivate setConfigured() {\n\tupdateDataValue(\"configured\", \"true\")\n}\n\nprivate isConfigured() {\n\tgetDataValue(\"configured\") == \"true\"\n}\n\nprivate command(physicalgraph.zwave.Command cmd) {\n\tif (state.sec) {\n\t\tzwave.securityV1.securityMessageEncapsulation().encapsulate(cmd).format()\n\t} else {\n\t\tcmd.format()\n\t}\n}\n\nprivate commands(commands, delay=200) {\n\tdelayBetween(commands.collect{ command(it) }, delay)\n}"
  },
  {
    "path": "Aeon Multisensor 6/device_type-aeon-multisensor6-v1.5",
    "content": "/*\n * V 1.5 of Multisensor 6 code 9/14/2015\n * Uses some original code from @Duncan Aeon Multisensor 6 code for secure configuration, Copyright 2015 SmartThings, modified for setting\n * preferences around configuration and the reporting of tampering and ultraviolet index, and reconfiguration after pairing.\n * Robert Vandervoort 6/19/2015 - 9/20/2015\n *\n *  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except\n *  in compliance with the License. You may obtain a copy of the License at:\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n *  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed\n *  on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License\n *  for the specific language governing permissions and limitations under the License.\n * \n * INSTRUCTIONS: Pair device to SmartThings by double tapping the inclusion button. Allow it to join with SmartThings device type. After\n * adding, go to device entry in the website, edit it, change type to Aeon Multisensor 6 - RV, open device in SmartThings app, edit\n * edit preferences to your liking but do not save yet, short press action button on sensor one time and the light should go blue, hit save\n * in the app, a couple seconds later the light should go out (you can verify in live logging that it says it woke up and settings were sent\n * over).. Now on device screen, short press the action button one more time and hit secure configure button on the app screen... Your sensor\n * should now follow your polling interval, but will go no lower than 5 minute intervals unless a large enough change happens to warrant it.\n * motion activates immediately and clears after 20 seconds. tamper activates immediately and also clears after 20 seconds. Currently tamper\n * is just used for logging and as an indicator on the screen. If requests for functionality outside of that are required please message me.\n */\n\n metadata {\n\tdefinition (name: \"Aeon Multisensor 6 - RV 1.5\", namespace: \"robertvandervoort\", author: \"Robert Vandervoort\") {\n\t\tcapability \"Motion Sensor\"\n\t\tcapability \"Temperature Measurement\"\n\t\tcapability \"Relative Humidity Measurement\"\n\t\tcapability \"Illuminance Measurement\"\n\t\tcapability \"Ultraviolet Index\" \n\t\tcapability \"Configuration\"\n\t\tcapability \"Sensor\"\n\t\tcapability \"Battery\"\n\t\t\n\t\t// CCs supported - 94, 134, 114, 132, 89, 133, 115, 113, 128, 48, 49, 112, 152, 122\n\t\tattribute \"tamper\", \"enum\", [\"detected\", \"clear\"]\n\t\tfingerprint deviceId: \"0x2101\", inClusters: \"0x5E,0x86,0x72,0x59,0x85,0x73,0x71,0x84,0x80,0x30,0x31,0x70,0xEF,0x5A,0x98,0x7A\"\n\t\t}\n\tsimulator {\n\t\tstatus \"no motion\" : \"command: 9881, payload: 00300300\"\n\t\tstatus \"motion\"    : \"command: 9881, payload: 003003FF\"\n        status \"clear\" : \" command: 9881, payload: 0071050000000007030000\"\n        status \"tamper\" : \"command: 9881, payload: 007105000000FF07030000\"\n        \n        for (int i = 0; i <= 100; i += 20) {\n\t\t\tstatus \"temperature ${i}F\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().sensorMultilevelV2.sensorMultilevelReport(\n                \tscaledSensorValue: i,\n                    precision: 1,\n                    sensorType: 1,\n                    scale: 1\n\t\t\t\t)\n\t\t\t).incomingMessage()\n\t\t}\n\t\tfor (int i = 0; i <= 100; i += 20) {\n\t\t\tstatus \"RH ${i}%\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().sensorMultilevelV2.sensorMultilevelReport(\n                \tscaledSensorValue: i,\n                    sensorType: 5\n            \t)\n\t\t\t).incomingMessage()\n\t\t}\n\t\tfor (int i in [0, 1, 2, 8, 12, 16, 20, 24, 30, 64, 82, 100, 200, 500, 1000]) {\n\t\t\tstatus \"illuminance ${i} lux\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().sensorMultilevelV2.sensorMultilevelReport(\n                scaledSensorValue: i,\n                sensorType: 3\n                )\n\t\t\t).incomingMessage()\n\t\t}\n\t\tfor (int i = 0; i <= 11; i += 1) {\n\t\t\tstatus \"ultravioletultravioletIndex ${i}\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().sensorMultilevelV2.sensorMultilevelReport(\n                scaledSensorValue: i,\n                sensorType: 27\n                )\n\t\t\t).incomingMessage()\n\t\t}\n\t\tfor (int i in [0, 5, 10, 15, 50, 99, 100]) {\n\t\t\tstatus \"battery ${i}%\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().batteryV1.batteryReport(\n                batteryLevel: i\n                )\n\t\t\t).incomingMessage()\n\t\t}\n\t\tstatus \"low battery alert\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().batteryV1.batteryReport(\n            \tbatteryLevel: 255\n            \t)\n\t\t\t).incomingMessage()\n\t\tstatus \"wake up\": \"command: 8407, payload:\"\n\t}\n\ttiles {\n\t\tstandardTile(\"motion\",\"device.motion\") {\n            \tstate \"active\",label:'motion',icon:\"st.motion.motion.active\",backgroundColor:\"#53a7c0\"\n                state \"inactive\",label:'no motion',icon:\"st.motion.motion.inactive\",backgroundColor:\"#ffffff\"\n\t\t\t}\n\t\tvalueTile(\"temperature\",\"device.temperature\") {\n            \tstate \"temperature\",label:'${currentValue}°',backgroundColors:[\n                \t[value: 32, color: \"#153591\"],\n                    [value: 44, color: \"#1e9cbb\"],\n                    [value: 59, color: \"#90d2a7\"],\n\t\t\t\t\t[value: 74, color: \"#44b621\"],\n\t\t\t\t\t[value: 84, color: \"#f1d801\"],\n\t\t\t\t\t[value: 92, color: \"#d04e00\"],\n\t\t\t\t\t[value: 98, color: \"#bc2323\"]\n\t\t\t\t]\n\t\t\t}\n\t\tvalueTile(\n        \t\"humidity\",\"device.humidity\") {\n            \tstate \"humidity\",label:'RH ${currentValue} %',unit:\"\"\n\t\t\t}\n\t\tvalueTile(\n        \t\"illuminance\",\"device.illuminance\") {\n            \tstate \"luminosity\",label:'${currentValue} ${unit}', unit:\"lux\", backgroundColors:[\n                \t[value: 0, color: \"#000000\"],\n                    [value: 1, color: \"#060053\"],\n                    [value: 3, color: \"#3E3900\"],\n                    [value: 12, color: \"#8E8400\"],\n\t\t\t\t\t[value: 24, color: \"#C5C08B\"],\n\t\t\t\t\t[value: 36, color: \"#DAD7B6\"],\n\t\t\t\t\t[value: 128, color: \"#F3F2E9\"],\n                    [value: 1000, color: \"#FFFFFF\"]\n\t\t\t\t]\n\t\t\t}\n\t\tvalueTile(\n        \t\"ultravioletIndex\",\"device.ultravioletIndex\") {\n\t\t\t\tstate \"ultravioletIndex\",label:'${currentValue} UV INDEX',unit:\"\"\n\t\t\t}\n\t\tstandardTile(\n        \t\"tamper\",\"device.tamper\") {\n\t\t\t\tstate \"tamper\",label:'tamper',icon:\"st.motion.motion.active\",backgroundColor:\"#ff0000\"\n                state \"clear\",label:'clear',icon:\"st.motion.motion.inactive\",backgroundColor:\"#00ff00\"\n\t\t\t}\n\t\tvalueTile(\n\t\t\t\"battery\", \"device.battery\", decoration: \"flat\") {\n\t\t\tstate \"battery\", label:'${currentValue}% battery', unit:\"\"\n\t\t}\n\t\tstandardTile(\n        \t\"configure\",\"device.configure\", decoration: \"flat\") {\n\t\t\t\tstate \"configure\", label:'config', action:\"configure\", icon:\"st.secondary.tools\"\n\t\t\t}\n\t\tmain([\n        \t\"temperature\",\"humidity\",\"illuminance\",\"motion\",\"tamper\",\"ultravioletIndex\"\n            ])\n\t\tdetails([\n        \t\"temperature\",\"humidity\",\"illuminance\",\"motion\",\"tamper\",\"ultravioletIndex\",\"battery\",\"configure\"\n            ])\n\t}\n\t\n    preferences {\n\t\tinput \"tempoffset\",\n\t\t\t\"number\",\n\t\t\ttitle: \"Temperature offset\",\n            description: \"negative values reduce the monitored value positive ones add to it\",\n            range: \"-11..11\",\n\t\t\tdefaultValue: 0,\n            required: false,\n            displayDuringSetup: false\n\t\tinput \"humidityoffset\",\n        \t\"number\",\n            title: \"Humidity offset\",\n            description: \"negative values reduce the monitored value positive ones add to it\",\n\t\t\trange: \"-50..50\",\n\t\t\tdefaultValue: 0,\n\t\t\trequired: false,\n            displayDuringSetup: false\n\t\tinput \"luminanceoffset\",\n          \t\"number\",\n            title: \"Luminance offset\",\n            description: \"negative values reduce the monitored value positive ones add to it\",\n            range: \"-1000..1000\",\n\t\t\tdefaultValue: 0,\n            required: false,\n\t        displayDuringSetup: false\n\t\tinput \"ultravioletoffset\",\n          \t\"number\",\n            title: \"Ultraviolet offset\",\n            description: \"negative values reduce the monitored value positive ones add to it\",\n            range: \"-10..10\",\n\t\t\tdefaultValue: 0,\n\t        required: false,\n\t\t\tdisplayDuringSetup: false\n\t\tinput \"PIRsensitivity\",\n\t        \"number\",\n    \t    title: \"PIR motion sensitivity\",\n\t\t\tdescription: \"A value from 0-5, from disabled to high sensitivity\",\n\t\t\trange: \"0..5\",\n\t\t\tdefaultValue: 1,\n\t\t\trequired: true,\n\t\t\tdisplayDuringSetup: true\n\t\tinput \"MotionReset\",\n\t        \"number\",\n    \t    title: \"PIR reset time\",\n\t\t\tdescription: \"Number of seconds to wait to report motion cleared after a motion event if there is no motion detected.\",\n\t\t\tdefaultValue: 20,\n\t\t\trequired: true,\n\t\t\tdisplayDuringSetup: true            \n\t\tinput \"ReportingInterval\",\n        \t\"number\",\n            title: \"Report data interval\",\n            description: \"A value in seconds.\",\n            defaultValue: 300,\n            required: true,\n            displayDuringSetup: true\n\t}\n}\n\ndef updated()\n{\n\tif (state.sec && !isConfigured()) {\n\t\t// in case we miss the SCSR\n\t\tresponse(configure())\n\t}\n}\n\ndef parse(String description)\n{\n\tdef result = null\n\tif (description.startsWith(\"Err 106\")) {\n\t\tstate.sec = 0\n\t\tresult = createEvent( name: \"secureInclusion\", value: \"failed\", isStateChange: true,\n\t\t\tdescriptionText: \"This sensor failed to complete the network security key exchange. If you are unable to control it via SmartThings, you must remove it from your network and add it again.\")\n\t} else if (description != \"updated\") {\n\t\tdef cmd = zwave.parse(description, [0x31: 5, 0x30: 2, 0x84: 1])\n\t\tif (cmd) {\n\t\t\tresult = zwaveEvent(cmd)\n\t\t}\n\t}\n\tlog.debug \"Parsed '${description}' to ${result.inspect()}\"\n\treturn result\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.wakeupv1.WakeUpNotification cmd)\n{\n\tdef result = [createEvent(descriptionText: \"${device.displayName} woke up\", isStateChange: false)]\n\n\tif (!isConfigured()) {\n\t\t// we're still in the process of configuring a newly joined device\n\t\tlog.debug(\"late configure\")\n\t\tresult += response(configure())\n\t} else {\n\t\tresult += response(zwave.wakeUpV1.wakeUpNoMoreInformation())\n\t}\n\tresult\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.securityv1.SecurityMessageEncapsulation cmd) {\n\tdef encapsulatedCommand = cmd.encapsulatedCommand([0x31: 5, 0x30: 2, 0x84: 1])\n\tstate.sec = 1\n\tlog.debug \"encapsulated: ${encapsulatedCommand}\"\n\tif (encapsulatedCommand) {\n\t\tzwaveEvent(encapsulatedCommand)\n\t} else {\n\t\tlog.warn \"Unable to extract encapsulated cmd from $cmd\"\n\t\tcreateEvent(descriptionText: cmd.toString())\n\t}\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.securityv1.SecurityCommandsSupportedReport cmd) {\n\tresponse(configure())\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.configurationv2.ConfigurationReport cmd) {\n    log.debug \"---CONFIGURATION REPORT V2--- ${device.displayName} parameter ${cmd.parameterNumber} with a byte size of ${cmd.size} is set to ${cmd.configurationValue}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.configurationv1.ConfigurationReport cmd) {\n    log.debug \"---CONFIGURATION REPORT V1--- ${device.displayName} parameter ${cmd.parameterNumber} with a byte size of ${cmd.size} is set to ${cmd.configurationValue}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.batteryv1.BatteryReport cmd) {\n\tdef map = [ name: \"battery\", unit: \"%\" ]\n\tif (cmd.batteryLevel == 0xFF) {\n\t\tmap.value = 1\n\t\tmap.descriptionText = \"${device.displayName} battery is low\"\n\t\tmap.isStateChange = true\n\t} else {\n\t\tmap.value = cmd.batteryLevel\n\t}\n\tstate.lastbatt = now()\n\tcreateEvent(map)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.sensormultilevelv5.SensorMultilevelReport cmd)\n{\n\tdef map = [:]\n\tswitch (cmd.sensorType) {\n\t\tcase 1:\n\t\t\tmap.name = \"temperature\"\n\t\t\tdef cmdScale = cmd.scale == 1 ? \"F\" : \"C\"\n\t\t\tmap.value = convertTemperatureIfNeeded(cmd.scaledSensorValue, cmdScale, cmd.precision)\n\t\t\tmap.unit = getTemperatureScale()\n\t\t\tbreak;\n\t\tcase 3:\n\t\t\tmap.name = \"illuminance\"\n\t\t\tmap.value = cmd.scaledSensorValue.toInteger()\n\t\t\tmap.unit = \"lux\"\n\t\t\tbreak;\n        case 5:\n\t\t\tmap.name = \"humidity\"\n\t\t\tmap.value = cmd.scaledSensorValue.toInteger()\n\t\t\tmap.unit = \"%\"\n\t\t\tbreak;\n\t\tcase 27:\n        \tmap.name = \"ultravioletIndex\"\n            map.value = cmd.scaledSensorValue.toInteger()\n            map.unit = \"\"\n            break;\n\t\tdefault:\n\t\t\tmap.descriptionText = cmd.toString()\n\t}\n\tcreateEvent(map)\n}\n\ndef motionEvent(value) {\n\tdef map = [name: \"motion\"]\n\tif (value) {\n\t\tmap.value = \"active\"\n\t\tmap.descriptionText = \"$device.displayName detected motion\"\n\t} else {\n\t\tmap.value = \"inactive\"\n\t\tmap.descriptionText = \"$device.displayName motion has stopped\"\n\t}\n\tcreateEvent(map)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.sensorbinaryv2.SensorBinaryReport cmd) {\n\tsetConfigured()\n\tmotionEvent(cmd.sensorValue)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicSet cmd) {\n\tmotionEvent(cmd.value)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.notificationv3.NotificationReport cmd) {\n\tdef result = []\n\tif (cmd.notificationType == 7) {\n\t\tswitch (cmd.event) {\n\t\t\tcase 0:\n\t\t\t\tresult << motionEvent(0)\n\t\t\t\tresult << createEvent(name: \"tamper\", value: \"clear\", descriptionText: \"$device.displayName tamper cleared\")\n\t\t\t\tbreak\n\t\t\tcase 3:\n\t\t\t\tresult << createEvent(name: \"tamper\", value: \"detected\", descriptionText: \"$device.displayName was moved\")\n\t\t\t\tbreak\n\t\t\tcase 7:\n\t\t\t\tresult << motionEvent(1)\n\t\t\t\tbreak\n\t\t}\n\t} else {\n\t\tresult << createEvent(descriptionText: cmd.toString(), isStateChange: false)\n\t}\n\tresult\n}\n\ndef zwaveEvent(physicalgraph.zwave.Command cmd) {\n\tcreateEvent(descriptionText: cmd.toString(), isStateChange: false)\n}\n\ndef configure() {\n\t// This sensor joins as a secure device if you double-click the button to include it\n\t//if (device.device.rawDescription =~ /98/ && !state.sec) {\n\t//\tlog.debug \"Multi 6 not sending configure until secure\"\n\t//\treturn []\n\t//}\n\tlog.debug \"--Sending configuration command to Multisensor 6--\"\n    log.debug \"Prefernces settings: PIRsensitivity: $PIRsensitivity, Reporting Interval: $ReportingInterval, Temp offset: $tempoffset, Humidity offset: $humidityoffset, Luminance offset: $luminanceoffset, UV offset: $ultravioletoffset\"\n\t\n\tdef PIRsens = 1\n\tif (PIRsensitivity) {\n\t\tPIRsens=PIRsensitivity.toInteger()\n\t}\n    def MotionRst = 20\n\tif (MotionReset) {\n\t\tMotionRst=MotionReset.toInteger()\n\t}\n\tdef ReportingInt = 300\n\tif (ReportingInterval) {\n\t\tReportingInt=ReportingInterval.toInteger()\n\t}\n\tdef tempoff = 0\n\tif (tempoffset) {\n\t\ttempoff=tempoffset*10\n\t}\n\tdef humidityoff = 0\n\tif (humidityoffset) {\n\t\thumidityoff=humidityoffset\n\t}\n\tdef luminanceoff = 0\n\tif (luminanceoffset) {\n\t\tluminanceoff=luminanceoffset\n\t}\n\tdef ultravioletoff = 0\n\tif (ultravioletoffset) {\n\t\tultravioletoff=ultravioletoffset\n\t}\n    log.debug \"Setting - PIRsens: $PIRsens, ReportingInt: $ReportingInt, Tempoffset: $tempoff, Humidityoff: $humidityoff, Luminanceoff: $luminanceoff, UVoff: $ultravioletoff\"\n\tdef request = [\n\t\t// set wakeup interval to 5 mins\n\t\tzwave.wakeUpV1.wakeUpIntervalSet(seconds:300, nodeid:zwaveHubNodeId),\n\t\t\n\t\t// send temperature, humidity, illuminance, ultraviolet based on reporting interval preference default 5 mins\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x65, size: 4, scaledConfigurationValue: 128|64|32|16),\n\t\t\n\t\t// configure frequency of reporting \n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x6F,size: 4, scaledConfigurationValue: ReportingInt),\n\t\t\n\t\t// send battery every 20 hours\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x66, size: 4, scaledConfigurationValue: 1),\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x70, size: 4, scaledConfigurationValue: 20*60*60),\n\t\t\n        // send no-motion report 20 seconds after motion stops\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x03, size: 2, scaledConfigurationValue: MotionRst),\n\t\t\n\t\t// enable motion sensor and set sensitivity\n        zwave.configurationV1.configurationSet(parameterNumber: 0x04, size: 1, scaledConfigurationValue: PIRsens),\n\t\t\n\t\t// send binary sensor report for motion\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x05, size: 1, scaledConfigurationValue: 2),\n\t\t\n\t\t// Enable the function of touch sensor\n        zwave.configurationV1.configurationSet(parameterNumber: 0x07, size: 1, scaledConfigurationValue: 1),\n\t\t\n\t\t// disable notification-style motion events\n\t\t// zwave.notificationV3.notificationSet(notificationType: 7, notificationStatus: 0),\n\t\t\n        // configure temp offset\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0xC9, size: 1, scaledConfigurationValue: tempoff),\n\t\t\n        // configure humidity offset\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0xCA, size: 1, scaledConfigurationValue: humidityoff),\n\t\t\n        // configure luminance offset\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0xCB, size: 2, scaledConfigurationValue: luminanceoff),\n\t\t\n        // configure ultraviolet offset\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0xCC, size: 1, scaledConfigurationValue: ultravioletoff), \n\t\t\n        zwave.configurationV1.configurationGet(parameterNumber: 0x6F),\n    \tzwave.configurationV1.configurationGet(parameterNumber: 0x03),\n    \tzwave.configurationV1.configurationGet(parameterNumber: 0x04),\n    \tzwave.configurationV1.configurationGet(parameterNumber: 0x28),\n    \tzwave.configurationV1.configurationGet(parameterNumber: 0xC9),\n        zwave.configurationV1.configurationGet(parameterNumber: 0xCA),\n        zwave.configurationV1.configurationGet(parameterNumber: 0xCB),\n        zwave.configurationV1.configurationGet(parameterNumber: 0xCC),\n\n\t\tzwave.batteryV1.batteryGet(),\n\t\tzwave.sensorBinaryV2.sensorBinaryGet(),\n        \n\t\t// Can use the zwaveHubNodeId variable to add the hub to the device's associations:\n\t\tzwave.associationV1.associationSet(groupingIdentifier:2, nodeId:zwaveHubNodeId)\n    ]\n\tcommands(request) + [\"delay 20000\", zwave.wakeUpV1.wakeUpNoMoreInformation().format()]\n}\n\nprivate setConfigured() {\n\tupdateDataValue(\"configured\", \"true\")\n}\n\nprivate isConfigured() {\n\tgetDataValue(\"configured\") == \"true\"\n}\n\nprivate command(physicalgraph.zwave.Command cmd) {\n\tif (state.sec) {\n\t\tzwave.securityV1.securityMessageEncapsulation().encapsulate(cmd).format()\n\t} else {\n\t\tcmd.format()\n\t}\n}\n\nprivate commands(commands, delay=200) {\n\tdelayBetween(commands.collect{ command(it) }, delay)\n}\n"
  },
  {
    "path": "Aeon Multisensor 6/device_type-aeon-multisensor6-v2.0",
    "content": "/*\n * V 2.0 of Multisensor 6 code 9/14/2015\n * Uses some original code from @Duncan Aeon Multisensor 6 code for secure configuration, Copyright 2015 SmartThings, modified for setting\n * preferences around configuration and the reporting of tampering and ultraviolet index, and reconfiguration after pairing.\n * 2.0 brings about the new style look with multiattribute tile for temp and humidity\n * Robert Vandervoort 6/19/2015 - 11/5/2015\n *\n *  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except\n *  in compliance with the License. You may obtain a copy of the License at:\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n *  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed\n *  on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License\n *  for the specific language governing permissions and limitations under the License.\n * \n * INSTRUCTIONS: Pair device to SmartThings by double tapping the inclusion button. Allow it to join with SmartThings device type. After\n * adding, go to device entry in the website, edit it, change type to Aeon Multisensor 6 - RV, open device in SmartThings app, edit\n * edit preferences to your liking but do not save yet, short press action button on sensor one time and the light should go blue, hit save\n * in the app, a couple seconds later the light should go out (you can verify in live logging that it says it woke up and settings were sent\n * over).. Now on device screen, short press the action button one more time and hit secure configure button on the app screen... Your sensor\n * should now follow your polling interval, but will go no lower than 5 minute intervals unless a large enough change happens to warrant it.\n * motion activates immediately and clears after 20 seconds. tamper activates immediately and also clears after 20 seconds. Currently tamper\n * is just used for logging and as an indicator on the screen. If requests for functionality outside of that are required please message me.\n */\n\n metadata {\n\tdefinition (name: \"Aeon Multisensor 6 - RV 2.0\", namespace: \"robertvandervoort\", author: \"Robert Vandervoort\") {\n\t\tcapability \"Motion Sensor\"\n\t\tcapability \"Temperature Measurement\"\n\t\tcapability \"Relative Humidity Measurement\"\n\t\tcapability \"Illuminance Measurement\"\n\t\tcapability \"Ultraviolet Index\" \n\t\tcapability \"Configuration\"\n\t\tcapability \"Sensor\"\n\t\tcapability \"Battery\"\n\t\t\n\t\t// CCs supported - 94, 134, 114, 132, 89, 133, 115, 113, 128, 48, 49, 112, 152, 122\n\t\tattribute \"tamper\", \"enum\", [\"detected\", \"clear\"]\n\t\tfingerprint deviceId: \"0x2101\", inClusters: \"0x5E,0x86,0x72,0x59,0x85,0x73,0x71,0x84,0x80,0x30,0x31,0x70,0xEF,0x5A,0x98,0x7A\"\n\t\t}\n\tsimulator {\n\t\tstatus \"no motion\" : \"command: 9881, payload: 00300300\"\n\t\tstatus \"motion\"    : \"command: 9881, payload: 003003FF\"\n        status \"clear\" : \" command: 9881, payload: 0071050000000007030000\"\n        status \"tamper\" : \"command: 9881, payload: 007105000000FF07030000\"\n        \n        for (int i = 0; i <= 100; i += 20) {\n\t\t\tstatus \"temperature ${i}F\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().sensorMultilevelV2.sensorMultilevelReport(\n                \tscaledSensorValue: i,\n                    precision: 1,\n                    sensorType: 1,\n                    scale: 1\n\t\t\t\t)\n\t\t\t).incomingMessage()\n\t\t}\n\t\tfor (int i = 0; i <= 100; i += 20) {\n\t\t\tstatus \"RH ${i}%\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().sensorMultilevelV2.sensorMultilevelReport(\n                \tscaledSensorValue: i,\n                    sensorType: 5\n            \t)\n\t\t\t).incomingMessage()\n\t\t}\n\t\tfor (int i in [0, 1, 2, 8, 12, 16, 20, 24, 30, 64, 82, 100, 200, 500, 1000]) {\n\t\t\tstatus \"illuminance ${i} lux\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().sensorMultilevelV2.sensorMultilevelReport(\n                scaledSensorValue: i,\n                sensorType: 3\n                )\n\t\t\t).incomingMessage()\n\t\t}\n\t\tfor (int i = 0; i <= 11; i += 1) {\n\t\t\tstatus \"ultravioletultravioletIndex ${i}\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().sensorMultilevelV2.sensorMultilevelReport(\n                scaledSensorValue: i,\n                sensorType: 27\n                )\n\t\t\t).incomingMessage()\n\t\t}\n\t\tfor (int i in [0, 5, 10, 15, 50, 99, 100]) {\n\t\t\tstatus \"battery ${i}%\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().batteryV1.batteryReport(\n                batteryLevel: i\n                )\n\t\t\t).incomingMessage()\n\t\t}\n\t\tstatus \"low battery alert\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().batteryV1.batteryReport(\n            \tbatteryLevel: 255\n            \t)\n\t\t\t).incomingMessage()\n\t\tstatus \"wake up\": \"command: 8407, payload:\"\n\t}\n\ttiles (scale: 2) {\n\t\tmultiAttributeTile(name:\"main\", type:\"generic\", width:6, height:4) {\n\t\t\ttileAttribute(\"device.temperature\", key: \"PRIMARY_CONTROL\") {\n            \tattributeState \"temperature\",label:'${currentValue}°',backgroundColors:[\n                \t[value: 32, color: \"#153591\"],\n                    [value: 44, color: \"#1e9cbb\"],\n                    [value: 59, color: \"#90d2a7\"],\n\t\t\t\t\t[value: 74, color: \"#44b621\"],\n\t\t\t\t\t[value: 84, color: \"#f1d801\"],\n\t\t\t\t\t[value: 92, color: \"#d04e00\"],\n\t\t\t\t\t[value: 98, color: \"#bc2323\"]\n\t\t\t\t]\n            }\n            tileAttribute(\"device.humidity\", key: \"SECONDARY_CONTROL\") {\n                attributeState \"humidity\",label:'RH ${currentValue} %',unit:\"\"\n            }\n\t\t}\n        standardTile(\"motion\",\"device.motion\", width: 2, height: 2) {\n            \tstate \"active\",label:'motion',icon:\"st.motion.motion.active\",backgroundColor:\"#53a7c0\"\n                state \"inactive\",label:'no motion',icon:\"st.motion.motion.inactive\",backgroundColor:\"#ffffff\"\n\t\t\t}\n\t\tvalueTile(\"temperature\",\"device.temperature\", width: 2, height: 2) {\n            \tstate \"temperature\",label:'${currentValue}°',backgroundColors:[\n                \t[value: 32, color: \"#153591\"],\n                    [value: 44, color: \"#1e9cbb\"],\n                    [value: 59, color: \"#90d2a7\"],\n\t\t\t\t\t[value: 74, color: \"#44b621\"],\n\t\t\t\t\t[value: 84, color: \"#f1d801\"],\n\t\t\t\t\t[value: 92, color: \"#d04e00\"],\n\t\t\t\t\t[value: 98, color: \"#bc2323\"]\n\t\t\t\t]\n\t\t\t}\n\t\tvalueTile(\n        \t\"illuminance\",\"device.illuminance\", width: 2, height: 2) {\n            \tstate \"luminosity\",label:'${currentValue} ${unit}', unit:\"lux\", backgroundColors:[\n                \t[value: 0, color: \"#000000\"],\n                    [value: 1, color: \"#060053\"],\n                    [value: 3, color: \"#3E3900\"],\n                    [value: 12, color: \"#8E8400\"],\n\t\t\t\t\t[value: 24, color: \"#C5C08B\"],\n\t\t\t\t\t[value: 36, color: \"#DAD7B6\"],\n\t\t\t\t\t[value: 128, color: \"#F3F2E9\"],\n                    [value: 1000, color: \"#FFFFFF\"]\n\t\t\t\t]\n\t\t\t}\n\t\tvalueTile(\n        \t\"ultravioletIndex\",\"device.ultravioletIndex\", width: 2, height: 2) {\n\t\t\t\tstate \"ultravioletIndex\",label:'${currentValue} UV INDEX',unit:\"\"\n\t\t\t}\n\t\tstandardTile(\n        \t\"tamper\",\"device.tamper\", width: 2, height: 2) {\n\t\t\t\tstate \"tamper\",label:'tamper',icon:\"st.motion.motion.active\",backgroundColor:\"#ff0000\"\n                state \"clear\",label:'clear',icon:\"st.motion.motion.inactive\",backgroundColor:\"#00ff00\"\n\t\t\t}\n\t\tvalueTile(\n\t\t\t\"battery\", \"device.battery\", decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"battery\", label:'${currentValue}% battery', unit:\"\"\n\t\t}\n\t\tstandardTile(\n        \t\"configure\",\"device.configure\", decoration: \"flat\", width: 2, height: 2) {\n\t\t\t\tstate \"configure\", label:'config', action:\"configure\", icon:\"st.secondary.tools\"\n\t\t\t}\n\t\tmain([\n        \t\"main\"\n            ])\n\t\tdetails([\n        \t\"main\",\"illuminance\",\"ultravioletIndex\",\"motion\",\"tamper\",\"battery\",\"configure\"\n            ])\n\t}\n\t\n    preferences {\n\t\tinput \"tempoffset\",\n\t\t\t\"number\",\n\t\t\ttitle: \"Temperature offset\",\n            description: \"negative values reduce the monitored value positive ones add to it\",\n            range: \"-11..11\",\n\t\t\tdefaultValue: 0,\n            required: false,\n            displayDuringSetup: false\n\t\tinput \"humidityoffset\",\n        \t\"number\",\n            title: \"Humidity offset\",\n            description: \"negative values reduce the monitored value positive ones add to it\",\n\t\t\trange: \"-50..50\",\n\t\t\tdefaultValue: 0,\n\t\t\trequired: false,\n            displayDuringSetup: false\n\t\tinput \"luminanceoffset\",\n          \t\"number\",\n            title: \"Luminance offset\",\n            description: \"negative values reduce the monitored value positive ones add to it\",\n            range: \"-1000..1000\",\n\t\t\tdefaultValue: 0,\n            required: false,\n\t        displayDuringSetup: false\n\t\tinput \"ultravioletoffset\",\n          \t\"number\",\n            title: \"Ultraviolet offset\",\n            description: \"negative values reduce the monitored value positive ones add to it\",\n            range: \"-10..10\",\n\t\t\tdefaultValue: 0,\n\t        required: false,\n\t\t\tdisplayDuringSetup: false\n\t\tinput \"PIRsensitivity\",\n\t        \"number\",\n    \t    title: \"PIR motion sensitivity\",\n\t\t\tdescription: \"A value from 0-5, from disabled to high sensitivity\",\n\t\t\trange: \"0..5\",\n\t\t\tdefaultValue: 1,\n\t\t\trequired: true,\n\t\t\tdisplayDuringSetup: true\n\t\tinput \"MotionReset\",\n\t        \"number\",\n    \t    title: \"PIR reset time\",\n\t\t\tdescription: \"Number of seconds to wait to report motion cleared after a motion event if there is no motion detected.\",\n\t\t\tdefaultValue: 20,\n\t\t\trequired: true,\n\t\t\tdisplayDuringSetup: true            \n\t\tinput \"ReportingInterval\",\n        \t\"number\",\n            title: \"Report data interval\",\n            description: \"A value in seconds.\",\n            defaultValue: 300,\n            required: true,\n            displayDuringSetup: true\n\t}\n}\n\ndef updated()\n{\n\tif (state.sec && !isConfigured()) {\n\t\t// in case we miss the SCSR\n\t\tresponse(configure())\n\t}\n}\n\ndef parse(String description)\n{\n\tdef result = null\n\tif (description.startsWith(\"Err 106\")) {\n\t\tstate.sec = 0\n\t\tresult = createEvent( name: \"secureInclusion\", value: \"failed\", isStateChange: true,\n\t\t\tdescriptionText: \"This sensor failed to complete the network security key exchange. If you are unable to control it via SmartThings, you must remove it from your network and add it again.\")\n\t} else if (description != \"updated\") {\n\t\tdef cmd = zwave.parse(description, [0x31: 5, 0x30: 2, 0x84: 1])\n\t\tif (cmd) {\n\t\t\tresult = zwaveEvent(cmd)\n\t\t}\n\t}\n\tlog.debug \"Parsed '${description}' to ${result.inspect()}\"\n\treturn result\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.wakeupv1.WakeUpNotification cmd)\n{\n\tdef result = [createEvent(descriptionText: \"${device.displayName} woke up\", isStateChange: false)]\n\n\tif (!isConfigured()) {\n\t\t// we're still in the process of configuring a newly joined device\n\t\tlog.debug(\"late configure\")\n\t\tresult += response(configure())\n\t} else {\n\t\tresult += response(zwave.wakeUpV1.wakeUpNoMoreInformation())\n\t}\n\tresult\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.securityv1.SecurityMessageEncapsulation cmd) {\n\tdef encapsulatedCommand = cmd.encapsulatedCommand([0x31: 5, 0x30: 2, 0x84: 1])\n\tstate.sec = 1\n\tlog.debug \"encapsulated: ${encapsulatedCommand}\"\n\tif (encapsulatedCommand) {\n\t\tzwaveEvent(encapsulatedCommand)\n\t} else {\n\t\tlog.warn \"Unable to extract encapsulated cmd from $cmd\"\n\t\tcreateEvent(descriptionText: cmd.toString())\n\t}\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.securityv1.SecurityCommandsSupportedReport cmd) {\n\tresponse(configure())\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.configurationv2.ConfigurationReport cmd) {\n    log.debug \"---CONFIGURATION REPORT V2--- ${device.displayName} parameter ${cmd.parameterNumber} with a byte size of ${cmd.size} is set to ${cmd.configurationValue}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.configurationv1.ConfigurationReport cmd) {\n    log.debug \"---CONFIGURATION REPORT V1--- ${device.displayName} parameter ${cmd.parameterNumber} with a byte size of ${cmd.size} is set to ${cmd.configurationValue}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.batteryv1.BatteryReport cmd) {\n\tdef map = [ name: \"battery\", unit: \"%\" ]\n\tif (cmd.batteryLevel == 0xFF) {\n\t\tmap.value = 1\n\t\tmap.descriptionText = \"${device.displayName} battery is low\"\n\t\tmap.isStateChange = true\n\t} else {\n\t\tmap.value = cmd.batteryLevel\n\t}\n\tstate.lastbatt = now()\n\tcreateEvent(map)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.sensormultilevelv5.SensorMultilevelReport cmd)\n{\n\tdef map = [:]\n\tswitch (cmd.sensorType) {\n\t\tcase 1:\n\t\t\tmap.name = \"temperature\"\n\t\t\tdef cmdScale = cmd.scale == 1 ? \"F\" : \"C\"\n\t\t\tmap.value = convertTemperatureIfNeeded(cmd.scaledSensorValue, cmdScale, cmd.precision)\n\t\t\tmap.unit = getTemperatureScale()\n\t\t\tbreak;\n\t\tcase 3:\n\t\t\tmap.name = \"illuminance\"\n\t\t\tmap.value = cmd.scaledSensorValue.toInteger()\n\t\t\tmap.unit = \"lux\"\n\t\t\tbreak;\n        case 5:\n\t\t\tmap.name = \"humidity\"\n\t\t\tmap.value = cmd.scaledSensorValue.toInteger()\n\t\t\tmap.unit = \"%\"\n\t\t\tbreak;\n\t\tcase 27:\n        \tmap.name = \"ultravioletIndex\"\n            map.value = cmd.scaledSensorValue.toInteger()\n            map.unit = \"\"\n            break;\n\t\tdefault:\n\t\t\tmap.descriptionText = cmd.toString()\n\t}\n\tcreateEvent(map)\n}\n\ndef motionEvent(value) {\n\tdef map = [name: \"motion\"]\n\tif (value) {\n\t\tmap.value = \"active\"\n\t\tmap.descriptionText = \"$device.displayName detected motion\"\n\t} else {\n\t\tmap.value = \"inactive\"\n\t\tmap.descriptionText = \"$device.displayName motion has stopped\"\n\t}\n\tcreateEvent(map)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.sensorbinaryv2.SensorBinaryReport cmd) {\n\tsetConfigured()\n\tmotionEvent(cmd.sensorValue)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicSet cmd) {\n\tmotionEvent(cmd.value)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.notificationv3.NotificationReport cmd) {\n\tdef result = []\n\tif (cmd.notificationType == 7) {\n\t\tswitch (cmd.event) {\n\t\t\tcase 0:\n\t\t\t\tresult << motionEvent(0)\n\t\t\t\tresult << createEvent(name: \"tamper\", value: \"clear\", descriptionText: \"$device.displayName tamper cleared\")\n\t\t\t\tbreak\n\t\t\tcase 3:\n\t\t\t\tresult << createEvent(name: \"tamper\", value: \"detected\", descriptionText: \"$device.displayName was moved\")\n\t\t\t\tbreak\n\t\t\tcase 7:\n\t\t\t\tresult << motionEvent(1)\n\t\t\t\tbreak\n\t\t}\n\t} else {\n\t\tresult << createEvent(descriptionText: cmd.toString(), isStateChange: false)\n\t}\n\tresult\n}\n\ndef zwaveEvent(physicalgraph.zwave.Command cmd) {\n\tcreateEvent(descriptionText: cmd.toString(), isStateChange: false)\n}\n\ndef configure() {\n\t// This sensor joins as a secure device if you double-click the button to include it\n\t//if (device.device.rawDescription =~ /98/ && !state.sec) {\n\t//\tlog.debug \"Multi 6 not sending configure until secure\"\n\t//\treturn []\n\t//}\n\tlog.debug \"--Sending configuration command to Multisensor 6--\"\n    log.debug \"Prefernces settings: PIRsensitivity: $PIRsensitivity, Reporting Interval: $ReportingInterval, Temp offset: $tempoffset, Humidity offset: $humidityoffset, Luminance offset: $luminanceoffset, UV offset: $ultravioletoffset\"\n\t\n\tdef PIRsens = 1\n\tif (PIRsensitivity) {\n\t\tPIRsens=PIRsensitivity.toInteger()\n\t}\n    def MotionRst = 20\n\tif (MotionReset) {\n\t\tMotionRst=MotionReset.toInteger()\n\t}\n\tdef ReportingInt = 300\n\tif (ReportingInterval) {\n\t\tReportingInt=ReportingInterval.toInteger()\n\t}\n\tdef tempoff = 0\n\tif (tempoffset) {\n\t\ttempoff=tempoffset*10\n\t}\n\tdef humidityoff = 0\n\tif (humidityoffset) {\n\t\thumidityoff=humidityoffset\n\t}\n\tdef luminanceoff = 0\n\tif (luminanceoffset) {\n\t\tluminanceoff=luminanceoffset\n\t}\n\tdef ultravioletoff = 0\n\tif (ultravioletoffset) {\n\t\tultravioletoff=ultravioletoffset\n\t}\n    log.debug \"Setting - PIRsens: $PIRsens, ReportingInt: $ReportingInt, Tempoffset: $tempoff, Humidityoff: $humidityoff, Luminanceoff: $luminanceoff, UVoff: $ultravioletoff\"\n\tdef request = [\n\t\t// set wakeup interval to 5 mins\n\t\tzwave.wakeUpV1.wakeUpIntervalSet(seconds:300, nodeid:zwaveHubNodeId),\n\t\t\n\t\t// send temperature, humidity, illuminance, ultraviolet based on reporting interval preference default 5 mins\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x65, size: 4, scaledConfigurationValue: 128|64|32|16),\n\t\t\n\t\t// configure frequency of reporting \n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x6F,size: 4, scaledConfigurationValue: ReportingInt),\n\t\t\n\t\t// send battery every 20 hours\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x66, size: 4, scaledConfigurationValue: 1),\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x70, size: 4, scaledConfigurationValue: 20*60*60),\n\t\t\n        // send no-motion report 20 seconds after motion stops\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x03, size: 2, scaledConfigurationValue: MotionRst),\n\t\t\n\t\t// enable motion sensor and set sensitivity\n        zwave.configurationV1.configurationSet(parameterNumber: 0x04, size: 1, scaledConfigurationValue: PIRsens),\n\t\t\n\t\t// send binary sensor report for motion\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x05, size: 1, scaledConfigurationValue: 2),\n\t\t\n\t\t// Enable the function of touch sensor\n        zwave.configurationV1.configurationSet(parameterNumber: 0x07, size: 1, scaledConfigurationValue: 1),\n\t\t\n\t\t// disable notification-style motion events\n\t\t// zwave.notificationV3.notificationSet(notificationType: 7, notificationStatus: 0),\n\t\t\n        // configure temp offset\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0xC9, size: 1, scaledConfigurationValue: tempoff),\n\t\t\n        // configure humidity offset\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0xCA, size: 1, scaledConfigurationValue: humidityoff),\n\t\t\n        // configure luminance offset\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0xCB, size: 2, scaledConfigurationValue: luminanceoff),\n\t\t\n        // configure ultraviolet offset\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0xCC, size: 1, scaledConfigurationValue: ultravioletoff), \n\t\t\n        zwave.configurationV1.configurationGet(parameterNumber: 0x6F),\n    \tzwave.configurationV1.configurationGet(parameterNumber: 0x03),\n    \tzwave.configurationV1.configurationGet(parameterNumber: 0x04),\n    \tzwave.configurationV1.configurationGet(parameterNumber: 0x28),\n    \tzwave.configurationV1.configurationGet(parameterNumber: 0xC9),\n        zwave.configurationV1.configurationGet(parameterNumber: 0xCA),\n        zwave.configurationV1.configurationGet(parameterNumber: 0xCB),\n        zwave.configurationV1.configurationGet(parameterNumber: 0xCC),\n\n\t\tzwave.batteryV1.batteryGet(),\n\t\tzwave.sensorBinaryV2.sensorBinaryGet(),\n        \n\t\t// Can use the zwaveHubNodeId variable to add the hub to the device's associations:\n\t\tzwave.associationV1.associationSet(groupingIdentifier:2, nodeId:zwaveHubNodeId)\n    ]\n\tcommands(request) + [\"delay 20000\", zwave.wakeUpV1.wakeUpNoMoreInformation().format()]\n}\n\nprivate setConfigured() {\n\tupdateDataValue(\"configured\", \"true\")\n}\n\nprivate isConfigured() {\n\tgetDataValue(\"configured\") == \"true\"\n}\n\nprivate command(physicalgraph.zwave.Command cmd) {\n\tif (state.sec) {\n\t\tzwave.securityV1.securityMessageEncapsulation().encapsulate(cmd).format()\n\t} else {\n\t\tcmd.format()\n\t}\n}\n\nprivate commands(commands, delay=200) {\n\tdelayBetween(commands.collect{ command(it) }, delay)\n}\n"
  },
  {
    "path": "Aeon Multisensor 6/device_type-aeon-multisensor6-v2.1",
    "content": "/*\n * V 2.1 of Multisensor 6 code 10/10/2015\n * Uses some original code from @Duncan Aeon Multisensor 6 code for secure configuration, Copyright 2015 SmartThings, modified for setting\n * preferences around configuration and the reporting of tampering and ultraviolet index, and reconfiguration after pairing.\n * 2.0 brings about the new style look with multiattribute tile for temp and humidity and all adjustments working\n * 2.1 provides vibration sensor output to smartthings in the form of the acceleration capability for use in the home security section. You can create push notifications, SMS, and trigger\ncameras and the like if you sensor is tampered with or it detects a significant enough vibration, like a door slamming close by.\n\n * Robert Vandervoort 6/19/2015 - 11/10/2015\n *\n *  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except\n *  in compliance with the License. You may obtain a copy of the License at:\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n *  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed\n *  on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License\n *  for the specific language governing permissions and limitations under the License.\n * \n---------------------------------------------------------------------------------------------------------------------------\n   INSTRUCTIONS: \n\n*- Log in to the IDE and add my device type \"from code\" copy pasting the raw code from github and save it\n*- Open the live logging view in a new tab\n*- With the sensor plugged in via usb, note the light color. It should cycle through many different colors continually.\nIf it does not, it was previously joined. The sensor may come this way from wherever you ordered it. To reset, perform the following:\nHold the action button for about 25 seconds until the light blinks red quickly and then the colors cycle. It is now reset.\n*- Put smart things into inclusion mode by doing the add device procedure on the app.\n*- Quickly double tap the action button. The light on the sensor should blink blue several times quickly. Please read the rest before continuing!\n*- Before you do anything else and when you see the device smartthings found on the screen, go to your devices in the IDE, select the newly added sensor and edit it.\nChange the device type to my device type and save it.\n*- Back on your app, click the device on the screen to add it. Walk through the next few steps setting preferences and smart app stuff if you like.\nAfter you save the preferences the device should update and send the configuration. You can see this on the live logging view in the debug comments.\nIt may help to select just the newly added sensor from the available items to see past the other noise in the view. When in doubt, hit the configure tile and watch..\n*- That's it. \n */\n\n metadata {\n\tdefinition (name: \"Aeon Multisensor 6 - RV 2.1\", namespace: \"robertvandervoort\", author: \"Robert Vandervoort\") {\n\t\tcapability \"Motion Sensor\"\n\t\tcapability \"Acceleration Sensor\"\n\t\tcapability \"Temperature Measurement\"\n\t\tcapability \"Relative Humidity Measurement\"\n\t\tcapability \"Illuminance Measurement\"\n\t\tcapability \"Ultraviolet Index\" \n\t\tcapability \"Configuration\"\n\t\tcapability \"Sensor\"\n\t\tcapability \"Battery\"\n\t\t\n\t\t// CCs supported - 94, 134, 114, 132, 89, 133, 115, 113, 128, 48, 49, 112, 152, 122\n\t\tattribute \"tamper\", \"enum\", [\"detected\", \"clear\"]\n\t\tfingerprint deviceId: \"0x2101\", inClusters: \"0x5E,0x86,0x72,0x59,0x85,0x73,0x71,0x84,0x80,0x30,0x31,0x70,0xEF,0x5A,0x98,0x7A\"\n\t\t}\n\tsimulator {\n\t\tstatus \"no motion\" : \"command: 9881, payload: 00300300\"\n\t\tstatus \"motion\"    : \"command: 9881, payload: 003003FF\"\n        status \"clear\" : \" command: 9881, payload: 0071050000000007030000\"\n        status \"tamper\" : \"command: 9881, payload: 007105000000FF07030000\"\n        \n        for (int i = 0; i <= 100; i += 20) {\n\t\t\tstatus \"temperature ${i}F\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().sensorMultilevelV2.sensorMultilevelReport(\n                \tscaledSensorValue: i,\n                    precision: 1,\n                    sensorType: 1,\n                    scale: 1\n\t\t\t\t)\n\t\t\t).incomingMessage()\n\t\t}\n\t\tfor (int i = 0; i <= 100; i += 20) {\n\t\t\tstatus \"RH ${i}%\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().sensorMultilevelV2.sensorMultilevelReport(\n                \tscaledSensorValue: i,\n                    sensorType: 5\n            \t)\n\t\t\t).incomingMessage()\n\t\t}\n\t\tfor (int i in [0, 1, 2, 8, 12, 16, 20, 24, 30, 64, 82, 100, 200, 500, 1000]) {\n\t\t\tstatus \"illuminance ${i} lux\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().sensorMultilevelV2.sensorMultilevelReport(\n                scaledSensorValue: i,\n                sensorType: 3\n                )\n\t\t\t).incomingMessage()\n\t\t}\n\t\tfor (int i = 0; i <= 11; i += 1) {\n\t\t\tstatus \"ultravioletultravioletIndex ${i}\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().sensorMultilevelV2.sensorMultilevelReport(\n                scaledSensorValue: i,\n                sensorType: 27\n                )\n\t\t\t).incomingMessage()\n\t\t}\n\t\tfor (int i in [0, 5, 10, 15, 50, 99, 100]) {\n\t\t\tstatus \"battery ${i}%\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().batteryV1.batteryReport(\n                batteryLevel: i\n                )\n\t\t\t).incomingMessage()\n\t\t}\n\t\tstatus \"low battery alert\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().batteryV1.batteryReport(\n            \tbatteryLevel: 255\n            \t)\n\t\t\t).incomingMessage()\n\t\tstatus \"wake up\": \"command: 8407, payload:\"\n\t}\n\ttiles (scale: 2) {\n\t\tmultiAttributeTile(name:\"main\", type:\"generic\", width:6, height:4) {\n\t\t\ttileAttribute(\"device.temperature\", key: \"PRIMARY_CONTROL\") {\n            \tattributeState \"temperature\",label:'${currentValue}°',backgroundColors:[\n                \t[value: 32, color: \"#153591\"],\n                    [value: 44, color: \"#1e9cbb\"],\n                    [value: 59, color: \"#90d2a7\"],\n\t\t\t\t\t[value: 74, color: \"#44b621\"],\n\t\t\t\t\t[value: 84, color: \"#f1d801\"],\n\t\t\t\t\t[value: 92, color: \"#d04e00\"],\n\t\t\t\t\t[value: 98, color: \"#bc2323\"]\n\t\t\t\t]\n            }\n            tileAttribute(\"device.humidity\", key: \"SECONDARY_CONTROL\") {\n                attributeState \"humidity\",label:'RH ${currentValue} %',unit:\"\"\n            }\n\t\t}\n        standardTile(\"motion\",\"device.motion\", width: 2, height: 2) {\n            \tstate \"active\",label:'motion',icon:\"st.motion.motion.active\",backgroundColor:\"#53a7c0\"\n                state \"inactive\",label:'no motion',icon:\"st.motion.motion.inactive\",backgroundColor:\"#ffffff\"\n\t\t\t}\n\t\tvalueTile(\"humidity\",\"device.humidity\", width: 2, height: 2) {\n           \tstate \"humidity\",label:'RH ${currentValue} %',unit:\"\"\n\t\t\t}\n\t\tvalueTile(\"illuminance\",\"device.illuminance\", width: 2, height: 2) {\n            \tstate \"luminosity\",label:'${currentValue} ${unit}', unit:\"lux\", backgroundColors:[\n                \t[value: 0, color: \"#000000\"],\n                    [value: 1, color: \"#060053\"],\n                    [value: 3, color: \"#3E3900\"],\n                    [value: 12, color: \"#8E8400\"],\n\t\t\t\t\t[value: 24, color: \"#C5C08B\"],\n\t\t\t\t\t[value: 36, color: \"#DAD7B6\"],\n\t\t\t\t\t[value: 128, color: \"#F3F2E9\"],\n                    [value: 1000, color: \"#FFFFFF\"]\n\t\t\t\t]\n\t\t\t}\n\t\tvalueTile(\"ultravioletIndex\",\"device.ultravioletIndex\", width: 2, height: 2) {\n\t\t\t\tstate \"ultravioletIndex\",label:'${currentValue} UV INDEX',unit:\"\"\n\t\t\t}\n\t\tstandardTile(\"acceleration\", \"device.acceleration\", width: 2, height: 2) {\n\t\t\tstate(\"active\", label:'tamper', icon:\"st.motion.acceleration.active\", backgroundColor:\"#ff0000\")\n\t\t\tstate(\"inactive\", label:'clear', icon:\"st.motion.acceleration.inactive\", backgroundColor:\"#00ff00\")\n\t\t}\n\t\tvalueTile(\"battery\", \"device.battery\", decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"battery\", label:'${currentValue}% battery', unit:\"\"\n\t\t}\n\t\tstandardTile(\"configure\",\"device.configure\", decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"configure\", label:'config', action:\"configure\", icon:\"st.secondary.tools\"\n\t\t}\n\t\tmain([\"main\"])\n\t\tdetails([\"main\",\"humidity\",\"illuminance\",\"ultravioletIndex\",\"motion\",\"acceleration\",\"battery\",\"configure\"])\n\t}\n\t\n    preferences {\n\t\tinput \"tempoffset\",\n\t\t\t\"number\",\n\t\t\ttitle: \"Temperature offset\",\n            description: \"negative values reduce the monitored value positive ones add to it\",\n            range: \"-11..11\",\n\t\t\tdefaultValue: 0,\n            required: false,\n            displayDuringSetup: false\n\t\tinput \"humidityoffset\",\n        \t\"number\",\n            title: \"Humidity offset\",\n            description: \"negative values reduce the monitored value positive ones add to it\",\n\t\t\trange: \"-50..50\",\n\t\t\tdefaultValue: 0,\n\t\t\trequired: false,\n            displayDuringSetup: false\n\t\tinput \"luminanceoffset\",\n          \t\"number\",\n            title: \"Luminance offset\",\n            description: \"negative values reduce the monitored value positive ones add to it\",\n            range: \"-1000..1000\",\n\t\t\tdefaultValue: 0,\n            required: false,\n\t        displayDuringSetup: false\n\t\tinput \"ultravioletoffset\",\n          \t\"number\",\n            title: \"Ultraviolet offset\",\n            description: \"negative values reduce the monitored value positive ones add to it\",\n            range: \"-10..10\",\n\t\t\tdefaultValue: 0,\n\t        required: false,\n\t\t\tdisplayDuringSetup: false\n\t\tinput \"PIRsensitivity\",\n\t        \"number\",\n    \t    title: \"PIR motion sensitivity\",\n\t\t\tdescription: \"A value from 0-5, from disabled to high sensitivity\",\n\t\t\trange: \"0..5\",\n\t\t\tdefaultValue: 1,\n\t\t\trequired: true,\n\t\t\tdisplayDuringSetup: true\n\t\tinput \"MotionReset\",\n\t        \"number\",\n    \t    title: \"PIR reset time\",\n\t\t\tdescription: \"Number of seconds to wait to report motion cleared after a motion event if there is no motion detected.\",\n\t\t\tdefaultValue: 20,\n\t\t\trequired: true,\n\t\t\tdisplayDuringSetup: true            \n\t\tinput \"ReportingInterval\",\n        \t\"number\",\n            title: \"Report data interval\",\n            description: \"A value in seconds.\",\n            defaultValue: 300,\n            required: true,\n            displayDuringSetup: true\n\t}\n}\n\ndef updated()\n{\n\tif (state.sec && !isConfigured()) {\n\t\t// in case we miss the SCSR\n\t\tresponse(configure())\n\t}\n}\n\ndef parse(String description)\n{\n\tdef result = null\n\tif (description.startsWith(\"Err 106\")) {\n\t\tstate.sec = 0\n\t\tresult = createEvent( name: \"secureInclusion\", value: \"failed\", isStateChange: true,\n\t\t\tdescriptionText: \"This sensor failed to complete the network security key exchange. If you are unable to control it via SmartThings, you must remove it from your network and add it again.\")\n\t} else if (description != \"updated\") {\n\t\tdef cmd = zwave.parse(description, [0x31: 5, 0x30: 2, 0x84: 1])\n\t\tif (cmd) {\n\t\t\tresult = zwaveEvent(cmd)\n\t\t}\n\t}\n\tlog.debug \"Parsed '${description}' to ${result.inspect()}\"\n\treturn result\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.wakeupv1.WakeUpNotification cmd)\n{\n\tdef result = [createEvent(descriptionText: \"${device.displayName} woke up\", isStateChange: false)]\n\n\tif (!isConfigured()) {\n\t\t// we're still in the process of configuring a newly joined device\n\t\tlog.debug(\"late configure\")\n\t\tresult += response(configure())\n\t} else {\n\t\tresult += response(zwave.wakeUpV1.wakeUpNoMoreInformation())\n\t}\n\tresult\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.securityv1.SecurityMessageEncapsulation cmd) {\n\tdef encapsulatedCommand = cmd.encapsulatedCommand([0x31: 5, 0x30: 2, 0x84: 1])\n\tstate.sec = 1\n\tlog.debug \"encapsulated: ${encapsulatedCommand}\"\n\tif (encapsulatedCommand) {\n\t\tzwaveEvent(encapsulatedCommand)\n\t} else {\n\t\tlog.warn \"Unable to extract encapsulated cmd from $cmd\"\n\t\tcreateEvent(descriptionText: cmd.toString())\n\t}\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.securityv1.SecurityCommandsSupportedReport cmd) {\n\tresponse(configure())\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.configurationv2.ConfigurationReport cmd) {\n    log.debug \"---CONFIGURATION REPORT V2--- ${device.displayName} parameter ${cmd.parameterNumber} with a byte size of ${cmd.size} is set to ${cmd.configurationValue}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.configurationv1.ConfigurationReport cmd) {\n    log.debug \"---CONFIGURATION REPORT V1--- ${device.displayName} parameter ${cmd.parameterNumber} with a byte size of ${cmd.size} is set to ${cmd.configurationValue}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.batteryv1.BatteryReport cmd) {\n\tdef map = [ name: \"battery\", unit: \"%\" ]\n\tif (cmd.batteryLevel == 0xFF) {\n\t\tmap.value = 1\n\t\tmap.descriptionText = \"${device.displayName} battery is low\"\n\t\tmap.isStateChange = true\n\t} else {\n\t\tmap.value = cmd.batteryLevel\n\t}\n\tstate.lastbatt = now()\n\tcreateEvent(map)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.sensormultilevelv5.SensorMultilevelReport cmd)\n{\n\tdef map = [:]\n\tswitch (cmd.sensorType) {\n\t\tcase 1:\n\t\t\tmap.name = \"temperature\"\n\t\t\tdef cmdScale = cmd.scale == 1 ? \"F\" : \"C\"\n\t\t\tmap.value = convertTemperatureIfNeeded(cmd.scaledSensorValue, cmdScale, cmd.precision)\n\t\t\tmap.unit = getTemperatureScale()\n\t\t\tbreak;\n\t\tcase 3:\n\t\t\tmap.name = \"illuminance\"\n\t\t\tmap.value = cmd.scaledSensorValue.toInteger()\n\t\t\tmap.unit = \"lux\"\n\t\t\tbreak;\n        case 5:\n\t\t\tmap.name = \"humidity\"\n\t\t\tmap.value = cmd.scaledSensorValue.toInteger()\n\t\t\tmap.unit = \"%\"\n\t\t\tbreak;\n\t\tcase 27:\n        \tmap.name = \"ultravioletIndex\"\n            map.value = cmd.scaledSensorValue.toInteger()\n            map.unit = \"\"\n            break;\n\t\tdefault:\n\t\t\tmap.descriptionText = cmd.toString()\n\t}\n\tcreateEvent(map)\n}\n\ndef motionEvent(value) {\n\tdef map = [name: \"motion\"]\n\tif (value) {\n\t\tmap.value = \"active\"\n\t\tmap.descriptionText = \"$device.displayName detected motion\"\n\t} else {\n\t\tmap.value = \"inactive\"\n\t\tmap.descriptionText = \"$device.displayName motion has stopped\"\n\t}\n\tcreateEvent(map)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.sensorbinaryv2.SensorBinaryReport cmd) {\n\tsetConfigured()\n\tmotionEvent(cmd.sensorValue)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicSet cmd) {\n\tmotionEvent(cmd.value)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.notificationv3.NotificationReport cmd) {\n\tdef result = []\n\tif (cmd.notificationType == 7) {\n\t\tswitch (cmd.event) {\n\t\t\tcase 0:\n\t\t\t\tresult << motionEvent(0)\n\t\t\t\tresult << createEvent(name: \"acceleration\", value: \"inactive\", descriptionText: \"$device.displayName tamper cleared\")\n\t\t\t\tbreak\n\t\t\tcase 3:\n\t\t\t\tresult << createEvent(name: \"acceleration\", value: \"active\", descriptionText: \"$device.displayName was moved\")\n\t\t\t\tbreak\n\t\t\tcase 7:\n\t\t\t\tresult << motionEvent(1)\n\t\t\t\tbreak\n\t\t}\n\t} else {\n\t\tresult << createEvent(descriptionText: cmd.toString(), isStateChange: false)\n\t}\n\tresult\n}\n\ndef zwaveEvent(physicalgraph.zwave.Command cmd) {\n\tcreateEvent(descriptionText: cmd.toString(), isStateChange: false)\n}\n\ndef configure() {\n\t// This sensor joins as a secure device if you double-click the button to include it\n\t//if (device.device.rawDescription =~ /98/ && !state.sec) {\n\t//\tlog.debug \"Multi 6 not sending configure until secure\"\n\t//\treturn []\n\t//}\n\tlog.debug \"--Sending configuration command to Multisensor 6--\"\n    log.debug \"Prefernces settings: PIRsensitivity: $PIRsensitivity, Reporting Interval: $ReportingInterval, Temp offset: $tempoffset, Humidity offset: $humidityoffset, Luminance offset: $luminanceoffset, UV offset: $ultravioletoffset\"\n\t\n\tdef PIRsens = 1\n\tif (PIRsensitivity) {\n\t\tPIRsens=PIRsensitivity.toInteger()\n\t}\n    def MotionRst = 20\n\tif (MotionReset) {\n\t\tMotionRst=MotionReset.toInteger()\n\t}\n\tdef ReportingInt = 300\n\tif (ReportingInterval) {\n\t\tReportingInt=ReportingInterval.toInteger()\n\t}\n\tdef tempoff = 0\n\tif (tempoffset) {\n\t\ttempoff=tempoffset*10\n\t}\n\tdef humidityoff = 0\n\tif (humidityoffset) {\n\t\thumidityoff=humidityoffset\n\t}\n\tdef luminanceoff = 0\n\tif (luminanceoffset) {\n\t\tluminanceoff=luminanceoffset\n\t}\n\tdef ultravioletoff = 0\n\tif (ultravioletoffset) {\n\t\tultravioletoff=ultravioletoffset\n\t}\n    log.debug \"Setting - PIRsens: $PIRsens, ReportingInt: $ReportingInt, Tempoffset: $tempoff, Humidityoff: $humidityoff, Luminanceoff: $luminanceoff, UVoff: $ultravioletoff\"\n\tdef request = [\n\t\t// set wakeup interval to 5 mins\n\t\tzwave.wakeUpV1.wakeUpIntervalSet(seconds:300, nodeid:zwaveHubNodeId),\n\t\t\n\t\t// send temperature, humidity, illuminance, ultraviolet based on reporting interval preference default 5 mins\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x65, size: 4, scaledConfigurationValue: 128|64|32|16),\n\t\t\n\t\t// configure frequency of reporting \n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x6F,size: 4, scaledConfigurationValue: ReportingInt),\n\t\t\n\t\t// send battery every 20 hours\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x66, size: 4, scaledConfigurationValue: 1),\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x70, size: 4, scaledConfigurationValue: 20*60*60),\n\t\t\n        // send no-motion report 20 seconds after motion stops\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x03, size: 2, scaledConfigurationValue: MotionRst),\n\t\t\n\t\t// enable motion sensor and set sensitivity\n        zwave.configurationV1.configurationSet(parameterNumber: 0x04, size: 1, scaledConfigurationValue: PIRsens),\n\t\t\n\t\t// send binary sensor report for motion\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x05, size: 1, scaledConfigurationValue: 2),\n\t\t\n\t\t// Enable the function of touch sensor\n        zwave.configurationV1.configurationSet(parameterNumber: 0x07, size: 1, scaledConfigurationValue: 1),\n\t\t\n\t\t// disable notification-style motion events\n\t\t// zwave.notificationV3.notificationSet(notificationType: 7, notificationStatus: 0),\n\t\t\n        // configure temp offset\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0xC9, size: 1, scaledConfigurationValue: tempoff),\n\t\t\n        // configure humidity offset\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0xCA, size: 1, scaledConfigurationValue: humidityoff),\n\t\t\n        // configure luminance offset\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0xCB, size: 2, scaledConfigurationValue: luminanceoff),\n\t\t\n        // configure ultraviolet offset\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0xCC, size: 1, scaledConfigurationValue: ultravioletoff), \n\t\t\n        zwave.configurationV1.configurationGet(parameterNumber: 0x6F),\n    \tzwave.configurationV1.configurationGet(parameterNumber: 0x03),\n    \tzwave.configurationV1.configurationGet(parameterNumber: 0x04),\n    \tzwave.configurationV1.configurationGet(parameterNumber: 0x28),\n    \tzwave.configurationV1.configurationGet(parameterNumber: 0xC9),\n        zwave.configurationV1.configurationGet(parameterNumber: 0xCA),\n        zwave.configurationV1.configurationGet(parameterNumber: 0xCB),\n        zwave.configurationV1.configurationGet(parameterNumber: 0xCC),\n\n\t\tzwave.batteryV1.batteryGet(),\n\t\tzwave.sensorBinaryV2.sensorBinaryGet(),\n        \n\t\t// Can use the zwaveHubNodeId variable to add the hub to the device's associations:\n\t\tzwave.associationV1.associationSet(groupingIdentifier:2, nodeId:zwaveHubNodeId)\n    ]\n\tcommands(request) + [\"delay 20000\", zwave.wakeUpV1.wakeUpNoMoreInformation().format()]\n}\n\nprivate setConfigured() {\n\tupdateDataValue(\"configured\", \"true\")\n}\n\nprivate isConfigured() {\n\tgetDataValue(\"configured\") == \"true\"\n}\n\nprivate command(physicalgraph.zwave.Command cmd) {\n\tif (state.sec) {\n\t\tzwave.securityV1.securityMessageEncapsulation().encapsulate(cmd).format()\n\t} else {\n\t\tcmd.format()\n\t}\n}\n\nprivate commands(commands, delay=1000) {\n\tdelayBetween(commands.collect{ command(it) }, delay)\n}\n"
  },
  {
    "path": "Aeon Multisensor 6/device_type-aeon-multisensor6-v2.2",
    "content": "/*\n * V 2.2 of Multisensor 6 code 10/10/2015\n * Uses some original code from @Duncan Aeon Multisensor 6 code for secure configuration, Copyright 2015 SmartThings, modified for setting\n * preferences around configuration and the reporting of tampering and ultraviolet index, and reconfiguration after pairing.\n * 2.0 brings about the new style look with multiattribute tile for temp and humidity and all adjustments working\n * 2.1 provides vibration sensor output to smartthings in the form of the acceleration capability for use in the home security section. You can create push notifications, SMS, and trigger\ncameras and the like if you sensor is tampered with or it detects a significant enough vibration, like a door slamming close by.\n\n * Robert Vandervoort 6/19/2015 - 11/10/2015\n *\n *  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except\n *  in compliance with the License. You may obtain a copy of the License at:\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n *  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed\n *  on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License\n *  for the specific language governing permissions and limitations under the License.\n * \n---------------------------------------------------------------------------------------------------------------------------\n   INSTRUCTIONS: \n\n*- Log in to the IDE and add my device type \"from code\" copy pasting the raw code from github and save it\n*- Open the live logging view in a new tab\n*- With the sensor plugged in via usb, note the light color. It should cycle through many different colors continually.\nIf it does not, it was previously joined. The sensor may come this way from wherever you ordered it. To reset, perform the following:\nHold the action button for about 25 seconds until the light blinks red quickly and then the colors cycle. It is now reset.\n*- Put smart things into inclusion mode by doing the add device procedure on the app.\n*- Quickly double tap the action button. The light on the sensor should blink blue several times quickly. Please read the rest before continuing!\n*- Before you do anything else and when you see the device smartthings found on the screen, go to your devices in the IDE, select the newly added sensor and edit it.\nChange the device type to my device type and save it.\n*- Back on your app, click the device on the screen to add it. Walk through the next few steps setting preferences and smart app stuff if you like.\nAfter you save the preferences the device should update and send the configuration. You can see this on the live logging view in the debug comments.\nIt may help to select just the newly added sensor from the available items to see past the other noise in the view. When in doubt, hit the configure tile and watch..\n*- That's it. \n */\n\n metadata {\n\tdefinition (name: \"Aeon Multisensor 6 - RV 2.2\", namespace: \"robertvandervoort\", author: \"Robert Vandervoort\") {\n\t\tcapability \"Motion Sensor\"\n\t\tcapability \"Acceleration Sensor\"\n\t\tcapability \"Temperature Measurement\"\n\t\tcapability \"Relative Humidity Measurement\"\n\t\tcapability \"Illuminance Measurement\"\n\t\tcapability \"Ultraviolet Index\" \n\t\tcapability \"Configuration\"\n\t\tcapability \"Sensor\"\n\t\tcapability \"Battery\"\n\t\t\n\t\t// CCs supported - 94, 134, 114, 132, 89, 133, 115, 113, 128, 48, 49, 112, 152, 122\n\t\tattribute \"tamper\", \"enum\", [\"detected\", \"clear\"]\n\t\tfingerprint deviceId: \"0x2101\", inClusters: \"0x5E,0x86,0x72,0x59,0x85,0x73,0x71,0x84,0x80,0x30,0x31,0x70,0xEF,0x5A,0x98,0x7A\"\n\t\t}\n\tsimulator {\n\t\tstatus \"no motion\" : \"command: 9881, payload: 00300300\"\n\t\tstatus \"motion\"    : \"command: 9881, payload: 003003FF\"\n        status \"clear\" : \" command: 9881, payload: 0071050000000007030000\"\n        status \"tamper\" : \"command: 9881, payload: 007105000000FF07030000\"\n        \n        for (int i = 0; i <= 100; i += 20) {\n\t\t\tstatus \"temperature ${i}F\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().sensorMultilevelV2.sensorMultilevelReport(\n                \tscaledSensorValue: i,\n                    precision: 1,\n                    sensorType: 1,\n                    scale: 1\n\t\t\t\t)\n\t\t\t).incomingMessage()\n\t\t}\n\t\tfor (int i = 0; i <= 100; i += 20) {\n\t\t\tstatus \"RH ${i}%\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().sensorMultilevelV2.sensorMultilevelReport(\n                \tscaledSensorValue: i,\n                    sensorType: 5\n            \t)\n\t\t\t).incomingMessage()\n\t\t}\n\t\tfor (int i in [0, 1, 2, 8, 12, 16, 20, 24, 30, 64, 82, 100, 200, 500, 1000]) {\n\t\t\tstatus \"illuminance ${i} lux\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().sensorMultilevelV2.sensorMultilevelReport(\n                scaledSensorValue: i,\n                sensorType: 3\n                )\n\t\t\t).incomingMessage()\n\t\t}\n\t\tfor (int i = 0; i <= 11; i += 1) {\n\t\t\tstatus \"ultravioletultravioletIndex ${i}\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().sensorMultilevelV2.sensorMultilevelReport(\n                scaledSensorValue: i,\n                sensorType: 27\n                )\n\t\t\t).incomingMessage()\n\t\t}\n\t\tfor (int i in [0, 5, 10, 15, 50, 99, 100]) {\n\t\t\tstatus \"battery ${i}%\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().batteryV1.batteryReport(\n                batteryLevel: i\n                )\n\t\t\t).incomingMessage()\n\t\t}\n\t\tstatus \"low battery alert\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().batteryV1.batteryReport(\n            \tbatteryLevel: 255\n            \t)\n\t\t\t).incomingMessage()\n\t\tstatus \"wake up\": \"command: 8407, payload:\"\n\t}\n\ttiles (scale: 2) {\n\t\tmultiAttributeTile(name:\"main\", type:\"generic\", width:6, height:4) {\n\t\t\ttileAttribute(\"device.temperature\", key: \"PRIMARY_CONTROL\") {\n            \tattributeState \"temperature\",label:'${currentValue}°',backgroundColors:[\n                \t[value: 32, color: \"#153591\"],\n                    [value: 44, color: \"#1e9cbb\"],\n                    [value: 59, color: \"#90d2a7\"],\n\t\t\t\t\t[value: 74, color: \"#44b621\"],\n\t\t\t\t\t[value: 84, color: \"#f1d801\"],\n\t\t\t\t\t[value: 92, color: \"#d04e00\"],\n\t\t\t\t\t[value: 98, color: \"#bc2323\"]\n\t\t\t\t]       \n            }\n            tileAttribute(\"device.humidity\", key: \"SECONDARY_CONTROL\") {\n                attributeState \"humidity\",label:'RH ${currentValue}%',icon:\" \"\n            }\n\t\t}\n        standardTile(\"motion\",\"device.motion\", width: 2, height: 2) {\n            \tstate \"active\",label:'motion',icon:\"st.motion.motion.active\",backgroundColor:\"#53a7c0\"\n                state \"inactive\",label:'no motion',icon:\"st.motion.motion.inactive\",backgroundColor:\"#ffffff\"\n\t\t\t}\n\t\tvalueTile(\"humidity\",\"device.humidity\", width: 2, height: 2) {\n           \tstate \"humidity\",label:'RH ${currentValue}%',unit:\"${unit}\"\n\t\t\t}\n\t\tvalueTile(\"illuminance\",\"device.illuminance\", width: 2, height: 2) {\n            \tstate \"luminosity\",label:'${currentValue}', unit:\"${unit}\", backgroundColors:[\n                \t[value: 0, color: \"#000000\"],\n                    [value: 1, color: \"#060053\"],\n                    [value: 3, color: \"#3E3900\"],\n                    [value: 12, color: \"#8E8400\"],\n\t\t\t\t\t[value: 24, color: \"#C5C08B\"],\n\t\t\t\t\t[value: 36, color: \"#DAD7B6\"],\n\t\t\t\t\t[value: 128, color: \"#F3F2E9\"],\n                    [value: 1000, color: \"#FFFFFF\"]\n\t\t\t\t]\n\t\t\t}\n\t\tvalueTile(\"ultravioletIndex\",\"device.ultravioletIndex\", width: 2, height: 2) {\n\t\t\t\tstate \"ultravioletIndex\",label:'${currentValue} UV INDEX',unit:\"\"\n\t\t\t}\n\t\tstandardTile(\"acceleration\", \"device.acceleration\", width: 2, height: 2) {\n\t\t\tstate(\"active\", label:'tamper', icon:\"st.motion.acceleration.active\", backgroundColor:\"#ff0000\")\n\t\t\tstate(\"inactive\", label:'clear', icon:\"st.motion.acceleration.inactive\", backgroundColor:\"#00ff00\")\n\t\t}\n\t\tvalueTile(\"battery\", \"device.battery\", decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"battery\", label:'${currentValue}% battery', unit:\"\"\n\t\t}\n\t\tstandardTile(\"configure\",\"device.configure\", decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"configure\", label:'config', action:\"configure\", icon:\"st.secondary.tools\"\n\t\t}\n\t\tmain([\"main\"])\n\t\tdetails([\"main\",\"humidity\",\"illuminance\",\"ultravioletIndex\",\"motion\",\"acceleration\",\"battery\",\"configure\"])\n\t}\n\t\n    preferences {\n\t\tinput \"debugOutput\", \"boolean\", \n\t\t\ttitle: \"Enable debug logging?\",\n\t\t\tdefaultValue: false,\n\t\t\tdisplayDuringSetup: true\n\t\tinput \"tempoffset\",\n\t\t\t\"number\",\n\t\t\ttitle: \"Temperature offset\",\n            description: \"negative values reduce the monitored value positive ones add to it\",\n            range: \"-11..11\",\n\t\t\tdefaultValue: 0,\n            required: false,\n            displayDuringSetup: false\n\t\tinput \"humidityoffset\",\n        \t\"number\",\n            title: \"Humidity offset\",\n            description: \"negative values reduce the monitored value positive ones add to it\",\n\t\t\trange: \"-50..50\",\n\t\t\tdefaultValue: 0,\n\t\t\trequired: false,\n            displayDuringSetup: false\n\t\tinput \"luminanceoffset\",\n          \t\"number\",\n            title: \"Luminance offset\",\n            description: \"negative values reduce the monitored value positive ones add to it\",\n            range: \"-1000..1000\",\n\t\t\tdefaultValue: 0,\n            required: false,\n\t        displayDuringSetup: false\n\t\tinput \"ultravioletoffset\",\n          \t\"number\",\n            title: \"Ultraviolet offset\",\n            description: \"negative values reduce the monitored value positive ones add to it\",\n            range: \"-10..10\",\n\t\t\tdefaultValue: 0,\n\t        required: false,\n\t\t\tdisplayDuringSetup: false\n\t\tinput \"PIRsensitivity\",\n\t        \"number\",\n    \t    title: \"PIR motion sensitivity\",\n\t\t\tdescription: \"A value from 0-5, from disabled to high sensitivity\",\n\t\t\trange: \"0..5\",\n\t\t\tdefaultValue: 1,\n\t\t\trequired: true,\n\t\t\tdisplayDuringSetup: true\n\t\tinput \"MotionReset\",\n\t        \"number\",\n    \t    title: \"PIR reset time\",\n\t\t\tdescription: \"Number of seconds to wait to report motion cleared after a motion event if there is no motion detected.\",\n\t\t\tdefaultValue: 20,\n\t\t\trequired: true,\n\t\t\tdisplayDuringSetup: true            \n\t\tinput \"ReportingInterval\",\n        \t\"number\",\n            title: \"Report data interval\",\n            description: \"A value in seconds.\",\n            defaultValue: 300,\n            required: true,\n            displayDuringSetup: true\n\t}\n}\n\ndef updated()\n{\n\tstate.debug = (\"true\" == debugOutput)\n\tif (state.sec && !isConfigured()) {\n\t\t// in case we miss the SCSR\n\t\tresponse(configure())\n\t}\n}\n\ndef parse(String description)\n{\n\tdef result = null\n\tif (description.startsWith(\"Err 106\")) {\n\t\tstate.sec = 0\n\t\tresult = createEvent( name: \"secureInclusion\", value: \"failed\", isStateChange: true,\n\t\t\tdescriptionText: \"This sensor failed to complete the network security key exchange. If you are unable to control it via SmartThings, you must remove it from your network and add it again.\")\n\t} else if (description != \"updated\") {\n\t\tdef cmd = zwave.parse(description, [0x31: 5, 0x30: 2, 0x7A: 2, 0x84: 1, 0x86: 1])\n\t\tif (cmd) {\n\t\t\tresult = zwaveEvent(cmd)\n\t\t}\n\t}\n\t//if (state.debug) log.debug \"Parsed '${description}' to ${result.inspect()}\"\n\treturn result\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.wakeupv1.WakeUpNotification cmd)\n{\n\tdef result = [createEvent(descriptionText: \"${device.displayName} woke up\", isStateChange: false)]\n\n\tif (!isConfigured()) {\n\t\t// we're still in the process of configuring a newly joined device\n\t\tif (state.debug) log.debug(\"late configure\")\n\t\tresult += response(configure())\n\t} else {\n\t\tresult += response(zwave.wakeUpV1.wakeUpNoMoreInformation())\n\t}\n\tresult\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.securityv1.SecurityMessageEncapsulation cmd) {\n\tdef encapsulatedCommand = cmd.encapsulatedCommand([0x31: 5, 0x30: 2, 0x7A: 2, 0x84: 1, 0x86: 1])\n\tstate.sec = 1\n\t//if (state.debug) log.debug \"encapsulated: ${encapsulatedCommand}\"\n\tif (encapsulatedCommand) {\n\t\tzwaveEvent(encapsulatedCommand)\n\t} else {\n\t\tlog.warn \"Unable to extract encapsulated cmd from $cmd\"\n\t\tcreateEvent(descriptionText: cmd.toString())\n\t}\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.securityv1.SecurityCommandsSupportedReport cmd) {\n\tresponse(configure())\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.versionv1.VersionCommandClassReport cmd) {\n\tif (state.debug) log.debug \"---COMMAND CLASS VERSION REPORT V1--- ${device.displayName} has command class version: ${cmd.commandClassVersion} - payload: ${cmd.payload}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.versionv1.VersionReport cmd) {\n\tdef fw = \"${cmd.applicationVersion}.${cmd.applicationSubVersion}\"\n\tupdateDataValue(\"fw\", fw)\n\tif (state.debug) log.debug \"---VERSION REPORT V1--- ${device.displayName} is running firmware version: $fw, Z-Wave version: ${cmd.zWaveProtocolVersion}.${cmd.zWaveProtocolSubVersion}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.configurationv2.ConfigurationReport cmd) {\n    if (state.debug) log.debug \"---CONFIGURATION REPORT V2--- ${device.displayName} parameter ${cmd.parameterNumber} with a byte size of ${cmd.size} is set to ${cmd.configurationValue}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.configurationv1.ConfigurationReport cmd) {\n    if (state.debug) log.debug \"---CONFIGURATION REPORT V1--- ${device.displayName} parameter ${cmd.parameterNumber} with a byte size of ${cmd.size} is set to ${cmd.configurationValue}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.batteryv1.BatteryReport cmd) {\n\tdef map = [ name: \"battery\", unit: \"%\" ]\n\tif (cmd.batteryLevel == 0xFF) {\n\t\tmap.value = 1\n\t\tmap.descriptionText = \"${device.displayName} battery is low\"\n\t\tmap.isStateChange = true\n\t} else {\n\t\tmap.value = cmd.batteryLevel\n\t}\n\tstate.lastbatt = now()\n\tcreateEvent(map)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.sensormultilevelv5.SensorMultilevelReport cmd)\n{\n\tdef map = [:]\n\tswitch (cmd.sensorType) {\n\t\tcase 1:\n\t\t\tmap.name = \"temperature\"\n\t\t\tdef cmdScale = cmd.scale == 1 ? \"F\" : \"C\"\n\t\t\tmap.value = convertTemperatureIfNeeded(cmd.scaledSensorValue, cmdScale, cmd.precision)\n\t\t\tmap.unit = getTemperatureScale()\n\t\t\tbreak;\n\t\tcase 3:\n\t\t\tmap.name = \"illuminance\"\n\t\t\tmap.value = cmd.scaledSensorValue.toInteger()\n\t\t\tmap.unit = \"lux\"\n\t\t\tbreak;\n        case 5:\n\t\t\tmap.name = \"humidity\"\n\t\t\tmap.value = cmd.scaledSensorValue.toInteger()\n\t\t\tmap.unit = \"%\"\n\t\t\tbreak;\n\t\tcase 27:\n        \tmap.name = \"ultravioletIndex\"\n            map.value = cmd.scaledSensorValue.toInteger()\n            map.unit = \"\"\n            break;\n\t\tdefault:\n\t\t\tmap.descriptionText = cmd.toString()\n\t}\n\tcreateEvent(map)\n}\n\ndef motionEvent(value) {\n\tdef map = [name: \"motion\"]\n\tif (value) {\n\t\tmap.value = \"active\"\n\t\tmap.descriptionText = \"$device.displayName detected motion\"\n\t} else {\n\t\tmap.value = \"inactive\"\n\t\tmap.descriptionText = \"$device.displayName motion has stopped\"\n\t}\n\tcreateEvent(map)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.sensorbinaryv2.SensorBinaryReport cmd) {\n\tsetConfigured()\n\tmotionEvent(cmd.sensorValue)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicSet cmd) {\n\tmotionEvent(cmd.value)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.notificationv3.NotificationReport cmd) {\n\tdef result = []\n\tif (cmd.notificationType == 7) {\n\t\tswitch (cmd.event) {\n\t\t\tcase 0:\n\t\t\t\tresult << motionEvent(0)\n\t\t\t\tresult << createEvent(name: \"acceleration\", value: \"inactive\", descriptionText: \"$device.displayName tamper cleared\")\n\t\t\t\tbreak\n\t\t\tcase 3:\n\t\t\t\tresult << createEvent(name: \"acceleration\", value: \"active\", descriptionText: \"$device.displayName was moved\")\n\t\t\t\tbreak\n\t\t\tcase 7:\n\t\t\t\tresult << motionEvent(1)\n\t\t\t\tbreak\n\t\t}\n\t} else {\n\t\tresult << createEvent(descriptionText: cmd.toString(), isStateChange: false)\n\t}\n\tresult\n}\n\ndef zwaveEvent(physicalgraph.zwave.Command cmd) {\n\tcreateEvent(descriptionText: cmd.toString(), isStateChange: false)\n}\n\ndef configure() {\n\t// This sensor joins as a secure device if you double-click the button to include it\n\t//if (device.device.rawDescription =~ /98/ && !state.sec) {\n\t//\tif (state.debug) log.debug \"Multi 6 not sending configure until secure\"\n\t//\treturn []\n\t//}\n\tif (state.debug) log.debug \"--Sending configuration command to Multisensor 6--\"\n    if (state.debug) log.debug \"Prefernces settings: PIRsensitivity: $PIRsensitivity, Reporting Interval: $ReportingInterval, Temp offset: $tempoffset, Humidity offset: $humidityoffset, Luminance offset: $luminanceoffset, UV offset: $ultravioletoffset\"\n\t\n\tdef PIRsens = 1\n\tif (PIRsensitivity) {\n\t\tPIRsens=PIRsensitivity.toInteger()\n\t}\n    def MotionRst = 20\n\tif (MotionReset) {\n\t\tMotionRst=MotionReset.toInteger()\n\t}\n\tdef ReportingInt = 300\n\tif (ReportingInterval) {\n\t\tReportingInt=ReportingInterval.toInteger()\n\t}\n\tdef tempoff = 0\n\tif (tempoffset) {\n\t\ttempoff=tempoffset*10\n\t}\n\tdef humidityoff = 0\n\tif (humidityoffset) {\n\t\thumidityoff=humidityoffset\n\t}\n\tdef luminanceoff = 0\n\tif (luminanceoffset) {\n\t\tluminanceoff=luminanceoffset\n\t}\n\tdef ultravioletoff = 0\n\tif (ultravioletoffset) {\n\t\tultravioletoff=ultravioletoffset\n\t}\n    if (state.debug) \tlog.debug \"settings: ${settings.inspect()}, state: ${state.inspect()}\"\n\tdef request = [\n\t\t// set wakeup interval to 5 mins\n\t\tzwave.wakeUpV1.wakeUpIntervalSet(seconds:300, nodeid:zwaveHubNodeId),\n\t\t\n\t\t// Get Version information\n        zwave.versionV1.versionGet(),\n        zwave.firmwareUpdateMdV2.firmwareMdGet(),\n\n\t\t// send temperature, humidity, illuminance, ultraviolet based on reporting interval preference default 5 mins\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x65, size: 4, scaledConfigurationValue: 128|64|32|16),\n\t\t\n\t\t// configure frequency of reporting \n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x6F,size: 4, scaledConfigurationValue: ReportingInt),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0x6F),\n    \t\n\t\t// send battery every 20 hours\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x66, size: 4, scaledConfigurationValue: 1),\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x70, size: 4, scaledConfigurationValue: 20*60*60),\n\t\t\n        // send no-motion report 20 seconds after motion stops\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x03, size: 2, scaledConfigurationValue: MotionRst),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0x03),\n    \t\n\t\t// enable motion sensor and set sensitivity\n        zwave.configurationV1.configurationSet(parameterNumber: 0x04, size: 1, scaledConfigurationValue: PIRsens),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0x04),\n    \t\n\t\t// send binary sensor report for motion\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x05, size: 1, scaledConfigurationValue: 2),\n\t\t\n\t\t// Enable the function of touch sensor\n        zwave.configurationV1.configurationSet(parameterNumber: 0x07, size: 1, scaledConfigurationValue: 1),\n\t\t\n\t\t// disable notification-style motion events\n\t\t// zwave.notificationV3.notificationSet(notificationType: 7, notificationStatus: 0),\n\t\t\n        // configure temp offset\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0xC9, size: 1, scaledConfigurationValue: tempoff),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0xC9),\n\t\t\n        // configure humidity offset\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0xCA, size: 1, scaledConfigurationValue: humidityoff),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0xCA),\n\t\t\n        // configure luminance offset\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0xCB, size: 2, scaledConfigurationValue: luminanceoff),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0xCB),\n\t\t\n        // configure ultraviolet offset\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0xCC, size: 1, scaledConfigurationValue: ultravioletoff), \n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0xCC),\n        \n\t\tzwave.batteryV1.batteryGet(),\n\t\tzwave.sensorBinaryV2.sensorBinaryGet(),\n        \n\t\t// Can use the zwaveHubNodeId variable to add the hub to the device's associations:\n\t\tzwave.associationV1.associationSet(groupingIdentifier:2, nodeId:zwaveHubNodeId)\n    ]\n\tcommands(request) + [\"delay 20000\", zwave.wakeUpV1.wakeUpNoMoreInformation().format()]\n}\n\nprivate setConfigured() {\n\tupdateDataValue(\"configured\", \"true\")\n}\n\nprivate isConfigured() {\n\tgetDataValue(\"configured\") == \"true\"\n}\n\nprivate command(physicalgraph.zwave.Command cmd) {\n\tif (state.sec) {\n\t\tzwave.securityV1.securityMessageEncapsulation().encapsulate(cmd).format()\n\t} else {\n\t\tcmd.format()\n\t}\n}\n\nprivate commands(commands, delay=1000) {\n\tdelayBetween(commands.collect{ command(it) }, delay)\n}\n"
  },
  {
    "path": "Aeon Multisensor 6/device_type-aeon-multisensor6-v2.3",
    "content": "/*\n * V 2.3 of Multisensor 6 code 5/18/2016\n * Uses some original code from @Duncan Aeon Multisensor 6 code for secure configuration, Copyright 2015 SmartThings, modified for setting\n * preferences around configuration and the reporting of tampering and ultraviolet index, and reconfiguration after pairing.\n * 2.0 brings about the new style look with multiattribute tile for temp and humidity and all adjustments working\n * 2.1 provides vibration sensor output to smartthings in the form of the acceleration capability for use in the home security section. You can create push notifications, SMS, and trigger\ncameras and the like if you sensor is tampered with or it detects a significant enough vibration, like a door slamming close by.\n\n * Robert Vandervoort 6/19/2015 - 5/18/2016\n *\n *  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except\n *  in compliance with the License. You may obtain a copy of the License at:\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n *  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed\n *  on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License\n *  for the specific language governing permissions and limitations under the License.\n * \n---------------------------------------------------------------------------------------------------------------------------\n   INSTRUCTIONS: \n\n*- Log in to the IDE and add my device type \"from code\" copy pasting the raw code from github and save it\n*- Open the live logging view in a new tab\n*- With the sensor plugged in via usb, note the light color. It should cycle through many different colors continually.\nIf it does not, it was previously joined. The sensor may come this way from wherever you ordered it. To reset, perform the following:\nHold the action button for about 25 seconds until the light blinks red quickly and then the colors cycle. It is now reset.\n*- Put smart things into inclusion mode by doing the add device procedure on the app.\n*- Quickly double tap the action button. The light on the sensor should blink blue several times quickly. Please read the rest before continuing!\n*- Before you do anything else and when you see the device smartthings found on the screen, go to your devices in the IDE, select the newly added sensor and edit it.\nChange the device type to my device type and save it.\n*- Back on your app, click the device on the screen to add it. Walk through the next few steps setting preferences and smart app stuff if you like.\nAfter you save the preferences the device should update and send the configuration. You can see this on the live logging view in the debug comments.\nIt may help to select just the newly added sensor from the available items to see past the other noise in the view. When in doubt, hit the configure tile and watch..\n*- That's it. \n */\n\n metadata {\n\tdefinition (name: \"Aeon Multisensor 6 - RV 2.3\", namespace: \"robertvandervoort\", author: \"Robert Vandervoort\") {\n\t\tcapability \"Motion Sensor\"\n\t\tcapability \"Acceleration Sensor\"\n\t\tcapability \"Temperature Measurement\"\n\t\tcapability \"Relative Humidity Measurement\"\n\t\tcapability \"Illuminance Measurement\"\n\t\tcapability \"Ultraviolet Index\" \n\t\tcapability \"Configuration\"\n\t\tcapability \"Sensor\"\n\t\tcapability \"Battery\"\n\t\t\n\t\t// CCs supported - 94, 134, 114, 132, 89, 133, 115, 113, 128, 48, 49, 112, 152, 122\n\t\tattribute \"tamper\", \"enum\", [\"detected\", \"clear\"]\n\t\tfingerprint deviceId: \"0x2101\", inClusters: \"0x5E,0x86,0x72,0x59,0x85,0x73,0x71,0x84,0x80,0x30,0x31,0x70,0xEF,0x5A,0x98,0x7A\"\n\t\t}\n\tsimulator {\n\t\tstatus \"no motion\" : \"command: 9881, payload: 00300300\"\n\t\tstatus \"motion\"    : \"command: 9881, payload: 003003FF\"\n        status \"clear\" : \" command: 9881, payload: 0071050000000007030000\"\n        status \"tamper\" : \"command: 9881, payload: 007105000000FF07030000\"\n        \n        for (int i = 0; i <= 100; i += 20) {\n\t\t\tstatus \"temperature ${i}F\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().sensorMultilevelV2.sensorMultilevelReport(\n                \tscaledSensorValue: i,\n                    precision: 1,\n                    sensorType: 1,\n                    scale: 1\n\t\t\t\t)\n\t\t\t).incomingMessage()\n\t\t}\n\t\tfor (int i = 0; i <= 100; i += 20) {\n\t\t\tstatus \"RH ${i}%\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().sensorMultilevelV2.sensorMultilevelReport(\n                \tscaledSensorValue: i,\n                    sensorType: 5\n            \t)\n\t\t\t).incomingMessage()\n\t\t}\n\t\tfor (int i in [0, 1, 2, 8, 12, 16, 20, 24, 30, 64, 82, 100, 200, 500, 1000]) {\n\t\t\tstatus \"illuminance ${i} lux\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().sensorMultilevelV2.sensorMultilevelReport(\n                scaledSensorValue: i,\n                sensorType: 3\n                )\n\t\t\t).incomingMessage()\n\t\t}\n\t\tfor (int i = 0; i <= 11; i += 1) {\n\t\t\tstatus \"ultravioletultravioletIndex ${i}\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().sensorMultilevelV2.sensorMultilevelReport(\n                scaledSensorValue: i,\n                sensorType: 27\n                )\n\t\t\t).incomingMessage()\n\t\t}\n\t\tfor (int i in [0, 5, 10, 15, 50, 99, 100]) {\n\t\t\tstatus \"battery ${i}%\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().batteryV1.batteryReport(\n                batteryLevel: i\n                )\n\t\t\t).incomingMessage()\n\t\t}\n\t\tstatus \"low battery alert\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().batteryV1.batteryReport(\n            \tbatteryLevel: 255\n            \t)\n\t\t\t).incomingMessage()\n\t\tstatus \"wake up\": \"command: 8407, payload:\"\n\t}\n\ttiles (scale: 2) {\n\t\tmultiAttributeTile(name:\"main\", type:\"generic\", width:6, height:4) {\n\t\t\ttileAttribute(\"device.temperature\", key: \"PRIMARY_CONTROL\") {\n            \tattributeState \"temperature\",label:'${currentValue}',backgroundColors:[\n                \t[value: 32, color: \"#153591\"],\n                    [value: 44, color: \"#1e9cbb\"],\n                    [value: 59, color: \"#90d2a7\"],\n\t\t\t\t\t[value: 74, color: \"#44b621\"],\n\t\t\t\t\t[value: 84, color: \"#f1d801\"],\n\t\t\t\t\t[value: 92, color: \"#d04e00\"],\n\t\t\t\t\t[value: 98, color: \"#bc2323\"]\n\t\t\t\t]       \n            }\n            tileAttribute(\"device.humidity\", key: \"SECONDARY_CONTROL\") {\n                attributeState \"humidity\",label:'RH ${currentValue}%',precision:2,icon:\" \"\n            }\n\t\t}\n        standardTile(\"motion\",\"device.motion\", width: 2, height: 2) {\n            \tstate \"active\",label:'motion',icon:\"st.motion.motion.active\",backgroundColor:\"#53a7c0\"\n                state \"inactive\",label:'no motion',icon:\"st.motion.motion.inactive\",backgroundColor:\"#ffffff\"\n\t\t\t}\n\t\tvalueTile(\"humidity\",\"device.humidity\", width: 2, height: 2) {\n           \tstate \"humidity\",label:'RH ${currentValue}%', precision:2\n\t\t\t}\n\t\tvalueTile(\"illuminance\",\"device.illuminance\", width: 2, height: 2) {\n            \tstate \"luminosity\",label:'${currentValue} lx', precision:2, backgroundColors:[\n                \t[value: 0, color: \"#000000\"],\n                    [value: 1, color: \"#060053\"],\n                    [value: 3, color: \"#3E3900\"],\n                    [value: 12, color: \"#8E8400\"],\n\t\t\t\t\t[value: 24, color: \"#C5C08B\"],\n\t\t\t\t\t[value: 36, color: \"#DAD7B6\"],\n\t\t\t\t\t[value: 128, color: \"#F3F2E9\"],\n                    [value: 1000, color: \"#FFFFFF\"]\n\t\t\t\t]\n\t\t\t}\n\t\tvalueTile(\"ultravioletIndex\",\"device.ultravioletIndex\", width: 2, height: 2) {\n\t\t\t\tstate \"ultravioletIndex\",label:'${currentValue} UV INDEX'\n\t\t\t}\n\t\tstandardTile(\"acceleration\", \"device.acceleration\", width: 2, height: 2) {\n\t\t\tstate(\"active\", label:'tamper', icon:\"st.motion.acceleration.active\", backgroundColor:\"#ff0000\")\n\t\t\tstate(\"inactive\", label:'clear', icon:\"st.motion.acceleration.inactive\", backgroundColor:\"#00ff00\")\n\t\t}\n\t\tvalueTile(\"battery\", \"device.battery\", decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"battery\", label:'${currentValue}% battery', unit:\"\"\n\t\t}\n\t\tstandardTile(\"configure\",\"device.configure\", decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"configure\", label:'config', action:\"configure\", icon:\"st.secondary.tools\"\n\t\t}\n\t\tmain([\"main\"])\n\t\tdetails([\"main\",\"humidity\",\"illuminance\",\"ultravioletIndex\",\"motion\",\"acceleration\",\"battery\",\"configure\"])\n\t}\n\t\n    preferences {\n\t\tinput \"debugOutput\", \"boolean\", \n\t\t\ttitle: \"Enable debug logging?\",\n\t\t\tdefaultValue: false,\n\t\t\tdisplayDuringSetup: true\n\t\tinput \"tempoffset\",\n\t\t\t\"number\",\n\t\t\ttitle: \"Temperature offset\",\n            description: \"negative values reduce the monitored value positive ones add to it\",\n            range: \"-11..11\",\n\t\t\tdefaultValue: 0,\n            required: false,\n            displayDuringSetup: false\n\t\tinput \"humidityoffset\",\n        \t\"number\",\n            title: \"Humidity offset\",\n            description: \"negative values reduce the monitored value positive ones add to it\",\n\t\t\trange: \"-50..50\",\n\t\t\tdefaultValue: 0,\n\t\t\trequired: false,\n            displayDuringSetup: false\n\t\tinput \"luminanceoffset\",\n          \t\"number\",\n            title: \"Luminance offset\",\n            description: \"negative values reduce the monitored value positive ones add to it\",\n            range: \"-1000..1000\",\n\t\t\tdefaultValue: 0,\n            required: false,\n\t        displayDuringSetup: false\n\t\tinput \"ultravioletoffset\",\n          \t\"number\",\n            title: \"Ultraviolet offset\",\n            description: \"negative values reduce the monitored value positive ones add to it\",\n            range: \"-10..10\",\n\t\t\tdefaultValue: 0,\n\t        required: false,\n\t\t\tdisplayDuringSetup: false\n\t\tinput \"PIRsensitivity\",\n\t        \"number\",\n    \t    title: \"PIR motion sensitivity\",\n\t\t\tdescription: \"A value from 0-5, from disabled to high sensitivity\",\n\t\t\trange: \"0..5\",\n\t\t\tdefaultValue: 1,\n\t\t\trequired: true,\n\t\t\tdisplayDuringSetup: true\n\t\tinput \"MotionReset\",\n\t        \"number\",\n    \t    title: \"PIR reset time\",\n\t\t\tdescription: \"Number of seconds to wait to report motion cleared after a motion event if there is no motion detected.\",\n\t\t\tdefaultValue: 20,\n\t\t\trequired: true,\n\t\t\tdisplayDuringSetup: true            \n\t\tinput \"ReportingInterval\",\n        \t\"number\",\n            title: \"Report data interval\",\n            description: \"A value in seconds.\",\n            defaultValue: 300,\n            required: true,\n            displayDuringSetup: true\n\t}\n}\n\ndef updated()\n{\n\tupdateDataValue(\"configured\", \"false\")\n\tstate.debug = (\"true\" == debugOutput)\n\tif (state.sec && !isConfigured()) {\n\t\t// in case we miss the SCSR\n\t\tresponse(configure())\n\t}\n}\n\ndef parse(String description)\n{\n\tdef result = null\n\tif (description.startsWith(\"Err 106\")) {\n\t\tstate.sec = 0\n\t\tresult = createEvent( name: \"secureInclusion\", value: \"failed\", isStateChange: true,\n\t\t\tdescriptionText: \"This sensor failed to complete the network security key exchange. If you are unable to control it via SmartThings, you must remove it from your network and add it again.\")\n\t} else if (description != \"updated\") {\n\t\tdef cmd = zwave.parse(description, [0x31: 5, 0x30: 2, 0x7A: 2, 0x84: 1, 0x86: 1])\n\t\tif (cmd) {\n\t\t\tresult = zwaveEvent(cmd)\n\t\t}\n\t}\n\t//if (state.debug) log.debug \"Parsed '${description}' to ${result.inspect()}\"\n\treturn result\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.wakeupv1.WakeUpNotification cmd)\n{\n\tdef result = [createEvent(descriptionText: \"${device.displayName} woke up\", isStateChange: false)]\n\n\tif (!isConfigured()) {\n\t\t// we're still in the process of configuring a newly joined device\n\t\tif (state.debug) log.debug(\"late configure\")\n\t\tresult += response(configure())\n\t} else {\n\t\tresult += response(zwave.wakeUpV1.wakeUpNoMoreInformation())\n\t}\n\tresult\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.securityv1.SecurityMessageEncapsulation cmd) {\n\tdef encapsulatedCommand = cmd.encapsulatedCommand([0x31: 5, 0x30: 2, 0x7A: 2, 0x84: 1, 0x86: 1])\n\tstate.sec = 1\n\t//if (state.debug) log.debug \"encapsulated: ${encapsulatedCommand}\"\n\tif (encapsulatedCommand) {\n\t\tzwaveEvent(encapsulatedCommand)\n\t} else {\n\t\tlog.warn \"Unable to extract encapsulated cmd from $cmd\"\n\t\tcreateEvent(descriptionText: cmd.toString())\n\t}\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.securityv1.SecurityCommandsSupportedReport cmd) {\n\tresponse(configure())\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.versionv1.VersionCommandClassReport cmd) {\n\tif (state.debug) log.debug \"---COMMAND CLASS VERSION REPORT V1--- ${device.displayName} has command class version: ${cmd.commandClassVersion} - payload: ${cmd.payload}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.versionv1.VersionReport cmd) {\n\tdef fw = \"${cmd.applicationVersion}.${cmd.applicationSubVersion}\"\n\tupdateDataValue(\"fw\", fw)\n\tif (state.debug) log.debug \"---VERSION REPORT V1--- ${device.displayName} is running firmware version: $fw, Z-Wave version: ${cmd.zWaveProtocolVersion}.${cmd.zWaveProtocolSubVersion}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.configurationv2.ConfigurationReport cmd) {\n    if (state.debug) log.debug \"---CONFIGURATION REPORT V2--- ${device.displayName} parameter ${cmd.parameterNumber} with a byte size of ${cmd.size} is set to ${cmd.configurationValue}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.configurationv1.ConfigurationReport cmd) {\n    if (state.debug) log.debug \"---CONFIGURATION REPORT V1--- ${device.displayName} parameter ${cmd.parameterNumber} with a byte size of ${cmd.size} is set to ${cmd.configurationValue}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.batteryv1.BatteryReport cmd) {\n\tif (state.debug) log.debug \"---BATTERY V1 REPORT--- ${device.displayName} reports battery level of ${cmd.batteryLevel}\"\n\tdef result = []\n\tdef map = [ name: \"battery\", unit: \"%\" ]\n\tif (cmd.batteryLevel == 0xFF) {\n\t\tmap.value = 1\n\t\tmap.descriptionText = \"${device.displayName} battery is low\"\n\t\tmap.isStateChange = true\n\t} else {\n\t\tmap.value = cmd.batteryLevel\n\t\tmap.descriptionText = \"${device.displayName} battery is at ${cmd.batteryLevel}\"\n\t\tmap.isStateChange = true\n\t}\n\tstate.lastbatt = now()\n\tresult << createEvent(map)\n\tresult\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.sensormultilevelv5.SensorMultilevelReport cmd)\n{\n\tdef map = [:]\n\tswitch (cmd.sensorType) {\n\t\tcase 1:\n\t\t\tmap.name = \"temperature\"\n\t\t\tdef cmdScale = cmd.scale == 1 ? \"F\" : \"C\"\n\t\t\tmap.value = convertTemperatureIfNeeded(cmd.scaledSensorValue, cmdScale, cmd.precision)\n\t\t\tmap.unit = getTemperatureScale()\n\t\t\tbreak;\n\t\tcase 3:\n\t\t\tmap.name = \"illuminance\"\n\t\t\tmap.value = cmd.scaledSensorValue\n\t\t\tmap.unit = \"lux\"\n\t\t\tbreak;\n        case 5:\n\t\t\tmap.name = \"humidity\"\n\t\t\tmap.value = cmd.scaledSensorValue.toInteger()\n\t\t\tmap.unit = \"%\"\n\t\t\tbreak;\n\t\tcase 27:\n        \tmap.name = \"ultravioletIndex\"\n            map.value = cmd.scaledSensorValue.toInteger()\n            break;\n\t\tdefault:\n\t\t\tmap.descriptionText = cmd.toString()\n\t}\n\tcreateEvent(map)\n}\n\ndef motionEvent(value) {\n\tdef map = [name: \"motion\"]\n\tif (value) {\n\t\tmap.value = \"active\"\n\t\tmap.descriptionText = \"$device.displayName detected motion\"\n\t} else {\n\t\tmap.value = \"inactive\"\n\t\tmap.descriptionText = \"$device.displayName motion has stopped\"\n\t}\n\tcreateEvent(map)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.sensorbinaryv2.SensorBinaryReport cmd) {\n\tsetConfigured()\n\tmotionEvent(cmd.sensorValue)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicSet cmd) {\n\tmotionEvent(cmd.value)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.notificationv3.NotificationReport cmd) {\n\tdef result = []\n\tif (cmd.notificationType == 7) {\n\t\tswitch (cmd.event) {\n\t\t\tcase 0:\n\t\t\t\tresult << motionEvent(0)\n\t\t\t\tresult << createEvent(name: \"acceleration\", value: \"inactive\", descriptionText: \"$device.displayName tamper cleared\")\n\t\t\t\tbreak\n\t\t\tcase 3:\n\t\t\t\tresult << createEvent(name: \"acceleration\", value: \"active\", descriptionText: \"$device.displayName was moved\")\n\t\t\t\tbreak\n\t\t\tcase 7:\n\t\t\t\tresult << motionEvent(1)\n\t\t\t\tbreak\n\t\t}\n\t} else {\n\t\tresult << createEvent(descriptionText: cmd.toString(), isStateChange: false)\n\t}\n\tresult\n}\n\ndef zwaveEvent(physicalgraph.zwave.Command cmd) {\n\tcreateEvent(descriptionText: cmd.toString(), isStateChange: false)\n}\n\ndef configure() {\n\t// This sensor joins as a secure device if you double-click the button to include it\n\t//if (device.device.rawDescription =~ /98/ && !state.sec) {\n\t//\tif (state.debug) log.debug \"Multi 6 not sending configure until secure\"\n\t//\treturn []\n\t//}\n\tif (state.debug) log.debug \"--Sending configuration command to Multisensor 6--\"\n    if (state.debug) log.debug \"Prefernces settings: PIRsensitivity: $PIRsensitivity, Reporting Interval: $ReportingInterval, Temp offset: $tempoffset, Humidity offset: $humidityoffset, Luminance offset: $luminanceoffset, UV offset: $ultravioletoffset\"\n\t\n\tdef PIRsens = 1\n\tif (PIRsensitivity) {\n\t\tPIRsens=PIRsensitivity.toInteger()\n\t}\n    def MotionRst = 20\n\tif (MotionReset) {\n\t\tMotionRst=MotionReset.toInteger()\n\t}\n\tdef ReportingInt = 300\n\tif (ReportingInterval) {\n\t\tReportingInt=ReportingInterval.toInteger()\n\t}\n\tdef tempoff = 0\n\tif (tempoffset) {\n\t\ttempoff=tempoffset*10\n\t}\n\tdef humidityoff = 0\n\tif (humidityoffset) {\n\t\thumidityoff=humidityoffset\n\t}\n\tdef luminanceoff = 0\n\tif (luminanceoffset) {\n\t\tluminanceoff=luminanceoffset\n\t}\n\tdef ultravioletoff = 0\n\tif (ultravioletoffset) {\n\t\tultravioletoff=ultravioletoffset\n\t}\n    if (state.debug) \tlog.debug \"settings: ${settings.inspect()}, state: ${state.inspect()}\"\n\tdef request = [\n\t\t// set wakeup interval to 5 mins\n\t\tzwave.wakeUpV1.wakeUpIntervalSet(seconds:300, nodeid:zwaveHubNodeId),\n\t\t\n\t\t// Get Version information\n        zwave.versionV1.versionGet(),\n        zwave.firmwareUpdateMdV2.firmwareMdGet(),\n\n\t\t// send temperature, humidity, illuminance, ultraviolet based on reporting interval preference default 5 mins\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x65, size: 4, scaledConfigurationValue: 128|64|32|16),\n\t\t\n\t\t// configure frequency of reporting \n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x6F,size: 4, scaledConfigurationValue: ReportingInt),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0x6F),\n    \t\n\t\t// send battery every 20 hours\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x66, size: 4, scaledConfigurationValue: 1),\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x70, size: 4, scaledConfigurationValue: 20*60*60),\n\t\t\n        // send no-motion report 20 seconds after motion stops\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x03, size: 2, scaledConfigurationValue: MotionRst),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0x03),\n    \t\n\t\t// enable motion sensor and set sensitivity\n        zwave.configurationV1.configurationSet(parameterNumber: 0x04, size: 1, scaledConfigurationValue: PIRsens),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0x04),\n    \t\n\t\t// send binary sensor report for motion\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x05, size: 1, scaledConfigurationValue: 2),\n\t\t\n\t\t// Enable the function of touch sensor\n        zwave.configurationV1.configurationSet(parameterNumber: 0x07, size: 1, scaledConfigurationValue: 1),\n\t\t\n\t\t// disable notification-style motion events\n\t\t// zwave.notificationV3.notificationSet(notificationType: 7, notificationStatus: 0),\n\t\t\n        // configure temp offset\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0xC9, size: 1, scaledConfigurationValue: tempoff),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0xC9),\n\t\t\n        // configure humidity offset\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0xCA, size: 1, scaledConfigurationValue: humidityoff),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0xCA),\n\t\t\n        // configure luminance offset\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0xCB, size: 2, scaledConfigurationValue: luminanceoff),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0xCB),\n\t\t\n        // configure ultraviolet offset\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0xCC, size: 1, scaledConfigurationValue: ultravioletoff), \n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0xCC),\n        \n\t\tzwave.batteryV1.batteryGet(),\n\t\tzwave.sensorBinaryV2.sensorBinaryGet(),\n        \n\t\t// Can use the zwaveHubNodeId variable to add the hub to the device's associations:\n\t\tzwave.associationV1.associationSet(groupingIdentifier:2, nodeId:zwaveHubNodeId)\n    ]\n\tcommands(request) + [\"delay 20000\", zwave.wakeUpV1.wakeUpNoMoreInformation().format()]\n}\n\nprivate setConfigured() {\n\tupdateDataValue(\"configured\", \"true\")\n}\n\nprivate isConfigured() {\n\tgetDataValue(\"configured\") == \"true\"\n}\n\nprivate command(physicalgraph.zwave.Command cmd) {\n\tif (state.sec) {\n\t\tzwave.securityV1.securityMessageEncapsulation().encapsulate(cmd).format()\n\t} else {\n\t\tcmd.format()\n\t}\n}\n\nprivate commands(commands, delay=1000) {\n\tdelayBetween(commands.collect{ command(it) }, delay)\n}\n"
  },
  {
    "path": "Aeon Multisensor 6/device_type-aeon-multisensor6-v2.3.1",
    "content": "/*\n * V 2.3 of Multisensor 6 code 5/18/2016\n * Uses some original code from @Duncan Aeon Multisensor 6 code for secure configuration, Copyright 2015 SmartThings, modified for setting\n * preferences around configuration and the reporting of tampering and ultraviolet index, and reconfiguration after pairing.\n * 2.0 brings about the new style look with multiattribute tile for temp and humidity and all adjustments working\n * 2.1 provides vibration sensor output to smartthings in the form of the acceleration capability for use in the home security section. You can create push notifications, SMS, and trigger\ncameras and the like if you sensor is tampered with or it detects a significant enough vibration, like a door slamming close by.\n\n * Robert Vandervoort 6/19/2015 - 5/18/2016\n *\n *  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except\n *  in compliance with the License. You may obtain a copy of the License at:\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n *  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed\n *  on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License\n *  for the specific language governing permissions and limitations under the License.\n * \n---------------------------------------------------------------------------------------------------------------------------\n   INSTRUCTIONS: \n\n*- Log in to the IDE and add my device type \"from code\" copy pasting the raw code from github and save it\n*- Open the live logging view in a new tab\n*- With the sensor plugged in via usb, note the light color. It should cycle through many different colors continually.\nIf it does not, it was previously joined. The sensor may come this way from wherever you ordered it. To reset, perform the following:\nHold the action button for about 25 seconds until the light blinks red quickly and then the colors cycle. It is now reset.\n*- Put smart things into inclusion mode by doing the add device procedure on the app.\n*- Quickly double tap the action button. The light on the sensor should blink blue several times quickly. Please read the rest before continuing!\n*- Before you do anything else and when you see the device smartthings found on the screen, go to your devices in the IDE, select the newly added sensor and edit it.\nChange the device type to my device type and save it.\n*- Back on your app, click the device on the screen to add it. Walk through the next few steps setting preferences and smart app stuff if you like.\nAfter you save the preferences the device should update and send the configuration. You can see this on the live logging view in the debug comments.\nIt may help to select just the newly added sensor from the available items to see past the other noise in the view. When in doubt, hit the configure tile and watch..\n*- That's it. \n */\n\n metadata {\n\tdefinition (name: \"Aeon Multisensor 6 - RV 2.3\", namespace: \"robertvandervoort\", author: \"Robert Vandervoort\") {\n\t\tcapability \"Motion Sensor\"\n\t\tcapability \"Acceleration Sensor\"\n\t\tcapability \"Temperature Measurement\"\n\t\tcapability \"Relative Humidity Measurement\"\n\t\tcapability \"Illuminance Measurement\"\n\t\tcapability \"Ultraviolet Index\" \n\t\tcapability \"Configuration\"\n\t\tcapability \"Sensor\"\n\t\tcapability \"Battery\"\n\t\t\n\t\t// CCs supported - 94, 134, 114, 132, 89, 133, 115, 113, 128, 48, 49, 112, 152, 122\n\t\tattribute \"tamper\", \"enum\", [\"detected\", \"clear\"]\n\t\tfingerprint deviceId: \"0x2101\", inClusters: \"0x5E,0x86,0x72,0x59,0x85,0x73,0x71,0x84,0x80,0x30,0x31,0x70,0xEF,0x5A,0x98,0x7A\"\n\t\t}\n\tsimulator {\n\t\tstatus \"no motion\" : \"command: 9881, payload: 00300300\"\n\t\tstatus \"motion\"    : \"command: 9881, payload: 003003FF\"\n        status \"clear\" : \" command: 9881, payload: 0071050000000007030000\"\n        status \"tamper\" : \"command: 9881, payload: 007105000000FF07030000\"\n        \n        for (int i = 0; i <= 100; i += 20) {\n\t\t\tstatus \"temperature ${i}F\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().sensorMultilevelV2.sensorMultilevelReport(\n                \tscaledSensorValue: i,\n                    precision: 1,\n                    sensorType: 1,\n                    scale: 1\n\t\t\t\t)\n\t\t\t).incomingMessage()\n\t\t}\n\t\tfor (int i = 0; i <= 100; i += 20) {\n\t\t\tstatus \"RH ${i}%\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().sensorMultilevelV2.sensorMultilevelReport(\n                \tscaledSensorValue: i,\n                    sensorType: 5\n            \t)\n\t\t\t).incomingMessage()\n\t\t}\n\t\tfor (int i in [0, 1, 2, 8, 12, 16, 20, 24, 30, 64, 82, 100, 200, 500, 1000]) {\n\t\t\tstatus \"illuminance ${i} lux\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().sensorMultilevelV2.sensorMultilevelReport(\n                scaledSensorValue: i,\n                sensorType: 3\n                )\n\t\t\t).incomingMessage()\n\t\t}\n\t\tfor (int i = 0; i <= 11; i += 1) {\n\t\t\tstatus \"ultravioletultravioletIndex ${i}\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().sensorMultilevelV2.sensorMultilevelReport(\n                scaledSensorValue: i,\n                sensorType: 27\n                )\n\t\t\t).incomingMessage()\n\t\t}\n\t\tfor (int i in [0, 5, 10, 15, 50, 99, 100]) {\n\t\t\tstatus \"battery ${i}%\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().batteryV1.batteryReport(\n                batteryLevel: i\n                )\n\t\t\t).incomingMessage()\n\t\t}\n\t\tstatus \"low battery alert\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().batteryV1.batteryReport(\n            \tbatteryLevel: 255\n            \t)\n\t\t\t).incomingMessage()\n\t\tstatus \"wake up\": \"command: 8407, payload:\"\n\t}\n\ttiles (scale: 2) {\n\t\tmultiAttributeTile(name:\"main\", type:\"generic\", width:6, height:4) {\n\t\t\ttileAttribute(\"device.temperature\", key: \"PRIMARY_CONTROL\") {\n            \tattributeState \"temperature\",label:'${currentValue}',backgroundColors:[\n                \t[value: 32, color: \"#153591\"],\n                    [value: 44, color: \"#1e9cbb\"],\n                    [value: 59, color: \"#90d2a7\"],\n\t\t\t\t\t[value: 74, color: \"#44b621\"],\n\t\t\t\t\t[value: 84, color: \"#f1d801\"],\n\t\t\t\t\t[value: 92, color: \"#d04e00\"],\n\t\t\t\t\t[value: 98, color: \"#bc2323\"]\n\t\t\t\t]       \n            }\n            tileAttribute(\"device.humidity\", key: \"SECONDARY_CONTROL\") {\n                attributeState \"humidity\",label:'RH ${currentValue}%',precision:2,icon:\" \"\n            }\n\t\t}\n        standardTile(\"motion\",\"device.motion\", width: 2, height: 2) {\n            \tstate \"active\",label:'motion',icon:\"st.motion.motion.active\",backgroundColor:\"#53a7c0\"\n                state \"inactive\",label:'no motion',icon:\"st.motion.motion.inactive\",backgroundColor:\"#ffffff\"\n\t\t\t}\n\t\tvalueTile(\"humidity\",\"device.humidity\", width: 2, height: 2) {\n           \tstate \"humidity\",label:'RH ${currentValue}%', precision:2\n\t\t\t}\n\t\tvalueTile(\"illuminance\",\"device.illuminance\", width: 2, height: 2) {\n            \tstate \"luminosity\",label:'${currentValue} lx', precision:2, backgroundColors:[\n                \t[value: 0, color: \"#000000\"],\n                    [value: 1, color: \"#060053\"],\n                    [value: 3, color: \"#3E3900\"],\n                    [value: 12, color: \"#8E8400\"],\n\t\t\t\t\t[value: 24, color: \"#C5C08B\"],\n\t\t\t\t\t[value: 36, color: \"#DAD7B6\"],\n\t\t\t\t\t[value: 128, color: \"#F3F2E9\"],\n                    [value: 1000, color: \"#FFFFFF\"]\n\t\t\t\t]\n\t\t\t}\n\t\tvalueTile(\"ultravioletIndex\",\"device.ultravioletIndex\", width: 2, height: 2) {\n\t\t\t\tstate \"ultravioletIndex\",label:'${currentValue} UV INDEX'\n\t\t\t}\n\t\tstandardTile(\"acceleration\", \"device.acceleration\", width: 2, height: 2) {\n\t\t\tstate(\"active\", label:'tamper', icon:\"st.motion.acceleration.active\", backgroundColor:\"#ff0000\")\n\t\t\tstate(\"inactive\", label:'clear', icon:\"st.motion.acceleration.inactive\", backgroundColor:\"#00ff00\")\n\t\t}\n\t\tvalueTile(\"battery\", \"device.battery\", decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"battery\", label:'${currentValue}% battery', unit:\"\"\n\t\t}\n\t\tstandardTile(\"configure\",\"device.configure\", decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"configure\", label:'config', action:\"configure\", icon:\"st.secondary.tools\"\n\t\t}\n\t\tmain([\"main\"])\n\t\tdetails([\"main\",\"humidity\",\"illuminance\",\"ultravioletIndex\",\"motion\",\"acceleration\",\"battery\",\"configure\"])\n\t}\n\t\n    preferences {\n\t\tinput \"debugOutput\", \"boolean\", \n\t\t\ttitle: \"Enable debug logging?\",\n\t\t\tdefaultValue: false,\n\t\t\tdisplayDuringSetup: true\n\t\tinput \"tempoffset\",\n\t\t\t\"number\",\n\t\t\ttitle: \"Temperature offset\",\n            description: \"negative values reduce the monitored value positive ones add to it\",\n            range: \"-11..11\",\n\t\t\tdefaultValue: 0,\n            required: false,\n            displayDuringSetup: false\n\t\tinput \"humidityoffset\",\n        \t\"number\",\n            title: \"Humidity offset\",\n            description: \"negative values reduce the monitored value positive ones add to it\",\n\t\t\trange: \"-50..50\",\n\t\t\tdefaultValue: 0,\n\t\t\trequired: false,\n            displayDuringSetup: false\n\t\tinput \"luminanceoffset\",\n          \t\"number\",\n            title: \"Luminance offset\",\n            description: \"negative values reduce the monitored value positive ones add to it\",\n            range: \"-1000..1000\",\n\t\t\tdefaultValue: 0,\n            required: false,\n\t        displayDuringSetup: false\n\t\tinput \"ultravioletoffset\",\n          \t\"number\",\n            title: \"Ultraviolet offset\",\n            description: \"negative values reduce the monitored value positive ones add to it\",\n            range: \"-10..10\",\n\t\t\tdefaultValue: 0,\n\t        required: false,\n\t\t\tdisplayDuringSetup: false\n\t\tinput \"PIRsensitivity\",\n\t        \"number\",\n    \t    title: \"PIR motion sensitivity\",\n\t\t\tdescription: \"A value from 0-5, from disabled to high sensitivity\",\n\t\t\trange: \"0..5\",\n\t\t\tdefaultValue: 1,\n\t\t\trequired: false,\n\t\t\tdisplayDuringSetup: true\n\t\tinput \"MotionReset\",\n\t        \"number\",\n    \t    title: \"PIR reset time\",\n\t\t\tdescription: \"Number of seconds to wait to report motion cleared after a motion event if there is no motion detected.\",\n\t\t\tdefaultValue: 20,\n\t\t\trequired: false,\n\t\t\tdisplayDuringSetup: true            \n\t\tinput \"ReportingInterval\",\n        \t\"number\",\n            title: \"Report data interval\",\n            description: \"A value in seconds.\",\n            defaultValue: 300,\n            required: false,\n            displayDuringSetup: true\n\t}\n}\n\ndef updated()\n{\n\tupdateDataValue(\"configured\", \"false\")\n\tstate.debug = (\"true\" == debugOutput)\n\tif (state.sec && !isConfigured()) {\n\t\t// in case we miss the SCSR\n\t\tresponse(configure())\n\t}\n}\n\ndef parse(String description)\n{\n\tdef result = null\n\tif (description.startsWith(\"Err 106\")) {\n\t\tstate.sec = 0\n\t\tresult = createEvent( name: \"secureInclusion\", value: \"failed\", isStateChange: true,\n\t\t\tdescriptionText: \"This sensor failed to complete the network security key exchange. If you are unable to control it via SmartThings, you must remove it from your network and add it again.\")\n\t} else if (description != \"updated\") {\n\t\tdef cmd = zwave.parse(description, [0x31: 5, 0x30: 2, 0x7A: 2, 0x84: 1, 0x86: 1])\n\t\tif (cmd) {\n\t\t\tresult = zwaveEvent(cmd)\n\t\t}\n\t}\n\t//if (state.debug) log.debug \"Parsed '${description}' to ${result.inspect()}\"\n\treturn result\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.wakeupv1.WakeUpNotification cmd)\n{\n\tdef result = [createEvent(descriptionText: \"${device.displayName} woke up\", isStateChange: false)]\n\n\tif (!isConfigured()) {\n\t\t// we're still in the process of configuring a newly joined device\n\t\tif (state.debug) log.debug(\"late configure\")\n\t\tresult += response(configure())\n\t} else {\n\t\tresult += response(zwave.wakeUpV1.wakeUpNoMoreInformation())\n\t}\n\tresult\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.securityv1.SecurityMessageEncapsulation cmd) {\n\tdef encapsulatedCommand = cmd.encapsulatedCommand([0x31: 5, 0x30: 2, 0x7A: 2, 0x84: 1, 0x86: 1])\n\tstate.sec = 1\n\t//if (state.debug) log.debug \"encapsulated: ${encapsulatedCommand}\"\n\tif (encapsulatedCommand) {\n\t\tzwaveEvent(encapsulatedCommand)\n\t} else {\n\t\tlog.warn \"Unable to extract encapsulated cmd from $cmd\"\n\t\tcreateEvent(descriptionText: cmd.toString())\n\t}\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.securityv1.SecurityCommandsSupportedReport cmd) {\n\tresponse(configure())\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.versionv1.VersionCommandClassReport cmd) {\n\tif (state.debug) log.debug \"---COMMAND CLASS VERSION REPORT V1--- ${device.displayName} has command class version: ${cmd.commandClassVersion} - payload: ${cmd.payload}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.versionv1.VersionReport cmd) {\n\tdef fw = \"${cmd.applicationVersion}.${cmd.applicationSubVersion}\"\n\tupdateDataValue(\"fw\", fw)\n\tif (state.debug) log.debug \"---VERSION REPORT V1--- ${device.displayName} is running firmware version: $fw, Z-Wave version: ${cmd.zWaveProtocolVersion}.${cmd.zWaveProtocolSubVersion}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.configurationv2.ConfigurationReport cmd) {\n    if (state.debug) log.debug \"---CONFIGURATION REPORT V2--- ${device.displayName} parameter ${cmd.parameterNumber} with a byte size of ${cmd.size} is set to ${cmd.configurationValue}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.configurationv1.ConfigurationReport cmd) {\n    if (state.debug) log.debug \"---CONFIGURATION REPORT V1--- ${device.displayName} parameter ${cmd.parameterNumber} with a byte size of ${cmd.size} is set to ${cmd.configurationValue}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.batteryv1.BatteryReport cmd) {\n\tif (state.debug) log.debug \"---BATTERY V1 REPORT--- ${device.displayName} reports battery level of ${cmd.batteryLevel}\"\n\tdef result = []\n\tdef map = [ name: \"battery\", unit: \"%\" ]\n\tif (cmd.batteryLevel == 0xFF) {\n\t\tmap.value = 1\n\t\tmap.descriptionText = \"${device.displayName} battery is low\"\n\t\tmap.isStateChange = true\n\t} else {\n\t\tmap.value = cmd.batteryLevel\n\t\tmap.descriptionText = \"${device.displayName} battery is at ${cmd.batteryLevel}\"\n\t\tmap.isStateChange = true\n\t}\n\tstate.lastbatt = now()\n\tresult << createEvent(map)\n\tresult\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.sensormultilevelv5.SensorMultilevelReport cmd)\n{\n\tdef map = [:]\n\tswitch (cmd.sensorType) {\n\t\tcase 1:\n\t\t\tmap.name = \"temperature\"\n\t\t\tdef cmdScale = cmd.scale == 1 ? \"F\" : \"C\"\n\t\t\tmap.value = convertTemperatureIfNeeded(cmd.scaledSensorValue, cmdScale, cmd.precision)\n\t\t\tmap.unit = getTemperatureScale()\n\t\t\tbreak;\n\t\tcase 3:\n\t\t\tmap.name = \"illuminance\"\n\t\t\tmap.value = cmd.scaledSensorValue\n\t\t\tmap.unit = \"lux\"\n\t\t\tbreak;\n        case 5:\n\t\t\tmap.name = \"humidity\"\n\t\t\tmap.value = cmd.scaledSensorValue.toInteger()\n\t\t\tmap.unit = \"%\"\n\t\t\tbreak;\n\t\tcase 27:\n        \tmap.name = \"ultravioletIndex\"\n            map.value = cmd.scaledSensorValue.toInteger()\n            break;\n\t\tdefault:\n\t\t\tmap.descriptionText = cmd.toString()\n\t}\n\tcreateEvent(map)\n}\n\ndef motionEvent(value) {\n\tdef map = [name: \"motion\"]\n\tif (value) {\n\t\tmap.value = \"active\"\n\t\tmap.descriptionText = \"$device.displayName detected motion\"\n\t} else {\n\t\tmap.value = \"inactive\"\n\t\tmap.descriptionText = \"$device.displayName motion has stopped\"\n\t}\n\tcreateEvent(map)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.sensorbinaryv2.SensorBinaryReport cmd) {\n\tsetConfigured()\n\tmotionEvent(cmd.sensorValue)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicSet cmd) {\n\tmotionEvent(cmd.value)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.notificationv3.NotificationReport cmd) {\n\tdef result = []\n\tif (cmd.notificationType == 7) {\n\t\tswitch (cmd.event) {\n\t\t\tcase 0:\n\t\t\t\tresult << motionEvent(0)\n\t\t\t\tresult << createEvent(name: \"acceleration\", value: \"inactive\", descriptionText: \"$device.displayName tamper cleared\")\n\t\t\t\tbreak\n\t\t\tcase 3:\n\t\t\t\tresult << createEvent(name: \"acceleration\", value: \"active\", descriptionText: \"$device.displayName was moved\")\n\t\t\t\tbreak\n\t\t\tcase 7:\n\t\t\t\tresult << motionEvent(1)\n\t\t\t\tbreak\n\t\t}\n\t} else {\n\t\tresult << createEvent(descriptionText: cmd.toString(), isStateChange: false)\n\t}\n\tresult\n}\n\ndef zwaveEvent(physicalgraph.zwave.Command cmd) {\n\tcreateEvent(descriptionText: cmd.toString(), isStateChange: false)\n}\n\ndef configure() {\n\t// This sensor joins as a secure device if you double-click the button to include it\n\t//if (device.device.rawDescription =~ /98/ && !state.sec) {\n\t//\tif (state.debug) log.debug \"Multi 6 not sending configure until secure\"\n\t//\treturn []\n\t//}\n\tif (state.debug) log.debug \"--Sending configuration command to Multisensor 6--\"\n    if (state.debug) log.debug \"Prefernces settings: PIRsensitivity: $PIRsensitivity, Reporting Interval: $ReportingInterval, Temp offset: $tempoffset, Humidity offset: $humidityoffset, Luminance offset: $luminanceoffset, UV offset: $ultravioletoffset\"\n\t\n\tdef PIRsens = 1\n\tif (PIRsensitivity) {\n\t\tPIRsens=PIRsensitivity.toInteger()\n\t}\n    def MotionRst = 20\n\tif (MotionReset) {\n\t\tMotionRst=MotionReset.toInteger()\n\t}\n\tdef ReportingInt = 300\n\tif (ReportingInterval) {\n\t\tReportingInt=ReportingInterval.toInteger()\n\t}\n\tdef tempoff = 0\n\tif (tempoffset) {\n\t\ttempoff=tempoffset*10\n\t}\n\tdef humidityoff = 0\n\tif (humidityoffset) {\n\t\thumidityoff=humidityoffset\n\t}\n\tdef luminanceoff = 0\n\tif (luminanceoffset) {\n\t\tluminanceoff=luminanceoffset\n\t}\n\tdef ultravioletoff = 0\n\tif (ultravioletoffset) {\n\t\tultravioletoff=ultravioletoffset\n\t}\n    if (state.debug) \tlog.debug \"settings: ${settings.inspect()}, state: ${state.inspect()}\"\n\tdef request = [\n\t\t// set wakeup interval to 5 mins\n\t\tzwave.wakeUpV1.wakeUpIntervalSet(seconds:300, nodeid:zwaveHubNodeId),\n\t\t\n\t\t// Get Version information\n        zwave.versionV1.versionGet(),\n        zwave.firmwareUpdateMdV2.firmwareMdGet(),\n\n\t\t// send temperature, humidity, illuminance, ultraviolet based on reporting interval preference default 5 mins\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x65, size: 4, scaledConfigurationValue: 128|64|32|16),\n\t\t\n\t\t// configure frequency of reporting \n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x6F,size: 4, scaledConfigurationValue: ReportingInt),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0x6F),\n    \t\n\t\t// send battery every 20 hours\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x66, size: 4, scaledConfigurationValue: 1),\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x70, size: 4, scaledConfigurationValue: 20*60*60),\n\t\t\n        // send no-motion report 20 seconds after motion stops\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x03, size: 2, scaledConfigurationValue: MotionRst),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0x03),\n    \t\n\t\t// enable motion sensor and set sensitivity\n        zwave.configurationV1.configurationSet(parameterNumber: 0x04, size: 1, scaledConfigurationValue: PIRsens),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0x04),\n    \t\n\t\t// send binary sensor report for motion\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x05, size: 1, scaledConfigurationValue: 2),\n\t\t\n\t\t// Enable the function of touch sensor\n        zwave.configurationV1.configurationSet(parameterNumber: 0x07, size: 1, scaledConfigurationValue: 1),\n\t\t\n\t\t// disable notification-style motion events\n\t\t// zwave.notificationV3.notificationSet(notificationType: 7, notificationStatus: 0),\n\t\t\n        // configure temp offset\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0xC9, size: 1, scaledConfigurationValue: tempoff),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0xC9),\n\t\t\n        // configure humidity offset\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0xCA, size: 1, scaledConfigurationValue: humidityoff),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0xCA),\n\t\t\n        // configure luminance offset\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0xCB, size: 2, scaledConfigurationValue: luminanceoff),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0xCB),\n\t\t\n        // configure ultraviolet offset\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0xCC, size: 1, scaledConfigurationValue: ultravioletoff), \n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0xCC),\n        \n\t\tzwave.batteryV1.batteryGet(),\n\t\tzwave.sensorBinaryV2.sensorBinaryGet(),\n        \n\t\t// Can use the zwaveHubNodeId variable to add the hub to the device's associations:\n\t\tzwave.associationV1.associationSet(groupingIdentifier:2, nodeId:zwaveHubNodeId)\n    ]\n\tcommands(request) + [\"delay 20000\", zwave.wakeUpV1.wakeUpNoMoreInformation().format()]\n}\n\nprivate setConfigured() {\n\tupdateDataValue(\"configured\", \"true\")\n}\n\nprivate isConfigured() {\n\tgetDataValue(\"configured\") == \"true\"\n}\n\nprivate command(physicalgraph.zwave.Command cmd) {\n\tif (state.sec) {\n\t\tzwave.securityV1.securityMessageEncapsulation().encapsulate(cmd).format()\n\t} else {\n\t\tcmd.format()\n\t}\n}\n\nprivate commands(commands, delay=1000) {\n\tdelayBetween(commands.collect{ command(it) }, delay)\n}"
  },
  {
    "path": "Aeon SmartDimmer 6/device_type-aeon-smartdimmer6-v0.1",
    "content": "/*\n * V 0.1 of Aeon Smart Dimmer 6 code 10/6/2015\n *  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except\n *  in compliance with the License. You may obtain a copy of the License at:\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n *  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed\n *  on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License\n *  for the specific language governing permissions and limitations under the License.\n *\n * some code used from various SmartThings device type and metering code from ElasticDev\n *\n*/\n\n metadata {\n\tdefinition (name: \"Aeon Smart Dimmer 6 - RV v0.1\", namespace: \"robertvandervoort\", author: \"Robert Vandervoort\") {\n\t\tcapability \"Energy Meter\"\n\t\tcapability \"Power Meter\"\n\t\tcapability \"Actuator\"\n\t\tcapability \"Switch\"\n\t\tcapability \"Switch Level\"\n        capability \"Color Control\"\n\t\tcapability \"Configuration\"\n\t\tcapability \"Polling\"\n\t\tcapability \"Refresh\"\n\t\tcapability \"Sensor\"\n\n\t\tcommand \"reset\"\n\n\t\t/* Capability notes\n\t\t0x26 COMMAND_CLASS_SWITCH_MULTILEVEL 2\n        0x27 COMMAND_CLASS_SWITCH_ALL 1\n        0x32 COMMAND_CLASS_METER 3\n        0x33 COMMAND_CLASS_COLOR_SWITCH 3\n\t\t0x59 COMMAND_CLASS_ASSOCIATION_GRP_INFO  1\n\t\t0x5A COMMAND_CLASS_DEVICE_RESET_LOCALLY 1\n\t\t0x5E COMMAND_CLASS_ZWAVE_PLUS_INFO 2\n\t\t0x60 Multi Channel Command Class (V3)\n\t\t0x70 COMMAND_CLASS_CONFIGURATION 1\n        0x72 COMMAND_CLASS_MANUFACTURER_SPECIFIC 2\n        0x73 COMMAND_CLASS_POWERLEVEL 1\n\t\t0x7A COMMAND_CLASS_FIRMWARE_UPDATE_MD 2\n\t\t0x81 COMMAND_CLASS_CLOCK 1\n        0x82 COMMAND_CLASS_HAIL 1\n\t\t0x8E COMMAND_CLASS_MULTI_INSTANCE_ASSOCIATION 2\n        0x85 COMMAND_CLASS_ASSOCIATION 2\n        0x86 COMMAND_CLASS_VERSION 2\n\t\t0xEF COMMAND_CLASS_MARK 1\n        */\n\n\t\tfingerprint deviceId: \"0x1101\", inClusters: \"0x98\"\n        fingerprint inClusters: \"0x26,0x27,0x32,0x33,0x59,0x5A,0x5E,0x60,0x70,0x72,0x73,0x7A,0x81,0x8E,0x85,0x86,0xEF\", outClusters: \"0x82\"\n\t}\n\t// simulator metadata\n\tsimulator {\n\t\tstatus \"on\":  \"command: 2603, payload: FF\"\n\t\tstatus \"off\": \"command: 2603, payload: 00\"\n\t\tstatus \"09%\": \"command: 2603, payload: 09\"\n\t\tstatus \"10%\": \"command: 2603, payload: 0A\"\n\t\tstatus \"33%\": \"command: 2603, payload: 21\"\n\t\tstatus \"66%\": \"command: 2603, payload: 42\"\n\t\tstatus \"99%\": \"command: 2603, payload: 63\"\n\n\tfor (int i = 0; i <= 10000; i += 1000) {\n\t    status \"power  ${i} W\": \n\t\t    new physicalgraph.zwave.Zwave().meterV3.meterReport(scaledMeterValue: i, precision: 3, meterType: 4, scale: 2, size: 4).incomingMessage()\n\t}\n\tfor (int i = 0; i <= 100; i += 10) {\n\t    status \"energy  ${i} kWh\":\n\t\t    new physicalgraph.zwave.Zwave().meterV3.meterReport(scaledMeterValue: i, precision: 3, meterType: 0, scale: 0, size: 4).incomingMessage()\n\t}\n\t// reply messages\n\t[\"FF\", \"00\", \"09\", \"0A\", \"21\", \"42\", \"63\"].each { val -> reply \"2001$val,delay 100,2602\": \"command: 2603, payload: $val\" }\n}\n\t// tile definitions\n\ttiles (scale: 2) {\n    \tmultiAttributeTile(name:\"main\", type:\"lighting\", width:6, height:4, canChangeIcon: true) {\n\t\t\ttileAttribute(\"device.switch\", key: \"PRIMARY_CONTROL\") {\n            \tattributeState \"on\", label: '${name}', action: \"switch.off\", icon: \"st.switches.switch.on\", backgroundColor: \"#00a0dc\"\n\t\t\t\tattributeState \"off\", label: '${name}', action: \"switch.on\", icon: \"st.switches.switch.off\", backgroundColor: \"#ffffff\"\n            }\n\t\t\ttileAttribute (\"device.level\", key: \"SLIDER_CONTROL\") {\n\t\t\t\tattributeState \"level\", action:\"switch level.setLevel\"\n\t\t\t}\n            tileAttribute(\"device.power\", key: \"SECONDARY_CONTROL\") {\n                attributeState \"default\",label:'${currentValue} W'\n            }\n\t\t}\n\t\tvalueTile(\"energy\", \"device.energy\", decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'${currentValue} kWh', action:\"poll\"\n\t\t}\n\t\tvalueTile(\"current\", \"device.current\", decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'${currentValue} A', action:\"poll\"\n\t\t}\n        valueTile(\"voltage\", \"device.voltage\", decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'${currentValue} V', action:\"poll\"\n\t\t}\n        controlTile(\"rgbSelector\", \"device.color\", \"color\", height: 2, width: 2, inactiveLabel: false) {\n\t\t\tstate \"color\", action:\"setColor\"\n\t\t}\n\t\tstandardTile(\"reset\", \"device.energy\", inactiveLabel: false, decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'reset kWh', action:\"reset\"\n\t\t}\n\t\tstandardTile(\"configure\", \"device.power\", inactiveLabel: false, decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"configure\", label:'', action:\"configuration.configure\", icon:\"st.secondary.configure\"\n\t\t}\n\t\tstandardTile(\"refresh\", \"device.power\", inactiveLabel: false, decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'', action:\"refresh.refresh\", icon:\"st.secondary.refresh\"\n\t\t}\n\t\tmain \"main\",\"energy\",\"current\",\"voltage\"\n\t\tdetails([\"main\",\"energy\",\"current\",\"voltage\",\"rgbSelector\",\"reset\",\"refresh\",\"configure\"])\n\t}\n\t\n    preferences { \n\t\tinput \"ledBehavior\", \"integer\", \n\t\t\ttitle: \"LED Behavior\",\n            description: \"0=energy tracking, 1=momentary status, 2=night light\",\n\t\t\tdefaultValue: 0, \n\t\t\tdisplayDuringSetup: true,\n            range: \"0..2\"\n\t\tinput \"monitorInterval\", \"integer\", \n\t\t\ttitle: \"Monitoring Interval\", \n\t\t\tdescription: \"The time interval in seconds for sending device reports\", \n\t\t\tdefaultValue: 60, \n            range: \"1..4294967295‬\",\n\t\t\trequired: false, \n\t\t\tdisplayDuringSetup: true\n\t\tinput \"ledBrightness\", \"integer\",\n        \ttitle: \"LED Brightness\",\n            description: \"Set the % brightness of indicator LEDs\",\n            defaultValue: 50,\n            range: \"0..100\",\n            required: false,\n            displayduringSetup: true\n\t\tinput \"debugOutput\", \"boolean\", \n\t\t\ttitle: \"Enable debug logging?\",\n\t\t\tdefaultValue: false,\n\t\t\tdisplayDuringSetup: true\n\t}\n}\n\ndef updated()\n{\n\tstate.debug = (\"true\" == debugOutput)\n\tif (state.sec && !isConfigured()) {\n\t\t// in case we miss the SCSR\n\t\tresponse(configure())\n\t\t\n\t}\n}\n\ndef parse(String description)\n{\n\tdef result = null\n\tif (description.startsWith(\"Err 106\")) {\n\t\tstate.sec = 0\n\t\tresult = createEvent( name: \"secureInclusion\", value: \"failed\", isStateChange: true,\n\t\t\tdescriptionText: \"This sensor failed to complete the network security key exchange. If you are unable to control it via SmartThings, you must remove it from your network and add it again.\")\n\t} else if (description != \"updated\") {\n\t\tdef cmd = zwave.parse(description, [0x25: 1, 0x26: 1, 0x27: 1, 0x32: 3, 0x33: 3, 0x59: 1, 0x70: 1, 0x72: 2, 0x73: 1, 0x82: 1, 0x85: 2, 0x86: 2])\n\t\tif (cmd) {\n\t\t\tresult = zwaveEvent(cmd)\n\t\t}\n\t}\n\t// if (state.debug) log.debug \"Parsed '${description}' to ${result.inspect()}\"\n\treturn result\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.securityv1.SecurityMessageEncapsulation cmd) {\n\tdef encapsulatedCommand = cmd.encapsulatedCommand([0x25: 1, 0x26: 1, 0x27: 1, 0x32: 3, 0x33: 3, 0x59: 1, 0x70: 1, 0x72: 2, 0x73: 1, 0x82: 1, 0x85: 2, 0x86: 2])\n\tstate.sec = 1\n\tif (state.debug) log.debug \"encapsulated: ${encapsulatedCommand}\"\n\tif (encapsulatedCommand) {\n\t\tzwaveEvent(encapsulatedCommand)\n\t} else {\n\t\tlog.warn \"Unable to extract encapsulated cmd from $cmd\"\n\t\tcreateEvent(descriptionText: cmd.toString())\n\t}\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.securityv1.SecurityCommandsSupportedReport cmd) {\n\tresponse(configure())\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.powerlevelv1.PowerlevelTestNodeReport cmd) {\n\tif (state.debug) log.debug \"===Power level test node report received=== ${device.displayName}: statusOfOperation: ${cmd.statusOfOperation} testFrameCount: ${cmd.testFrameCount} testNodeid: ${cmd.testNodeid}\"\n\tdef request = [\n        physicalgraph.zwave.commands.powerlevelv1.PowerlevelGet()\n    ]\n    response(commands(request))\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.configurationv2.ConfigurationReport cmd) {\n    if (state.debug) log.debug \"---CONFIGURATION REPORT V2--- ${device.displayName} parameter ${cmd.parameterNumber} with a byte size of ${cmd.size} is set to ${cmd.configurationValue}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.configurationv1.ConfigurationReport cmd) {\n    if (state.debug) log.debug \"---CONFIGURATION REPORT V1--- ${device.displayName} parameter ${cmd.parameterNumber} with a byte size of ${cmd.size} is set to ${cmd.configurationValue}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.meterv3.MeterReport cmd) {\n    def meterTypes = [\"Unknown\", \"Electric\", \"Gas\", \"Water\"]\n    def electricNames = [\"energy\", \"energy\", \"power\", \"count\",  \"voltage\", \"current\", \"powerFactor\",  \"unknown\"]\n    def electricUnits = [\"kWh\",    \"kVAh\",   \"W\",     \"pulses\", \"V\",       \"A\",       \"Power Factor\", \"\"]\n\n    //NOTE ScaledPreviousMeterValue does not always contain a value\n    def previousValue = cmd.scaledPreviousMeterValue ?: 0\n\n    def map = [ name: electricNames[cmd.scale], unit: electricUnits[cmd.scale], displayed: state.display]\n    switch(cmd.scale) {\n        case 0: //kWh\n\t    previousValue = device.currentValue(\"energy\") ?: cmd.scaledPreviousMeterValue ?: 0\n            map.value = cmd.scaledMeterValue\n            break;\n        case 1: //kVAh\n            map.value = cmd.scaledMeterValue\n            break;\n        case 2: //Watts\n            previousValue = device.currentValue(\"power\") ?: cmd.scaledPreviousMeterValue ?: 0\n            map.value = Math.round(cmd.scaledMeterValue)\n            break;\n        case 3: //pulses\n            map.value = Math.round(cmd.scaledMeterValue)\n            break;\n        case 4: //Volts\n            previousValue = device.currentValue(\"voltage\") ?: cmd.scaledPreviousMeterValue ?: 0\n            map.value = cmd.scaledMeterValue\n            break;\n        case 5: //Amps\n            previousValue = device.currentValue(\"current\") ?: cmd.scaledPreviousMeterValue ?: 0\n            map.value = cmd.scaledMeterValue\n            break;\n        case 6: //Power Factor\n            previousValue = device.currentValue(\"powerFactor\") ?: cmd.scaledPreviousMeterValue ?: 0\n            map.value = cmd.scaledMeterValue\n            break;\n        case 7: //Unknown\n            map.value = cmd.scaledMeterValue\n            break;\n        default:\n            break;\n    }\n    //Check if the value has changed by more than 5%, if so mark as a stateChange\n    //map.isStateChange = ((cmd.scaledMeterValue - previousValue).abs() > (cmd.scaledMeterValue * 0.05))\n\n    createEvent(map)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicReport cmd)\n{\n\t[name: \"switch\", value: cmd.value ? \"on\" : \"off\", type: \"physical\", displayed: true, isStateChange: true]\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicSet cmd) \n{\n    [name: \"switch\", value: cmd.value ? \"on\" : \"off\", type: \"physical\", displayed: true, isStateChange: true]\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.switchbinaryv1.SwitchBinaryReport cmd)\n{\n\t[name: \"switch\", value: cmd.value ? \"on\" : \"off\", type: \"digital\", displayed: true, isStateChange: true]\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.switchmultilevelv1.SwitchMultilevelReport cmd)\n{\n\t[name: \"level\", value: cmd.value, type: \"digital\", displayed: true, isStateChange: true]\n}\n\t\ndef zwaveEvent(physicalgraph.zwave.commands.switchbinaryv1.SwitchBinarySet cmd)\n{\n    [name: \"switch\", value: cmd.value ? \"on\" : \"off\", type: \"digital\", displayed: true, isStateChange: true]\n}\n\ndef zwaveEvent(physicalgraph.zwave.Command cmd) {\n\tif (state.debug) log.debug \"Unhandled: $cmd sent to ${device.displayName}\"\n    createEvent(descriptionText: cmd.toString(), isStateChange: false)\n}\n\ndef on() {\n\tif (state.debug) log.debug \"turning on ${device.displayName}\"\n\tdef request = [\n\t\tzwave.basicV1.basicSet(value: 0xFF),\n\t    zwave.basicV1.basicGet(),\n\t\tzwave.switchBinaryV1.switchBinaryGet(),\n\t\tzwave.switchMultilevelV1.switchMultilevelGet()\n\t]\n    commands(request)\n}\n\ndef off() {\n\tif (state.debug) log.debug \"turning off ${device.displayName}\"\n\tdef request = [\n\t\tzwave.basicV1.basicSet(value: 0x00),\n        zwave.basicV1.basicGet(),\n\t\tzwave.switchBinaryV1.switchBinaryGet(),\n\t\tzwave.switchMultilevelV1.switchMultilevelGet()\n\t]\n    commands(request)\n}\n\ndef setLevel(value) {\n\tif (state.debug) log.debug \"setting level to ${value} on ${device.displayName}\"\n\tdef valueaux = value as Integer\n\tdef level = Math.min(valueaux, 99)\n\tdef request = [\n\t\tzwave.basicV1.basicSet(value: level),\n\t\tzwave.switchMultilevelV1.switchMultilevelGet()\n\t\t]\n\tcommands(request)\t\n}\n\ndef setLevel(value, duration) {\n\tdef valueaux = value as Integer\n\tdef level = Math.min(valueaux, 99)\n\tdef dimmingDuration = duration < 128 ? duration : 128 + Math.round(duration / 60)\n\tdef request = [\n\t\tzwave.switchMultilevelV2.switchMultilevelSet(value: level, dimmingDuration: dimmingDuration)\n\t\t]\n\tcommands(request)\t\n}\n\ndef setColor(value) {\n\tdef result = []\n\tif (state.debug) log.debug \"setColor: ${value}\"\n\tif (value.hex) {\n\t\tdef c = value.hex.findAll(/[0-9a-fA-F]{2}/).collect { Integer.parseInt(it, 16) }\n        result << zwave.configurationV1.configurationSet(parameterNumber: 83, size: 3, configurationValue: [c[0], c[1], c[2]])\n\t}\n\tif(value.hex) sendEvent(name: \"color\", value: value.hex)\n    commands(result)\n}\n\ndef poll() {\n\tif (state.debug) log.debug \"poll request sent to ${device.displayName}\"\n\tdef request = [\n\t\tzwave.switchBinaryV1.switchBinaryGet(),\n        zwave.basicV1.basicGet(),\n\t\tzwave.switchMultilevelV1.switchMultilevelGet(),\n\t\tzwave.meterV3.meterGet(scale: 0),\t//kWh\n        zwave.meterV3.meterGet(scale: 1),\t//kVAh\n\t\tzwave.meterV3.meterGet(scale: 2),\t//Wattage\n\t\tzwave.meterV3.meterGet(scale: 4),\t//Volts\n\t\tzwave.meterV3.meterGet(scale: 5),\t//Amps\n        zwave.meterV3.meterGet(scale: 6)\t//Power Factor\n\t]\n    commands(request)\n}\n\ndef refresh() {\n\tif (state.debug) log.debug \"refresh request sent to ${device.displayName}\"\n\tdef request = [\n        zwave.basicV1.basicGet(),\n\t\tzwave.switchMultilevelV1.switchMultilevelGet(),\n\t\tzwave.switchBinaryV1.switchBinaryGet()\n\t]\n    commands(request)\n}\n\ndef reset() {\n\tif (state.debug) log.debug \"reset request sent to ${device.displayName}\"\n\tdef request = [\n\t\tzwave.meterV3.meterReset(),\n\t\tzwave.meterV3.meterGet(scale: 0),\t//kWh\n        zwave.meterV3.meterGet(scale: 1),\t//kVAh\n\t\tzwave.meterV3.meterGet(scale: 2),\t//Wattage\n\t\tzwave.meterV3.meterGet(scale: 4),\t//Volts\n\t\tzwave.meterV3.meterGet(scale: 5),\t//Amps\n        zwave.meterV3.meterGet(scale: 6)\t//Power Factor\n\t]\n    commands(request)\n}\n\ndef configure() {\n\tif (state.debug) {\n    \tif (state.sec) {\n        \tlog.debug \"secure configuration being sent to ${device.displayName}\"\n            }\n        else\n        \tif (state.debug) log.debug \"configuration being sent to ${device.displayName}\"\n\t\t}            \n    def monitorInt = 60\n\t\tif (monitorInterval) {\n\t\t\tmonitorInt=monitorInterval.toInteger()\n\t\t}\n\tdef ledBehave = 0\n    \tif (ledBehavior) {\n        \tledBehave=ledBehavior.toInteger()\n        }\n\tdef ledBright = 50\n    \tif (ledBrightness) {\n        \tledBright=ledBrightness.toInteger()\n\t\t}\n    if (state.debug) log.debug \"Sending configure commands - monitorInterval '${monitorInt}', ledBehavior '${ledBehave}'\"\n\tdef request = [\n    \t// Reset switch configuration to defaults\n        // zwave.configurationV1.configurationSet(parameterNumber: 255, size: 1, scaledConfigurationValue: 1),\n\t\t// Enable to send notifications to associated devices (Group 1) when the state of Micro Switch’s load changed (0=nothing, 1=hail CC, 2=basic CC report)\n        zwave.configurationV1.configurationSet(parameterNumber: 80, size: 1, configurationValue: [2]),\n        // set LED behavior 0 energy mode 1 momentary display 2 night light\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 81, size: 1, scaledConfigurationValue: ledBehave),\n\t\t// Set LED brightness\n        zwave.configurationV1.configurationSet(parameterNumber: 84, size: 3, configurationValue: [ledBright,ledBright,ledBright]),\n        // Which reports need to send in Report group 1\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 101, size: 4, scaledConfigurationValue: 4|2|1),\n\t\t// Which reports need to send in Report group 2\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 102, size: 4, scaledConfigurationValue: 8),\n\t\t// Which reports need to send in Report group 3\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 103, size: 4, scaledConfigurationValue: 0),\n\t\t// Interval to send Report group 1\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 111, size: 4, scaledConfigurationValue: monitorInt),\n\t\t// Interval to send Report group 2\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 112, size: 4, scaledConfigurationValue: 60),\n\t\t// Interval to send Report group 3\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 113, size: 4, scaledConfigurationValue: 0),\n        \n        // get notification behavior\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 80),\n\t\t// get LED behavior\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 81),\n    \t// get night light RGB value\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 83),\n    \t// get Energy Mode/momentary indicate LED brightness value\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 84),\n    \t// Which reports need to send in Report group 1\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 101),\n\t\t// Which reports need to send in Report group 2\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 102),\n\t\t// Which reports need to send in Report group 3\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 103),\n    \t// Interval to send Report group 1\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 111),\n\t\t// Interval to send Report group 2\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 112),\n\t\t// Interval to send Report group 3\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 113),\n\t\t\n\t\t// Can use the zwaveHubNodeId variable to add the hub to the device's associations:\n\t\tzwave.associationV1.associationSet(groupingIdentifier:2, nodeId:zwaveHubNodeId)\n    ]\n\tcommands(request)\n}\n\nprivate setConfigured() {\n\tupdateDataValue(\"configured\", \"true\")\n}\n\nprivate isConfigured() {\n\tgetDataValue(\"configured\") == \"true\"\n}\n\nprivate command(physicalgraph.zwave.Command cmd) {\n\tif (state.sec) {\n\t\tzwave.securityV1.securityMessageEncapsulation().encapsulate(cmd).format()\n\t} else {\n\t\tcmd.format()\n\t}\n}\n\nprivate commands(commands, delay=500) {\n\tdelayBetween(commands.collect{ command(it) }, delay)\n}"
  },
  {
    "path": "Aeon SmartDimmer 6/device_type-aeon-smartdimmer6-v0.1-ANDROID",
    "content": "/*\n * V 0.1 of Aeon Smart Dimmer 6 code 10/6/2015\n *  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except\n *  in compliance with the License. You may obtain a copy of the License at:\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n *  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed\n *  on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License\n *  for the specific language governing permissions and limitations under the License.\n *\n * some code used from various SmartThings device type and metering code from ElasticDev\n *\n * ANDROID - Thanks Jeff_Pollock and RBoy for pointing out the Range values bug in Android helping to get this workign on Android OS\n*/\n\n metadata {\n\tdefinition (name: \"Aeon Smart Dimmer 6 - RV v0.1\", namespace: \"robertvandervoort\", author: \"Robert Vandervoort\") {\n\t\tcapability \"Energy Meter\"\n\t\tcapability \"Power Meter\"\n\t\tcapability \"Actuator\"\n\t\tcapability \"Switch\"\n\t\tcapability \"Switch Level\"\n        capability \"Color Control\"\n\t\tcapability \"Configuration\"\n\t\tcapability \"Polling\"\n\t\tcapability \"Refresh\"\n\t\tcapability \"Sensor\"\n\n\t\tcommand \"reset\"\n\n\t\t/* Capability notes\n\t\t0x26 COMMAND_CLASS_SWITCH_MULTILEVEL 2\n        0x27 COMMAND_CLASS_SWITCH_ALL 1\n        0x32 COMMAND_CLASS_METER 3\n        0x33 COMMAND_CLASS_COLOR_SWITCH 3\n\t\t0x59 COMMAND_CLASS_ASSOCIATION_GRP_INFO  1\n\t\t0x5A COMMAND_CLASS_DEVICE_RESET_LOCALLY 1\n\t\t0x5E COMMAND_CLASS_ZWAVE_PLUS_INFO 2\n\t\t0x60 Multi Channel Command Class (V3)\n\t\t0x70 COMMAND_CLASS_CONFIGURATION 1\n        0x72 COMMAND_CLASS_MANUFACTURER_SPECIFIC 2\n        0x73 COMMAND_CLASS_POWERLEVEL 1\n\t\t0x7A COMMAND_CLASS_FIRMWARE_UPDATE_MD 2\n\t\t0x81 COMMAND_CLASS_CLOCK 1\n        0x82 COMMAND_CLASS_HAIL 1\n\t\t0x8E COMMAND_CLASS_MULTI_INSTANCE_ASSOCIATION 2\n        0x85 COMMAND_CLASS_ASSOCIATION 2\n        0x86 COMMAND_CLASS_VERSION 2\n\t\t0xEF COMMAND_CLASS_MARK 1\n        */\n\n\t\tfingerprint deviceId: \"0x1101\", inClusters: \"0x98\"\n        fingerprint inClusters: \"0x26,0x27,0x32,0x33,0x59,0x5A,0x5E,0x60,0x70,0x72,0x73,0x7A,0x81,0x8E,0x85,0x86,0xEF\", outClusters: \"0x82\"\n\t}\n\t// simulator metadata\n\tsimulator {\n\t\tstatus \"on\":  \"command: 2603, payload: FF\"\n\t\tstatus \"off\": \"command: 2603, payload: 00\"\n\t\tstatus \"09%\": \"command: 2603, payload: 09\"\n\t\tstatus \"10%\": \"command: 2603, payload: 0A\"\n\t\tstatus \"33%\": \"command: 2603, payload: 21\"\n\t\tstatus \"66%\": \"command: 2603, payload: 42\"\n\t\tstatus \"99%\": \"command: 2603, payload: 63\"\n\n\tfor (int i = 0; i <= 10000; i += 1000) {\n\t    status \"power  ${i} W\": \n\t\t    new physicalgraph.zwave.Zwave().meterV3.meterReport(scaledMeterValue: i, precision: 3, meterType: 4, scale: 2, size: 4).incomingMessage()\n\t}\n\tfor (int i = 0; i <= 100; i += 10) {\n\t    status \"energy  ${i} kWh\":\n\t\t    new physicalgraph.zwave.Zwave().meterV3.meterReport(scaledMeterValue: i, precision: 3, meterType: 0, scale: 0, size: 4).incomingMessage()\n\t}\n\t// reply messages\n\t[\"FF\", \"00\", \"09\", \"0A\", \"21\", \"42\", \"63\"].each { val -> reply \"2001$val,delay 100,2602\": \"command: 2603, payload: $val\" }\n}\n\t// tile definitions\n\ttiles (scale: 2) {\n    \tmultiAttributeTile(name:\"main\", type:\"lighting\", width:6, height:4, canChangeIcon: true) {\n\t\t\ttileAttribute(\"device.switch\", key: \"PRIMARY_CONTROL\") {\n            \tattributeState \"on\", label: '${name}', action: \"switch.off\", icon: \"st.switches.switch.on\", backgroundColor: \"#00a0dc\"\n\t\t\t\tattributeState \"off\", label: '${name}', action: \"switch.on\", icon: \"st.switches.switch.off\", backgroundColor: \"#ffffff\"\n            }\n\t\t\ttileAttribute (\"device.level\", key: \"SLIDER_CONTROL\") {\n\t\t\t\tattributeState \"level\", action:\"switch level.setLevel\"\n\t\t\t}\n            tileAttribute(\"device.power\", key: \"SECONDARY_CONTROL\") {\n                attributeState \"default\",label:'${currentValue} W'\n            }\n\t\t}\n\t\tvalueTile(\"energy\", \"device.energy\", decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'${currentValue} kWh', action:\"poll\"\n\t\t}\n\t\tvalueTile(\"current\", \"device.current\", decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'${currentValue} A', action:\"poll\"\n\t\t}\n        valueTile(\"voltage\", \"device.voltage\", decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'${currentValue} V', action:\"poll\"\n\t\t}\n        controlTile(\"rgbSelector\", \"device.color\", \"color\", height: 2, width: 2, inactiveLabel: false) {\n\t\t\tstate \"color\", action:\"setColor\"\n\t\t}\n\t\tstandardTile(\"reset\", \"device.energy\", inactiveLabel: false, decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'reset kWh', action:\"reset\"\n\t\t}\n\t\tstandardTile(\"configure\", \"device.power\", inactiveLabel: false, decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"configure\", label:'', action:\"configuration.configure\", icon:\"st.secondary.configure\"\n\t\t}\n\t\tstandardTile(\"refresh\", \"device.power\", inactiveLabel: false, decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'', action:\"refresh.refresh\", icon:\"st.secondary.refresh\"\n\t\t}\n\t\tmain \"main\",\"energy\",\"current\",\"voltage\"\n\t\tdetails([\"main\",\"energy\",\"current\",\"voltage\",\"rgbSelector\",\"reset\",\"refresh\",\"configure\"])\n\t}\n\t\n    preferences { \n\t\tinput \"ledBehavior\", \"integer\", \n\t\t\ttitle: \"LED Behavior\",\n            description: \"0=energy tracking, 1=momentary status, 2=night light\",\n\t\t\tdefaultValue: 0, \n\t\t\tdisplayDuringSetup: true\n\t\tinput \"monitorInterval\", \"integer\", \n\t\t\ttitle: \"Monitoring Interval\", \n\t\t\tdescription: \"The time interval in seconds for sending device reports\", \n\t\t\tdefaultValue: 60, \n\t\t\trequired: false, \n\t\t\tdisplayDuringSetup: true\n\t\tinput \"ledBrightness\", \"integer\",\n        \ttitle: \"LED Brightness\",\n            description: \"Set the % brightness of indicator LEDs\",\n            defaultValue: 50,\n            required: false,\n            displayduringSetup: true\n\t\tinput \"debugOutput\", \"boolean\", \n\t\t\ttitle: \"Enable debug logging?\",\n\t\t\tdefaultValue: false,\n\t\t\tdisplayDuringSetup: true\n\t}\n}\n\ndef updated()\n{\n\tstate.debug = (\"true\" == debugOutput)\n\tif (state.sec && !isConfigured()) {\n\t\t// in case we miss the SCSR\n\t\tresponse(configure())\n\t\t\n\t}\n}\n\ndef parse(String description)\n{\n\tdef result = null\n\tif (description.startsWith(\"Err 106\")) {\n\t\tstate.sec = 0\n\t\tresult = createEvent( name: \"secureInclusion\", value: \"failed\", isStateChange: true,\n\t\t\tdescriptionText: \"This sensor failed to complete the network security key exchange. If you are unable to control it via SmartThings, you must remove it from your network and add it again.\")\n\t} else if (description != \"updated\") {\n\t\tdef cmd = zwave.parse(description, [0x25: 1, 0x26: 1, 0x27: 1, 0x32: 3, 0x33: 3, 0x59: 1, 0x70: 1, 0x72: 2, 0x73: 1, 0x82: 1, 0x85: 2, 0x86: 2])\n\t\tif (cmd) {\n\t\t\tresult = zwaveEvent(cmd)\n\t\t}\n\t}\n\t// if (state.debug) log.debug \"Parsed '${description}' to ${result.inspect()}\"\n\treturn result\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.securityv1.SecurityMessageEncapsulation cmd) {\n\tdef encapsulatedCommand = cmd.encapsulatedCommand([0x25: 1, 0x26: 1, 0x27: 1, 0x32: 3, 0x33: 3, 0x59: 1, 0x70: 1, 0x72: 2, 0x73: 1, 0x82: 1, 0x85: 2, 0x86: 2])\n\tstate.sec = 1\n\tif (state.debug) log.debug \"encapsulated: ${encapsulatedCommand}\"\n\tif (encapsulatedCommand) {\n\t\tzwaveEvent(encapsulatedCommand)\n\t} else {\n\t\tlog.warn \"Unable to extract encapsulated cmd from $cmd\"\n\t\tcreateEvent(descriptionText: cmd.toString())\n\t}\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.securityv1.SecurityCommandsSupportedReport cmd) {\n\tresponse(configure())\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.powerlevelv1.PowerlevelTestNodeReport cmd) {\n\tif (state.debug) log.debug \"===Power level test node report received=== ${device.displayName}: statusOfOperation: ${cmd.statusOfOperation} testFrameCount: ${cmd.testFrameCount} testNodeid: ${cmd.testNodeid}\"\n\tdef request = [\n        physicalgraph.zwave.commands.powerlevelv1.PowerlevelGet()\n    ]\n    response(commands(request))\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.configurationv2.ConfigurationReport cmd) {\n    if (state.debug) log.debug \"---CONFIGURATION REPORT V2--- ${device.displayName} parameter ${cmd.parameterNumber} with a byte size of ${cmd.size} is set to ${cmd.configurationValue}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.configurationv1.ConfigurationReport cmd) {\n    if (state.debug) log.debug \"---CONFIGURATION REPORT V1--- ${device.displayName} parameter ${cmd.parameterNumber} with a byte size of ${cmd.size} is set to ${cmd.configurationValue}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.meterv3.MeterReport cmd) {\n    def meterTypes = [\"Unknown\", \"Electric\", \"Gas\", \"Water\"]\n    def electricNames = [\"energy\", \"energy\", \"power\", \"count\",  \"voltage\", \"current\", \"powerFactor\",  \"unknown\"]\n    def electricUnits = [\"kWh\",    \"kVAh\",   \"W\",     \"pulses\", \"V\",       \"A\",       \"Power Factor\", \"\"]\n\n    //NOTE ScaledPreviousMeterValue does not always contain a value\n    def previousValue = cmd.scaledPreviousMeterValue ?: 0\n\n    def map = [ name: electricNames[cmd.scale], unit: electricUnits[cmd.scale], displayed: state.display]\n    switch(cmd.scale) {\n        case 0: //kWh\n\t    previousValue = device.currentValue(\"energy\") ?: cmd.scaledPreviousMeterValue ?: 0\n            map.value = cmd.scaledMeterValue\n            break;\n        case 1: //kVAh\n            map.value = cmd.scaledMeterValue\n            break;\n        case 2: //Watts\n            previousValue = device.currentValue(\"power\") ?: cmd.scaledPreviousMeterValue ?: 0\n            map.value = Math.round(cmd.scaledMeterValue)\n            break;\n        case 3: //pulses\n            map.value = Math.round(cmd.scaledMeterValue)\n            break;\n        case 4: //Volts\n            previousValue = device.currentValue(\"voltage\") ?: cmd.scaledPreviousMeterValue ?: 0\n            map.value = cmd.scaledMeterValue\n            break;\n        case 5: //Amps\n            previousValue = device.currentValue(\"current\") ?: cmd.scaledPreviousMeterValue ?: 0\n            map.value = cmd.scaledMeterValue\n            break;\n        case 6: //Power Factor\n            previousValue = device.currentValue(\"powerFactor\") ?: cmd.scaledPreviousMeterValue ?: 0\n            map.value = cmd.scaledMeterValue\n            break;\n        case 7: //Unknown\n            map.value = cmd.scaledMeterValue\n            break;\n        default:\n            break;\n    }\n    //Check if the value has changed by more than 5%, if so mark as a stateChange\n    //map.isStateChange = ((cmd.scaledMeterValue - previousValue).abs() > (cmd.scaledMeterValue * 0.05))\n\n    createEvent(map)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicReport cmd)\n{\n\t[name: \"switch\", value: cmd.value ? \"on\" : \"off\", type: \"physical\", displayed: true, isStateChange: true]\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicSet cmd) \n{\n    [name: \"switch\", value: cmd.value ? \"on\" : \"off\", type: \"physical\", displayed: true, isStateChange: true]\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.switchbinaryv1.SwitchBinaryReport cmd)\n{\n\t[name: \"switch\", value: cmd.value ? \"on\" : \"off\", type: \"digital\", displayed: true, isStateChange: true]\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.switchmultilevelv1.SwitchMultilevelReport cmd)\n{\n\t[name: \"level\", value: cmd.value, type: \"digital\", displayed: true, isStateChange: true]\n}\n\t\ndef zwaveEvent(physicalgraph.zwave.commands.switchbinaryv1.SwitchBinarySet cmd)\n{\n    [name: \"switch\", value: cmd.value ? \"on\" : \"off\", type: \"digital\", displayed: true, isStateChange: true]\n}\n\ndef zwaveEvent(physicalgraph.zwave.Command cmd) {\n\tif (state.debug) log.debug \"Unhandled: $cmd sent to ${device.displayName}\"\n    createEvent(descriptionText: cmd.toString(), isStateChange: false)\n}\n\ndef on() {\n\tif (state.debug) log.debug \"turning on ${device.displayName}\"\n\tdef request = [\n\t\tzwave.basicV1.basicSet(value: 0xFF),\n\t    zwave.basicV1.basicGet(),\n\t\tzwave.switchBinaryV1.switchBinaryGet(),\n\t\tzwave.switchMultilevelV1.switchMultilevelGet()\n\t]\n    commands(request)\n}\n\ndef off() {\n\tif (state.debug) log.debug \"turning off ${device.displayName}\"\n\tdef request = [\n\t\tzwave.basicV1.basicSet(value: 0x00),\n        zwave.basicV1.basicGet(),\n\t\tzwave.switchBinaryV1.switchBinaryGet(),\n\t\tzwave.switchMultilevelV1.switchMultilevelGet()\n\t]\n    commands(request)\n}\n\ndef setLevel(value) {\n\tif (state.debug) log.debug \"setting level to ${value} on ${device.displayName}\"\n\tdef valueaux = value as Integer\n\tdef level = Math.min(valueaux, 99)\n\tdef request = [\n\t\tzwave.basicV1.basicSet(value: level),\n\t\tzwave.switchMultilevelV1.switchMultilevelGet()\n\t\t]\n\tcommands(request)\t\n}\n\ndef setLevel(value, duration) {\n\tdef valueaux = value as Integer\n\tdef level = Math.min(valueaux, 99)\n\tdef dimmingDuration = duration < 128 ? duration : 128 + Math.round(duration / 60)\n\tdef request = [\n\t\tzwave.switchMultilevelV2.switchMultilevelSet(value: level, dimmingDuration: dimmingDuration)\n\t\t]\n\tcommands(request)\t\n}\n\ndef setColor(value) {\n\tdef result = []\n\tif (state.debug) log.debug \"setColor: ${value}\"\n\tif (value.hex) {\n\t\tdef c = value.hex.findAll(/[0-9a-fA-F]{2}/).collect { Integer.parseInt(it, 16) }\n        result << zwave.configurationV1.configurationSet(parameterNumber: 83, size: 3, configurationValue: [c[0], c[1], c[2]])\n\t}\n\tif(value.hex) sendEvent(name: \"color\", value: value.hex)\n    commands(result)\n}\n\ndef poll() {\n\tif (state.debug) log.debug \"poll request sent to ${device.displayName}\"\n\tdef request = [\n\t\tzwave.switchBinaryV1.switchBinaryGet(),\n        zwave.basicV1.basicGet(),\n\t\tzwave.switchMultilevelV1.switchMultilevelGet(),\n\t\tzwave.meterV3.meterGet(scale: 0),\t//kWh\n        zwave.meterV3.meterGet(scale: 1),\t//kVAh\n\t\tzwave.meterV3.meterGet(scale: 2),\t//Wattage\n\t\tzwave.meterV3.meterGet(scale: 4),\t//Volts\n\t\tzwave.meterV3.meterGet(scale: 5),\t//Amps\n        zwave.meterV3.meterGet(scale: 6)\t//Power Factor\n\t]\n    commands(request)\n}\n\ndef refresh() {\n\tif (state.debug) log.debug \"refresh request sent to ${device.displayName}\"\n\tdef request = [\n        zwave.basicV1.basicGet(),\n\t\tzwave.switchMultilevelV1.switchMultilevelGet(),\n\t\tzwave.switchBinaryV1.switchBinaryGet()\n\t]\n    commands(request)\n}\n\ndef reset() {\n\tif (state.debug) log.debug \"reset request sent to ${device.displayName}\"\n\tdef request = [\n\t\tzwave.meterV3.meterReset(),\n\t\tzwave.meterV3.meterGet(scale: 0),\t//kWh\n        zwave.meterV3.meterGet(scale: 1),\t//kVAh\n\t\tzwave.meterV3.meterGet(scale: 2),\t//Wattage\n\t\tzwave.meterV3.meterGet(scale: 4),\t//Volts\n\t\tzwave.meterV3.meterGet(scale: 5),\t//Amps\n        zwave.meterV3.meterGet(scale: 6)\t//Power Factor\n\t]\n    commands(request)\n}\n\ndef configure() {\n\tif (state.debug) {\n    \tif (state.sec) {\n        \tlog.debug \"secure configuration being sent to ${device.displayName}\"\n            }\n        else\n        \tif (state.debug) log.debug \"configuration being sent to ${device.displayName}\"\n\t\t}            \n    def monitorInt = 60\n\t\tif (monitorInterval) {\n\t\t\tmonitorInt=monitorInterval.toInteger()\n\t\t}\n\tdef ledBehave = 0\n    \tif (ledBehavior) {\n        \tledBehave=ledBehavior.toInteger()\n        }\n\tdef ledBright = 50\n    \tif (ledBrightness) {\n        \tledBright=ledBrightness.toInteger()\n\t\t}\n    if (state.debug) log.debug \"Sending configure commands - monitorInterval '${monitorInt}', ledBehavior '${ledBehave}'\"\n\tdef request = [\n    \t// Reset switch configuration to defaults\n        // zwave.configurationV1.configurationSet(parameterNumber: 255, size: 1, scaledConfigurationValue: 1),\n\t\t// Enable to send notifications to associated devices (Group 1) when the state of Micro Switch’s load changed (0=nothing, 1=hail CC, 2=basic CC report)\n        zwave.configurationV1.configurationSet(parameterNumber: 80, size: 1, configurationValue: [2]),\n        // set LED behavior 0 energy mode 1 momentary display 2 night light\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 81, size: 1, scaledConfigurationValue: ledBehave),\n\t\t// Set LED brightness\n        zwave.configurationV1.configurationSet(parameterNumber: 84, size: 3, configurationValue: [ledBright,ledBright,ledBright]),\n        // Which reports need to send in Report group 1\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 101, size: 4, scaledConfigurationValue: 4|2|1),\n\t\t// Which reports need to send in Report group 2\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 102, size: 4, scaledConfigurationValue: 8),\n\t\t// Which reports need to send in Report group 3\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 103, size: 4, scaledConfigurationValue: 0),\n\t\t// Interval to send Report group 1\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 111, size: 4, scaledConfigurationValue: monitorInt),\n\t\t// Interval to send Report group 2\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 112, size: 4, scaledConfigurationValue: 60),\n\t\t// Interval to send Report group 3\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 113, size: 4, scaledConfigurationValue: 0),\n        \n        // get notification behavior\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 80),\n\t\t// get LED behavior\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 81),\n    \t// get night light RGB value\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 83),\n    \t// get Energy Mode/momentary indicate LED brightness value\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 84),\n    \t// Which reports need to send in Report group 1\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 101),\n\t\t// Which reports need to send in Report group 2\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 102),\n\t\t// Which reports need to send in Report group 3\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 103),\n    \t// Interval to send Report group 1\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 111),\n\t\t// Interval to send Report group 2\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 112),\n\t\t// Interval to send Report group 3\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 113),\n\t\t\n\t\t// Can use the zwaveHubNodeId variable to add the hub to the device's associations:\n\t\tzwave.associationV1.associationSet(groupingIdentifier:2, nodeId:zwaveHubNodeId)\n    ]\n\tcommands(request)\n}\n\nprivate setConfigured() {\n\tupdateDataValue(\"configured\", \"true\")\n}\n\nprivate isConfigured() {\n\tgetDataValue(\"configured\") == \"true\"\n}\n\nprivate command(physicalgraph.zwave.Command cmd) {\n\tif (state.sec) {\n\t\tzwave.securityV1.securityMessageEncapsulation().encapsulate(cmd).format()\n\t} else {\n\t\tcmd.format()\n\t}\n}\n\nprivate commands(commands, delay=500) {\n\tdelayBetween(commands.collect{ command(it) }, delay)\n}"
  },
  {
    "path": "Aeon SmartDimmer 6/device_type-aeon-smartdimmer6-v0.2.groovy",
    "content": "/*\n * V 0.2 of Aeon Smart Dimmer 6 code 9/24/2017\n *  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except\n *  in compliance with the License. You may obtain a copy of the License at:\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n *  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed\n *  on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License\n *  for the specific language governing permissions and limitations under the License.\n *\n * some code used from various SmartThings device type and metering code from ElasticDev\n *\n*/\n\n metadata {\n\tdefinition (name: \"Aeon Smart Dimmer 6 - RV v0.2\", namespace: \"robertvandervoort\", author: \"Robert Vandervoort\") {\n\t\tcapability \"Energy Meter\"\n\t\tcapability \"Power Meter\"\n\t\tcapability \"Actuator\"\n\t\tcapability \"Switch\"\n\t\tcapability \"Switch Level\"\n        capability \"Color Control\"\n\t\tcapability \"Configuration\"\n\t\tcapability \"Polling\"\n\t\tcapability \"Refresh\"\n\t\tcapability \"Sensor\"\n\n\t\tcommand \"reset\"\n\n\t\t/* Capability notes\n\t\t0x26 COMMAND_CLASS_SWITCH_MULTILEVEL 2\n        0x27 COMMAND_CLASS_SWITCH_ALL 1\n        0x32 COMMAND_CLASS_METER 3\n        0x33 COMMAND_CLASS_COLOR_SWITCH 3\n\t\t0x59 COMMAND_CLASS_ASSOCIATION_GRP_INFO  1\n\t\t0x5A COMMAND_CLASS_DEVICE_RESET_LOCALLY 1\n\t\t0x5E COMMAND_CLASS_ZWAVE_PLUS_INFO 2\n\t\t0x60 Multi Channel Command Class (V3)\n\t\t0x70 COMMAND_CLASS_CONFIGURATION 1\n        0x72 COMMAND_CLASS_MANUFACTURER_SPECIFIC 2\n        0x73 COMMAND_CLASS_POWERLEVEL 1\n\t\t0x7A COMMAND_CLASS_FIRMWARE_UPDATE_MD 2\n\t\t0x81 COMMAND_CLASS_CLOCK 1\n        0x82 COMMAND_CLASS_HAIL 1\n\t\t0x8E COMMAND_CLASS_MULTI_INSTANCE_ASSOCIATION 2\n        0x85 COMMAND_CLASS_ASSOCIATION 2\n        0x86 COMMAND_CLASS_VERSION 2\n\t\t0xEF COMMAND_CLASS_MARK 1\n        */\n\t\t\n        fingerprint mfr: \"0086\", prod: \"0103\", model: \"0063\"\n\t\t}\n\t// simulator metadata\n\tsimulator {\n\t\tstatus \"on\":  \"command: 2603, payload: FF\"\n\t\tstatus \"off\": \"command: 2603, payload: 00\"\n\t\tstatus \"09%\": \"command: 2603, payload: 09\"\n\t\tstatus \"10%\": \"command: 2603, payload: 0A\"\n\t\tstatus \"33%\": \"command: 2603, payload: 21\"\n\t\tstatus \"66%\": \"command: 2603, payload: 42\"\n\t\tstatus \"99%\": \"command: 2603, payload: 63\"\n\n\tfor (int i = 0; i <= 10000; i += 1000) {\n\t    status \"power  ${i} W\": \n\t\t    new physicalgraph.zwave.Zwave().meterV3.meterReport(scaledMeterValue: i, precision: 3, meterType: 4, scale: 2, size: 4).incomingMessage()\n\t}\n\tfor (int i = 0; i <= 100; i += 10) {\n\t    status \"energy  ${i} kWh\":\n\t\t    new physicalgraph.zwave.Zwave().meterV3.meterReport(scaledMeterValue: i, precision: 3, meterType: 0, scale: 0, size: 4).incomingMessage()\n\t}\n\t// reply messages\n\t[\"FF\", \"00\", \"09\", \"0A\", \"21\", \"42\", \"63\"].each { val -> reply \"2001$val,delay 100,2602\": \"command: 2603, payload: $val\" }\n}\n\t// tile definitions\n\ttiles (scale: 2) {\n    \tmultiAttributeTile(name:\"main\", type:\"lighting\", width:6, height:4, canChangeIcon: true) {\n\t\t\ttileAttribute(\"device.switch\", key: \"PRIMARY_CONTROL\") {\n            \tattributeState \"on\", label: '${name}', action: \"switch.off\", icon: \"st.switches.switch.on\", backgroundColor: \"#79b821\"\n\t\t\t\tattributeState \"off\", label: '${name}', action: \"switch.on\", icon: \"st.switches.switch.off\", backgroundColor: \"#ffffff\"\n            }\n\t\t\ttileAttribute (\"device.level\", key: \"SLIDER_CONTROL\") {\n\t\t\t\tattributeState \"level\", action:\"switch level.setLevel\"\n\t\t\t}\n            tileAttribute(\"device.power\", key: \"SECONDARY_CONTROL\") {\n                attributeState \"default\",label:'${currentValue} W'\n            }\n\t\t}\n\t\tvalueTile(\"energy\", \"device.energy\", decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'${currentValue} kWh', action:\"poll\"\n\t\t}\n\t\tvalueTile(\"current\", \"device.current\", decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'${currentValue} A', action:\"poll\"\n\t\t}\n        valueTile(\"voltage\", \"device.voltage\", decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'${currentValue} V', action:\"poll\"\n\t\t}\n        controlTile(\"rgbSelector\", \"device.color\", \"color\", height: 2, width: 2, inactiveLabel: false) {\n\t\t\tstate \"color\", action:\"setColor\"\n\t\t}\n\t\tstandardTile(\"reset\", \"device.energy\", inactiveLabel: false, decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'reset kWh', action:\"reset\"\n\t\t}\n\t\tstandardTile(\"configure\", \"device.power\", inactiveLabel: false, decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"configure\", label:'', action:\"configuration.configure\", icon:\"st.secondary.configure\"\n\t\t}\n\t\tstandardTile(\"refresh\", \"device.power\", inactiveLabel: false, decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'', action:\"refresh.refresh\", icon:\"st.secondary.refresh\"\n\t\t}\n\t\tmain \"main\",\"energy\",\"current\",\"voltage\"\n\t\tdetails([\"main\",\"energy\",\"current\",\"voltage\",\"rgbSelector\",\"reset\",\"refresh\",\"configure\"])\n\t}\n\t\n    preferences { \n\t\tinput \"ledBehavior\", \"integer\", \n\t\t\ttitle: \"LED Behavior\",\n            description: \"0=energy tracking, 1=momentary status, 2=night light\",\n\t\t\tdefaultValue: 0, \n\t\t\tdisplayDuringSetup: true,\n            range: \"0..2\"\n\t\tinput \"monitorInterval\", \"integer\", \n\t\t\ttitle: \"Monitoring Interval\", \n\t\t\tdescription: \"The time interval in seconds for sending device reports\", \n\t\t\tdefaultValue: 60, \n            range: \"1..4294967295‬\",\n\t\t\trequired: false, \n\t\t\tdisplayDuringSetup: true\n\t\tinput \"ledBrightness\", \"integer\",\n        \ttitle: \"LED Brightness\",\n            description: \"Set the % brightness of indicator LEDs\",\n            defaultValue: 50,\n            range: \"0..100\",\n            required: false,\n            displayduringSetup: true\n\t\tinput \"debugOutput\", \"boolean\", \n\t\t\ttitle: \"Enable debug logging?\",\n\t\t\tdefaultValue: false,\n\t\t\tdisplayDuringSetup: true\n\t}\n}\n\ndef updated()\n{\n\tstate.debug = (\"true\" == debugOutput)\n\tif (state.sec && !isConfigured()) {\n\t\t// in case we miss the SCSR\n\t\tresponse(configure())\n\t\t\n\t}\n}\n\ndef parse(String description)\n{\n\tdef result = null\n\tif (description.startsWith(\"Err 106\")) {\n\t\tstate.sec = 0\n\t\tresult = createEvent( name: \"secureInclusion\", value: \"failed\", isStateChange: true,\n\t\t\tdescriptionText: \"This sensor failed to complete the network security key exchange. If you are unable to control it via SmartThings, you must remove it from your network and add it again.\")\n\t} else if (description != \"updated\") {\n\t\tdef cmd = zwave.parse(description, [0x25: 1, 0x26: 1, 0x27: 1, 0x32: 3, 0x33: 3, 0x59: 1, 0x70: 1, 0x72: 2, 0x73: 1, 0x82: 1, 0x85: 2, 0x86: 2])\n\t\tif (cmd) {\n\t\t\tresult = zwaveEvent(cmd)\n\t\t}\n\t}\n\t// if (state.debug) log.debug \"Parsed '${description}' to ${result.inspect()}\"\n\treturn result\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.securityv1.SecurityMessageEncapsulation cmd) {\n\tdef encapsulatedCommand = cmd.encapsulatedCommand([0x25: 1, 0x26: 1, 0x27: 1, 0x32: 3, 0x33: 3, 0x59: 1, 0x70: 1, 0x72: 2, 0x73: 1, 0x82: 1, 0x85: 2, 0x86: 2])\n\tstate.sec = 1\n\tif (state.debug) log.debug \"encapsulated: ${encapsulatedCommand}\"\n\tif (encapsulatedCommand) {\n\t\tzwaveEvent(encapsulatedCommand)\n\t} else {\n\t\tlog.warn \"Unable to extract encapsulated cmd from $cmd\"\n\t\tcreateEvent(descriptionText: cmd.toString())\n\t}\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.securityv1.SecurityCommandsSupportedReport cmd) {\n\tresponse(configure())\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.powerlevelv1.PowerlevelTestNodeReport cmd) {\n\tif (state.debug) log.debug \"===Power level test node report received=== ${device.displayName}: statusOfOperation: ${cmd.statusOfOperation} testFrameCount: ${cmd.testFrameCount} testNodeid: ${cmd.testNodeid}\"\n\tdef request = [\n        physicalgraph.zwave.commands.powerlevelv1.PowerlevelGet()\n    ]\n    response(commands(request))\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.configurationv2.ConfigurationReport cmd) {\n    if (state.debug) log.debug \"---CONFIGURATION REPORT V2--- ${device.displayName} parameter ${cmd.parameterNumber} with a byte size of ${cmd.size} is set to ${cmd.configurationValue}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.configurationv1.ConfigurationReport cmd) {\n    if (state.debug) log.debug \"---CONFIGURATION REPORT V1--- ${device.displayName} parameter ${cmd.parameterNumber} with a byte size of ${cmd.size} is set to ${cmd.configurationValue}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.meterv3.MeterReport cmd) {\n    if (state.debug) log.debug cmd\n    def meterTypes = [\"Unknown\", \"Electric\", \"Gas\", \"Water\"]\n    def electricNames = [\"energy\", \"energy\", \"power\", \"count\",  \"voltage\", \"current\", \"powerFactor\",  \"unknown\"]\n    def electricUnits = [\"kWh\",    \"kVAh\",   \"W\",     \"pulses\", \"V\",       \"A\",       \"Power Factor\", \"\"]\n\n    //NOTE ScaledPreviousMeterValue does not always contain a value\n    def previousValue = cmd.scaledPreviousMeterValue ?: 0\n\n    def map = [ name: electricNames[cmd.scale], unit: electricUnits[cmd.scale], displayed: true]\n    switch(cmd.scale) {\n        case 0: //kWh\n\t    \tpreviousValue = device.currentValue(\"energy\") ?: cmd.scaledPreviousMeterValue ?: 0\n            map.value = cmd.scaledMeterValue\n            break;\n        case 1: //kVAh\n            map.value = cmd.scaledMeterValue\n            break;\n        case 2: //Watts\n            previousValue = device.currentValue(\"power\") ?: cmd.scaledPreviousMeterValue ?: 0\n            map.value = Math.round(cmd.scaledMeterValue)\n            break;\n        case 3: //pulses\n            map.value = Math.round(cmd.scaledMeterValue)\n            break;\n        case 4: //Volts\n            previousValue = device.currentValue(\"voltage\") ?: cmd.scaledPreviousMeterValue ?: 0\n            map.value = cmd.scaledMeterValue\n            break;\n        case 5: //Amps\n            previousValue = device.currentValue(\"current\") ?: cmd.scaledPreviousMeterValue ?: 0\n            map.value = cmd.scaledMeterValue\n            break;\n        case 6: //Power Factor\n            previousValue = device.currentValue(\"powerFactor\") ?: cmd.scaledPreviousMeterValue ?: 0\n            map.value = cmd.scaledMeterValue\n            break;\n        case 7: //Unknown\n            map.value = cmd.scaledMeterValue\n            break;\n        default:\n            break;\n    }\n    //Check if the value has changed by more than 5%, if so mark as a stateChange\n    //map.isStateChange = ((cmd.scaledMeterValue - previousValue).abs() > (cmd.scaledMeterValue * 0.05))\n\n    createEvent(map)\n    return map\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicReport cmd) {\n\tdef result;\n    result = createEvent(name: \"switch\", value: cmd.value ? \"on\" : \"off\", type: \"physical\", displayed: true, isStateChange: true);\n    return result;\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicSet cmd) {\n\tdef result;\n\tresult = createEvent(name: \"switch\", value: cmd.value ? \"on\" : \"off\", type: \"physical\", displayed: true, isStateChange: true);\n    return result;\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.switchbinaryv1.SwitchBinaryReport cmd) {\n\tdef result;\n    result = createEvent(name: \"switch\", value: cmd.value ? \"on\" : \"off\", type: \"digital\", displayed: true, isStateChange: true);\n    return result;\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.switchmultilevelv1.SwitchMultilevelReport cmd) {\n\tdef result;\n    result = createEvent(name: \"level\", value: cmd.value, type: \"digital\", displayed: true, isStateChange: true);\n    return result;\n}\n\t\ndef zwaveEvent(physicalgraph.zwave.commands.switchbinaryv1.SwitchBinarySet cmd) {\n\tdef result;\n    result = createEvent(name: \"switch\", value: cmd.value ? \"on\" : \"off\", type: \"digital\", displayed: true, isStateChange: true);\n    return result;\n}\n\ndef zwaveEvent(physicalgraph.zwave.Command cmd) {\n\tif (state.debug) log.debug \"Unhandled: $cmd sent to ${device.displayName}\"\n    createEvent(descriptionText: cmd.toString(), isStateChange: false)\n}\n\ndef on() {\n\tif (state.debug) log.debug \"turning on ${device.displayName}\"\n\tdef request = [\n\t\tzwave.basicV1.basicSet(value: 0xFF),\n\t    zwave.basicV1.basicGet(),\n\t\tzwave.switchBinaryV1.switchBinaryGet(),\n\t\tzwave.switchMultilevelV1.switchMultilevelGet()\n\t]\n    commands(request)\n}\n\ndef off() {\n\tif (state.debug) log.debug \"turning off ${device.displayName}\"\n\tdef request = [\n\t\tzwave.basicV1.basicSet(value: 0x00),\n        zwave.basicV1.basicGet(),\n\t\tzwave.switchBinaryV1.switchBinaryGet(),\n\t\tzwave.switchMultilevelV1.switchMultilevelGet()\n\t]\n    commands(request)\n}\n\ndef setLevel(value) {\n\tif (state.debug) log.debug \"setting level to ${value} on ${device.displayName}\"\n\tdef valueaux = value as Integer\n\tdef level = Math.min(valueaux, 99)\n\tdef request = [\n\t\tzwave.basicV1.basicSet(value: level),\n\t\tzwave.switchMultilevelV1.switchMultilevelGet()\n\t\t]\n\tcommands(request)\t\n}\n\ndef setLevel(value, duration) {\n\tdef valueaux = value as Integer\n\tdef level = Math.min(valueaux, 99)\n\tdef dimmingDuration = duration < 128 ? duration : 128 + Math.round(duration / 60)\n\tdef request = [\n\t\tzwave.switchMultilevelV2.switchMultilevelSet(value: level, dimmingDuration: dimmingDuration)\n\t\t]\n\tcommands(request)\t\n}\n\ndef setColor(value) {\n\tdef result = []\n\tif (state.debug) log.debug \"setColor: ${value}\"\n\tif (value.hex) {\n\t\tdef c = value.hex.findAll(/[0-9a-fA-F]{2}/).collect { Integer.parseInt(it, 16) }\n        result << zwave.configurationV1.configurationSet(parameterNumber: 83, size: 3, configurationValue: [c[0], c[1], c[2]])\n\t}\n\tif(value.hex) sendEvent(name: \"color\", value: value.hex)\n    commands(result)\n}\n\ndef poll() {\n\tif (state.debug) log.debug \"poll request sent to ${device.displayName}\"\n\tdef request = [\n\t\tzwave.switchBinaryV1.switchBinaryGet(),\n        zwave.basicV1.basicGet(),\n\t\tzwave.switchMultilevelV1.switchMultilevelGet(),\n\t\tzwave.meterV3.meterGet(scale: 0),\t//kWh\n        zwave.meterV3.meterGet(scale: 1),\t//kVAh\n\t\tzwave.meterV3.meterGet(scale: 2),\t//Wattage\n\t\tzwave.meterV3.meterGet(scale: 4),\t//Volts\n\t\tzwave.meterV3.meterGet(scale: 5),\t//Amps\n        zwave.meterV3.meterGet(scale: 6)\t//Power Factor\n\t]\n    commands(request)\n}\n\ndef refresh() {\n\tif (state.debug) log.debug \"refresh request sent to ${device.displayName}\"\n\tdef request = [\n        zwave.basicV1.basicGet(),\n\t\tzwave.switchMultilevelV1.switchMultilevelGet(),\n\t\tzwave.switchBinaryV1.switchBinaryGet()\n\t]\n    commands(request)\n}\n\ndef reset() {\n\tif (state.debug) log.debug \"reset request sent to ${device.displayName}\"\n\tdef request = [\n\t\tzwave.meterV3.meterReset(),\n\t\tzwave.meterV3.meterGet(scale: 0),\t//kWh\n        zwave.meterV3.meterGet(scale: 1),\t//kVAh\n\t\tzwave.meterV3.meterGet(scale: 2),\t//Wattage\n\t\tzwave.meterV3.meterGet(scale: 4),\t//Volts\n\t\tzwave.meterV3.meterGet(scale: 5),\t//Amps\n        zwave.meterV3.meterGet(scale: 6)\t//Power Factor\n\t]\n    commands(request)\n}\n\ndef configure() {\n\tif (state.debug) {\n    \tif (state.sec) {\n        \tlog.debug \"secure configuration being sent to ${device.displayName}\"\n            }\n        else\n        \tif (state.debug) log.debug \"configuration being sent to ${device.displayName}\"\n\t\t}            \n    def monitorInt = 60\n\t\tif (monitorInterval) {\n\t\t\tmonitorInt=monitorInterval.toInteger()\n\t\t}\n\tdef ledBehave = 0\n    \tif (ledBehavior) {\n        \tledBehave=ledBehavior.toInteger()\n        }\n\tdef ledBright = 50\n    \tif (ledBrightness) {\n        \tledBright=ledBrightness.toInteger()\n\t\t}\n    if (state.debug) log.debug \"Sending configure commands - monitorInterval '${monitorInt}', ledBehavior '${ledBehave}'\"\n\tdef request = [\n    \t// Reset switch configuration to defaults\n        // zwave.configurationV1.configurationSet(parameterNumber: 255, size: 1, scaledConfigurationValue: 1),\n\t\t// Enable to send notifications to associated devices (Group 1) when the state of Micro Switch’s load changed (0=nothing, 1=hail CC, 2=basic CC report)\n        zwave.configurationV1.configurationSet(parameterNumber: 80, size: 1, configurationValue: [2]),\n        // set LED behavior 0 energy mode 1 momentary display 2 night light\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 81, size: 1, scaledConfigurationValue: ledBehave),\n\t\t// Set LED brightness\n        zwave.configurationV1.configurationSet(parameterNumber: 84, size: 3, configurationValue: [ledBright,ledBright,ledBright]),\n        // Which reports need to send in Report group 1\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 101, size: 4, scaledConfigurationValue: 4|2|1),\n\t\t// Which reports need to send in Report group 2\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 102, size: 4, scaledConfigurationValue: 8),\n\t\t// Which reports need to send in Report group 3\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 103, size: 4, scaledConfigurationValue: 0),\n\t\t// Interval to send Report group 1\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 111, size: 4, scaledConfigurationValue: monitorInt),\n\t\t// Interval to send Report group 2\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 112, size: 4, scaledConfigurationValue: 60),\n\t\t// Interval to send Report group 3\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 113, size: 4, scaledConfigurationValue: 0),\n        \n        // get LED behavior\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 81),\n    \t// get night light RGB value\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 83),\n    \t// get Energy Mode/momentary indicate LED brightness value\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 84),\n    \t// Which reports need to send in Report group 1\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 101),\n\t\t// Which reports need to send in Report group 2\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 102),\n\t\t// Which reports need to send in Report group 3\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 103),\n    \t// Interval to send Report group 1\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 111),\n\t\t// Interval to send Report group 2\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 112),\n\t\t// Interval to send Report group 3\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 113),\n\t\t\n\t\t// Can use the zwaveHubNodeId variable to add the hub to the device's associations:\n\t\tzwave.associationV1.associationSet(groupingIdentifier:2, nodeId:zwaveHubNodeId)\n    ]\n\tcommands(request)\n}\n\nprivate setConfigured() {\n\tupdateDataValue(\"configured\", \"true\")\n}\n\nprivate isConfigured() {\n\tgetDataValue(\"configured\") == \"true\"\n}\n\nprivate command(physicalgraph.zwave.Command cmd) {\n\tif (state.sec) {\n\t\tzwave.securityV1.securityMessageEncapsulation().encapsulate(cmd).format()\n\t} else {\n\t\tcmd.format()\n\t}\n}\n\nprivate commands(commands, delay=500) {\n\tdelayBetween(commands.collect{ command(it) }, delay)\n}\n"
  },
  {
    "path": "Aeon SmartSwitch 6/device_type-aeon-smartswitch6-v0.1",
    "content": "/*\n * V 0.1 of Aeon Smart Switch 6 code 10/5/2015\n *  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except\n *  in compliance with the License. You may obtain a copy of the License at:\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n *  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed\n *  on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License\n *  for the specific language governing permissions and limitations under the License.\n * \n*/\n\n metadata {\n\tdefinition (name: \"Aeon Smart Switch 6 - RV v0.1\", namespace: \"robertvandervoort\", author: \"Robert Vandervoort\") {\n\t\tcapability \"Energy Meter\"\n\t\tcapability \"Power Meter\"\n\t\tcapability \"Actuator\"\n\t\tcapability \"Switch\"\n\t\tcapability \"Configuration\"\n\t\tcapability \"Polling\"\n\t\tcapability \"Refresh\"\n\t\tcapability \"Sensor\"\n\n\t\tcommand \"reset\"\n\n\t\t/* find homes for these \n        0x2C COMMAND_CLASS_SCENE_ACTUATOR_CONF\n        0x2B COMMAND_CLASS_SCENE_ACTIVATION\t\t\n\t\t0x7A COMMAND_CLASS_FIRMWARE_UPDATE_MD 2\n\t\t0xEF COMMAND_CLASS_MARK 1\n\t\t0x5A ?\n\t\t0x5E ?   \n        0x25: 1 0x26: 1 0x27: 1 0x32: 3 0x33: 3 0x56: 0x59: 1 0x70: 1 0x72: 2 0x73: 1 0x82: 1 0x85: 2 0x86: 2\n        0x25 COMMAND_CLASS_SWITCH_BINARY 1 \n        0x26 COMMAND_CLASS_SWITCH_MULTILEVEL 1\n        0x27 COMMAND_CLASS_SWITCH_ALL 1\n        0x32 COMMAND_CLASS_METER 3\n        0x33 COMMAND_CLASS_COLOR_SWITCH 3\n        0x56 ?\n        0x59 COMMAND_CLASS_ASSOCIATION_GRP_INFO  1\n        0x70 COMMAND_CLASS_CONFIGURATION 1\n        0x72 COMMAND_CLASS_MANUFACTURER_SPECIFIC 2\n        0x73 COMMAND_CLASS_POWERLEVEL 1\n\t\t0x81 COMMAND_CLASS_CLOCK 1\n        0x82 COMMAND_CLASS_HAIL 1\n        0x85 COMMAND_CLASS_ASSOCIATION 2\n        0x86 COMMAND_CLASS_VERSION 2\n        */\n\t\tfingerprint deviceId: \"0x1001\", inClusters: \"0x25,0x26,0x27,0x32,0x2C,0x2B,0x33,0x85,0x56,0x59,0x5A,0x5E,0x70,0x72,0x73,0x85,0x86\", outClusters: \"0x82\"\n\t}\n\t// simulator metadata\n\tsimulator {\n\t\tstatus \"on\":  \"command: 2003, payload: FF\"\n\t\tstatus \"off\": \"command: 2003, payload: 00\"\n\n\tfor (int i = 0; i <= 10000; i += 1000) {\n\t    status \"power  ${i} W\": \n\t\t    new physicalgraph.zwave.Zwave().meterV3.meterReport(scaledMeterValue: i, precision: 3, meterType: 4, scale: 2, size: 4).incomingMessage()\n\t}\n\tfor (int i = 0; i <= 100; i += 10) {\n\t    status \"energy  ${i} kWh\":\n\t\t    new physicalgraph.zwave.Zwave().meterV3.meterReport(scaledMeterValue: i, precision: 3, meterType: 0, scale: 0, size: 4).incomingMessage()\n\t}\n\n\t\t// reply messages\n\t\treply \"2001FF,delay 100,2502\": \"command: 2503, payload: FF\"\n\t\treply \"200100,delay 100,2502\": \"command: 2503, payload: 00\"\n\n\t}\n\n\t// tile definitions\n\ttiles (scale: 2) {\n    \tmultiAttributeTile(name:\"main\", type:\"generic\", width:6, height:4, canChangeIcon: true) {\n\t\t\ttileAttribute(\"device.switch\", key: \"PRIMARY_CONTROL\") {\n            \tattributeState \"on\", label: '${name}', action: \"switch.off\", icon: \"st.switches.switch.on\", backgroundColor: \"#79b821\"\n\t\t\t\tattributeState \"off\", label: '${name}', action: \"switch.on\", icon: \"st.switches.switch.off\", backgroundColor: \"#ffffff\"\n            }\n            tileAttribute(\"device.power\", key: \"SECONDARY_CONTROL\") {\n                attributeState \"default\",label:'${currentValue} W'\n            }\n\t\t}\n\t\t/*standardTile(\"switch\", \"device.switch\", width: 2, height: 2, canChangeIcon: true) {\n\t\t\tstate \"on\", label: '${name}', action: \"switch.off\", icon: \"st.switches.switch.on\", backgroundColor: \"#79b821\"\n\t\t\tstate \"off\", label: '${name}', action: \"switch.on\", icon: \"st.switches.switch.off\", backgroundColor: \"#ffffff\"\n\t\t}*/\n\t\tvalueTile(\"energy\", \"device.energy\", decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'${currentValue} kWh', action:\"poll\"\n\t\t}\n\t\tvalueTile(\"current\", \"device.current\", decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'${currentValue} A', action:\"poll\"\n\t\t}\n        valueTile(\"voltage\", \"device.voltage\", decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'${currentValue} V', action:\"poll\"\n\t\t}\n\t\tstandardTile(\"reset\", \"device.energy\", inactiveLabel: false, decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'reset kWh', action:\"reset\"\n\t\t}\n\t\tstandardTile(\"configure\", \"device.power\", inactiveLabel: false, decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"configure\", label:'', action:\"configuration.configure\", icon:\"st.secondary.configure\"\n\t\t}\n\t\tstandardTile(\"refresh\", \"device.power\", inactiveLabel: false, decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'', action:\"refresh.refresh\", icon:\"st.secondary.refresh\"\n\t\t}\n\n\t\tmain \"main\",\"energy\",\"current\",\"voltage\"\n\t\tdetails([\"main\",\"energy\",\"current\",\"voltage\",\"reset\",\"refresh\",\"configure\"])\n\t}\n\t\n    preferences { \n\t\tinput \"ledBehavior\", \"number\", \n\t\t\ttitle: \"LED Behavior\",\n            description: \"0=energy tracking, 1=momentary status, 2=night light\",\n\t\t\tdefaultValue: 0, \n\t\t\tdisplayDuringSetup: true,\n            range: \"0..2\"\n\t\tinput \"monitorInterval\", \"number\", \n\t\t\ttitle: \"Monitoring Interval\", \n\t\t\tdescription: \"The time interval in seconds for sending device reports\", \n\t\t\tdefaultValue: 60, \n            range: \"1..4294967295‬\",\n\t\t\trequired: false, \n\t\t\tdisplayDuringSetup: true\n\t}\n}\n\ndef updated()\n{\n\tif (state.sec && !isConfigured()) {\n\t\t// in case we miss the SCSR\n\t\tresponse(configure())\n\t}\n}\n\ndef parse(String description)\n{\n\tdef result = null\n\tif (description.startsWith(\"Err 106\")) {\n\t\tstate.sec = 0\n\t\tresult = createEvent( name: \"secureInclusion\", value: \"failed\", isStateChange: true,\n\t\t\tdescriptionText: \"This sensor failed to complete the network security key exchange. If you are unable to control it via SmartThings, you must remove it from your network and add it again.\")\n\t} else if (description != \"updated\") {\n\t\tdef cmd = zwave.parse(description, [0x25: 1, 0x26: 1, 0x27: 1, 0x32: 3, 0x33: 3, 0x59: 1, 0x70: 1, 0x72: 2, 0x73: 1, 0x82: 1, 0x85: 2, 0x86: 2])\n\t\tif (cmd) {\n\t\t\tresult = zwaveEvent(cmd)\n\t\t}\n\t}\n\t// log.debug \"Parsed '${description}' to ${result.inspect()}\"\n\treturn result\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.securityv1.SecurityMessageEncapsulation cmd) {\n\tdef encapsulatedCommand = cmd.encapsulatedCommand([0x25: 1, 0x26: 1, 0x27: 1, 0x32: 3, 0x33: 3, 0x59: 1, 0x70: 1, 0x72: 2, 0x73: 1, 0x82: 1, 0x85: 2, 0x86: 2])\n\tstate.sec = 1\n\tlog.debug \"encapsulated: ${encapsulatedCommand}\"\n\tif (encapsulatedCommand) {\n\t\tzwaveEvent(encapsulatedCommand)\n\t} else {\n\t\tlog.warn \"Unable to extract encapsulated cmd from $cmd\"\n\t\tcreateEvent(descriptionText: cmd.toString())\n\t}\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.securityv1.SecurityCommandsSupportedReport cmd) {\n\tresponse(configure())\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.configurationv2.ConfigurationReport cmd) {\n    log.debug \"---CONFIGURATION REPORT V2--- ${device.displayName} parameter ${cmd.parameterNumber} with a byte size of ${cmd.size} is set to ${cmd.configurationValue}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.configurationv1.ConfigurationReport cmd) {\n    log.debug \"---CONFIGURATION REPORT V1--- ${device.displayName} parameter ${cmd.parameterNumber} with a byte size of ${cmd.size} is set to ${cmd.configurationValue}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.meterv3.MeterReport cmd) {\n    def meterTypes = [\"Unknown\", \"Electric\", \"Gas\", \"Water\"]\n    def electricNames = [\"energy\", \"energy\", \"power\", \"count\",  \"voltage\", \"current\", \"powerFactor\",  \"unknown\"]\n    def electricUnits = [\"kWh\",    \"kVAh\",   \"W\",     \"pulses\", \"V\",       \"A\",       \"Power Factor\", \"\"]\n\n    //NOTE ScaledPreviousMeterValue does not always contain a value\n    def previousValue = cmd.scaledPreviousMeterValue ?: 0\n\n    def map = [ name: electricNames[cmd.scale], unit: electricUnits[cmd.scale], displayed: state.display]\n    switch(cmd.scale) {\n        case 0: //kWh\n\t    previousValue = device.currentValue(\"energy\") ?: cmd.scaledPreviousMeterValue ?: 0\n            map.value = cmd.scaledMeterValue\n            break;\n        case 1: //kVAh\n            map.value = cmd.scaledMeterValue\n            break;\n        case 2: //Watts\n            previousValue = device.currentValue(\"power\") ?: cmd.scaledPreviousMeterValue ?: 0\n            map.value = Math.round(cmd.scaledMeterValue)\n            break;\n        case 3: //pulses\n            map.value = Math.round(cmd.scaledMeterValue)\n            break;\n        case 4: //Volts\n            previousValue = device.currentValue(\"voltage\") ?: cmd.scaledPreviousMeterValue ?: 0\n            map.value = cmd.scaledMeterValue\n            break;\n        case 5: //Amps\n            previousValue = device.currentValue(\"current\") ?: cmd.scaledPreviousMeterValue ?: 0\n            map.value = cmd.scaledMeterValue\n            break;\n        case 6: //Power Factor\n        case 7: //Unknown\n            map.value = cmd.scaledMeterValue\n            break;\n        default:\n            break;\n    }\n    //Check if the value has changed by more than 5%, if so mark as a stateChange\n    //map.isStateChange = ((cmd.scaledMeterValue - previousValue).abs() > (cmd.scaledMeterValue * 0.05))\n\n    createEvent(map)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicReport cmd)\n{\n\t[name: \"switch\", value: cmd.value ? \"on\" : \"off\", type: \"physical\", displayed: true, isStateChange: true]\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicSet cmd) \n{\n    [name: \"switch\", value: cmd.value ? \"on\" : \"off\", type: \"physical\", displayed: true, isStateChange: true]\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.switchbinaryv1.SwitchBinaryReport cmd)\n{\n\t[name: \"switch\", value: cmd.value ? \"on\" : \"off\", type: \"digital\", displayed: true, isStateChange: true]\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.switchbinaryv1.SwitchBinarySet cmd)\n{\n    [name: \"switch\", value: cmd.value ? \"on\" : \"off\", type: \"digital\", displayed: true, isStateChange: true]\n}\n\ndef zwaveEvent(physicalgraph.zwave.Command cmd) {\n\tlog.debug \"Unhandled: $cmd\"\n    createEvent(descriptionText: cmd.toString(), isStateChange: false)\n}\n\ndef on() {\n\tdelayBetween([\n\t\tzwave.basicV1.basicSet(value: 0xFF).format(),\n        zwave.basicV1.basicGet().format(),\n\t\tzwave.switchBinaryV1.switchBinaryGet().format()\n\t], 2)\n}\n\ndef off() {\n\tdelayBetween([\n\t\tzwave.basicV1.basicSet(value: 0x00).format(),\n        zwave.basicV1.basicGet().format(),\n\t\tzwave.switchBinaryV1.switchBinaryGet().format()\n\t], 2)\n}\n\ndef poll() {\n\tdelayBetween([\n\t\tzwave.switchBinaryV1.switchBinaryGet().format(),\n        zwave.basicV1.basicGet().format(),\n\t\tzwave.meterV3.meterGet(scale: 0).format(),\t//kWh\n        zwave.meterV3.meterGet(scale: 1).format(),\t//kVAh\n\t\tzwave.meterV3.meterGet(scale: 2).format(),\t//Wattage\n\t\tzwave.meterV3.meterGet(scale: 4).format(),\t//Volts\n\t\tzwave.meterV3.meterGet(scale: 5).format(),\t//Amps\n        zwave.meterV3.meterGet(scale: 6).format()\t//Power Factor\n\t], 500)\n}\n\ndef refresh() {\n\tdelayBetween([\n        zwave.basicV1.basicGet().format(),\n\t\tzwave.switchBinaryV1.switchBinaryGet().format()\n\t], 2)\n}\n\ndef reset() {\n\treturn [\n\t\tzwave.meterV3.meterReset().format(),\n\t\tzwave.meterV3.meterGet(scale: 0).format(),\t//kWh\n\t\tzwave.meterV3.meterGet(scale: 2).format()\t//Wattage\n\t]\n}\n\ndef configure() {\n    log.debug \"Sending configure commands\"\n    def monitorInt = 60\n\t\tif (monitorInterval) {\n\t\t\tmonitorInt=monitorInterval\n\t\t}\n\tdef ledBehave = 0\n    \tif (ledBehavior) {\n        \tledBehave=ledBehavior\n        }\n\tdef request = [\n\t\t// set LED behavior 0 energy mode 1 momentary display 2 night light\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 81, size: 1, scaledConfigurationValue: ledBehave),\n\t\t// Which reports need to send in Report group 1\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 101, size: 4, scaledConfigurationValue: 15),\n\t\t// Which reports need to send in Report group 2\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 102, size: 4, scaledConfigurationValue: 0),\n\t\t// Which reports need to send in Report group 3\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 103, size: 4, scaledConfigurationValue: 0),\n\t\t// Interval to send Report group 1\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 111, size: 4, scaledConfigurationValue: monitorInt),\n\t\t// Interval to send Report group 2\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 112, size: 4, scaledConfigurationValue: 600),\n\t\t// Interval to send Report group 3\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 113, size: 4, scaledConfigurationValue: 600),\n        \n        // get LED behavior\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 81),\n    \t// get night light RGB value\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 83),\n    \t// get Energy Mode/momentary indicate LED brightness value\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 84),\n    \t// Which reports need to send in Report group 1\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 101),\n\t\t// Which reports need to send in Report group 2\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 102),\n\t\t// Which reports need to send in Report group 3\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 103),\n    \t// Interval to send Report group 1\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 111),\n\t\t// Interval to send Report group 2\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 112),\n\t\t// Interval to send Report group 3\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 113),\n\t\t\n\t\t// Can use the zwaveHubNodeId variable to add the hub to the device's associations:\n\t\tzwave.associationV1.associationSet(groupingIdentifier:2, nodeId:zwaveHubNodeId)\n    ]\n\tcommands(request)\n}\n\nprivate setConfigured() {\n\tupdateDataValue(\"configured\", \"true\")\n}\n\nprivate isConfigured() {\n\tgetDataValue(\"configured\") == \"true\"\n}\n\nprivate command(physicalgraph.zwave.Command cmd) {\n\tif (state.sec) {\n\t\tzwave.securityV1.securityMessageEncapsulation().encapsulate(cmd).format()\n\t} else {\n\t\tcmd.format()\n\t}\n}\n\nprivate commands(commands, delay=1000) {\n\tdelayBetween(commands.collect{ command(it) }, delay)\n}\n"
  },
  {
    "path": "Aeon SmartSwitch 6/device_type-aeon-smartswitch6-v0.2",
    "content": "/*\n * V 0.2 of Aeon Smart Switch 6 code 10/5/2015\n *  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except\n *  in compliance with the License. You may obtain a copy of the License at:\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n *  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed\n *  on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License\n *  for the specific language governing permissions and limitations under the License.\n *\n * change log:\n * v 0.2 - added support for secure inclusion and command encapsulation\n*/\n\n metadata {\n\tdefinition (name: \"Aeon Smart Switch 6 - RV v0.1\", namespace: \"robertvandervoort\", author: \"Robert Vandervoort\") {\n\t\tcapability \"Energy Meter\"\n\t\tcapability \"Power Meter\"\n\t\tcapability \"Actuator\"\n\t\tcapability \"Switch\"\n\t\tcapability \"Configuration\"\n\t\tcapability \"Polling\"\n\t\tcapability \"Refresh\"\n\t\tcapability \"Sensor\"\n\n\t\tcommand \"reset\"\n\n\t\t/* Capability notes\n        37, 38, 51, 112, 39, 50, 129, 133, 89, 122, 115\n        \n        0x2C COMMAND_CLASS_SCENE_ACTUATOR_CONF\n        0x2B COMMAND_CLASS_SCENE_ACTIVATION\t\t\n\t\t0x7A COMMAND_CLASS_FIRMWARE_UPDATE_MD 2\n\t\t0xEF COMMAND_CLASS_MARK 1\n\t\t0x5A ?\n\t\t0x5E ?   \n        0x25: 1 0x26: 1 0x27: 1 0x32: 3 0x33: 3 0x56: 0x59: 1 0x70: 1 0x72: 2 0x73: 1 0x82: 1 0x85: 2 0x86: 2\n        0x25 COMMAND_CLASS_SWITCH_BINARY 1 \n        0x26 COMMAND_CLASS_SWITCH_MULTILEVEL 1\n        0x27 COMMAND_CLASS_SWITCH_ALL 1\n        0x32 COMMAND_CLASS_METER 3\n        0x33 COMMAND_CLASS_COLOR_SWITCH 3\n        0x56 ?\n        0x59 COMMAND_CLASS_ASSOCIATION_GRP_INFO  1\n        0x70 COMMAND_CLASS_CONFIGURATION 1\n        0x72 COMMAND_CLASS_MANUFACTURER_SPECIFIC 2\n        0x73 COMMAND_CLASS_POWERLEVEL 1\n\t\t0x81 COMMAND_CLASS_CLOCK 1\n        0x82 COMMAND_CLASS_HAIL 1\n        0x85 COMMAND_CLASS_ASSOCIATION 2\n        0x86 COMMAND_CLASS_VERSION 2\n        */\n\t\tfingerprint deviceId: \"0x1001\", inClusters: \"0x25,0x26,0x27,0x32,0x2C,0x2B,0x33,0x85,0x56,0x59,0x5A,0x5E,0x70,0x72,0x73,0x85,0x86\", outClusters: \"0x82\"\n\t}\n\t// simulator metadata\n\tsimulator {\n\t\tstatus \"on\":  \"command: 2003, payload: FF\"\n\t\tstatus \"off\": \"command: 2003, payload: 00\"\n\n\tfor (int i = 0; i <= 10000; i += 1000) {\n\t    status \"power  ${i} W\": \n\t\t    new physicalgraph.zwave.Zwave().meterV3.meterReport(scaledMeterValue: i, precision: 3, meterType: 4, scale: 2, size: 4).incomingMessage()\n\t}\n\tfor (int i = 0; i <= 100; i += 10) {\n\t    status \"energy  ${i} kWh\":\n\t\t    new physicalgraph.zwave.Zwave().meterV3.meterReport(scaledMeterValue: i, precision: 3, meterType: 0, scale: 0, size: 4).incomingMessage()\n\t}\n\t\t// reply messages\n\t\treply \"2001FF,delay 100,2502\": \"command: 2503, payload: FF\"\n\t\treply \"200100,delay 100,2502\": \"command: 2503, payload: 00\"\n\n\t}\n\n\t// tile definitions\n\ttiles (scale: 2) {\n    \tmultiAttributeTile(name:\"main\", type:\"generic\", width:6, height:4, canChangeIcon: true) {\n\t\t\ttileAttribute(\"device.switch\", key: \"PRIMARY_CONTROL\") {\n            \tattributeState \"on\", label: '${name}', action: \"switch.off\", icon: \"st.switches.switch.on\", backgroundColor: \"#79b821\"\n\t\t\t\tattributeState \"off\", label: '${name}', action: \"switch.on\", icon: \"st.switches.switch.off\", backgroundColor: \"#ffffff\"\n            }\n            tileAttribute(\"device.power\", key: \"SECONDARY_CONTROL\") {\n                attributeState \"default\",label:'${currentValue} W'\n            }\n\t\t}\n\t\tvalueTile(\"energy\", \"device.energy\", decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'${currentValue} kWh', action:\"poll\"\n\t\t}\n\t\tvalueTile(\"current\", \"device.current\", decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'${currentValue} A', action:\"poll\"\n\t\t}\n        valueTile(\"voltage\", \"device.voltage\", decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'${currentValue} V', action:\"poll\"\n\t\t}\n\t\tstandardTile(\"reset\", \"device.energy\", inactiveLabel: false, decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'reset kWh', action:\"reset\"\n\t\t}\n\t\tstandardTile(\"configure\", \"device.power\", inactiveLabel: false, decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"configure\", label:'', action:\"configuration.configure\", icon:\"st.secondary.configure\"\n\t\t}\n\t\tstandardTile(\"refresh\", \"device.power\", inactiveLabel: false, decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'', action:\"refresh.refresh\", icon:\"st.secondary.refresh\"\n\t\t}\n\n\t\tmain \"main\",\"energy\",\"current\",\"voltage\"\n\t\tdetails([\"main\",\"energy\",\"current\",\"voltage\",\"reset\",\"refresh\",\"configure\"])\n\t}\n\t\n    preferences { \n\t\tinput \"ledBehavior\", \"integer\", \n\t\t\ttitle: \"LED Behavior\",\n            description: \"0=energy tracking, 1=momentary status, 2=night light\",\n\t\t\tdefaultValue: 0, \n\t\t\tdisplayDuringSetup: true,\n            range: \"0..2\"\n\t\tinput \"monitorInterval\", \"integer\", \n\t\t\ttitle: \"Monitoring Interval\", \n\t\t\tdescription: \"The time interval in seconds for sending device reports\", \n\t\t\tdefaultValue: 60, \n            range: \"1..4294967295‬\",\n\t\t\trequired: false, \n\t\t\tdisplayDuringSetup: true\n\t}\n}\n\ndef updated()\n{\n\tif (state.sec && !isConfigured()) {\n\t\t// in case we miss the SCSR\n\t\tresponse(configure())\n\t}\n}\n\ndef parse(String description)\n{\n\tdef result = null\n\tif (description.startsWith(\"Err 106\")) {\n\t\tstate.sec = 0\n\t\tresult = createEvent( name: \"secureInclusion\", value: \"failed\", isStateChange: true,\n\t\t\tdescriptionText: \"This sensor failed to complete the network security key exchange. If you are unable to control it via SmartThings, you must remove it from your network and add it again.\")\n\t} else if (description != \"updated\") {\n\t\tdef cmd = zwave.parse(description, [0x25: 1, 0x26: 1, 0x27: 1, 0x32: 3, 0x33: 3, 0x59: 1, 0x70: 1, 0x72: 2, 0x73: 1, 0x82: 1, 0x85: 2, 0x86: 2])\n\t\tif (cmd) {\n\t\t\tresult = zwaveEvent(cmd)\n\t\t}\n\t}\n\t// log.debug \"Parsed '${description}' to ${result.inspect()}\"\n\treturn result\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.securityv1.SecurityMessageEncapsulation cmd) {\n\tdef encapsulatedCommand = cmd.encapsulatedCommand([0x25: 1, 0x26: 1, 0x27: 1, 0x32: 3, 0x33: 3, 0x59: 1, 0x70: 1, 0x72: 2, 0x73: 1, 0x82: 1, 0x85: 2, 0x86: 2])\n\tstate.sec = 1\n\t// log.debug \"encapsulated: ${encapsulatedCommand}\"\n\tif (encapsulatedCommand) {\n\t\tzwaveEvent(encapsulatedCommand)\n\t} else {\n\t\tlog.warn \"Unable to extract encapsulated cmd from $cmd\"\n\t\tcreateEvent(descriptionText: cmd.toString())\n\t}\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.securityv1.SecurityCommandsSupportedReport cmd) {\n\tresponse(configure())\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.configurationv2.ConfigurationReport cmd) {\n    log.debug \"---CONFIGURATION REPORT V2--- ${device.displayName} parameter ${cmd.parameterNumber} with a byte size of ${cmd.size} is set to ${cmd.configurationValue}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.configurationv1.ConfigurationReport cmd) {\n    log.debug \"---CONFIGURATION REPORT V1--- ${device.displayName} parameter ${cmd.parameterNumber} with a byte size of ${cmd.size} is set to ${cmd.configurationValue}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.meterv3.MeterReport cmd) {\n    def meterTypes = [\"Unknown\", \"Electric\", \"Gas\", \"Water\"]\n    def electricNames = [\"energy\", \"energy\", \"power\", \"count\",  \"voltage\", \"current\", \"powerFactor\",  \"unknown\"]\n    def electricUnits = [\"kWh\",    \"kVAh\",   \"W\",     \"pulses\", \"V\",       \"A\",       \"Power Factor\", \"\"]\n\n    //NOTE ScaledPreviousMeterValue does not always contain a value\n    def previousValue = cmd.scaledPreviousMeterValue ?: 0\n\n    def map = [ name: electricNames[cmd.scale], unit: electricUnits[cmd.scale], displayed: state.display]\n    switch(cmd.scale) {\n        case 0: //kWh\n\t    previousValue = device.currentValue(\"energy\") ?: cmd.scaledPreviousMeterValue ?: 0\n            map.value = cmd.scaledMeterValue\n            break;\n        case 1: //kVAh\n            map.value = cmd.scaledMeterValue\n            break;\n        case 2: //Watts\n            previousValue = device.currentValue(\"power\") ?: cmd.scaledPreviousMeterValue ?: 0\n            map.value = Math.round(cmd.scaledMeterValue)\n            break;\n        case 3: //pulses\n            map.value = Math.round(cmd.scaledMeterValue)\n            break;\n        case 4: //Volts\n            previousValue = device.currentValue(\"voltage\") ?: cmd.scaledPreviousMeterValue ?: 0\n            map.value = cmd.scaledMeterValue\n            break;\n        case 5: //Amps\n            previousValue = device.currentValue(\"current\") ?: cmd.scaledPreviousMeterValue ?: 0\n            map.value = cmd.scaledMeterValue\n            break;\n        case 6: //Power Factor\n        case 7: //Unknown\n            map.value = cmd.scaledMeterValue\n            break;\n        default:\n            break;\n    }\n    //Check if the value has changed by more than 5%, if so mark as a stateChange\n    //map.isStateChange = ((cmd.scaledMeterValue - previousValue).abs() > (cmd.scaledMeterValue * 0.05))\n\n    createEvent(map)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicReport cmd)\n{\n\t[name: \"switch\", value: cmd.value ? \"on\" : \"off\", type: \"physical\", displayed: true, isStateChange: true]\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicSet cmd) \n{\n    [name: \"switch\", value: cmd.value ? \"on\" : \"off\", type: \"physical\", displayed: true, isStateChange: true]\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.switchbinaryv1.SwitchBinaryReport cmd)\n{\n\t[name: \"switch\", value: cmd.value ? \"on\" : \"off\", type: \"digital\", displayed: true, isStateChange: true]\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.switchbinaryv1.SwitchBinarySet cmd)\n{\n    [name: \"switch\", value: cmd.value ? \"on\" : \"off\", type: \"digital\", displayed: true, isStateChange: true]\n}\n\ndef zwaveEvent(physicalgraph.zwave.Command cmd) {\n\tlog.debug \"Unhandled: $cmd\"\n    createEvent(descriptionText: cmd.toString(), isStateChange: false)\n}\n\ndef on() {\n\tdef request = [\n\t\tzwave.basicV1.basicSet(value: 0xFF),\n\t    zwave.basicV1.basicGet(),\n\t\tzwave.switchBinaryV1.switchBinaryGet()\n\t]\n    commands(request)\n}\n\ndef off() {\n\tdef request = [\n\t\tzwave.basicV1.basicSet(value: 0x00),\n        zwave.basicV1.basicGet(),\n\t\tzwave.switchBinaryV1.switchBinaryGet()\n\t]\n    commands(request)\n}\n\ndef poll() {\n\tdef request = [\n\t\tzwave.switchBinaryV1.switchBinaryGet(),\n        zwave.basicV1.basicGet(),\n\t\tzwave.meterV3.meterGet(scale: 0),\t//kWh\n        zwave.meterV3.meterGet(scale: 1),\t//kVAh\n\t\tzwave.meterV3.meterGet(scale: 2),\t//Wattage\n\t\tzwave.meterV3.meterGet(scale: 4),\t//Volts\n\t\tzwave.meterV3.meterGet(scale: 5),\t//Amps\n        zwave.meterV3.meterGet(scale: 6)\t//Power Factor\n\t]\n    commands(request)\n}\n\ndef refresh() {\n\tdef request = [\n        zwave.basicV1.basicGet(),\n\t\tzwave.switchBinaryV1.switchBinaryGet()\n\t]\n    commands(request)\n}\n\ndef reset() {\n\tdef request = [\n\t\tzwave.meterV3.meterReset(),\n\t\tzwave.meterV3.meterGet(scale: 0),\t//kWh\n        zwave.meterV3.meterGet(scale: 1),\t//kVAh\n\t\tzwave.meterV3.meterGet(scale: 2),\t//Wattage\n\t\tzwave.meterV3.meterGet(scale: 4),\t//Volts\n\t\tzwave.meterV3.meterGet(scale: 5),\t//Amps\n        zwave.meterV3.meterGet(scale: 6)\t//Power Factor\n\t]\n    commands(request)\n}\n\ndef configure() {\n    def monitorInt = 60\n\t\tif (monitorInterval) {\n\t\t\tmonitorInt=monitorInterval.toInteger()\n\t\t}\n\tdef ledBehave = 0\n    \tif (ledBehavior) {\n        \tledBehave=ledBehavior.toInteger()\n        }\n    log.debug \"Sending configure commands - monitorInterval '${monitorInt}', ledBehavior '${ledBehave}'\"\n\tdef request = [\n    \t// Reset switch configuration to defaults\n        // zwave.configurationV1.configurationSet(parameterNumber: 255, size: 1, scaledConfigurationValue: 1),\n\t\t// set LED behavior 0 energy mode 1 momentary display 2 night light\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 81, size: 1, scaledConfigurationValue: ledBehave),\n\t\t// Which reports need to send in Report group 1\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 101, size: 4, scaledConfigurationValue: 4|2|1),\n\t\t// Which reports need to send in Report group 2\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 102, size: 4, scaledConfigurationValue: 8),\n\t\t// Which reports need to send in Report group 3\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 103, size: 4, scaledConfigurationValue: 0),\n\t\t// Interval to send Report group 1\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 111, size: 4, scaledConfigurationValue: monitorInt),\n\t\t// Interval to send Report group 2\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 112, size: 4, scaledConfigurationValue: 60),\n\t\t// Interval to send Report group 3\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 113, size: 4, scaledConfigurationValue: 0),\n        \n        // get LED behavior\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 81),\n    \t// get night light RGB value\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 83),\n    \t// get Energy Mode/momentary indicate LED brightness value\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 84),\n    \t// Which reports need to send in Report group 1\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 101),\n\t\t// Which reports need to send in Report group 2\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 102),\n\t\t// Which reports need to send in Report group 3\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 103),\n    \t// Interval to send Report group 1\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 111),\n\t\t// Interval to send Report group 2\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 112),\n\t\t// Interval to send Report group 3\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 113),\n\t\t\n\t\t// Can use the zwaveHubNodeId variable to add the hub to the device's associations:\n\t\tzwave.associationV1.associationSet(groupingIdentifier:2, nodeId:zwaveHubNodeId)\n    ]\n\tcommands(request)\n}\n\nprivate setConfigured() {\n\tupdateDataValue(\"configured\", \"true\")\n}\n\nprivate isConfigured() {\n\tgetDataValue(\"configured\") == \"true\"\n}\n\nprivate command(physicalgraph.zwave.Command cmd) {\n\tif (state.sec) {\n\t\tzwave.securityV1.securityMessageEncapsulation().encapsulate(cmd).format()\n\t} else {\n\t\tcmd.format()\n\t}\n}\n\nprivate commands(commands, delay=500) {\n\tdelayBetween(commands.collect{ command(it) }, delay)\n}\n"
  },
  {
    "path": "Aeon SmartSwitch 6/device_type-aeon-smartswitch6-v0.4",
    "content": "/*\n * V 0.4 of Aeon Smart Switch 6 code 10/5/2015\n *  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except\n *  in compliance with the License. You may obtain a copy of the License at:\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n *  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed\n *  on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License\n *  for the specific language governing permissions and limitations under the License.\n *\n * some code used from various SmartThings device type and metering code from ElasticDev\n *\n * change log:\n * v 0.2 - added support for secure inclusion and command encapsulation\n * v 0.3 - added brightness control and zwave power level node report reporting support (6 second button press)\n * v 0.4 - added color control for the night light behavior\n*/\n\n metadata {\n\tdefinition (name: \"Aeon Smart Switch 6 - RV v0.4\", namespace: \"robertvandervoort\", author: \"Robert Vandervoort\") {\n\t\tcapability \"Energy Meter\"\n\t\tcapability \"Power Meter\"\n\t\tcapability \"Actuator\"\n\t\tcapability \"Switch\"\n        capability \"Color Control\"\n\t\tcapability \"Configuration\"\n\t\tcapability \"Polling\"\n\t\tcapability \"Refresh\"\n\t\tcapability \"Sensor\"\n\n\t\tcommand \"reset\"\n\n\t\tfingerprint deviceId: \"0x1001\", inClusters: \"0x98\"\n        fingerprint inClusters: \"0x25,0x26,0x27,0x32,0x2C,0x2B,0x33,0x85,0x56,0x59,0x5A,0x5E,0x70,0x72,0x73,0x85,0x86\", outClusters: \"0x82\"\n\t}\n\t// simulator metadata\n\tsimulator {\n\t\tstatus \"on\":  \"command: 2003, payload: FF\"\n\t\tstatus \"off\": \"command: 2003, payload: 00\"\n\n\tfor (int i = 0; i <= 10000; i += 1000) {\n\t    status \"power  ${i} W\": \n\t\t    new physicalgraph.zwave.Zwave().meterV3.meterReport(scaledMeterValue: i, precision: 3, meterType: 4, scale: 2, size: 4).incomingMessage()\n\t}\n\tfor (int i = 0; i <= 100; i += 10) {\n\t    status \"energy  ${i} kWh\":\n\t\t    new physicalgraph.zwave.Zwave().meterV3.meterReport(scaledMeterValue: i, precision: 3, meterType: 0, scale: 0, size: 4).incomingMessage()\n\t}\n\t\t// reply messages\n\t\treply \"2001FF,delay 100,2502\": \"command: 2503, payload: FF\"\n\t\treply \"200100,delay 100,2502\": \"command: 2503, payload: 00\"\n\n\t}\n\n\t// tile definitions\n\ttiles (scale: 2) {\n    \tmultiAttributeTile(name:\"main\", type:\"generic\", width:6, height:4, canChangeIcon: true) {\n\t\t\ttileAttribute(\"device.switch\", key: \"PRIMARY_CONTROL\") {\n            \tattributeState \"on\", label: '${name}', action: \"switch.off\", icon: \"st.switches.switch.on\", backgroundColor: \"#79b821\"\n\t\t\t\tattributeState \"off\", label: '${name}', action: \"switch.on\", icon: \"st.switches.switch.off\", backgroundColor: \"#ffffff\"\n            }\n            tileAttribute(\"device.power\", key: \"SECONDARY_CONTROL\") {\n                attributeState \"default\",label:'${currentValue} W'\n            }\n\t\t}\n\t\tvalueTile(\"energy\", \"device.energy\", decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'${currentValue} kWh', action:\"poll\"\n\t\t}\n\t\tvalueTile(\"current\", \"device.current\", decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'${currentValue} A', action:\"poll\"\n\t\t}\n        valueTile(\"voltage\", \"device.voltage\", decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'${currentValue} V', action:\"poll\"\n\t\t}\n        controlTile(\"rgbSelector\", \"device.color\", \"color\", height: 2, width: 2, inactiveLabel: false) {\n\t\t\tstate \"color\", action:\"setColor\"\n\t\t}\n\t\tstandardTile(\"reset\", \"device.energy\", inactiveLabel: false, decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'reset kWh', action:\"reset\"\n\t\t}\n\t\tstandardTile(\"configure\", \"device.power\", inactiveLabel: false, decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"configure\", label:'', action:\"configuration.configure\", icon:\"st.secondary.configure\"\n\t\t}\n\t\tstandardTile(\"refresh\", \"device.power\", inactiveLabel: false, decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'', action:\"refresh.refresh\", icon:\"st.secondary.refresh\"\n\t\t}\n\t\tmain \"main\",\"energy\",\"current\",\"voltage\"\n\t\tdetails([\"main\",\"energy\",\"current\",\"voltage\",\"rgbSelector\",\"reset\",\"refresh\",\"configure\"])\n\t}\n\t\n    preferences { \n\t\tinput \"ledBehavior\", \"integer\", \n\t\t\ttitle: \"LED Behavior\",\n            description: \"0=energy tracking, 1=momentary status, 2=night light\",\n\t\t\tdefaultValue: 0, \n\t\t\tdisplayDuringSetup: true,\n            range: \"0..2\"\n\t\tinput \"monitorInterval\", \"integer\", \n\t\t\ttitle: \"Monitoring Interval\", \n\t\t\tdescription: \"The time interval in seconds for sending device reports\", \n\t\t\tdefaultValue: 60, \n            range: \"1..4294967295‬\",\n\t\t\trequired: false, \n\t\t\tdisplayDuringSetup: true\n\t\tinput \"ledBrightness\", \"integer\",\n        \ttitle: \"LED Brightness\",\n            description: \"Set the % brightness of indicator LEDs\",\n            defaultValue: 50,\n            range: \"0..100\",\n            required: false,\n            displayduringSetup: true\n\t}\n}\n\ndef updated()\n{\n\tif (state.sec && !isConfigured()) {\n\t\t// in case we miss the SCSR\n\t\tresponse(configure())\n\t}\n}\n\ndef parse(String description)\n{\n\tdef result = null\n\tif (description.startsWith(\"Err 106\")) {\n\t\tstate.sec = 0\n\t\tresult = createEvent( name: \"secureInclusion\", value: \"failed\", isStateChange: true,\n\t\t\tdescriptionText: \"This sensor failed to complete the network security key exchange. If you are unable to control it via SmartThings, you must remove it from your network and add it again.\")\n\t} else if (description != \"updated\") {\n\t\tdef cmd = zwave.parse(description, [0x25: 1, 0x26: 1, 0x27: 1, 0x32: 3, 0x33: 3, 0x59: 1, 0x70: 1, 0x72: 2, 0x73: 1, 0x82: 1, 0x85: 2, 0x86: 2])\n\t\tif (cmd) {\n\t\t\tresult = zwaveEvent(cmd)\n\t\t}\n\t}\n\t// log.debug \"Parsed '${description}' to ${result.inspect()}\"\n\treturn result\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.securityv1.SecurityMessageEncapsulation cmd) {\n\tdef encapsulatedCommand = cmd.encapsulatedCommand([0x25: 1, 0x26: 1, 0x27: 1, 0x32: 3, 0x33: 3, 0x59: 1, 0x70: 1, 0x72: 2, 0x73: 1, 0x82: 1, 0x85: 2, 0x86: 2])\n\tstate.sec = 1\n\t// log.debug \"encapsulated: ${encapsulatedCommand}\"\n\tif (encapsulatedCommand) {\n\t\tzwaveEvent(encapsulatedCommand)\n\t} else {\n\t\tlog.warn \"Unable to extract encapsulated cmd from $cmd\"\n\t\tcreateEvent(descriptionText: cmd.toString())\n\t}\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.securityv1.SecurityCommandsSupportedReport cmd) {\n\tresponse(configure())\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.powerlevelv1.PowerlevelTestNodeReport cmd) {\n\tlog.debug \"===Power level test node report received=== ${device.displayName}: statusOfOperation: ${cmd.statusOfOperation} testFrameCount: ${cmd.testFrameCount} testNodeid: ${cmd.testNodeid}\"\n\tdef request = [\n        physicalgraph.zwave.commands.powerlevelv1.PowerlevelGet()\n    ]\n    response(commands(request))\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.configurationv2.ConfigurationReport cmd) {\n    log.debug \"---CONFIGURATION REPORT V2--- ${device.displayName} parameter ${cmd.parameterNumber} with a byte size of ${cmd.size} is set to ${cmd.configurationValue}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.configurationv1.ConfigurationReport cmd) {\n    log.debug \"---CONFIGURATION REPORT V1--- ${device.displayName} parameter ${cmd.parameterNumber} with a byte size of ${cmd.size} is set to ${cmd.configurationValue}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.meterv3.MeterReport cmd) {\n    def meterTypes = [\"Unknown\", \"Electric\", \"Gas\", \"Water\"]\n    def electricNames = [\"energy\", \"energy\", \"power\", \"count\",  \"voltage\", \"current\", \"powerFactor\",  \"unknown\"]\n    def electricUnits = [\"kWh\",    \"kVAh\",   \"W\",     \"pulses\", \"V\",       \"A\",       \"Power Factor\", \"\"]\n\n    //NOTE ScaledPreviousMeterValue does not always contain a value\n    def previousValue = cmd.scaledPreviousMeterValue ?: 0\n\n    def map = [ name: electricNames[cmd.scale], unit: electricUnits[cmd.scale], displayed: state.display]\n    switch(cmd.scale) {\n        case 0: //kWh\n\t    previousValue = device.currentValue(\"energy\") ?: cmd.scaledPreviousMeterValue ?: 0\n            map.value = cmd.scaledMeterValue\n            break;\n        case 1: //kVAh\n            map.value = cmd.scaledMeterValue\n            break;\n        case 2: //Watts\n            previousValue = device.currentValue(\"power\") ?: cmd.scaledPreviousMeterValue ?: 0\n            map.value = Math.round(cmd.scaledMeterValue)\n            break;\n        case 3: //pulses\n            map.value = Math.round(cmd.scaledMeterValue)\n            break;\n        case 4: //Volts\n            previousValue = device.currentValue(\"voltage\") ?: cmd.scaledPreviousMeterValue ?: 0\n            map.value = cmd.scaledMeterValue\n            break;\n        case 5: //Amps\n            previousValue = device.currentValue(\"current\") ?: cmd.scaledPreviousMeterValue ?: 0\n            map.value = cmd.scaledMeterValue\n            break;\n        case 6: //Power Factor\n        case 7: //Unknown\n            map.value = cmd.scaledMeterValue\n            break;\n        default:\n            break;\n    }\n    //Check if the value has changed by more than 5%, if so mark as a stateChange\n    //map.isStateChange = ((cmd.scaledMeterValue - previousValue).abs() > (cmd.scaledMeterValue * 0.05))\n\n    createEvent(map)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicReport cmd)\n{\n\t[name: \"switch\", value: cmd.value ? \"on\" : \"off\", type: \"physical\", displayed: true, isStateChange: true]\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicSet cmd) \n{\n    [name: \"switch\", value: cmd.value ? \"on\" : \"off\", type: \"physical\", displayed: true, isStateChange: true]\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.switchbinaryv1.SwitchBinaryReport cmd)\n{\n\t[name: \"switch\", value: cmd.value ? \"on\" : \"off\", type: \"digital\", displayed: true, isStateChange: true]\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.switchbinaryv1.SwitchBinarySet cmd)\n{\n    [name: \"switch\", value: cmd.value ? \"on\" : \"off\", type: \"digital\", displayed: true, isStateChange: true]\n}\n\ndef zwaveEvent(physicalgraph.zwave.Command cmd) {\n\tlog.debug \"Unhandled: $cmd\"\n    createEvent(descriptionText: cmd.toString(), isStateChange: false)\n}\n\ndef on() {\n\tdef request = [\n\t\tzwave.basicV1.basicSet(value: 0xFF),\n\t    zwave.basicV1.basicGet(),\n\t\tzwave.switchBinaryV1.switchBinaryGet()\n\t]\n    commands(request)\n}\n\ndef off() {\n\tdef request = [\n\t\tzwave.basicV1.basicSet(value: 0x00),\n        zwave.basicV1.basicGet(),\n\t\tzwave.switchBinaryV1.switchBinaryGet()\n\t]\n    commands(request)\n}\n\ndef setColor(value) {\n\tdef result = []\n\tlog.debug \"setColor: ${value}\"\n\tif (value.hex) {\n\t\tdef c = value.hex.findAll(/[0-9a-fA-F]{2}/).collect { Integer.parseInt(it, 16) }\n        result << zwave.configurationV1.configurationSet(parameterNumber: 83, size: 3, configurationValue: [c[0], c[1], c[2]])\n\t}\n\tif(value.hex) sendEvent(name: \"color\", value: value.hex)\n    commands(result)\n}\n\ndef poll() {\n\tdef request = [\n\t\tzwave.switchBinaryV1.switchBinaryGet(),\n        zwave.basicV1.basicGet(),\n\t\tzwave.meterV3.meterGet(scale: 0),\t//kWh\n        zwave.meterV3.meterGet(scale: 1),\t//kVAh\n\t\tzwave.meterV3.meterGet(scale: 2),\t//Wattage\n\t\tzwave.meterV3.meterGet(scale: 4),\t//Volts\n\t\tzwave.meterV3.meterGet(scale: 5),\t//Amps\n        zwave.meterV3.meterGet(scale: 6)\t//Power Factor\n\t]\n    commands(request)\n}\n\ndef refresh() {\n\tdef request = [\n        zwave.basicV1.basicGet(),\n\t\tzwave.switchBinaryV1.switchBinaryGet()\n\t]\n    commands(request)\n}\n\ndef reset() {\n\tdef request = [\n\t\tzwave.meterV3.meterReset(),\n\t\tzwave.meterV3.meterGet(scale: 0),\t//kWh\n        zwave.meterV3.meterGet(scale: 1),\t//kVAh\n\t\tzwave.meterV3.meterGet(scale: 2),\t//Wattage\n\t\tzwave.meterV3.meterGet(scale: 4),\t//Volts\n\t\tzwave.meterV3.meterGet(scale: 5),\t//Amps\n        zwave.meterV3.meterGet(scale: 6)\t//Power Factor\n\t]\n    commands(request)\n}\n\ndef configure() {\n    def monitorInt = 60\n\t\tif (monitorInterval) {\n\t\t\tmonitorInt=monitorInterval.toInteger()\n\t\t}\n\tdef ledBehave = 0\n    \tif (ledBehavior) {\n        \tledBehave=ledBehavior.toInteger()\n        }\n\tdef ledBright = 50\n    \tif (ledBrightness) {\n        \tledBright=ledBrightness.toInteger()\n\t\t}\n    log.debug \"Sending configure commands - monitorInterval '${monitorInt}', ledBehavior '${ledBehave}'\"\n\tdef request = [\n    \t// Reset switch configuration to defaults\n        // zwave.configurationV1.configurationSet(parameterNumber: 255, size: 1, scaledConfigurationValue: 1),\n\t\t// Enable to send notifications to associated devices (Group 1) when the state of Micro Switch’s load changed (0=nothing, 1=hail CC, 2=basic CC report)\n        zwave.configurationV1.configurationSet(parameterNumber: 80, size: 1, configurationValue: [2]),\n        // set LED behavior 0 energy mode 1 momentary display 2 night light\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 81, size: 1, scaledConfigurationValue: ledBehave),\n\t\t// Set LED brightness\n        zwave.configurationV1.configurationSet(parameterNumber: 84, size: 3, configurationValue: [ledBright,ledBright,ledBright]),\n        // Which reports need to send in Report group 1\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 101, size: 4, scaledConfigurationValue: 4|2|1),\n\t\t// Which reports need to send in Report group 2\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 102, size: 4, scaledConfigurationValue: 8),\n\t\t// Which reports need to send in Report group 3\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 103, size: 4, scaledConfigurationValue: 0),\n\t\t// Interval to send Report group 1\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 111, size: 4, scaledConfigurationValue: monitorInt),\n\t\t// Interval to send Report group 2\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 112, size: 4, scaledConfigurationValue: 60),\n\t\t// Interval to send Report group 3\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 113, size: 4, scaledConfigurationValue: 0),\n        \n        // get LED behavior\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 81),\n    \t// get night light RGB value\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 83),\n    \t// get Energy Mode/momentary indicate LED brightness value\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 84),\n    \t// Which reports need to send in Report group 1\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 101),\n\t\t// Which reports need to send in Report group 2\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 102),\n\t\t// Which reports need to send in Report group 3\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 103),\n    \t// Interval to send Report group 1\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 111),\n\t\t// Interval to send Report group 2\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 112),\n\t\t// Interval to send Report group 3\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 113),\n\t\t\n\t\t// Can use the zwaveHubNodeId variable to add the hub to the device's associations:\n\t\tzwave.associationV1.associationSet(groupingIdentifier:2, nodeId:zwaveHubNodeId)\n    ]\n\tcommands(request)\n}\n\nprivate setConfigured() {\n\tupdateDataValue(\"configured\", \"true\")\n}\n\nprivate isConfigured() {\n\tgetDataValue(\"configured\") == \"true\"\n}\n\nprivate command(physicalgraph.zwave.Command cmd) {\n\tif (state.sec) {\n\t\tzwave.securityV1.securityMessageEncapsulation().encapsulate(cmd).format()\n\t} else {\n\t\tcmd.format()\n\t}\n}\n\nprivate commands(commands, delay=500) {\n\tdelayBetween(commands.collect{ command(it) }, delay)\n}"
  },
  {
    "path": "Aeon SmartSwitch 6/device_type-aeon-smartswitch6-v0.4-ANDROID",
    "content": "/*\n * V 0.4 of Aeon Smart Switch 6 code 10/5/2015\n *  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except\n *  in compliance with the License. You may obtain a copy of the License at:\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n *  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed\n *  on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License\n *  for the specific language governing permissions and limitations under the License.\n *\n * some code used from various SmartThings device type and metering code from ElasticDev\n *\n * change log:\n * v 0.2 - added support for secure inclusion and command encapsulation\n * v 0.3 - added brightness control and zwave power level node report reporting support (6 second button press)\n * v 0.4 - added color control for the night light behavior\n * ANDROID - Thanks Jeff_Pollock and RBoy for pointing out the Range values bug in Android helping to get this workign on Android OS\n\n*/\n\n metadata {\n\tdefinition (name: \"Aeon Smart Switch 6 - RV v0.4\", namespace: \"robertvandervoort\", author: \"Robert Vandervoort\") {\n\t\tcapability \"Energy Meter\"\n\t\tcapability \"Power Meter\"\n\t\tcapability \"Actuator\"\n\t\tcapability \"Switch\"\n        capability \"Color Control\"\n\t\tcapability \"Configuration\"\n\t\tcapability \"Polling\"\n\t\tcapability \"Refresh\"\n\t\tcapability \"Sensor\"\n\n\t\tcommand \"reset\"\n\n\t\tfingerprint deviceId: \"0x1001\", inClusters: \"0x98\"\n        fingerprint inClusters: \"0x25,0x26,0x27,0x32,0x2C,0x2B,0x33,0x85,0x56,0x59,0x5A,0x5E,0x70,0x72,0x73,0x85,0x86\", outClusters: \"0x82\"\n\t}\n\t// simulator metadata\n\tsimulator {\n\t\tstatus \"on\":  \"command: 2003, payload: FF\"\n\t\tstatus \"off\": \"command: 2003, payload: 00\"\n\n\tfor (int i = 0; i <= 10000; i += 1000) {\n\t    status \"power  ${i} W\": \n\t\t    new physicalgraph.zwave.Zwave().meterV3.meterReport(scaledMeterValue: i, precision: 3, meterType: 4, scale: 2, size: 4).incomingMessage()\n\t}\n\tfor (int i = 0; i <= 100; i += 10) {\n\t    status \"energy  ${i} kWh\":\n\t\t    new physicalgraph.zwave.Zwave().meterV3.meterReport(scaledMeterValue: i, precision: 3, meterType: 0, scale: 0, size: 4).incomingMessage()\n\t}\n\t\t// reply messages\n\t\treply \"2001FF,delay 100,2502\": \"command: 2503, payload: FF\"\n\t\treply \"200100,delay 100,2502\": \"command: 2503, payload: 00\"\n\n\t}\n\n\t// tile definitions\n\ttiles (scale: 2) {\n    \tmultiAttributeTile(name:\"main\", type:\"generic\", width:6, height:4, canChangeIcon: true) {\n\t\t\ttileAttribute(\"device.switch\", key: \"PRIMARY_CONTROL\") {\n            \tattributeState \"on\", label: '${name}', action: \"switch.off\", icon: \"st.switches.switch.on\", backgroundColor: \"#79b821\"\n\t\t\t\tattributeState \"off\", label: '${name}', action: \"switch.on\", icon: \"st.switches.switch.off\", backgroundColor: \"#ffffff\"\n            }\n            tileAttribute(\"device.power\", key: \"SECONDARY_CONTROL\") {\n                attributeState \"default\",label:'${currentValue} W'\n            }\n\t\t}\n\t\tvalueTile(\"energy\", \"device.energy\", decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'${currentValue} kWh', action:\"poll\"\n\t\t}\n\t\tvalueTile(\"current\", \"device.current\", decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'${currentValue} A', action:\"poll\"\n\t\t}\n        valueTile(\"voltage\", \"device.voltage\", decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'${currentValue} V', action:\"poll\"\n\t\t}\n        controlTile(\"rgbSelector\", \"device.color\", \"color\", height: 2, width: 2, inactiveLabel: false) {\n\t\t\tstate \"color\", action:\"setColor\"\n\t\t}\n\t\tstandardTile(\"reset\", \"device.energy\", inactiveLabel: false, decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'reset kWh', action:\"reset\"\n\t\t}\n\t\tstandardTile(\"configure\", \"device.power\", inactiveLabel: false, decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"configure\", label:'', action:\"configuration.configure\", icon:\"st.secondary.configure\"\n\t\t}\n\t\tstandardTile(\"refresh\", \"device.power\", inactiveLabel: false, decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'', action:\"refresh.refresh\", icon:\"st.secondary.refresh\"\n\t\t}\n\t\tmain \"main\",\"energy\",\"current\",\"voltage\"\n\t\tdetails([\"main\",\"energy\",\"current\",\"voltage\",\"rgbSelector\",\"reset\",\"refresh\",\"configure\"])\n\t}\n\t\n    preferences { \n\t\tinput \"ledBehavior\", \"integer\", \n\t\t\ttitle: \"LED Behavior\",\n            description: \"0=energy tracking, 1=momentary status, 2=night light\",\n\t\t\tdefaultValue: 0, \n\t\t\tdisplayDuringSetup: true\n\t\tinput \"monitorInterval\", \"integer\", \n\t\t\ttitle: \"Monitoring Interval\", \n\t\t\tdescription: \"The time interval in seconds for sending device reports\", \n\t\t\tdefaultValue: 60, \n\t\t\trequired: false, \n\t\t\tdisplayDuringSetup: true\n\t\tinput \"ledBrightness\", \"integer\",\n        \ttitle: \"LED Brightness\",\n            description: \"Set the % brightness of indicator LEDs\",\n            defaultValue: 50,\n            required: false,\n            displayduringSetup: true\n\t}\n}\n\ndef updated()\n{\n\tif (state.sec && !isConfigured()) {\n\t\t// in case we miss the SCSR\n\t\tresponse(configure())\n\t}\n}\n\ndef parse(String description)\n{\n\tdef result = null\n\tif (description.startsWith(\"Err 106\")) {\n\t\tstate.sec = 0\n\t\tresult = createEvent( name: \"secureInclusion\", value: \"failed\", isStateChange: true,\n\t\t\tdescriptionText: \"This sensor failed to complete the network security key exchange. If you are unable to control it via SmartThings, you must remove it from your network and add it again.\")\n\t} else if (description != \"updated\") {\n\t\tdef cmd = zwave.parse(description, [0x25: 1, 0x26: 1, 0x27: 1, 0x32: 3, 0x33: 3, 0x59: 1, 0x70: 1, 0x72: 2, 0x73: 1, 0x82: 1, 0x85: 2, 0x86: 2])\n\t\tif (cmd) {\n\t\t\tresult = zwaveEvent(cmd)\n\t\t}\n\t}\n\t// log.debug \"Parsed '${description}' to ${result.inspect()}\"\n\treturn result\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.securityv1.SecurityMessageEncapsulation cmd) {\n\tdef encapsulatedCommand = cmd.encapsulatedCommand([0x25: 1, 0x26: 1, 0x27: 1, 0x32: 3, 0x33: 3, 0x59: 1, 0x70: 1, 0x72: 2, 0x73: 1, 0x82: 1, 0x85: 2, 0x86: 2])\n\tstate.sec = 1\n\t// log.debug \"encapsulated: ${encapsulatedCommand}\"\n\tif (encapsulatedCommand) {\n\t\tzwaveEvent(encapsulatedCommand)\n\t} else {\n\t\tlog.warn \"Unable to extract encapsulated cmd from $cmd\"\n\t\tcreateEvent(descriptionText: cmd.toString())\n\t}\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.securityv1.SecurityCommandsSupportedReport cmd) {\n\tresponse(configure())\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.powerlevelv1.PowerlevelTestNodeReport cmd) {\n\tlog.debug \"===Power level test node report received=== ${device.displayName}: statusOfOperation: ${cmd.statusOfOperation} testFrameCount: ${cmd.testFrameCount} testNodeid: ${cmd.testNodeid}\"\n\tdef request = [\n        physicalgraph.zwave.commands.powerlevelv1.PowerlevelGet()\n    ]\n    response(commands(request))\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.configurationv2.ConfigurationReport cmd) {\n    log.debug \"---CONFIGURATION REPORT V2--- ${device.displayName} parameter ${cmd.parameterNumber} with a byte size of ${cmd.size} is set to ${cmd.configurationValue}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.configurationv1.ConfigurationReport cmd) {\n    log.debug \"---CONFIGURATION REPORT V1--- ${device.displayName} parameter ${cmd.parameterNumber} with a byte size of ${cmd.size} is set to ${cmd.configurationValue}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.meterv3.MeterReport cmd) {\n    def meterTypes = [\"Unknown\", \"Electric\", \"Gas\", \"Water\"]\n    def electricNames = [\"energy\", \"energy\", \"power\", \"count\",  \"voltage\", \"current\", \"powerFactor\",  \"unknown\"]\n    def electricUnits = [\"kWh\",    \"kVAh\",   \"W\",     \"pulses\", \"V\",       \"A\",       \"Power Factor\", \"\"]\n\n    //NOTE ScaledPreviousMeterValue does not always contain a value\n    def previousValue = cmd.scaledPreviousMeterValue ?: 0\n\n    def map = [ name: electricNames[cmd.scale], unit: electricUnits[cmd.scale], displayed: state.display]\n    switch(cmd.scale) {\n        case 0: //kWh\n\t    previousValue = device.currentValue(\"energy\") ?: cmd.scaledPreviousMeterValue ?: 0\n            map.value = cmd.scaledMeterValue\n            break;\n        case 1: //kVAh\n            map.value = cmd.scaledMeterValue\n            break;\n        case 2: //Watts\n            previousValue = device.currentValue(\"power\") ?: cmd.scaledPreviousMeterValue ?: 0\n            map.value = Math.round(cmd.scaledMeterValue)\n            break;\n        case 3: //pulses\n            map.value = Math.round(cmd.scaledMeterValue)\n            break;\n        case 4: //Volts\n            previousValue = device.currentValue(\"voltage\") ?: cmd.scaledPreviousMeterValue ?: 0\n            map.value = cmd.scaledMeterValue\n            break;\n        case 5: //Amps\n            previousValue = device.currentValue(\"current\") ?: cmd.scaledPreviousMeterValue ?: 0\n            map.value = cmd.scaledMeterValue\n            break;\n        case 6: //Power Factor\n        case 7: //Unknown\n            map.value = cmd.scaledMeterValue\n            break;\n        default:\n            break;\n    }\n    //Check if the value has changed by more than 5%, if so mark as a stateChange\n    //map.isStateChange = ((cmd.scaledMeterValue - previousValue).abs() > (cmd.scaledMeterValue * 0.05))\n\n    createEvent(map)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicReport cmd)\n{\n\t[name: \"switch\", value: cmd.value ? \"on\" : \"off\", type: \"physical\", displayed: true, isStateChange: true]\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicSet cmd) \n{\n    [name: \"switch\", value: cmd.value ? \"on\" : \"off\", type: \"physical\", displayed: true, isStateChange: true]\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.switchbinaryv1.SwitchBinaryReport cmd)\n{\n\t[name: \"switch\", value: cmd.value ? \"on\" : \"off\", type: \"digital\", displayed: true, isStateChange: true]\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.switchbinaryv1.SwitchBinarySet cmd)\n{\n    [name: \"switch\", value: cmd.value ? \"on\" : \"off\", type: \"digital\", displayed: true, isStateChange: true]\n}\n\ndef zwaveEvent(physicalgraph.zwave.Command cmd) {\n\tlog.debug \"Unhandled: $cmd\"\n    createEvent(descriptionText: cmd.toString(), isStateChange: false)\n}\n\ndef on() {\n\tdef request = [\n\t\tzwave.basicV1.basicSet(value: 0xFF),\n\t    zwave.basicV1.basicGet(),\n\t\tzwave.switchBinaryV1.switchBinaryGet()\n\t]\n    commands(request)\n}\n\ndef off() {\n\tdef request = [\n\t\tzwave.basicV1.basicSet(value: 0x00),\n        zwave.basicV1.basicGet(),\n\t\tzwave.switchBinaryV1.switchBinaryGet()\n\t]\n    commands(request)\n}\n\ndef setColor(value) {\n\tdef result = []\n\tlog.debug \"setColor: ${value}\"\n\tif (value.hex) {\n\t\tdef c = value.hex.findAll(/[0-9a-fA-F]{2}/).collect { Integer.parseInt(it, 16) }\n        result << zwave.configurationV1.configurationSet(parameterNumber: 83, size: 3, configurationValue: [c[0], c[1], c[2]])\n\t}\n\tif(value.hex) sendEvent(name: \"color\", value: value.hex)\n    commands(result)\n}\n\ndef poll() {\n\tdef request = [\n\t\tzwave.switchBinaryV1.switchBinaryGet(),\n        zwave.basicV1.basicGet(),\n\t\tzwave.meterV3.meterGet(scale: 0),\t//kWh\n        zwave.meterV3.meterGet(scale: 1),\t//kVAh\n\t\tzwave.meterV3.meterGet(scale: 2),\t//Wattage\n\t\tzwave.meterV3.meterGet(scale: 4),\t//Volts\n\t\tzwave.meterV3.meterGet(scale: 5),\t//Amps\n        zwave.meterV3.meterGet(scale: 6)\t//Power Factor\n\t]\n    commands(request)\n}\n\ndef refresh() {\n\tdef request = [\n        zwave.basicV1.basicGet(),\n\t\tzwave.switchBinaryV1.switchBinaryGet()\n\t]\n    commands(request)\n}\n\ndef reset() {\n\tdef request = [\n\t\tzwave.meterV3.meterReset(),\n\t\tzwave.meterV3.meterGet(scale: 0),\t//kWh\n        zwave.meterV3.meterGet(scale: 1),\t//kVAh\n\t\tzwave.meterV3.meterGet(scale: 2),\t//Wattage\n\t\tzwave.meterV3.meterGet(scale: 4),\t//Volts\n\t\tzwave.meterV3.meterGet(scale: 5),\t//Amps\n        zwave.meterV3.meterGet(scale: 6)\t//Power Factor\n\t]\n    commands(request)\n}\n\ndef configure() {\n    def monitorInt = 60\n\t\tif (monitorInterval) {\n\t\t\tmonitorInt=monitorInterval.toInteger()\n\t\t}\n\tdef ledBehave = 0\n    \tif (ledBehavior) {\n        \tledBehave=ledBehavior.toInteger()\n        }\n\tdef ledBright = 50\n    \tif (ledBrightness) {\n        \tledBright=ledBrightness.toInteger()\n\t\t}\n    log.debug \"Sending configure commands - monitorInterval '${monitorInt}', ledBehavior '${ledBehave}'\"\n\tdef request = [\n    \t// Reset switch configuration to defaults\n        // zwave.configurationV1.configurationSet(parameterNumber: 255, size: 1, scaledConfigurationValue: 1),\n\t\t// Enable to send notifications to associated devices (Group 1) when the state of Micro Switch’s load changed (0=nothing, 1=hail CC, 2=basic CC report)\n        zwave.configurationV1.configurationSet(parameterNumber: 80, size: 1, configurationValue: [2]),\n        // set LED behavior 0 energy mode 1 momentary display 2 night light\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 81, size: 1, scaledConfigurationValue: ledBehave),\n\t\t// Set LED brightness\n        zwave.configurationV1.configurationSet(parameterNumber: 84, size: 3, configurationValue: [ledBright,ledBright,ledBright]),\n        // Which reports need to send in Report group 1\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 101, size: 4, scaledConfigurationValue: 4|2|1),\n\t\t// Which reports need to send in Report group 2\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 102, size: 4, scaledConfigurationValue: 8),\n\t\t// Which reports need to send in Report group 3\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 103, size: 4, scaledConfigurationValue: 0),\n\t\t// Interval to send Report group 1\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 111, size: 4, scaledConfigurationValue: monitorInt),\n\t\t// Interval to send Report group 2\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 112, size: 4, scaledConfigurationValue: 60),\n\t\t// Interval to send Report group 3\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 113, size: 4, scaledConfigurationValue: 0),\n        \n        // get LED behavior\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 81),\n    \t// get night light RGB value\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 83),\n    \t// get Energy Mode/momentary indicate LED brightness value\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 84),\n    \t// Which reports need to send in Report group 1\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 101),\n\t\t// Which reports need to send in Report group 2\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 102),\n\t\t// Which reports need to send in Report group 3\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 103),\n    \t// Interval to send Report group 1\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 111),\n\t\t// Interval to send Report group 2\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 112),\n\t\t// Interval to send Report group 3\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 113),\n\t\t\n\t\t// Can use the zwaveHubNodeId variable to add the hub to the device's associations:\n\t\tzwave.associationV1.associationSet(groupingIdentifier:2, nodeId:zwaveHubNodeId)\n    ]\n\tcommands(request)\n}\n\nprivate setConfigured() {\n\tupdateDataValue(\"configured\", \"true\")\n}\n\nprivate isConfigured() {\n\tgetDataValue(\"configured\") == \"true\"\n}\n\nprivate command(physicalgraph.zwave.Command cmd) {\n\tif (state.sec) {\n\t\tzwave.securityV1.securityMessageEncapsulation().encapsulate(cmd).format()\n\t} else {\n\t\tcmd.format()\n\t}\n}\n\nprivate commands(commands, delay=500) {\n\tdelayBetween(commands.collect{ command(it) }, delay)\n}"
  },
  {
    "path": "GE Z-Wave Switch - Improved/device_type-GE-Z-Wave-Switch-Improved",
    "content": "/**\n *  Created from code Copyright 2015 SmartThings\n *\tmodified by Robert Vandervoort 6/12/2016\n *\n *  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except\n *  in compliance with the License. You may obtain a copy of the License at:\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n *  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed\n *  on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License\n *  for the specific language governing permissions and limitations under the License.\n *\n */\nmetadata {\n\tdefinition (name: \"GE/Jasco Z-Wave Switch\", namespace: \"robertvandervoort\", author: \"Robert Vandervoort\") {\n\t\tcapability \"Actuator\"\n\t\tcapability \"Indicator\"\n\t\tcapability \"Switch\"\n\t\tcapability \"Polling\"\n\t\tcapability \"Refresh\"\n\t\tcapability \"Sensor\"\n\t\tcapability \"Configuration\"\n\n\t\tfingerprint inClusters: \"0x25\"\n\t}\n\n\t// simulator metadata\n\tsimulator {\n\t\tstatus \"on\":  \"command: 2003, payload: FF\"\n\t\tstatus \"off\": \"command: 2003, payload: 00\"\n\n\t\t// reply messages\n\t\treply \"2001FF,delay 100,2502\": \"command: 2503, payload: FF\"\n\t\treply \"200100,delay 100,2502\": \"command: 2503, payload: 00\"\n\t}\n\n\t// tile definitions\n\ttiles(scale: 2) {\n\t\tmultiAttributeTile(name:\"switch\", type: \"lighting\", width: 6, height: 4, canChangeIcon: true){\n\t\t\ttileAttribute (\"device.switch\", key: \"PRIMARY_CONTROL\") {\n\t\t\t\tattributeState \"on\", label: '${name}', action: \"switch.off\", icon: \"st.switches.switch.on\", backgroundColor: \"#79b821\"\n\t\t\t\tattributeState \"off\", label: '${name}', action: \"switch.on\", icon: \"st.switches.switch.off\", backgroundColor: \"#ffffff\"\n\t\t\t}\n\t\t}\n\t\tstandardTile(\"indicator\", \"device.indicatorStatus\", width: 2, height: 2, inactiveLabel: false, decoration: \"flat\") {\n\t\t\tstate \"when off\", action:\"indicator.indicatorWhenOn\", icon:\"st.indicators.lit-when-off\"\n\t\t\tstate \"when on\", action:\"indicator.indicatorNever\", icon:\"st.indicators.lit-when-on\"\n\t\t\tstate \"never\", action:\"indicator.indicatorWhenOff\", icon:\"st.indicators.never-lit\"\n\t\t}\n\t\tstandardTile(\"refresh\", \"device.switch\", width: 2, height: 2, inactiveLabel: false, decoration: \"flat\") {\n\t\t\tstate \"default\", label:'', action:\"refresh.refresh\", icon:\"st.secondary.refresh\"\n\t\t}\n\t\tmain \"switch\"\n\t\tdetails([\"switch\",\"refresh\",\"indicator\"])\n\t}\n\tpreferences {\n\t\tinput \"debugOutput\", \"boolean\", \n\t\t\ttitle: \"Enable debug logging?\",\n\t\t\tdefaultValue: false,\n\t\t\tdisplayDuringSetup: true\n\t\tinput \"switchInvert\", \"boolean\",\n\t\t\ttitle: \"Switch inverted?\",\n\t\t\tdefaultValue: false,\n\t\t\tdisplayDuringSetup: false\n\t}\n}\n\ndef updated() {\n\tstate.debug = (\"true\" == debugOutput)\n\tresponse(configure())\n}\n\ndef parse(String description) {\n\tdef result = null\n\tdef cmd = zwave.parse(description, [0x20: 1, 0x70: 1])\n\tif (cmd) {\n\t\tresult = createEvent(zwaveEvent(cmd))\n\t}\n\tif (result?.name == 'hail' && hubFirmwareLessThan(\"000.011.00602\")) {\n\t\tresult = [result, response(zwave.basicV1.basicGet())]\n\t\tlog.debug \"Was hailed: requesting state update\"\n\t} else {\n\t\tlog.debug \"Parse returned ${result?.descriptionText}\"\n\t}\n\treturn result\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicReport cmd) {\n\t[name: \"switch\", value: cmd.value ? \"on\" : \"off\", type: \"physical\"]\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicSet cmd) {\n\t[name: \"switch\", value: cmd.value ? \"on\" : \"off\", type: \"physical\"]\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.switchbinaryv1.SwitchBinaryReport cmd) {\n\t[name: \"switch\", value: cmd.value ? \"on\" : \"off\", type: \"digital\"]\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.configurationv1.ConfigurationReport cmd) {\n\tif (state.debug) log.debug \"---CONFIGURATION REPORT V1--- ${device.displayName} parameter ${cmd.parameterNumber} with a byte size of ${cmd.size} is set to ${cmd.configurationValue}\"\n\tdef value = \"when off\"\n\tif (cmd.configurationValue[0] == 1) {value = \"when on\"}\n\tif (cmd.configurationValue[0] == 2) {value = \"never\"}\n\t[name: \"indicatorStatus\", value: value, display: true]\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.hailv1.Hail cmd) {\n\t[name: \"hail\", value: \"hail\", descriptionText: \"Switch button was pressed\", displayed: false]\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.manufacturerspecificv2.ManufacturerSpecificReport cmd) {\n\tif (state.debug) log.debug \"manufacturerId:   ${cmd.manufacturerId}\"\n\tif (state.debug) log.debug \"manufacturerName: ${cmd.manufacturerName}\"\n\tif (state.debug) log.debug \"productId:        ${cmd.productId}\"\n\tif (state.debug) log.debug \"productTypeId:    ${cmd.productTypeId}\"\n\tdef msr = String.format(\"%04X-%04X-%04X\", cmd.manufacturerId, cmd.productTypeId, cmd.productId)\n\tupdateDataValue(\"MSR\", msr)\n\tupdateDataValue(\"manufacturer\", cmd.manufacturerName)\n\tcreateEvent([descriptionText: \"$device.displayName MSR: $msr\", isStateChange: false])\n}\n\ndef zwaveEvent(physicalgraph.zwave.Command cmd) {\n\t// Handles all Z-Wave commands we aren't interested in\n\tif (state.debug) log.debug cmd\n\t}\n\ndef on() {\n\tdelayBetween([\n\t\tzwave.basicV1.basicSet(value: 0xFF).format(),\n\t\tzwave.switchBinaryV1.switchBinaryGet().format()\n\t])\n}\n\ndef off() {\n\tdelayBetween([\n\t\tzwave.basicV1.basicSet(value: 0x00).format(),\n\t\tzwave.switchBinaryV1.switchBinaryGet().format()\n\t])\n}\n\ndef poll() {\n\tdelayBetween([\n\t\tzwave.switchBinaryV1.switchBinaryGet().format(),\n\t\tzwave.manufacturerSpecificV1.manufacturerSpecificGet().format()\n\t])\n}\n\ndef refresh() {\n\tdelayBetween([\n\t\tzwave.switchBinaryV1.switchBinaryGet().format(),\n\t\tzwave.manufacturerSpecificV1.manufacturerSpecificGet().format()\n\t])\n}\n\ndef indicatorWhenOn() {\n\tsendEvent(name: \"indicatorStatus\", value: \"when on\", display: false)\n\tzwave.configurationV1.configurationSet(configurationValue: [1], parameterNumber: 3, size: 1).format()\n}\n\ndef indicatorWhenOff() {\n\tsendEvent(name: \"indicatorStatus\", value: \"when off\", display: false)\n\tzwave.configurationV1.configurationSet(configurationValue: [0], parameterNumber: 3, size: 1).format()\n}\n\ndef indicatorNever() {\n\tsendEvent(name: \"indicatorStatus\", value: \"never\", display: false)\n\tzwave.configurationV1.configurationSet(configurationValue: [2], parameterNumber: 3, size: 1).format()\n}\n\ndef configure() {\n\tif (state.debug) log.debug \"sending configuration to ${device.displayName}\"\n\tdef invertSwitch = 0\n\tif (switchInvert == true) {invertSwitch = 1}\n\tif (switchInvert == false) {invertSwitch = 0}\n\tdelayBetween([\n\t\tzwave.configurationV1.configurationSet(scaledConfigurationValue: invertSwitch, parameterNumber: 4, size: 1).format(),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0x00).format(),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0x04).format()\n\t])\n}\n\n"
  },
  {
    "path": "zooZ-4-in-1-Sensor-ZSE40/device_type-zooZ-4-in-1-Sensor-ZSE40_v1.2",
    "content": "/*\n * V 1.2 of zooZ 4-in-1 sensor code 6/12/2016\n * by Robert Vandervoort\n *\n *  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except\n *  in compliance with the License. You may obtain a copy of the License at:\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n *  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed\n *  on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License\n *  for the specific language governing permissions and limitations under the License.\n * \n---------------------------------------------------------------------------------------------------------------------------\n   INSTRUCTIONS:\n   * First you will need to create a new device handler in SmartThings. Log in to the IDE and click on Device Handlers in the top menu.\n   Then click \"from code\" below. You'l be presented with a blank area where you can copy this code and paste it in.\n   * Next, scroll to the bottom and click create. Now click save, then click publish > for me.\n   * You should now see this device type in your list of device handlers. Now we need to pair the device.\n   * Put SmartThings into inclusion mode by going through the add new device dialog.\n   On the bottom of the zooZ 4-in-1 you will see several small holes. There is a series of four holes and a hole all by itself.\n   You'll need a paperclip or something similar that fits into the hole. While holding the sensor a foot or so from the hub,\n   and with SmartThings in inclusion mode, gently depress the button inside the single hole twice rapidly. The light should blink.\n   Please wait a few moments (usually 10 seconds or so) and you should see \"zooZ 4-in-1 sensor - RV 1.0\" appear in the found devices area.\n   * Touch the \"zooZ 4-in-1 sensor - RV 1.0\" to configure. Here we will set your temperature scale preferecne and motion preferences.\n   After you make your choices, touch done in the app. \n   * Now go to your devices list in the SmartThings app and open up the newly added sensor.\n   * In order to get the configuration sent and initial sensor data, we need to wake the sensor up. Press the button on the device\n   one time while holding it close to the hub. If you pressed the button the sensor should blink yellow once. Wait about 30 seconds,\n   then refresh (drag the screen down) and you should see data on the screen for temp, humidity, illuminance, and battery.\n   ** If you do not, please wait a minute or so and refresh the screen again by sliding it down.\n   * If you still do not see anything after refreshing, touch the gear icon to enter the device preferences screen (make any adjustments or not) and then touch done.\n   This will reset the configuration state so the device can be configured again and polled for data. Once you're back at the device screen,\n   while holding the sensor close to the hub, press the small button we pressed earlier one time, making sure that the sensor blinks\n   (if it doesn't, press the button again) and wait a minute or so, then refresh the device screen in the app again.\n   You should see data on the screen now. \n   *** IF YOU STILL ARE NOT GETTING DATA, go back to the preferences screen and enable debug logging, and touch done. You do not need\n   to press the button on the sensor again at this point. Go into the SmartThings IDE and choose \"live logging\" from the top menu.\n   While on the live logging  screen and close to your hub with the sensor, press the button on the sensor, making sure it blinks, and watch the screen for results.\n   You should see several lines of data come in slowly. This should tell you all your settings and what the configuration on the sensor is actually set to.\n   It will then poll the sensors for data. If you do not ever see any data coming from the sensor, please post to the community or\n   message me via github or the SmartThings community. \n */\n \n metadata {\n\tdefinition (name: \"zooZ 4-in-1 sensor - RV 1.2\", namespace: \"robertvandervoort\", author: \"Robert Vandervoort\") {\n\t\tcapability \"Motion Sensor\"\n\t\tcapability \"Acceleration Sensor\"\n\t\tcapability \"Temperature Measurement\"\n\t\tcapability \"Relative Humidity Measurement\"\n\t\tcapability \"Illuminance Measurement\"\n\t\tcapability \"Configuration\"\n\t\tcapability \"Sensor\"\n\t\tcapability \"Battery\"\n\t\t\n        // RAW Description: 0 0 0x0701 0 0 0 e 0x5E 0x98 0x86 0x72 0x5A 0x85 0x59 0x73 0x80 0x71 0x31 0x70 0x84 0x7A   \t\t\t\t\t\t\t\t\t\t \n\t\tattribute \"tamper\", \"enum\", [\"detected\", \"clear\"]\n\t\tfingerprint deviceId: \"0x0701\", inClusters: \"0x5E,0x86,0x72,0x59,0x85,0x73,0x71,0x84,0x80,0x31,0x70,0x5A,0x98,0x7A\"\n\t\t}\n/*\tsimulator {\n\t\tstatus \"no motion\" : \"command: 9881, payload: 00300300\"\n\t\tstatus \"motion\"    : \"command: 9881, payload: 003003FF\"\n        status \"clear\" : \" command: 9881, payload: 0071050000000007030000\"\n        status \"tamper\" : \"command: 9881, payload: 007105000000FF07030000\"\n        \n        for (int i = 0; i <= 100; i += 20) {\n\t\t\tstatus \"temperature ${i}F\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().sensorMultilevelV2.sensorMultilevelReport(\n                \tscaledSensorValue: i,\n                    precision: 2,\n                    sensorType: 1,\n                    scale: 1\n\t\t\t\t)\n\t\t\t).incomingMessage()\n\t\t}\n\t\tfor (int i = 0; i <= 100; i += 20) {\n\t\t\tstatus \"RH ${i}%\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().sensorMultilevelV2.sensorMultilevelReport(\n                \tscaledSensorValue: i,\n                    sensorType: 5\n            \t)\n\t\t\t).incomingMessage()\n\t\t}\n\t\tfor (int i in [0, 1, 2, 8, 12, 16, 20, 24, 30, 64, 82, 100, 200, 500, 1000]) {\n\t\t\tstatus \"illuminance ${i}%\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().sensorMultilevelV2.sensorMultilevelReport(\n                scaledSensorValue: i,\n                sensorType: 3\n                )\n\t\t\t).incomingMessage()\n\t\t}\n\t\tfor (int i in [0, 5, 10, 15, 50, 99, 100]) {\n\t\t\tstatus \"battery ${i}%\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().batteryV1.batteryReport(\n                batteryLevel: i\n                )\n\t\t\t).incomingMessage()\n\t\t}\n\t\tstatus \"low battery alert\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().batteryV1.batteryReport(\n            \tbatteryLevel: 255\n            \t)\n\t\t\t).incomingMessage()\n\t\tstatus \"wake up\": \"command: 8407, payload:\"\n\t}\n*/\n\ttiles (scale: 2) {\n\t\tmultiAttributeTile(name:\"main\", type:\"generic\", width:6, height:4) {\n\t\t\ttileAttribute(\"device.temperature\", key: \"PRIMARY_CONTROL\") {\n            \tattributeState \"temperature\",label:'${currentValue}°', precision:2, backgroundColors:[\n                \t[value: 32, color: \"#153591\"],\n                    [value: 44, color: \"#1e9cbb\"],\n                    [value: 59, color: \"#90d2a7\"],\n\t\t\t\t\t[value: 74, color: \"#44b621\"],\n\t\t\t\t\t[value: 84, color: \"#f1d801\"],\n\t\t\t\t\t[value: 92, color: \"#d04e00\"],\n\t\t\t\t\t[value: 98, color: \"#bc2323\"]\n\t\t\t\t]\n            }\n            tileAttribute(\"device.humidity\", key: \"SECONDARY_CONTROL\") {\n                attributeState \"humidity\",label:'RH ${currentValue} %', precision:2\n            }\n\t\t}\n        standardTile(\"motion\",\"device.motion\", width: 2, height: 2) {\n            \tstate \"active\",label:'motion',icon:\"st.motion.motion.active\",backgroundColor:\"#53a7c0\"\n                state \"inactive\",label:'no motion',icon:\"st.motion.motion.inactive\",backgroundColor:\"#ffffff\"\n\t\t\t}\n\t\tvalueTile(\"humidity\",\"device.humidity\", width: 2, height: 2) {\n           \tstate \"humidity\",label:'RH ${currentValue}%', precision:2\n\t\t\t}\n\t\tvalueTile(\"illuminance\",\"device.illuminance\", width: 2, height: 2) {\n            \tstate \"luminosity\",label:'LIGHT ${currentValue}%', precision:2\n\t\t\t}\n\t\tstandardTile(\"acceleration\", \"device.acceleration\", width: 2, height: 2) {\n\t\t\tstate(\"active\", label:'tamper', icon:\"st.motion.acceleration.active\", backgroundColor:\"#ff0000\")\n\t\t\tstate(\"inactive\", label:'clear', icon:\"st.motion.acceleration.inactive\", backgroundColor:\"#00ff00\")\n\t\t}\n\t\tvalueTile(\"battery\", \"device.battery\", decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"battery\", label:'${currentValue}% battery'\n\t\t}\n\t\tmain([\"main\"])\n\t\tdetails([\"main\",\"humidity\",\"illuminance\",\"motion\",\"acceleration\",\"battery\"])\n\t}\n    preferences {\n\t\tinput \"debugOutput\", \"boolean\", \n\t\t\ttitle: \"Enable debug logging?\",\n\t\t\tdefaultValue: false,\n\t\t\tdisplayDuringSetup: true\n\t\tinput \"LEDbehavior\", \"enum\",\n\t\t\ttitle: \"LED Behavior\",\n\t\t\toptions: [\"LED Off\", \"Breathing\", \"Quick Blink on Temp/PIR\"],\n            defaultValue: \"Quick Blink on Temp/PIR\",\n\t\t\trequired: false,\n\t\t\tdisplayDuringSetup: false\n\t\tinput \"tempoffset\", \"number\",\n\t\t\ttitle: \"Reporting threshold  for temp\",\n            description: \"Enter a value 1-50 changing reporting threshold for temp. Represents 0.1 degree increments.\",\n            range: \"1..50\",\n\t\t\tdefaultValue: 50,\n            required: false,\n            displayDuringSetup: false\n\t\tinput \"humidityoffset\", \"number\",\n            title: \"Reporting threshold for humidity\",\n            description: \"Report when change occurs from 1%-50% RH)\",\n\t\t\trange: \"1..50\",\n\t\t\tdefaultValue: 1,\n\t\t\trequired: false,\n            displayDuringSetup: false\n\t\tinput \"luminanceoffset\", \"number\",\n            title: \"Reporting threshold for Luminance\",\n            description: \"valid values from 5% to 50%\",\n            range: \"5..50\",\n\t\t\tdefaultValue: 5,\n            required: false,\n\t        displayDuringSetup: false\n\t\tinput \"PIRsensitivity\", \"number\",\n    \t    title: \"PIR motion sensitivity\",\n\t\t\tdescription: \"A value from 1-7, from high to low sensitivity (1 is highest)\",\n\t\t\trange: \"1..7\",\n\t\t\tdefaultValue: 4,\n\t\t\trequired: false,\n\t\t\tdisplayDuringSetup: true\n\t\tinput \"MotionReset\", \"number\",\n    \t    title: \"PIR reset time\",\n\t\t\tdescription: \"Number of minutes to wait to report motion cleared after a motion event if there is no motion detected.\",\n\t\t\trange: \"1..255\",\n\t\t\tdefaultValue: 5,\n\t\t\trequired: false,\n\t\t\tdisplayDuringSetup: true            \n\t}\n}\n\ndef updated()\n{\n\tupdateDataValue(\"configured\", \"false\")\n\tstate.debug = (\"true\" == debugOutput)\n}\n\ndef parse(String description)\n{\n\tdef result = null\n\tif (description.startsWith(\"Err 106\")) {\n\t\tstate.sec = 0\n\t\tresult = createEvent( name: \"secureInclusion\", value: \"failed\", isStateChange: true,\n\t\t\tdescriptionText: \"This sensor failed to complete the network security key exchange. If you are unable to control it via SmartThings, you must remove it from your network and add it again.\")\n\t} else if (description != \"updated\") {\n\t\tdef cmd = zwave.parse(description, [0x31: 5, 0x71:3, 0x7A: 2, 0x81: 1, 0x84: 2, 0x86: 2])\n\t\tif (cmd) {\n\t\t\tresult = zwaveEvent(cmd)\n\t\t}\n\t}\n\tif (state.debug) log.debug \"Parsed '${description}' to ${result.inspect()}\"\n\treturn result\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.wakeupv2.WakeUpNotification cmd) \n{\n\tdef result = [createEvent(descriptionText: \"${device.displayName} woke up\", isStateChange: false)]\n\tif (!isConfigured()) {\n\t\t// we're still in the process of configuring a newly joined device\n\t\tif (state.debug) log.debug(\"late configure\")\n\t\tresult += response(configure())\n\t} else {\n\t\tresult += response(checkBattery())\n\t}\n\tresult\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.securityv1.SecurityMessageEncapsulation cmd) {\n\tdef encapsulatedCommand = cmd.encapsulatedCommand([0x31: 5, 0x71: 3, 0x7A: 2, 0x81: 1, 0x84: 2])\n\tstate.sec = 1\n\t// if (state.debug) log.debug \"encapsulated: ${encapsulatedCommand}\"\n\tif (encapsulatedCommand) {\n\t\tzwaveEvent(encapsulatedCommand)\n\t} else {\n\t\tlog.warn \"Unable to extract encapsulated cmd from $cmd\"\n\t\tcreateEvent(descriptionText: cmd.toString())\n\t}\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.securityv1.SecurityCommandsSupportedReport cmd) {\n\tif (state.debug) log.debug \"---SECURITY COMMANDS SUPPORTED REPORT V1--- ${device.displayName} sent commandClassControl: ${cmd.commandClassControl}, commandClassSupport: ${cmd.commandClassSupport}, reportsToFollow: ${cmd.reportsToFollow}\"\n\tresponse(configure())\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.manufacturerspecificv2.DeviceSpecificReport cmd) {\n\tif (state.debug) log.debug \"---MANUFACTURER SPECIFIC REPORT V2--- ${device.displayName} sent deviceIdDataFormat: ${cmd.deviceIdDataFormat}, deviceIdDataLengthIndicator: ${cmd.deviceIdDataLengthIndicator}, deviceIdType: ${cmd.deviceIdType}, payload: ${cmd.payload}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.versionv1.VersionCommandClassReport cmd) {\n\tif (state.debug) log.debug \"---COMMAND CLASS VERSION REPORT V1--- ${device.displayName} has command class version: ${cmd.commandClassVersion} - payload: ${cmd.payload}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.versionv1.VersionReport cmd) {\n\tdef fw = \"${cmd.applicationVersion}.${cmd.applicationSubVersion}\"\n\tupdateDataValue(\"fw\", fw)\n\tif (state.debug) log.debug \"---VERSION REPORT V1--- ${device.displayName} is running firmware version: $fw, Z-Wave version: ${cmd.zWaveProtocolVersion}.${cmd.zWaveProtocolSubVersion}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.configurationv1.ConfigurationReport cmd) {\n    if (state.debug) log.debug \"---CONFIGURATION REPORT V1--- ${device.displayName} parameter ${cmd.parameterNumber} with a byte size of ${cmd.size} is set to ${cmd.configurationValue}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.configurationv2.ConfigurationReport cmd) {\n    if (state.debug) log.debug \"---CONFIGURATION REPORT V2--- ${device.displayName} parameter ${cmd.parameterNumber} with a byte size of ${cmd.size} is set to ${cmd.configurationValue}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.batteryv1.BatteryReport cmd) {\n\tdef map = [ name: \"battery\", unit: \"%\" ]\n\tif (cmd.batteryLevel == 0xFF) {\n\t\tmap.value = 1\n\t\tmap.descriptionText = \"${device.displayName} battery is low\"\n\t\tmap.isStateChange = true\n\t\tcreateEvent(map)\n\t} else {\n\t\tmap.value = cmd.batteryLevel\n\t\tcreateEvent(map)\n\t}\n\tstate.lastbatt = now()\n\tcreateEvent(map)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.sensormultilevelv5.SensorMultilevelReport cmd) {\n\tif (state.debug) log.debug \"---SENSOR MULTILEVEL v5 REPORT--- ${device.displayName} sent sensorType: ${cmd.sensorType} value: ${cmd.sensorValue} scale: ${cmd.scale} scaledSensorValue: ${cmd.scaledSensorValue}\"\n\tdef map = [:]\n\tswitch (cmd.sensorType) {\n\t\tcase 1:\n\t\t\tmap.name = \"temperature\"\n\t\t\tdef cmdScale = cmd.scale == 1 ? \"F\" : \"C\"\n\t\t\tmap.value = convertTemperatureIfNeeded(cmd.scaledSensorValue, cmdScale, cmd.precision)\n\t\t\tmap.unit = getTemperatureScale()\n\t\t\tbreak;\n\t\tcase 3:\n\t\t\tmap.name = \"illuminance\"\n\t\t\tmap.value = cmd.scaledSensorValue\n\t\t\tmap.unit = \"%\"\n\t\t\tbreak;\n        case 5:\n\t\t\tmap.name = \"humidity\"\n\t\t\tmap.value = cmd.scaledSensorValue\n\t\t\tmap.unit = \"%\"\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tmap.descriptionText = cmd.toString()\n\t}\n\tcreateEvent(map)\n}\n\ndef motionEvent(value) {\n\tdef map = [name: \"motion\"]\n\tif (value != 0) {\n\t\tmap.value = \"active\"\n\t\tmap.descriptionText = \"$device.displayName detected motion\"\n\t} else {\n\t\tmap.value = \"inactive\"\n\t\tmap.descriptionText = \"$device.displayName motion has stopped\"\n\t}\n\tcreateEvent(map)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.sensorbinaryv2.SensorBinaryReport cmd) {\n\tif (state.debug) log.debug \"---SENSOR BINARY REPORT V2--- ${device.displayName} sent value: ${cmd.sensorValue}\"\n\tmotionEvent(cmd.sensorValue)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicSet cmd) {\n\tif (state.debug) log.debug \"---BASIC SET REPORT V1--- ${device.displayName} sent value: ${cmd.value}\"\n\tmotionEvent(cmd.value)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.notificationv3.NotificationReport cmd) {\nif (state.debug) log.debug \"---NOTIFICATION REPORT V3--- ${device.displayName} sent eventParametersLength: ${cmd.eventParametersLength} eventParameter: ${cmd.eventParameter} notificationType: ${cmd.notificationType} event: ${cmd.event}\"\t\ndef result = []\nif (cmd.notificationType == 7) {\n\tif (cmd.event == 0x00 && cmd.eventParameter == 0x08) {\n\t\tresult << motionEvent(0)\n        }\n    else if (cmd.event == 0x03) {\n    \tresult << createEvent(name: \"acceleration\", value: \"active\", descriptionText: \"$device.displayName cover is open.\")\n\t\t}\n\telse if (cmd.event == 0X00 || cmd.eventParameter == 0x03) {\n\t\tresult << createEvent(name: \"acceleration\", value: \"inactive\", descriptionText: \"$device.displayName cover has been closed.\")\n    }\n\telse if (cmd.event == 0x08) {\n    \tresult << motionEvent(255)\n\t}\n}\nelse {\n\tresult << createEvent(descriptionText: cmd.toString(), isStateChange: false)\n}\n\tresult\n}\n\ndef zwaveEvent(physicalgraph.zwave.Command cmd) {\n\tcreateEvent(descriptionText: cmd.toString(), isStateChange: false)\n}\n\nprivate checkBattery() {\n\tdef request = [\n\t\tzwave.batteryV1.batteryGet(),\n\t\tzwave.wakeUpV1.wakeUpNoMoreInformation()\n\t\t]\n\tcommands(request)\n}\n\ndef configure() {\n\t// This sensor joins as a secure device if you double-click the button to include it\n\t//if (device.device.rawDescription =~ /98/ && !state.sec) {\n\t//\tif (state.debug) log.debug \"4-in-1 sensor not sending configure until secure\"\n\t//\treturn []\n\t//}\n\tif (state.debug) log.debug \"--Sending configuration commands to zooZ 4-in-1 sensor--\"\n    //if (state.debug) log.debug \"Prefernces settings: PIRsensitivity: $PIRsensitivity, Temp offset: $tempoffset, Humidity offset: $humidityoffset, Luminance offset: $luminanceoffset\"\n\tdef LEDbehav = 3\n\tif (LEDbehavior == \"LED Off\") {\n    \tLEDbehav=1\n    }\n\telse if (LEDbehavior == \"Breathing\") {\n    \tLEDbehav=2\n\t}\n\telse {\n\t\tLEDbehav=3\n\t}\t\n\tdef PIRsens = 4\n\tif (PIRsensitivity) {\n\t\tPIRsens=PIRsensitivity\n\t}\n\telse {\n\t\tPIRsens = 4\n\t}\n    def MotionRst = 3\n\tif (MotionReset) {\n\t\tMotionRst=MotionReset\n\t}\n\telse {\n\t\tMotionRst = 3\n\t}\n\tdef tempoff = 1\n\tif (tempoffset) {\n\t\ttempoff=tempoffset\n\t}\n\telse {\n\t\ttempoff = 1\n\t}\n\tdef humidityoff = 10\n\tif (humidityoffset) {\n\t\thumidityoff=humidityoffset\n\t}\n\telse {\n\t\thumidityoff = 10\n\t}\n\tdef luminanceoff = 10\n\tif (luminanceoffset) {\n\t\tluminanceoff=luminanceoffset\n\t}\n\telse {\n\t\tluminanceoff = 10\n\t}\n    if (state.debug) log.debug \"settings: ${settings.inspect()}, state: ${state.inspect()}\"\n    setConfigured()\n\tdef request = [\n\t\t// set wakeup interval to 20 mins\n\t\tzwave.wakeUpV1.wakeUpIntervalSet(seconds:3600, nodeid:zwaveHubNodeId),\n\t\t\n\t\t// Get Version information\n        zwave.versionV1.versionGet(),\n        zwave.firmwareUpdateMdV2.firmwareMdGet(),\n\t\t\n        // configure temp scale to celcius or fahrenheight and set offset\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x01, size: 1, scaledConfigurationValue: 1),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0x01),\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x02, size: 1, scaledConfigurationValue: tempoff),\t\t\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0x02),\n\t\t\n        // configure humidity offset\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x03, size: 1, scaledConfigurationValue: humidityoff),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0x03),\n\t\t\n        // configure luminance offset\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x04, size: 1, scaledConfigurationValue: luminanceoff),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0x04),\n\t\t\n\t\t// send no-motion report x minutes after motion stops\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x05, size: 1, scaledConfigurationValue: MotionRst),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0x05),\n    \t\n\t\t// set motion sensor sensitivity\n        zwave.configurationV1.configurationSet(parameterNumber: 0x06, size: 1, scaledConfigurationValue: PIRsens),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0x06),\n\t\t\n        // set LED behavior\n        zwave.configurationV1.configurationSet(parameterNumber: 0x07, size: 1, scaledConfigurationValue: LEDbehav),\n        zwave.configurationV1.configurationGet(parameterNumber: 0x07),\n\t\t\n\t\t// get updated battery and sensor data\n        zwave.batteryV1.batteryGet(),\n\t\tzwave.sensorMultilevelV5.sensorMultilevelGet(sensorType:1, scale:1),\n        zwave.sensorMultilevelV5.sensorMultilevelGet(sensorType:3, scale:0),\n        zwave.sensorMultilevelV5.sensorMultilevelGet(sensorType:5, scale:0),\n        \n\t\t// Can use the zwaveHubNodeId variable to add the hub to the device's associations:\n\t\tzwave.associationV1.associationSet(groupingIdentifier:2, nodeId:zwaveHubNodeId)\n    ]\n\tcommands(request) + [\"delay 20000\", zwave.wakeUpV1.wakeUpNoMoreInformation().format()]\n}\n\nprivate setConfigured() {\n\tupdateDataValue(\"configured\", \"true\")\n    return []\n}\n\nprivate isConfigured() {\n\tgetDataValue(\"configured\") == \"true\"\n}\n\nprivate command(physicalgraph.zwave.Command cmd) {\n\tif (state.sec) {\n\t\tzwave.securityV1.securityMessageEncapsulation().encapsulate(cmd).format()\n\t} else {\n\t\tcmd.format()\n\t}\n}\n\nprivate commands(commands, delay=1000) {\n\tdelayBetween(commands.collect{ command(it) }, delay)\n}"
  },
  {
    "path": "zooZ-4-in-1-Sensor-ZSE40/device_type-zooZ-4-in-1-Sensor-ZSE40_v1.2_motion_primary",
    "content": "/*\n * V 1.2 of zooZ 4-in-1 sensor code 6/12/2016\n * by Robert Vandervoort\n *\n *  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except\n *  in compliance with the License. You may obtain a copy of the License at:\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n *  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed\n *  on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License\n *  for the specific language governing permissions and limitations under the License.\n * \n---------------------------------------------------------------------------------------------------------------------------\n   INSTRUCTIONS:\n   * First you will need to create a new device handler in SmartThings. Log in to the IDE and click on Device Handlers in the top menu.\n   Then click \"from code\" below. You'l be presented with a blank area where you can copy this code and paste it in.\n   * Next, scroll to the bottom and click create. Now click save, then click publish > for me.\n   * You should now see this device type in your list of device handlers. Now we need to pair the device.\n   * Put SmartThings into inclusion mode by going through the add new device dialog.\n   On the bottom of the zooZ 4-in-1 you will see several small holes. There is a series of four holes and a hole all by itself.\n   You'll need a paperclip or something similar that fits into the hole. While holding the sensor a foot or so from the hub,\n   and with SmartThings in inclusion mode, gently depress the button inside the single hole twice rapidly. The light should blink.\n   Please wait a few moments (usually 10 seconds or so) and you should see \"zooZ 4-in-1 sensor - RV 1.0\" appear in the found devices area.\n   * Touch the \"zooZ 4-in-1 sensor - RV 1.0\" to configure. Here we will set your temperature scale preferecne and motion preferences.\n   After you make your choices, touch done in the app. \n   * Now go to your devices list in the SmartThings app and open up the newly added sensor.\n   * In order to get the configuration sent and initial sensor data, we need to wake the sensor up. Press the button on the device\n   one time while holding it close to the hub. If you pressed the button the sensor should blink yellow once. Wait about 30 seconds,\n   then refresh (drag the screen down) and you should see data on the screen for temp, humidity, illuminance, and battery.\n   ** If you do not, please wait a minute or so and refresh the screen again by sliding it down.\n   * If you still do not see anything after refreshing, touch the gear icon to enter the device preferences screen (make any adjustments or not) and then touch done.\n   This will reset the configuration state so the device can be configured again and polled for data. Once you're back at the device screen,\n   while holding the sensor close to the hub, press the small button we pressed earlier one time, making sure that the sensor blinks\n   (if it doesn't, press the button again) and wait a minute or so, then refresh the device screen in the app again.\n   You should see data on the screen now. \n   *** IF YOU STILL ARE NOT GETTING DATA, go back to the preferences screen and enable debug logging, and touch done. You do not need\n   to press the button on the sensor again at this point. Go into the SmartThings IDE and choose \"live logging\" from the top menu.\n   While on the live logging  screen and close to your hub with the sensor, press the button on the sensor, making sure it blinks, and watch the screen for results.\n   You should see several lines of data come in slowly. This should tell you all your settings and what the configuration on the sensor is actually set to.\n   It will then poll the sensors for data. If you do not ever see any data coming from the sensor, please post to the community or\n   message me via github or the SmartThings community. \n */\n \n metadata {\n\tdefinition (name: \"zooZ 4-in-1 sensor - RV 1.2\", namespace: \"robertvandervoort\", author: \"Robert Vandervoort\") {\n\t\tcapability \"Motion Sensor\"\n\t\tcapability \"Acceleration Sensor\"\n\t\tcapability \"Temperature Measurement\"\n\t\tcapability \"Relative Humidity Measurement\"\n\t\tcapability \"Illuminance Measurement\"\n\t\tcapability \"Configuration\"\n\t\tcapability \"Sensor\"\n\t\tcapability \"Battery\"\n\t\t\n        // RAW Description: 0 0 0x0701 0 0 0 e 0x5E 0x98 0x86 0x72 0x5A 0x85 0x59 0x73 0x80 0x71 0x31 0x70 0x84 0x7A   \t\t\t\t\t\t\t\t\t\t \n\t\tattribute \"tamper\", \"enum\", [\"detected\", \"clear\"]\n\t\tfingerprint deviceId: \"0x0701\", inClusters: \"0x5E,0x86,0x72,0x59,0x85,0x73,0x71,0x84,0x80,0x31,0x70,0x5A,0x98,0x7A\"\n\t\t}\nsimulator {\n\t\tstatus \"no motion\" : \"command: 9881, payload: 00300300\"\n\t\tstatus \"motion\"    : \"command: 9881, payload: 003003FF\"\n        status \"clear\" : \" command: 9881, payload: 0071050000000007030000\"\n        status \"tamper\" : \"command: 9881, payload: 007105000000FF07030000\"\n        \n        for (int i = 0; i <= 100; i += 20) {\n\t\t\tstatus \"temperature ${i}F\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().sensorMultilevelV2.sensorMultilevelReport(\n                \tscaledSensorValue: i,\n                    precision: 1,\n                    sensorType: 1,\n                    scale: 1\n\t\t\t\t)\n\t\t\t).incomingMessage()\n\t\t}\n\t\tfor (int i = 0; i <= 100; i += 20) {\n\t\t\tstatus \"RH ${i}%\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().sensorMultilevelV2.sensorMultilevelReport(\n                \tscaledSensorValue: i,\n                    sensorType: 5\n            \t)\n\t\t\t).incomingMessage()\n\t\t}\n\t\tfor (int i in [0, 1, 2, 8, 12, 16, 20, 24, 30, 64, 82, 100, 200, 500, 1000]) {\n\t\t\tstatus \"illuminance ${i}%\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().sensorMultilevelV2.sensorMultilevelReport(\n                scaledSensorValue: i,\n                sensorType: 3\n                )\n\t\t\t).incomingMessage()\n\t\t}\n\t\tfor (int i in [0, 5, 10, 15, 50, 99, 100]) {\n\t\t\tstatus \"battery ${i}%\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().batteryV1.batteryReport(\n                batteryLevel: i\n                )\n\t\t\t).incomingMessage()\n\t\t}\n\t\tstatus \"low battery alert\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().batteryV1.batteryReport(\n            \tbatteryLevel: 255\n            \t)\n\t\t\t).incomingMessage()\n\t\tstatus \"wake up\": \"command: 8407, payload:\"\n\t}\n\ttiles (scale: 2) {\n\t\tmultiAttributeTile(name:\"main\", type: \"generic\", width: 6, height: 4){\n\t\t\ttileAttribute (\"device.motion\", key: \"PRIMARY_CONTROL\") {\n\t\t\t\tattributeState \"active\", label:'motion', icon:\"st.motion.motion.active\", backgroundColor:\"#53a7c0\"\n\t\t\t\tattributeState \"inactive\", label:'no motion', icon:\"st.motion.motion.inactive\", backgroundColor:\"#ffffff\"\n\t\t\t}\n\t\t}\n\t\tvalueTile(\"temperature\",\"device.temperature\", width: 2, height: 2) {\n            \tstate \"temperature\",label:'${currentValue}°', unit:\"${unit}\", precision:2, backgroundColors:[\n                \t[value: 32, color: \"#153591\"],\n                    [value: 44, color: \"#1e9cbb\"],\n                    [value: 59, color: \"#90d2a7\"],\n\t\t\t\t\t[value: 74, color: \"#44b621\"],\n\t\t\t\t\t[value: 84, color: \"#f1d801\"],\n\t\t\t\t\t[value: 92, color: \"#d04e00\"],\n\t\t\t\t\t[value: 98, color: \"#bc2323\"]\n\t\t\t\t]\n\t\t\t}\n\t\tvalueTile(\"humidity\",\"device.humidity\", width: 2, height: 2) {\n           \tstate \"humidity\",label:'RH ${currentValue}%', precision:2\n\t\t\t}\n\t\tvalueTile(\"illuminance\",\"device.illuminance\", width: 2, height: 2) {\n            \tstate \"luminosity\",label:'LIGHT ${currentValue}%',precision:2\n\t\t\t}\n\t\tstandardTile(\"acceleration\", \"device.acceleration\", width: 2, height: 2) {\n\t\t\tstate(\"active\", label:'tamper', icon:\"st.motion.acceleration.active\", backgroundColor:\"#ff0000\")\n\t\t\tstate(\"inactive\", label:'clear', icon:\"st.motion.acceleration.inactive\", backgroundColor:\"#00ff00\")\n\t\t}\n\t\tvalueTile(\"battery\", \"device.battery\", decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"battery\", label:'${currentValue}% battery'\n\t\t}\n\t\tmain([\"main\"])\n\t\tdetails([\"main\",\"temperature\",\"humidity\",\"illuminance\",\"acceleration\",\"battery\"])\n\t}\n    preferences {\n\t\tinput \"debugOutput\", \"boolean\", \n\t\t\ttitle: \"Enable debug logging?\",\n\t\t\tdefaultValue: false,\n\t\t\tdisplayDuringSetup: true\n\t\tinput \"LEDbehavior\", \"enum\",\n\t\t\ttitle: \"LED Behavior\",\n\t\t\toptions: [\"LED Off\", \"Breathing\", \"Quick Blink on Temp/PIR\"],\n            defaultValue: \"Quick Blink on Temp/PIR\",\n\t\t\trequired: false,\n\t\t\tdisplayDuringSetup: false\n\t\tinput \"tempoffset\", \"number\",\n\t\t\ttitle: \"Reporting threshold  for temp\",\n            description: \"Enter a value 1-50 changing reporting threshold for temp. Represents 0.1 degree increments.\",\n            range: \"1..50\",\n\t\t\tdefaultValue: 50,\n            required: false,\n            displayDuringSetup: false\n\t\tinput \"humidityoffset\", \"number\",\n            title: \"Reporting threshold for humidity\",\n            description: \"Report when change occurs from 1%-50% RH)\",\n\t\t\trange: \"1..50\",\n\t\t\tdefaultValue: 1,\n\t\t\trequired: false,\n            displayDuringSetup: false\n\t\tinput \"luminanceoffset\", \"number\",\n            title: \"Reporting threshold for Luminance\",\n            description: \"valid values from 5% to 50%\",\n            range: \"5..50\",\n\t\t\tdefaultValue: 5,\n            required: false,\n\t        displayDuringSetup: false\n\t\tinput \"PIRsensitivity\", \"number\",\n    \t    title: \"PIR motion sensitivity\",\n\t\t\tdescription: \"A value from 1-7, from high to low sensitivity (1 is highest)\",\n\t\t\trange: \"1..7\",\n\t\t\tdefaultValue: 4,\n\t\t\trequired: false,\n\t\t\tdisplayDuringSetup: true\n\t\tinput \"MotionReset\", \"number\",\n    \t    title: \"PIR reset time\",\n\t\t\tdescription: \"Number of minutes to wait to report motion cleared after a motion event if there is no motion detected.\",\n\t\t\trange: \"1..255\",\n\t\t\tdefaultValue: 5,\n\t\t\trequired: false,\n\t\t\tdisplayDuringSetup: true            \n\t}\n}\n\ndef updated()\n{\n\tupdateDataValue(\"configured\", \"false\")\n\tstate.debug = (\"true\" == debugOutput)\n}\n\ndef parse(String description)\n{\n\tdef result = null\n\tif (description.startsWith(\"Err 106\")) {\n\t\tstate.sec = 0\n\t\tresult = createEvent( name: \"secureInclusion\", value: \"failed\", isStateChange: true,\n\t\t\tdescriptionText: \"This sensor failed to complete the network security key exchange. If you are unable to control it via SmartThings, you must remove it from your network and add it again.\")\n\t} else if (description != \"updated\") {\n\t\tdef cmd = zwave.parse(description, [0x31: 5, 0x71:3, 0x7A: 2, 0x81: 1, 0x84: 2, 0x86: 1])\n\t\tif (cmd) {\n\t\t\tresult = zwaveEvent(cmd)\n\t\t}\n\t}\n\tif (state.debug) log.debug \"Parsed '${description}' to ${result.inspect()}\"\n\treturn result\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.wakeupv2.WakeUpNotification cmd) \n{\n\tdef result = [createEvent(descriptionText: \"${device.displayName} woke up\", isStateChange: false)]\n\tif (!isConfigured()) {\n\t\t// we're still in the process of configuring a newly joined device\n\t\tif (state.debug) log.debug(\"late configure\")\n\t\tresult += response(configure())\n\t} else {\n\t\tresult += response(checkBattery())\n\t}\n\tresult\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.securityv1.SecurityMessageEncapsulation cmd) {\n\tdef encapsulatedCommand = cmd.encapsulatedCommand([0x31: 5, 0x71: 3, 0x7A: 2, 0x81: 1, 0x84: 2])\n\tstate.sec = 1\n\t// if (state.debug) log.debug \"encapsulated: ${encapsulatedCommand}\"\n\tif (encapsulatedCommand) {\n\t\tzwaveEvent(encapsulatedCommand)\n\t} else {\n\t\tlog.warn \"Unable to extract encapsulated cmd from $cmd\"\n\t\tcreateEvent(descriptionText: cmd.toString())\n\t}\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.securityv1.SecurityCommandsSupportedReport cmd) {\n\tif (state.debug) log.debug \"---SECURITY COMMANDS SUPPORTED REPORT V1--- ${device.displayName} sent commandClassControl: ${cmd.commandClassControl}, commandClassSupport: ${cmd.commandClassSupport}, reportsToFollow: ${cmd.reportsToFollow}\"\n\tresponse(configure())\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.manufacturerspecificv2.DeviceSpecificReport cmd) {\n\tif (state.debug) log.debug \"---MANUFACTURER SPECIFIC REPORT V2--- ${device.displayName} sent deviceIdDataFormat: ${cmd.deviceIdDataFormat}, deviceIdDataLengthIndicator: ${cmd.deviceIdDataLengthIndicator}, deviceIdType: ${cmd.deviceIdType}, payload: ${cmd.payload}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.versionv1.VersionCommandClassReport cmd) {\n\tif (state.debug) log.debug \"---COMMAND CLASS VERSION REPORT V1--- ${device.displayName} has command class version: ${cmd.commandClassVersion} - payload: ${cmd.payload}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.versionv1.VersionReport cmd) {\n\tdef fw = \"${cmd.applicationVersion}.${cmd.applicationSubVersion}\"\n\tupdateDataValue(\"fw\", fw)\n\tif (state.debug) log.debug \"---VERSION REPORT V1--- ${device.displayName} is running firmware version: $fw, Z-Wave version: ${cmd.zWaveProtocolVersion}.${cmd.zWaveProtocolSubVersion}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.configurationv1.ConfigurationReport cmd) {\n    if (state.debug) log.debug \"---CONFIGURATION REPORT V1--- ${device.displayName} parameter ${cmd.parameterNumber} with a byte size of ${cmd.size} is set to ${cmd.configurationValue}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.configurationv2.ConfigurationReport cmd) {\n    if (state.debug) log.debug \"---CONFIGURATION REPORT V2--- ${device.displayName} parameter ${cmd.parameterNumber} with a byte size of ${cmd.size} is set to ${cmd.configurationValue}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.batteryv1.BatteryReport cmd) {\n\tdef map = [ name: \"battery\", unit: \"%\" ]\n\tif (cmd.batteryLevel == 0xFF) {\n\t\tmap.value = 1\n\t\tmap.descriptionText = \"${device.displayName} battery is low\"\n\t\tmap.isStateChange = true\n\t\tcreateEvent(map)\n\t} else {\n\t\tmap.value = cmd.batteryLevel\n\t\tcreateEvent(map)\n\t}\n\tstate.lastbatt = now()\n\tcreateEvent(map)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.sensormultilevelv5.SensorMultilevelReport cmd) {\n\tif (state.debug) log.debug \"---SENSOR MULTILEVEL v5 REPORT--- ${device.displayName} sent sensorType: ${cmd.sensorType} value: ${cmd.sensorValue} scale: ${cmd.scale} scaledSensorValue: ${cmd.scaledSensorValue}\"\n\tdef map = [:]\n\tswitch (cmd.sensorType) {\n\t\tcase 1:\n\t\t\tmap.name = \"temperature\"\n\t\t\tdef cmdScale = cmd.scale == 1 ? \"F\" : \"C\"\n\t\t\tmap.value = convertTemperatureIfNeeded(cmd.scaledSensorValue, cmdScale, cmd.precision)\n\t\t\tmap.unit = getTemperatureScale()\n\t\t\tbreak;\n\t\tcase 3:\n\t\t\tmap.name = \"illuminance\"\n\t\t\tmap.value = cmd.scaledSensorValue\n\t\t\tmap.unit = \"%\"\n\t\t\tbreak;\n        case 5:\n\t\t\tmap.name = \"humidity\"\n\t\t\tmap.value = cmd.scaledSensorValue\n\t\t\tmap.unit = \"%\"\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tmap.descriptionText = cmd.toString()\n\t}\n\tcreateEvent(map)\n}\n\ndef motionEvent(value) {\n\tdef map = [name: \"motion\"]\n\tif (value != 0) {\n\t\tmap.value = \"active\"\n\t\tmap.descriptionText = \"$device.displayName detected motion\"\n\t} else {\n\t\tmap.value = \"inactive\"\n\t\tmap.descriptionText = \"$device.displayName motion has stopped\"\n\t}\n\tcreateEvent(map)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.sensorbinaryv2.SensorBinaryReport cmd) {\n\tif (state.debug) log.debug \"---SENSOR BINARY REPORT V2--- ${device.displayName} sent value: ${cmd.sensorValue}\"\n\tmotionEvent(cmd.sensorValue)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicSet cmd) {\n\tif (state.debug) log.debug \"---BASIC SET REPORT V1--- ${device.displayName} sent value: ${cmd.value}\"\n\tmotionEvent(cmd.value)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.notificationv3.NotificationReport cmd) {\nif (state.debug) log.debug \"---NOTIFICATION REPORT V3--- ${device.displayName} sent eventParametersLength: ${cmd.eventParametersLength} eventParameter: ${cmd.eventParameter} notificationType: ${cmd.notificationType} event: ${cmd.event}\"\t\ndef result = []\nif (cmd.notificationType == 7) {\n\tif (cmd.event == 0x00 && cmd.eventParameter == 0x08) {\n\t\tresult << motionEvent(0)\n        }\n    else if (cmd.event == 0x03) {\n    \tresult << createEvent(name: \"acceleration\", value: \"active\", descriptionText: \"$device.displayName cover is open.\")\n\t\t}\n\telse if (cmd.event == 0X00 || cmd.eventParameter == 0x03) {\n\t\tresult << createEvent(name: \"acceleration\", value: \"inactive\", descriptionText: \"$device.displayName cover has been closed.\")\n    }\n\telse if (cmd.event == 0x08) {\n    \tresult << motionEvent(255)\n\t}\n}\nelse {\n\tresult << createEvent(descriptionText: cmd.toString(), isStateChange: false)\n}\n\tresult\n}\n\ndef zwaveEvent(physicalgraph.zwave.Command cmd) {\n\tcreateEvent(descriptionText: cmd.toString(), isStateChange: false)\n}\n\nprivate checkBattery() {\n\tdef request = [\n\t\tzwave.batteryV1.batteryGet(),\n\t\tzwave.wakeUpV1.wakeUpNoMoreInformation()\n\t\t]\n\tcommands(request)\n}\n\ndef configure() {\n\t// This sensor joins as a secure device if you double-click the button to include it\n\t//if (device.device.rawDescription =~ /98/ && !state.sec) {\n\t//\tif (state.debug) log.debug \"4-in-1 sensor not sending configure until secure\"\n\t//\treturn []\n\t//}\n\tif (state.debug) log.debug \"--Sending configuration commands to zooZ 4-in-1 sensor--\"\n    //if (state.debug) log.debug \"Prefernces settings: PIRsensitivity: $PIRsensitivity, Temp offset: $tempoffset, Humidity offset: $humidityoffset, Luminance offset: $luminanceoffset\"\n\tdef LEDbehav = 3\n\tif (LEDbehavior == \"LED Off\") {\n    \tLEDbehav=1\n    }\n\telse if (LEDbehavior == \"Breathing\") {\n    \tLEDbehav=2\n\t}\n\telse {\n\t\tLEDbehav=3\n\t}\t\n\tdef PIRsens = 4\n\tif (PIRsensitivity) {\n\t\tPIRsens=PIRsensitivity\n\t}\n\telse {\n\t\tPIRsens = 4\n\t}\n    def MotionRst = 3\n\tif (MotionReset) {\n\t\tMotionRst=MotionReset\n\t}\n\telse {\n\t\tMotionRst = 3\n\t}\n\tdef tempoff = 1\n\tif (tempoffset) {\n\t\ttempoff=tempoffset\n\t}\n\telse {\n\t\ttempoff = 1\n\t}\n\tdef humidityoff = 10\n\tif (humidityoffset) {\n\t\thumidityoff=humidityoffset\n\t}\n\telse {\n\t\thumidityoff = 10\n\t}\n\tdef luminanceoff = 10\n\tif (luminanceoffset) {\n\t\tluminanceoff=luminanceoffset\n\t}\n\telse {\n\t\tluminanceoff = 10\n\t}\n    if (state.debug) log.debug \"settings: ${settings.inspect()}, state: ${state.inspect()}\"\n    setConfigured()\n\tdef request = [\n\t\t// set wakeup interval to 20 mins\n\t\tzwave.wakeUpV1.wakeUpIntervalSet(seconds:3600, nodeid:zwaveHubNodeId),\n\t\t\n\t\t// Get Version information\n        zwave.versionV1.versionGet(),\n        zwave.firmwareUpdateMdV2.firmwareMdGet(),\n\t\t\n        // configure temp scale to celcius or fahrenheight and set offset\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x01, size: 1, scaledConfigurationValue: 1),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0x01),\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x02, size: 1, scaledConfigurationValue: tempoff),\t\t\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0x02),\n\t\t\n        // configure humidity offset\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x03, size: 1, scaledConfigurationValue: humidityoff),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0x03),\n\t\t\n        // configure luminance offset\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x04, size: 1, scaledConfigurationValue: luminanceoff),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0x04),\n\t\t\n\t\t// send no-motion report x minutes after motion stops\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x05, size: 1, scaledConfigurationValue: MotionRst),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0x05),\n    \t\n\t\t// set motion sensor sensitivity\n        zwave.configurationV1.configurationSet(parameterNumber: 0x06, size: 1, scaledConfigurationValue: PIRsens),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0x06),\n\t\t\n        // set LED behavior\n        zwave.configurationV1.configurationSet(parameterNumber: 0x07, size: 1, scaledConfigurationValue: LEDbehav),\n        zwave.configurationV1.configurationGet(parameterNumber: 0x07),\n\t\t\n\t\t// get updated battery and sensor data\n        zwave.batteryV1.batteryGet(),\n\t\tzwave.sensorMultilevelV5.sensorMultilevelGet(sensorType:1, scale:1),\n        zwave.sensorMultilevelV5.sensorMultilevelGet(sensorType:3, scale:0),\n        zwave.sensorMultilevelV5.sensorMultilevelGet(sensorType:5, scale:0),\n        \n\t\t// Can use the zwaveHubNodeId variable to add the hub to the device's associations:\n\t\tzwave.associationV1.associationSet(groupingIdentifier:2, nodeId:zwaveHubNodeId)\n    ]\n\tcommands(request) + [\"delay 20000\", zwave.wakeUpV1.wakeUpNoMoreInformation().format()]\n}\n\nprivate setConfigured() {\n\tupdateDataValue(\"configured\", \"true\")\n    return []\n}\n\nprivate isConfigured() {\n\tgetDataValue(\"configured\") == \"true\"\n}\n\nprivate command(physicalgraph.zwave.Command cmd) {\n\tif (state.sec) {\n\t\tzwave.securityV1.securityMessageEncapsulation().encapsulate(cmd).format()\n\t} else {\n\t\tcmd.format()\n\t}\n}\n\nprivate commands(commands, delay=1000) {\n\tdelayBetween(commands.collect{ command(it) }, delay)\n}"
  },
  {
    "path": "zooZ-Indoor-Siren-ZSE01/device_type-zooZ-indoor-siren-v1",
    "content": "/*\n * V 1.0 of zooZ Indoor Siren ZSE01\n *  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except\n *  in compliance with the License. You may obtain a copy of the License at:\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n *  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed\n *  on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License\n *  for the specific language governing permissions and limitations under the License.\n *\n \n*/\n\n metadata {\n\tdefinition (name: \"zooZ Indoor Siren ZSE01 - RV v1.0\", namespace: \"robertvandervoort\", author: \"Robert Vandervoort\") {\n\t\tcapability \"Actuator\"\n\t\tcapability \"Alarm\"\n        capability \"Battery\"\n\t\tcapability \"Switch\"\n        capability \"Sensor\"\n\t\tcapability \"Polling\"\n\t\tcapability \"Refresh\"\n\n\t\tcommand \"reset\"\n\t\t// RAW DESCRIPTION: 0 0 0x1005 0 0 0 9 0x5E 0x86 0x72 0x73 0x85 0x59 0x25 0x20 0x27\n\t\tfingerprint deviceId: \"0x1005\", inClusters: \"0x5E 0x86 0x72 0x73 0x85 0x59 0x25 0x20 0x27\", manufacturer: \"zooZ\", model: \"ZSE01\"\n        \n\t}\n\t// simulator metadata\n\n\t// tile definitions\n\ttiles (scale: 2) {\n    \tmultiAttributeTile(name:\"alarm\", type:\"generic\", width:6, height:4, canChangeIcon: true) {\n\t\t\ttileAttribute(\"device.alarm\", key: \"PRIMARY_CONTROL\") {\n            \tattributeState \"off\", label:'OFF', action:'on', icon:\"st.alarm.alarm.alarm\", backgroundColor:\"#ffffff\"\n\t\t\t\tattributeState \"on\", label:'ALARM!', action:'off', icon:\"st.alarm.alarm.alarm\", backgroundColor:\"#e86d13\"\n            }\n\t\t}\n\t\tstandardTile(\"off\", \"device.alarm\", inactiveLabel: false, width: 3, height: 3) {\n\t\t\tstate \"default\", label:'', action:\"off\", icon:\"st.secondary.off\"\n\t\t}\n\t\tvalueTile(\"battery\", \"device.battery\", decoration: \"flat\", width: 3, height: 3) {\n\t\t\tstate \"battery\", label:'${currentValue}% battery', unit:\"\"\n\t\t}\n\t\tmain \"alarm\"\n\t\tdetails([\"alarm\",\"off\",\"battery\"])\n\t}\n    preferences {\n\t\tinput \"debugOutput\", \"boolean\", \n\t\t\ttitle: \"Enable debug logging?\",\n\t\t\tdefaultValue: false,\n\t\t\tdisplayDuringSetup: false,\n            required: false\n\t}\n}\n\ndef updated()\n{\n\tupdateDataValue(\"configured\", \"false\")\n\tstate.debug = (\"true\" == debugOutput)\n}\n\ndef parse(String description)\n{\n\tdef result = null\n\tif (description != \"updated\") {\n\t\tdef cmd = zwave.parse(description, [0x25: 1])\n\t\tif (cmd) {\n\t\t\tresult = zwaveEvent(cmd)\n\t\t}\n\t}\n\tif (state.debug) log.debug \"Parsed '${description}' to ${result.inspect()}\"\n\treturn result\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.wakeupv2.WakeUpNotification cmd) \n{\n\tdef result = [createEvent(descriptionText: \"${device.displayName} woke up\", isStateChange: false)]\n\tif (!isConfigured()) {\n\t\t// we're still in the process of configuring a newly joined device\n\t\tif (state.debug) log.debug(\"late configure\")\n\t\tresult += response(configure())\n\t} else {\n\t\tresult += response(zwave.wakeUpV1.wakeUpNoMoreInformation())\n\t}\n\tresult\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.manufacturerspecificv2.DeviceSpecificReport cmd) {\n\tif (state.debug) log.debug \"---MANUFACTURER SPECIFIC REPORT V2--- ${device.displayName} sent deviceIdDataFormat: ${cmd.deviceIdDataFormat}, deviceIdDataLengthIndicator: ${cmd.deviceIdDataLengthIndicator}, deviceIdType: ${cmd.deviceIdType}, payload: ${cmd.payload}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.versionv1.VersionCommandClassReport cmd) {\n\tif (state.debug) log.debug \"---COMMAND CLASS VERSION REPORT V1--- ${device.displayName} has command class version: ${cmd.commandClassVersion} - payload: ${cmd.payload}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.versionv1.VersionReport cmd) {\n\tdef fw = \"${cmd.applicationVersion}.${cmd.applicationSubVersion}\"\n\tupdateDataValue(\"fw\", fw)\n\tif (state.debug) log.debug \"---VERSION REPORT V1--- ${device.displayName} is running firmware version: $fw, Z-Wave version: ${cmd.zWaveProtocolVersion}.${cmd.zWaveProtocolSubVersion}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.configurationv1.ConfigurationReport cmd) {\n    if (state.debug) log.debug \"---CONFIGURATION REPORT V1--- ${device.displayName} parameter ${cmd.parameterNumber} with a byte size of ${cmd.size} is set to ${cmd.configurationValue}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.configurationv2.ConfigurationReport cmd) {\n    if (state.debug) log.debug \"---CONFIGURATION REPORT V2--- ${device.displayName} parameter ${cmd.parameterNumber} with a byte size of ${cmd.size} is set to ${cmd.configurationValue}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.deviceresetlocallyv1.DeviceResetLocallyNotification cmd) {\n    if (state.debug) log.debug \"---DEVICE RESET LOCALLY V1--- ${device.displayName} ${cmd}\"\n    createEvent(descriptionText: cmd.toString(), isStateChange: true, displayed: true)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.powerlevelv1.PowerlevelTestNodeReport cmd) {\n\tlog.debug \"===Power level test node report received=== ${device.displayName}: statusOfOperation: ${cmd.statusOfOperation} testFrameCount: ${cmd.testFrameCount} testNodeid: ${cmd.testNodeid}\"\n\tdef request = [\n        physicalgraph.zwave.commands.powerlevelv1.PowerlevelGet()\n    ]\n    response(commands(request))\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.batteryv1.BatteryReport cmd) {\n\tdef map = [ name: \"battery\", unit: \"%\" ]\n\tif (cmd.batteryLevel == 0xFF) {\n\t\tmap.value = 1\n\t\tmap.descriptionText = \"${device.displayName} battery is low\"\n\t\tmap.isStateChange = true\n\t} else {\n\t\tmap.value = cmd.batteryLevel\n\t}\n\tstate.lastbatt = now()\n\tcreateEvent(map)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.associationv2.AssociationReport cmd) {\n    cmd.nodeId.each({log.debug \"---ASSOCIATION REPORT--- '${cmd}', hub: '$zwaveHubNodeId' reports nodeId: '$it' is associated in group: '${cmd.groupingIdentifier}'\"})\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.hailv1.Hail cmd) {\n\tif (state.debug) log.debug \"---HAIL RECEIVED--- ${cmd}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.sensorbinaryv2.SensorBinaryReport cmd) {\n\tif (state.debug) log.debug \"---SENSOR BINARY REPORT V2--- ${device.displayName} sent value: ${cmd.sensorValue}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicReport cmd) {\n\tif (state.debug) log.debug \"---BASIC REPORT V1--- ${device.displayName} sent value: ${cmd.value}\"\n\t[\n\t\tcreateEvent([name: \"switch\", value: cmd.value ? \"on\" : \"off\", type: \"physical\", displayed: true, isStateChange: true]),\n\t\tcreateEvent([name: \"alarm\", value: cmd.value ? \"on\" : \"off\", type: \"physical\", displayed: true, isStateChange: true])\n\t]\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicSet cmd) {\n\tif (state.debug) log.debug \"---BASIC SET V1--- ${device.displayName} sent value: ${cmd.value}\"\n\t[name: \"alarm\", value: cmd.value ? \"on\" : \"off\", type: \"physical\", displayed: true, isStateChange: true]\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.switchbinaryv1.SwitchBinaryReport cmd) {\n\tif (state.debug) log.debug \"---SWITCH BINARY REPORT V1--- ${device.displayName} sent value: ${cmd.value}\"\n\t[name: \"alarm\", value: cmd.value ? \"on\" : \"off\", type: \"digital\", displayed: true, isStateChange: true]\n}\n\t\ndef zwaveEvent(physicalgraph.zwave.commands.switchbinaryv1.SwitchBinarySet cmd) {\n\tif (state.debug) log.debug \"---SWITCH BINARY SET V1--- ${device.displayName} sent value: ${cmd.value}\"\n\t[name: \"alarm\", value: cmd.value ? \"on\" : \"off\", type: \"digital\", displayed: true, isStateChange: true]\n}\n\t\ndef zwaveEvent(physicalgraph.zwave.commands.notificationv3.NotificationReport cmd) {\nif (state.debug) log.debug \"---NOTIFICATION REPORT V3--- ${device.displayName} sent eventParametersLength: ${cmd.eventParametersLength} eventParameter: ${cmd.eventParameter} notificationType: ${cmd.notificationType} event: ${cmd.event}\"\t\ndef result = []\nif (cmd.notificationType == 7) {\n\tif (cmd.event == 0x03) {\n    \tresult << createEvent(name: \"acceleration\", value: \"active\", descriptionText: \"$device.displayName cover is open.\")\n\t\t}\n\telse if (cmd.event == 0X00 || cmd.eventParameter == 0x03) {\n\t\tresult << createEvent(name: \"acceleration\", value: \"inactive\", descriptionText: \"$device.displayName cover has been closed.\")\n    }\n}\nelse {\n\tresult << createEvent(descriptionText: cmd.toString(), isStateChange: false)\n}\n\tresult\n}\n\ndef zwaveEvent(physicalgraph.zwave.Command cmd) {\n\tif (state.debug) log.debug \"Unhandled: $cmd sent to ${device.displayName}\"\n    createEvent(descriptionText: cmd.toString(), isStateChange: false)\n}\n\ndef siren() {\n\tif (state.debug) log.debug \"Siren command received\"\n\ton()\n}\n\ndef both() {\n\tif (state.debug) log.debug \"Siren and Strobe commands received\"\n\ton()\n}\n\ndef on() {\n\tif (state.debug) log.debug \"Sounding Alarm : ${device.displayName}\"\n\tdef request = [\n\t\tzwave.basicV1.basicSet(value: 0xFF)\n\t]\n    commands(request)\n}\n\ndef off() {\n\tif (state.debug) log.debug \"Cancelling Alarm : ${device.displayName}\"\n\tdef request = [\n\t\tzwave.basicV1.basicSet(value: 0x00),\n        zwave.basicV1.basicGet()\n\t]\n    commands(request)\n}\n\ndef configure() {\n\tif (state.debug) log.debug \"--Sending configuration commands to zooZ indoor siren--\"\n    if (state.debug) log.debug \"settings: ${settings.inspect()}, state: ${state.inspect()}\"\n    setConfigured()\n\tdef request = [\n\t\t// set wakeup interval to 20 mins\n\t\tzwave.wakeUpV1.wakeUpIntervalSet(seconds:1200, nodeid:zwaveHubNodeId),\n\t\t\n\t\t// Can use the zwaveHubNodeId variable to add the hub to the device's associations:\n\t\t// zwave.associationV1.associationSet(groupingIdentifier:2, nodeId:zwaveHubNodeId),\n\t\t\n\t\t//Get association\n\t\tzwave.associationV1.associationGet(groupingIdentifier:1),\n        zwave.associationV1.associationGet(groupingIdentifier:2),\n\n\t\t// Get Version information\n        zwave.versionV1.versionGet(),\n        zwave.firmwareUpdateMdV2.firmwareMdGet(),\n\n\t\t// get updated battery and sensor data\n        zwave.batteryV1.batteryGet(),\n    ]\n\tcommands(request) + [\"delay 20000\", zwave.wakeUpV1.wakeUpNoMoreInformation().format()]\n}\n\nprivate setConfigured() {\n\tupdateDataValue(\"configured\", \"true\")\n    return []\n}\n\nprivate isConfigured() {\n\tgetDataValue(\"configured\") == \"true\"\n}\n\nprivate command(physicalgraph.zwave.Command cmd) {\n\tcmd.format()\n}\n\nprivate commands(commands, delay=1000) {\n\tdelayBetween(commands.collect{ command(it) }, delay)\n}"
  },
  {
    "path": "zooZ-Indoor-Siren-ZSE01/device_type-zooZ-indoor-siren-v1.1",
    "content": "/*\n * V 1.1 of zooZ Indoor Siren ZSE01\n *  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except\n *  in compliance with the License. You may obtain a copy of the License at:\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n *  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed\n *  on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License\n *  for the specific language governing permissions and limitations under the License.\n *\n \n*/\n\n metadata {\n\tdefinition (name: \"zooZ Indoor Siren ZSE01 - RV v1.1\", namespace: \"robertvandervoort\", author: \"Robert Vandervoort\") {\n\t\tcapability \"Actuator\"\n\t\tcapability \"Alarm\"\n        capability \"Battery\"\n\t\tcapability \"Switch\"\n        capability \"Sensor\"\n\t\tcapability \"Polling\"\n\t\tcapability \"Refresh\"\n\n\t\tcommand \"reset\"\n\t\tcommand \"getbatt\"\n\t\t// RAW DESCRIPTION: 0 0 0x1005 0 0 0 9 0x5E 0x86 0x72 0x73 0x85 0x59 0x25 0x20 0x27\n\t\tfingerprint deviceId: \"0x1005\", inClusters: \"0x5E 0x86 0x72 0x73 0x85 0x59 0x25 0x20 0x27\", manufacturer: \"zooZ\", model: \"ZSE01\"\n        \n\t}\n\t// simulator metadata\n\n\t// tile definitions\n\ttiles (scale: 2) {\n    \tmultiAttributeTile(name:\"alarm\", type:\"generic\", width:6, height:4, canChangeIcon: true) {\n\t\t\ttileAttribute(\"device.alarm\", key: \"PRIMARY_CONTROL\") {\n            \tattributeState \"off\", label:'OFF', action:'on', icon:\"st.alarm.alarm.alarm\", backgroundColor:\"#ffffff\"\n\t\t\t\tattributeState \"on\", label:'ALARM!', action:'off', icon:\"st.alarm.alarm.alarm\", backgroundColor:\"#e86d13\"\n            }\n\t\t}\n\t\tstandardTile(\"off\", \"device.alarm\", inactiveLabel: false, width: 3, height: 3) {\n\t\t\tstate \"default\", label:'', action:\"off\", icon:\"st.secondary.off\"\n\t\t}\n\t\tvalueTile(\"battery\", \"device.battery\", decoration: \"flat\", width: 3, height: 3) {\n\t\t\tstate \"battery\", label:'${currentValue}% battery', unit:\"\"\n\t\t}\n\t\tmain \"alarm\"\n\t\tdetails([\"alarm\",\"off\",\"battery\"])\n\t}\n    preferences {\n\t\tinput \"debugOutput\", \"boolean\", \n\t\t\ttitle: \"Enable debug logging?\",\n\t\t\tdefaultValue: false,\n\t\t\tdisplayDuringSetup: false,\n            required: false\n\t}\n}\n\ndef updated()\n{\n\tupdateDataValue(\"configured\", \"false\")\n\tstate.debug = (\"true\" == debugOutput)\n}\n\ndef parse(String description)\n{\n\tdef result = null\n\tif (description != \"updated\") {\n\t\tdef cmd = zwave.parse(description, [0x25: 1])\n\t\tif (cmd) {\n\t\t\tresult = zwaveEvent(cmd)\n\t\t}\n\t}\n\tif (state.debug) log.debug \"Parsed '${description}' to ${result.inspect()}\"\n\treturn result\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.wakeupv2.WakeUpNotification cmd) \n{\n\tdef result = [createEvent(descriptionText: \"${device.displayName} woke up\", isStateChange: false)]\n\tif (!isConfigured()) {\n\t\t// we're still in the process of configuring a newly joined device\n\t\tif (state.debug) log.debug(\"late configure\")\n\t\tresult += response(configure())\n\t} else {\n\t\tresult += response(zwave.wakeUpV1.wakeUpNoMoreInformation())\n\t}\n\tresult\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.manufacturerspecificv2.DeviceSpecificReport cmd) {\n\tif (state.debug) log.debug \"---MANUFACTURER SPECIFIC REPORT V2--- ${device.displayName} sent deviceIdDataFormat: ${cmd.deviceIdDataFormat}, deviceIdDataLengthIndicator: ${cmd.deviceIdDataLengthIndicator}, deviceIdType: ${cmd.deviceIdType}, payload: ${cmd.payload}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.versionv1.VersionCommandClassReport cmd) {\n\tif (state.debug) log.debug \"---COMMAND CLASS VERSION REPORT V1--- ${device.displayName} has command class version: ${cmd.commandClassVersion} - payload: ${cmd.payload}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.versionv1.VersionReport cmd) {\n\tdef fw = \"${cmd.applicationVersion}.${cmd.applicationSubVersion}\"\n\tupdateDataValue(\"fw\", fw)\n\tif (state.debug) log.debug \"---VERSION REPORT V1--- ${device.displayName} is running firmware version: $fw, Z-Wave version: ${cmd.zWaveProtocolVersion}.${cmd.zWaveProtocolSubVersion}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.configurationv1.ConfigurationReport cmd) {\n    if (state.debug) log.debug \"---CONFIGURATION REPORT V1--- ${device.displayName} parameter ${cmd.parameterNumber} with a byte size of ${cmd.size} is set to ${cmd.configurationValue}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.configurationv2.ConfigurationReport cmd) {\n    if (state.debug) log.debug \"---CONFIGURATION REPORT V2--- ${device.displayName} parameter ${cmd.parameterNumber} with a byte size of ${cmd.size} is set to ${cmd.configurationValue}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.deviceresetlocallyv1.DeviceResetLocallyNotification cmd) {\n    if (state.debug) log.debug \"---DEVICE RESET LOCALLY V1--- ${device.displayName} ${cmd}\"\n    createEvent(descriptionText: cmd.toString(), isStateChange: true, displayed: true)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.powerlevelv1.PowerlevelTestNodeReport cmd) {\n\tlog.debug \"===Power level test node report received=== ${device.displayName}: statusOfOperation: ${cmd.statusOfOperation} testFrameCount: ${cmd.testFrameCount} testNodeid: ${cmd.testNodeid}\"\n\tdef request = [\n        physicalgraph.zwave.commands.powerlevelv1.PowerlevelGet()\n    ]\n    response(commands(request))\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.batteryv1.BatteryReport cmd) {\n\tdef map = [ name: \"battery\", unit: \"%\" ]\n\tif (cmd.batteryLevel == 0xFF) {\n\t\tmap.value = 1\n\t\tmap.descriptionText = \"${device.displayName} battery is low\"\n\t\tmap.isStateChange = true\n\t} else {\n\t\tmap.value = cmd.batteryLevel\n\t}\n\tstate.lastbatt = now()\n\tcreateEvent(map)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.associationv2.AssociationReport cmd) {\n    cmd.nodeId.each({log.debug \"---ASSOCIATION REPORT--- '${cmd}', hub: '$zwaveHubNodeId' reports nodeId: '$it' is associated in group: '${cmd.groupingIdentifier}'\"})\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.hailv1.Hail cmd) {\n\tif (state.debug) log.debug \"---HAIL RECEIVED--- ${cmd}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.sensorbinaryv2.SensorBinaryReport cmd) {\n\tif (state.debug) log.debug \"---SENSOR BINARY REPORT V2--- ${device.displayName} sent value: ${cmd.sensorValue}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicReport cmd) {\n\tif (state.debug) log.debug \"---BASIC REPORT V1--- ${device.displayName} sent value: ${cmd.value}\"\n\t[\n\t\tcreateEvent([name: \"switch\", value: cmd.value ? \"on\" : \"off\", type: \"digital\", displayed: true, isStateChange: true]),\n\t\tcreateEvent([name: \"alarm\", value: cmd.value ? \"on\" : \"off\", type: \"digital\", displayed: true, isStateChange: true])\n\t]\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicSet cmd) {\n\tif (state.debug) log.debug \"---BASIC SET V1--- ${device.displayName} sent value: ${cmd.value}\"\n\t[name: \"alarm\", value: cmd.value ? \"on\" : \"off\", type: \"physical\", displayed: true, isStateChange: true]\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.switchbinaryv1.SwitchBinaryReport cmd) {\n\tif (state.debug) log.debug \"---SWITCH BINARY REPORT V1--- ${device.displayName} sent value: ${cmd.value}\"\n\t[name: \"alarm\", value: cmd.value ? \"on\" : \"off\", type: \"physical\", displayed: true, isStateChange: true]\n}\n\t\ndef zwaveEvent(physicalgraph.zwave.commands.switchbinaryv1.SwitchBinarySet cmd) {\n\tif (state.debug) log.debug \"---SWITCH BINARY SET V1--- ${device.displayName} sent value: ${cmd.value}\"\n\t[name: \"alarm\", value: cmd.value ? \"on\" : \"off\", type: \"digital\", displayed: true, isStateChange: true]\n}\n\t\ndef zwaveEvent(physicalgraph.zwave.commands.notificationv3.NotificationReport cmd) {\nif (state.debug) log.debug \"---NOTIFICATION REPORT V3--- ${device.displayName} sent eventParametersLength: ${cmd.eventParametersLength} eventParameter: ${cmd.eventParameter} notificationType: ${cmd.notificationType} event: ${cmd.event}\"\t\ndef result = []\nif (cmd.notificationType == 7) {\n\tif (cmd.event == 0x03) {\n    \tresult << createEvent(name: \"acceleration\", value: \"active\", descriptionText: \"$device.displayName cover is open.\")\n\t\t}\n\telse if (cmd.event == 0X00 || cmd.eventParameter == 0x03) {\n\t\tresult << createEvent(name: \"acceleration\", value: \"inactive\", descriptionText: \"$device.displayName cover has been closed.\")\n    }\n}\nelse {\n\tresult << createEvent(descriptionText: cmd.toString(), isStateChange: false)\n}\n\tresult\n}\n\ndef zwaveEvent(physicalgraph.zwave.Command cmd) {\n\tif (state.debug) log.debug \"Unhandled: $cmd sent to ${device.displayName}\"\n    createEvent(descriptionText: cmd.toString(), isStateChange: false)\n}\n\ndef siren() {\n\tif (state.debug) log.debug \"Siren command received\"\n\ton()\n}\n\ndef both() {\n\tif (state.debug) log.debug \"Siren and Strobe commands received\"\n\ton()\n}\n\ndef on() {\n\tif (state.debug) log.debug \"Sounding Alarm : ${device.displayName}\"\n\tdef request = [\n\t\tzwave.basicV1.basicSet(value: 0xFF)\n\t]\n    commands(request)\n}\n\ndef off() {\n\tif (state.debug) log.debug \"Cancelling Alarm : ${device.displayName}\"\n\tdef request = [\n\t\tzwave.basicV1.basicSet(value: 0x00),\n        zwave.basicV1.basicGet()\n\t]\n    commands(request)\n}\n\ndef configure() {\n\tif (state.debug) log.debug \"--Sending configuration commands to zooZ indoor siren--\"\n    if (state.debug) log.debug \"settings: ${settings.inspect()}, state: ${state.inspect()}\"\n    setConfigured()\n\tdef request = [\n\t\t// set wakeup interval to 20 mins\n\t\tzwave.wakeUpV1.wakeUpIntervalSet(seconds:1200, nodeid:zwaveHubNodeId),\n\t\t\n\t\t// Can use the zwaveHubNodeId variable to add the hub to the device's associations:\n\t\t// zwave.associationV1.associationSet(groupingIdentifier:2, nodeId:zwaveHubNodeId),\n\t\t\n\t\t//Get association\n\t\tzwave.associationV1.associationGet(groupingIdentifier:1),\n        zwave.associationV1.associationGet(groupingIdentifier:2),\n\n\t\t// Get Version information\n        zwave.versionV1.versionGet(),\n        zwave.firmwareUpdateMdV2.firmwareMdGet(),\n\n\t\t// get updated battery and sensor data\n        zwave.batteryV1.batteryGet(),\n    ]\n\tcommands(request) + [\"delay 20000\", zwave.wakeUpV1.wakeUpNoMoreInformation().format()]\n}\n\nprivate setConfigured() {\n\tupdateDataValue(\"configured\", \"true\")\n    return []\n}\n\nprivate isConfigured() {\n\tgetDataValue(\"configured\") == \"true\"\n}\n\nprivate command(physicalgraph.zwave.Command cmd) {\n\tcmd.format()\n}\n\nprivate commands(commands, delay=1000) {\n\tdelayBetween(commands.collect{ command(it) }, delay)\n}"
  },
  {
    "path": "zooZ-Indoor-Siren-ZSE01/device_type-zooZ-indoor-siren-v1.2",
    "content": "/*\n * V 1.2 of zooZ Indoor Siren ZSE01\n *  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except\n *  in compliance with the License. You may obtain a copy of the License at:\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n *  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed\n *  on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License\n *  for the specific language governing permissions and limitations under the License.\n *\n ---------------------------------------------------------------------------------------------------------------------------\n   INSTRUCTIONS:\n   * First you will need to create a new device handler in SmartThings. Log in to the IDE and click on Device Handlers in the top menu.\n   Then click \"from code\" below. You'l be presented with a blank area where you can copy this code and paste it in.\n   * Next, scroll to the bottom and click create. Now click save, then click publish > for me.\n   * You should now see this device type in your list of device handlers. Now we need to pair the device.\n   * Put SmartThings into inclusion mode by going through the add new device dialog.\n   * Tap the button on the siren a few times (turning siren on and off) and you should see it appear on the app screen.\n   * tap the discovered device on the app screen to continue.\n   * Now go to your devices list in the SmartThings app and open up the newly added siren.\n   * The configuration will get sent by pressing the button to activate the siren, then tapping again to cancel.\n   * That's it. Remember this is a USB powered device and the batteries are for BACKUP ONLY. There is no battery level indicator by design.\n\n*/\n\n metadata {\n\tdefinition (name: \"zooZ Indoor Siren ZSE01 - RV v1.2\", namespace: \"robertvandervoort\", author: \"Robert Vandervoort\") {\n\t\tcapability \"Actuator\"\n\t\tcapability \"Alarm\"\n        capability \"Battery\"\n\t\tcapability \"Switch\"\n        capability \"Sensor\"\n\t\tcapability \"Polling\"\n\t\tcapability \"Refresh\"\n\n\t\tcommand \"reset\"\n\t\t// RAW DESCRIPTION: 0 0 0x1005 0 0 0 9 0x5E 0x86 0x72 0x73 0x85 0x59 0x25 0x20 0x27\n\t\tfingerprint deviceId: \"0x1005\", inClusters: \"0x5E 0x86 0x72 0x73 0x85 0x59 0x25 0x20 0x27\", manufacturer: \"zooZ\", model: \"ZSE01\"\n        \n\t}\n\t// simulator metadata\n\n\t// tile definitions\n\ttiles (scale: 2) {\n    \tmultiAttributeTile(name:\"alarm\", type:\"generic\", width:6, height:4, canChangeIcon: true) {\n\t\t\ttileAttribute(\"device.alarm\", key: \"PRIMARY_CONTROL\") {\n            \tattributeState \"off\", label:'OFF', action:'on', icon:\"st.alarm.alarm.alarm\", backgroundColor:\"#ffffff\"\n\t\t\t\tattributeState \"on\", label:'ALARM!', action:'off', icon:\"st.alarm.alarm.alarm\", backgroundColor:\"#e86d13\"\n            }\n\t\t}\n\t\tstandardTile(\"off\", \"device.alarm\", inactiveLabel: false, width: 6, height: 4) {\n\t\t\tstate \"default\", label:'', action:\"off\", icon:\"st.secondary.off\"\n\t\t}\n\t\tmain \"alarm\"\n\t\tdetails([\"alarm\",\"off\"])\n\t}\n    preferences {\n\t\tinput \"debugOutput\", \"boolean\", \n\t\t\ttitle: \"Enable debug logging?\",\n\t\t\tdefaultValue: false,\n\t\t\tdisplayDuringSetup: false,\n            required: false\n\t}\n}\n\ndef updated()\n{\n\tupdateDataValue(\"configured\", \"false\")\n\tstate.debug = (\"true\" == debugOutput)\n\tdef result = createEvent(descriptionText: \"${device.displayName} was updated\", displayed: true)\n    configure()\n}\n\ndef parse(String description)\n{\n\tdef result = null\n\tif (description != \"updated\") {\n\t\tdef cmd = zwave.parse(description, [0x25: 1])\n\t\tif (cmd) {\n\t\t\tresult = zwaveEvent(cmd)\n\t\t}\n\t}\n\tif (state.debug) log.debug \"Parsed '${description}' to ${result.inspect()}\"\n\treturn result\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.manufacturerspecificv2.DeviceSpecificReport cmd) {\n\tif (state.debug) log.debug \"---MANUFACTURER SPECIFIC REPORT V2--- ${device.displayName} sent deviceIdDataFormat: ${cmd.deviceIdDataFormat}, deviceIdDataLengthIndicator: ${cmd.deviceIdDataLengthIndicator}, deviceIdType: ${cmd.deviceIdType}, payload: ${cmd.payload}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.versionv1.VersionCommandClassReport cmd) {\n\tif (state.debug) log.debug \"---COMMAND CLASS VERSION REPORT V1--- ${device.displayName} has command class version: ${cmd.commandClassVersion} - payload: ${cmd.payload}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.versionv1.VersionReport cmd) {\n\tdef fw = \"${cmd.applicationVersion}.${cmd.applicationSubVersion}\"\n\tupdateDataValue(\"fw\", fw)\n\tif (state.debug) log.debug \"---VERSION REPORT V1--- ${device.displayName} is running firmware version: $fw, Z-Wave version: ${cmd.zWaveProtocolVersion}.${cmd.zWaveProtocolSubVersion}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.deviceresetlocallyv1.DeviceResetLocallyNotification cmd) {\n    if (state.debug) log.debug \"---DEVICE RESET LOCALLY V1--- ${device.displayName} ${cmd}\"\n    createEvent(descriptionText: cmd.toString(), isStateChange: true, displayed: true)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.powerlevelv1.PowerlevelTestNodeReport cmd) {\n\tif (state.debug) log.debug \"===Power level test node report received=== ${device.displayName}: statusOfOperation: ${cmd.statusOfOperation} testFrameCount: ${cmd.testFrameCount} testNodeid: ${cmd.testNodeid}\"\n\tdef request = [\n        physicalgraph.zwave.commands.powerlevelv1.PowerlevelGet()\n    ]\n    response(commands(request))\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.associationv2.AssociationReport cmd) {\n    cmd.nodeId.each({log.debug \"---ASSOCIATION REPORT--- '${cmd}', hub: '$zwaveHubNodeId' reports nodeId: '$it' is associated in group: '${cmd.groupingIdentifier}'\"})\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicReport cmd) {\n\tif (state.debug) log.debug \"---BASIC REPORT V1--- ${device.displayName} sent value: ${cmd.value}\"\n\t[\n\t\tcreateEvent([name: \"switch\", value: cmd.value ? \"on\" : \"off\", type: \"physical\", displayed: true, isStateChange: true]),\n\t\tcreateEvent([name: \"alarm\", value: cmd.value ? \"on\" : \"off\", type: \"physical\", displayed: true, isStateChange: true])\n\t]\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicSet cmd) {\n\tif (state.debug) log.debug \"---BASIC SET V1--- ${device.displayName} sent value: ${cmd.value}\"\n\t[name: \"alarm\", value: cmd.value ? \"on\" : \"off\", type: \"digital\", displayed: true, isStateChange: true]\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.switchbinaryv1.SwitchBinaryReport cmd) {\n\tif (state.debug) log.debug \"---SWITCH BINARY REPORT V1--- ${device.displayName} sent value: ${cmd.value}\"\n\t[name: \"alarm\", value: cmd.value ? \"on\" : \"off\", type: \"physical\", displayed: true, isStateChange: true]\n}\n\t\ndef zwaveEvent(physicalgraph.zwave.commands.switchbinaryv1.SwitchBinarySet cmd) {\n\tif (state.debug) log.debug \"---SWITCH BINARY SET V1--- ${device.displayName} sent value: ${cmd.value}\"\n\t[name: \"alarm\", value: cmd.value ? \"on\" : \"off\", type: \"digital\", displayed: true, isStateChange: true]\n}\n\ndef zwaveEvent(physicalgraph.zwave.Command cmd) {\n\tif (state.debug) log.debug \"Unhandled: $cmd sent to ${device.displayName}\"\n    createEvent(descriptionText: cmd.toString(), isStateChange: false)\n}\n\ndef siren() {\n\tif (state.debug) log.debug \"Siren command received\"\n\ton()\n}\n\ndef both() {\n\tif (state.debug) log.debug \"Siren and Strobe commands received\"\n\ton()\n}\n\ndef on() {\n\tif (state.debug) log.debug \"Sounding Alarm : ${device.displayName}\"\n\tdef request = [\n\t\tzwave.basicV1.basicSet(value: 0xFF),\n\t\tzwave.basicV1.basicGet()\n\t]\n    commands(request)\n}\n\ndef off() {\n\tif (state.debug) log.debug \"Cancelling Alarm : ${device.displayName}\"\n\tdef request = [\n\t\tzwave.basicV1.basicSet(value: 0x00),\n        zwave.basicV1.basicGet()\n\t]\n    commands(request)\n}\n\ndef configure() {\n\tif (state.debug) log.debug \"--Sending configuration commands to zooZ indoor siren--\"\n    if (state.debug) log.debug \"settings: ${settings.inspect()}, state: ${state.inspect()}\"\n    setConfigured()\n\tdef request = [\n\t\t//Get association\n\t\tzwave.associationV1.associationGet(groupingIdentifier:1),\n        zwave.associationV1.associationGet(groupingIdentifier:2),\n\n\t\t// Get Version information\n        zwave.versionV1.versionGet(),\n        zwave.firmwareUpdateMdV2.firmwareMdGet(),\n    ]\n\tcommands(request)\n}\n\nprivate setConfigured() {\n\tupdateDataValue(\"configured\", \"true\")\n    return []\n}\n\nprivate isConfigured() {\n\tgetDataValue(\"configured\") == \"true\"\n}\n\nprivate command(physicalgraph.zwave.Command cmd) {\n\tcmd.format()\n}\n\nprivate commands(commands, delay=1000) {\n\tdelayBetween(commands.collect{ command(it) }, delay)\n}"
  },
  {
    "path": "zooZ-MiniPlug-ZEN07/device_type-zooZ-4-in-1-Sensor-ZSE40_v1.2.groovy",
    "content": "/*\n * V 1.2 of zooZ 4-in-1 sensor code 6/12/2016\n * by Robert Vandervoort\n *\n *  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except\n *  in compliance with the License. You may obtain a copy of the License at:\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n *  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed\n *  on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License\n *  for the specific language governing permissions and limitations under the License.\n * \n---------------------------------------------------------------------------------------------------------------------------\n   INSTRUCTIONS:\n   * First you will need to create a new device handler in SmartThings. Log in to the IDE and click on Device Handlers in the top menu.\n   Then click \"from code\" below. You'l be presented with a blank area where you can copy this code and paste it in.\n   * Next, scroll to the bottom and click create. Now click save, then click publish > for me.\n   * You should now see this device type in your list of device handlers. Now we need to pair the device.\n   * Put SmartThings into inclusion mode by going through the add new device dialog.\n   On the bottom of the zooZ 4-in-1 you will see several small holes. There is a series of four holes and a hole all by itself.\n   You'll need a paperclip or something similar that fits into the hole. While holding the sensor a foot or so from the hub,\n   and with SmartThings in inclusion mode, gently depress the button inside the single hole twice rapidly. The light should blink.\n   Please wait a few moments (usually 10 seconds or so) and you should see \"zooZ 4-in-1 sensor - RV 1.0\" appear in the found devices area.\n   * Touch the \"zooZ 4-in-1 sensor - RV 1.0\" to configure. Here we will set your temperature scale preferecne and motion preferences.\n   After you make your choices, touch done in the app. \n   * Now go to your devices list in the SmartThings app and open up the newly added sensor.\n   * In order to get the configuration sent and initial sensor data, we need to wake the sensor up. Press the button on the device\n   one time while holding it close to the hub. If you pressed the button the sensor should blink yellow once. Wait about 30 seconds,\n   then refresh (drag the screen down) and you should see data on the screen for temp, humidity, illuminance, and battery.\n   ** If you do not, please wait a minute or so and refresh the screen again by sliding it down.\n   * If you still do not see anything after refreshing, touch the gear icon to enter the device preferences screen (make any adjustments or not) and then touch done.\n   This will reset the configuration state so the device can be configured again and polled for data. Once you're back at the device screen,\n   while holding the sensor close to the hub, press the small button we pressed earlier one time, making sure that the sensor blinks\n   (if it doesn't, press the button again) and wait a minute or so, then refresh the device screen in the app again.\n   You should see data on the screen now. \n   *** IF YOU STILL ARE NOT GETTING DATA, go back to the preferences screen and enable debug logging, and touch done. You do not need\n   to press the button on the sensor again at this point. Go into the SmartThings IDE and choose \"live logging\" from the top menu.\n   While on the live logging  screen and close to your hub with the sensor, press the button on the sensor, making sure it blinks, and watch the screen for results.\n   You should see several lines of data come in slowly. This should tell you all your settings and what the configuration on the sensor is actually set to.\n   It will then poll the sensors for data. If you do not ever see any data coming from the sensor, please post to the community or\n   message me via github or the SmartThings community. \n */\n \n metadata {\n\tdefinition (name: \"zooZ 4-in-1 sensor - RV 1.2\", namespace: \"robertvandervoort\", author: \"Robert Vandervoort\") {\n\t\tcapability \"Motion Sensor\"\n\t\tcapability \"Acceleration Sensor\"\n\t\tcapability \"Temperature Measurement\"\n\t\tcapability \"Relative Humidity Measurement\"\n\t\tcapability \"Illuminance Measurement\"\n\t\tcapability \"Configuration\"\n\t\tcapability \"Sensor\"\n\t\tcapability \"Battery\"\n\t\t\n        // RAW Description: 0 0 0x0701 0 0 0 e 0x5E 0x98 0x86 0x72 0x5A 0x85 0x59 0x73 0x80 0x71 0x31 0x70 0x84 0x7A   \t\t\t\t\t\t\t\t\t\t \n\t\tattribute \"tamper\", \"enum\", [\"detected\", \"clear\"]\n\t\tfingerprint deviceId: \"0x0701\", inClusters: \"0x5E,0x86,0x72,0x59,0x85,0x73,0x71,0x84,0x80,0x31,0x70,0x5A,0x98,0x7A\"\n\t\t}\n/*\tsimulator {\n\t\tstatus \"no motion\" : \"command: 9881, payload: 00300300\"\n\t\tstatus \"motion\"    : \"command: 9881, payload: 003003FF\"\n        status \"clear\" : \" command: 9881, payload: 0071050000000007030000\"\n        status \"tamper\" : \"command: 9881, payload: 007105000000FF07030000\"\n        \n        for (int i = 0; i <= 100; i += 20) {\n\t\t\tstatus \"temperature ${i}F\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().sensorMultilevelV2.sensorMultilevelReport(\n                \tscaledSensorValue: i,\n                    precision: 2,\n                    sensorType: 1,\n                    scale: 1\n\t\t\t\t)\n\t\t\t).incomingMessage()\n\t\t}\n\t\tfor (int i = 0; i <= 100; i += 20) {\n\t\t\tstatus \"RH ${i}%\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().sensorMultilevelV2.sensorMultilevelReport(\n                \tscaledSensorValue: i,\n                    sensorType: 5\n            \t)\n\t\t\t).incomingMessage()\n\t\t}\n\t\tfor (int i in [0, 1, 2, 8, 12, 16, 20, 24, 30, 64, 82, 100, 200, 500, 1000]) {\n\t\t\tstatus \"illuminance ${i}%\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().sensorMultilevelV2.sensorMultilevelReport(\n                scaledSensorValue: i,\n                sensorType: 3\n                )\n\t\t\t).incomingMessage()\n\t\t}\n\t\tfor (int i in [0, 5, 10, 15, 50, 99, 100]) {\n\t\t\tstatus \"battery ${i}%\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().batteryV1.batteryReport(\n                batteryLevel: i\n                )\n\t\t\t).incomingMessage()\n\t\t}\n\t\tstatus \"low battery alert\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().batteryV1.batteryReport(\n            \tbatteryLevel: 255\n            \t)\n\t\t\t).incomingMessage()\n\t\tstatus \"wake up\": \"command: 8407, payload:\"\n\t}\n*/\n\ttiles (scale: 2) {\n\t\tmultiAttributeTile(name:\"main\", type:\"generic\", width:6, height:4) {\n\t\t\ttileAttribute(\"device.temperature\", key: \"PRIMARY_CONTROL\") {\n            \tattributeState \"temperature\",label:'${currentValue}°', precision:2, backgroundColors:[\n                \t[value: 32, color: \"#153591\"],\n                    [value: 44, color: \"#1e9cbb\"],\n                    [value: 59, color: \"#90d2a7\"],\n\t\t\t\t\t[value: 74, color: \"#44b621\"],\n\t\t\t\t\t[value: 84, color: \"#f1d801\"],\n\t\t\t\t\t[value: 92, color: \"#d04e00\"],\n\t\t\t\t\t[value: 98, color: \"#bc2323\"]\n\t\t\t\t]\n            }\n            tileAttribute(\"device.humidity\", key: \"SECONDARY_CONTROL\") {\n                attributeState \"humidity\",label:'RH ${currentValue} %', precision:2\n            }\n\t\t}\n        standardTile(\"motion\",\"device.motion\", width: 2, height: 2) {\n            \tstate \"active\",label:'motion',icon:\"st.motion.motion.active\",backgroundColor:\"#53a7c0\"\n                state \"inactive\",label:'no motion',icon:\"st.motion.motion.inactive\",backgroundColor:\"#ffffff\"\n\t\t\t}\n\t\tvalueTile(\"humidity\",\"device.humidity\", width: 2, height: 2) {\n           \tstate \"humidity\",label:'RH ${currentValue}%', precision:2\n\t\t\t}\n\t\tvalueTile(\"illuminance\",\"device.illuminance\", width: 2, height: 2) {\n            \tstate \"luminosity\",label:'LIGHT ${currentValue}%', precision:2\n\t\t\t}\n\t\tstandardTile(\"acceleration\", \"device.acceleration\", width: 2, height: 2) {\n\t\t\tstate(\"active\", label:'tamper', icon:\"st.motion.acceleration.active\", backgroundColor:\"#ff0000\")\n\t\t\tstate(\"inactive\", label:'clear', icon:\"st.motion.acceleration.inactive\", backgroundColor:\"#00ff00\")\n\t\t}\n\t\tvalueTile(\"battery\", \"device.battery\", decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"battery\", label:'${currentValue}% battery'\n\t\t}\n\t\tmain([\"main\"])\n\t\tdetails([\"main\",\"humidity\",\"illuminance\",\"motion\",\"acceleration\",\"battery\"])\n\t}\n    preferences {\n\t\tinput \"debugOutput\", \"boolean\", \n\t\t\ttitle: \"Enable debug logging?\",\n\t\t\tdefaultValue: false,\n\t\t\tdisplayDuringSetup: true\n\t\tinput \"LEDbehavior\", \"enum\",\n\t\t\ttitle: \"LED Behavior\",\n\t\t\toptions: [\"LED Off\", \"Breathing\", \"Quick Blink on Temp/PIR\"],\n            defaultValue: \"Quick Blink on Temp/PIR\",\n\t\t\trequired: false,\n\t\t\tdisplayDuringSetup: false\n\t\tinput \"tempoffset\", \"number\",\n\t\t\ttitle: \"Reporting threshold  for temp\",\n            description: \"Enter a value 1-50 changing reporting threshold for temp. Represents 0.1 degree increments.\",\n            range: \"1..50\",\n\t\t\tdefaultValue: 50,\n            required: false,\n            displayDuringSetup: false\n\t\tinput \"humidityoffset\", \"number\",\n            title: \"Reporting threshold for humidity\",\n            description: \"Report when change occurs from 1%-50% RH)\",\n\t\t\trange: \"1..50\",\n\t\t\tdefaultValue: 1,\n\t\t\trequired: false,\n            displayDuringSetup: false\n\t\tinput \"luminanceoffset\", \"number\",\n            title: \"Reporting threshold for Luminance\",\n            description: \"valid values from 5% to 50%\",\n            range: \"5..50\",\n\t\t\tdefaultValue: 5,\n            required: false,\n\t        displayDuringSetup: false\n\t\tinput \"PIRsensitivity\", \"number\",\n    \t    title: \"PIR motion sensitivity\",\n\t\t\tdescription: \"A value from 1-7, from high to low sensitivity (1 is highest)\",\n\t\t\trange: \"1..7\",\n\t\t\tdefaultValue: 4,\n\t\t\trequired: false,\n\t\t\tdisplayDuringSetup: true\n\t\tinput \"MotionReset\", \"number\",\n    \t    title: \"PIR reset time\",\n\t\t\tdescription: \"Number of minutes to wait to report motion cleared after a motion event if there is no motion detected.\",\n\t\t\trange: \"1..255\",\n\t\t\tdefaultValue: 5,\n\t\t\trequired: false,\n\t\t\tdisplayDuringSetup: true            \n\t}\n}\n\ndef updated()\n{\n\tupdateDataValue(\"configured\", \"false\")\n\tstate.debug = (\"true\" == debugOutput)\n}\n\ndef parse(String description)\n{\n\tdef result = null\n\tif (description.startsWith(\"Err 106\")) {\n\t\tstate.sec = 0\n\t\tresult = createEvent( name: \"secureInclusion\", value: \"failed\", isStateChange: true,\n\t\t\tdescriptionText: \"This sensor failed to complete the network security key exchange. If you are unable to control it via SmartThings, you must remove it from your network and add it again.\")\n\t} else if (description != \"updated\") {\n\t\tdef cmd = zwave.parse(description, [0x31: 5, 0x71:3, 0x7A: 2, 0x81: 1, 0x84: 2, 0x86: 2])\n\t\tif (cmd) {\n\t\t\tresult = zwaveEvent(cmd)\n\t\t}\n\t}\n\tif (state.debug) log.debug \"Parsed '${description}' to ${result.inspect()}\"\n\treturn result\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.wakeupv2.WakeUpNotification cmd) \n{\n\tdef result = [createEvent(descriptionText: \"${device.displayName} woke up\", isStateChange: false)]\n\tif (!isConfigured()) {\n\t\t// we're still in the process of configuring a newly joined device\n\t\tif (state.debug) log.debug(\"late configure\")\n\t\tresult += response(configure())\n\t} else {\n\t\tresult += response(checkBattery())\n\t}\n\tresult\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.securityv1.SecurityMessageEncapsulation cmd) {\n\tdef encapsulatedCommand = cmd.encapsulatedCommand([0x31: 5, 0x71: 3, 0x7A: 2, 0x81: 1, 0x84: 2])\n\tstate.sec = 1\n\t// if (state.debug) log.debug \"encapsulated: ${encapsulatedCommand}\"\n\tif (encapsulatedCommand) {\n\t\tzwaveEvent(encapsulatedCommand)\n\t} else {\n\t\tlog.warn \"Unable to extract encapsulated cmd from $cmd\"\n\t\tcreateEvent(descriptionText: cmd.toString())\n\t}\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.securityv1.SecurityCommandsSupportedReport cmd) {\n\tif (state.debug) log.debug \"---SECURITY COMMANDS SUPPORTED REPORT V1--- ${device.displayName} sent commandClassControl: ${cmd.commandClassControl}, commandClassSupport: ${cmd.commandClassSupport}, reportsToFollow: ${cmd.reportsToFollow}\"\n\tresponse(configure())\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.manufacturerspecificv2.DeviceSpecificReport cmd) {\n\tif (state.debug) log.debug \"---MANUFACTURER SPECIFIC REPORT V2--- ${device.displayName} sent deviceIdDataFormat: ${cmd.deviceIdDataFormat}, deviceIdDataLengthIndicator: ${cmd.deviceIdDataLengthIndicator}, deviceIdType: ${cmd.deviceIdType}, payload: ${cmd.payload}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.versionv1.VersionCommandClassReport cmd) {\n\tif (state.debug) log.debug \"---COMMAND CLASS VERSION REPORT V1--- ${device.displayName} has command class version: ${cmd.commandClassVersion} - payload: ${cmd.payload}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.versionv1.VersionReport cmd) {\n\tdef fw = \"${cmd.applicationVersion}.${cmd.applicationSubVersion}\"\n\tupdateDataValue(\"fw\", fw)\n\tif (state.debug) log.debug \"---VERSION REPORT V1--- ${device.displayName} is running firmware version: $fw, Z-Wave version: ${cmd.zWaveProtocolVersion}.${cmd.zWaveProtocolSubVersion}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.configurationv1.ConfigurationReport cmd) {\n    if (state.debug) log.debug \"---CONFIGURATION REPORT V1--- ${device.displayName} parameter ${cmd.parameterNumber} with a byte size of ${cmd.size} is set to ${cmd.configurationValue}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.configurationv2.ConfigurationReport cmd) {\n    if (state.debug) log.debug \"---CONFIGURATION REPORT V2--- ${device.displayName} parameter ${cmd.parameterNumber} with a byte size of ${cmd.size} is set to ${cmd.configurationValue}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.batteryv1.BatteryReport cmd) {\n\tdef map = [ name: \"battery\", unit: \"%\" ]\n\tif (cmd.batteryLevel == 0xFF) {\n\t\tmap.value = 1\n\t\tmap.descriptionText = \"${device.displayName} battery is low\"\n\t\tmap.isStateChange = true\n\t\tcreateEvent(map)\n\t} else {\n\t\tmap.value = cmd.batteryLevel\n\t\tcreateEvent(map)\n\t}\n\tstate.lastbatt = now()\n\tcreateEvent(map)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.sensormultilevelv5.SensorMultilevelReport cmd) {\n\tif (state.debug) log.debug \"---SENSOR MULTILEVEL v5 REPORT--- ${device.displayName} sent sensorType: ${cmd.sensorType} value: ${cmd.sensorValue} scale: ${cmd.scale} scaledSensorValue: ${cmd.scaledSensorValue}\"\n\tdef map = [:]\n\tswitch (cmd.sensorType) {\n\t\tcase 1:\n\t\t\tmap.name = \"temperature\"\n\t\t\tdef cmdScale = cmd.scale == 1 ? \"F\" : \"C\"\n\t\t\tmap.value = convertTemperatureIfNeeded(cmd.scaledSensorValue, cmdScale, cmd.precision)\n\t\t\tmap.unit = getTemperatureScale()\n\t\t\tbreak;\n\t\tcase 3:\n\t\t\tmap.name = \"illuminance\"\n\t\t\tmap.value = cmd.scaledSensorValue\n\t\t\tmap.unit = \"%\"\n\t\t\tbreak;\n        case 5:\n\t\t\tmap.name = \"humidity\"\n\t\t\tmap.value = cmd.scaledSensorValue\n\t\t\tmap.unit = \"%\"\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tmap.descriptionText = cmd.toString()\n\t}\n\tcreateEvent(map)\n}\n\ndef motionEvent(value) {\n\tdef map = [name: \"motion\"]\n\tif (value != 0) {\n\t\tmap.value = \"active\"\n\t\tmap.descriptionText = \"$device.displayName detected motion\"\n\t} else {\n\t\tmap.value = \"inactive\"\n\t\tmap.descriptionText = \"$device.displayName motion has stopped\"\n\t}\n\tcreateEvent(map)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.sensorbinaryv2.SensorBinaryReport cmd) {\n\tif (state.debug) log.debug \"---SENSOR BINARY REPORT V2--- ${device.displayName} sent value: ${cmd.sensorValue}\"\n\tmotionEvent(cmd.sensorValue)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicSet cmd) {\n\tif (state.debug) log.debug \"---BASIC SET REPORT V1--- ${device.displayName} sent value: ${cmd.value}\"\n\tmotionEvent(cmd.value)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.notificationv3.NotificationReport cmd) {\nif (state.debug) log.debug \"---NOTIFICATION REPORT V3--- ${device.displayName} sent eventParametersLength: ${cmd.eventParametersLength} eventParameter: ${cmd.eventParameter} notificationType: ${cmd.notificationType} event: ${cmd.event}\"\t\ndef result = []\nif (cmd.notificationType == 7) {\n\tif (cmd.event == 0x00 && cmd.eventParameter == 0x08) {\n\t\tresult << motionEvent(0)\n        }\n    else if (cmd.event == 0x03) {\n    \tresult << createEvent(name: \"acceleration\", value: \"active\", descriptionText: \"$device.displayName cover is open.\")\n\t\t}\n\telse if (cmd.event == 0X00 || cmd.eventParameter == 0x03) {\n\t\tresult << createEvent(name: \"acceleration\", value: \"inactive\", descriptionText: \"$device.displayName cover has been closed.\")\n    }\n\telse if (cmd.event == 0x08) {\n    \tresult << motionEvent(255)\n\t}\n}\nelse {\n\tresult << createEvent(descriptionText: cmd.toString(), isStateChange: false)\n}\n\tresult\n}\n\ndef zwaveEvent(physicalgraph.zwave.Command cmd) {\n\tcreateEvent(descriptionText: cmd.toString(), isStateChange: false)\n}\n\nprivate checkBattery() {\n\tdef request = [\n\t\tzwave.batteryV1.batteryGet(),\n\t\tzwave.wakeUpV1.wakeUpNoMoreInformation()\n\t\t]\n\tcommands(request)\n}\n\ndef configure() {\n\t// This sensor joins as a secure device if you double-click the button to include it\n\t//if (device.device.rawDescription =~ /98/ && !state.sec) {\n\t//\tif (state.debug) log.debug \"4-in-1 sensor not sending configure until secure\"\n\t//\treturn []\n\t//}\n\tif (state.debug) log.debug \"--Sending configuration commands to zooZ 4-in-1 sensor--\"\n    //if (state.debug) log.debug \"Prefernces settings: PIRsensitivity: $PIRsensitivity, Temp offset: $tempoffset, Humidity offset: $humidityoffset, Luminance offset: $luminanceoffset\"\n\tdef LEDbehav = 3\n\tif (LEDbehavior == \"LED Off\") {\n    \tLEDbehav=1\n    }\n\telse if (LEDbehavior == \"Breathing\") {\n    \tLEDbehav=2\n\t}\n\telse {\n\t\tLEDbehav=3\n\t}\t\n\tdef PIRsens = 4\n\tif (PIRsensitivity) {\n\t\tPIRsens=PIRsensitivity\n\t}\n\telse {\n\t\tPIRsens = 4\n\t}\n    def MotionRst = 3\n\tif (MotionReset) {\n\t\tMotionRst=MotionReset\n\t}\n\telse {\n\t\tMotionRst = 3\n\t}\n\tdef tempoff = 1\n\tif (tempoffset) {\n\t\ttempoff=tempoffset\n\t}\n\telse {\n\t\ttempoff = 1\n\t}\n\tdef humidityoff = 10\n\tif (humidityoffset) {\n\t\thumidityoff=humidityoffset\n\t}\n\telse {\n\t\thumidityoff = 10\n\t}\n\tdef luminanceoff = 10\n\tif (luminanceoffset) {\n\t\tluminanceoff=luminanceoffset\n\t}\n\telse {\n\t\tluminanceoff = 10\n\t}\n    if (state.debug) log.debug \"settings: ${settings.inspect()}, state: ${state.inspect()}\"\n    setConfigured()\n\tdef request = [\n\t\t// set wakeup interval to 20 mins\n\t\tzwave.wakeUpV1.wakeUpIntervalSet(seconds:3600, nodeid:zwaveHubNodeId),\n\t\t\n\t\t// Get Version information\n        zwave.versionV1.versionGet(),\n        zwave.firmwareUpdateMdV2.firmwareMdGet(),\n\t\t\n        // configure temp scale to celcius or fahrenheight and set offset\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x01, size: 1, scaledConfigurationValue: 1),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0x01),\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x02, size: 1, scaledConfigurationValue: tempoff),\t\t\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0x02),\n\t\t\n        // configure humidity offset\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x03, size: 1, scaledConfigurationValue: humidityoff),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0x03),\n\t\t\n        // configure luminance offset\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x04, size: 1, scaledConfigurationValue: luminanceoff),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0x04),\n\t\t\n\t\t// send no-motion report x minutes after motion stops\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x05, size: 1, scaledConfigurationValue: MotionRst),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0x05),\n    \t\n\t\t// set motion sensor sensitivity\n        zwave.configurationV1.configurationSet(parameterNumber: 0x06, size: 1, scaledConfigurationValue: PIRsens),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0x06),\n\t\t\n        // set LED behavior\n        zwave.configurationV1.configurationSet(parameterNumber: 0x07, size: 1, scaledConfigurationValue: LEDbehav),\n        zwave.configurationV1.configurationGet(parameterNumber: 0x07),\n\t\t\n\t\t// get updated battery and sensor data\n        zwave.batteryV1.batteryGet(),\n\t\tzwave.sensorMultilevelV5.sensorMultilevelGet(sensorType:1, scale:1),\n        zwave.sensorMultilevelV5.sensorMultilevelGet(sensorType:3, scale:0),\n        zwave.sensorMultilevelV5.sensorMultilevelGet(sensorType:5, scale:0),\n        \n\t\t// Can use the zwaveHubNodeId variable to add the hub to the device's associations:\n\t\tzwave.associationV1.associationSet(groupingIdentifier:2, nodeId:zwaveHubNodeId)\n    ]\n\tcommands(request) + [\"delay 20000\", zwave.wakeUpV1.wakeUpNoMoreInformation().format()]\n}\n\nprivate setConfigured() {\n\tupdateDataValue(\"configured\", \"true\")\n    return []\n}\n\nprivate isConfigured() {\n\tgetDataValue(\"configured\") == \"true\"\n}\n\nprivate command(physicalgraph.zwave.Command cmd) {\n\tif (state.sec) {\n\t\tzwave.securityV1.securityMessageEncapsulation().encapsulate(cmd).format()\n\t} else {\n\t\tcmd.format()\n\t}\n}\n\nprivate commands(commands, delay=1000) {\n\tdelayBetween(commands.collect{ command(it) }, delay)\n}"
  },
  {
    "path": "zooZ-MiniPlug-ZEN07/device_type-zooZ-MiniPlug-ZEN07-v1.1.groovy",
    "content": "/*\nzooZ MiniPlug ZEN07 device handler for SmartThings version 1.0 by Robert Vandervoort 10/10/2016\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except\nin compliance with the License. You may obtain a copy of the License at:\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under the License is distributed\non an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License\nfor the specific language governing permissions and limitations under the License.\n\nsome code used from various SmartThings device type and metering code from ElasticDev\n\n*/\n\nmetadata {\n\tdefinition (name: \"zooZ MiniPlug ZEN07 - RV v1.0\", namespace: \"robertvandervoort\", author: \"Robert Vandervoort\") {\n\t\tcapability \"Energy Meter\"\n\t\tcapability \"Power Meter\"\n\t\tcapability \"Actuator\"\n\t\tcapability \"Switch\"\n\t\tcapability \"Configuration\"\n\t\tcapability \"Polling\"\n\t\tcapability \"Refresh\"\n\t\tcapability \"Sensor\"\n\n\t\tcommand \"reset\"\n        command \"getPower\"\n        command \"getEnergy\"\n        command \"getVolts\"\n        command \"getCurrent\"\n        command \"checkstate\"\n\t\t\n\t// RAW 0 0 0x1001 0 0 0 d 0x5E 0x72 0x86 0x85 0x59 0x5A 0x73 0x70 0x25 0x27 0x71 0x32 0x20\n\t// MSR 027A-0003-0087\n\t\n\t\tfingerprint deviceId: \"0x1001\", inClusters: \"0x5E,0x72,0x86,0x85,0x59,0x5A,0x73,0x70,0x25,0x27,0x71,0x32,0x20\"\n\t}\n\t// simulator metadata\n\tsimulator {\n\t\tstatus \"on\":  \"command: 2003, payload: FF\"\n\t\tstatus \"off\": \"command: 2003, payload: 00\"\n\n\tfor (int i = 0; i <= 10000; i += 1000) {\n\t    status \"power  ${i} W\": \n\t\t    new physicalgraph.zwave.Zwave().meterV3.meterReport(scaledMeterValue: i, precision: 3, meterType: 4, scale: 2, size: 4).incomingMessage()\n\t}\n\tfor (int i = 0; i <= 100; i += 10) {\n\t    status \"energy  ${i} kWh\":\n\t\t    new physicalgraph.zwave.Zwave().meterV3.meterReport(scaledMeterValue: i, precision: 3, meterType: 0, scale: 0, size: 4).incomingMessage()\n\t}\n\t\t// reply messages\n\t\treply \"2001FF,delay 100,2502\": \"command: 2503, payload: FF\"\n\t\treply \"200100,delay 100,2502\": \"command: 2503, payload: 00\"\n\t}\n\n\t// tile definitions\n\ttiles (scale: 2) {\n    \tmultiAttributeTile(name:\"main\", type:\"generic\", width:6, height:4, canChangeIcon: true) {\n\t\t\ttileAttribute(\"device.switch\", key: \"PRIMARY_CONTROL\") {\n            \tattributeState \"on\", label: '${name}', action: \"switch.off\", icon: \"st.switches.switch.on\", backgroundColor: \"#79b821\"\n\t\t\t\tattributeState \"off\", label: '${name}', action: \"switch.on\", icon: \"st.switches.switch.off\", backgroundColor: \"#ffffff\"\n            }\n\t\t}\n        valueTile(\"power\", \"device.power\", decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'${currentValue} W', action:\"getPower\"\n\t\t}\n\t\tvalueTile(\"energy\", \"device.energy\", decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'${currentValue} kWh', action:\"getEnergy\"\n\t\t}\n\t\tvalueTile(\"current\", \"device.current\", decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'${currentValue} A', action:\"getCurrent\"\n\t\t}\n        valueTile(\"voltage\", \"device.voltage\", decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'${currentValue} V', action:\"getVoltage\"\n\t\t}\n\t\tstandardTile(\"reset\", \"device.energy\", inactiveLabel: false, decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'reset kWh', action:\"reset\"\n\t\t}\n\t\tstandardTile(\"refresh\", \"device.power\", inactiveLabel: false, decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'', action:\"refresh.refresh\", icon:\"st.secondary.refresh\"\n\t\t}\n        standardTile(\"configure\", \"device.configure\", inactiveLabel: false, decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'config', action:\"configure\", icon:\"st.secondary.refresh\"\n\t\t}\n        standardTile(\"check\", \"device.configure\", inactiveLabel: false, decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'check', action:\"checkstate\"\n\t\t}        \n\t\tmain \"main\"\n\t\tdetails([\"main\",\"power\",\"energy\",\"current\",\"voltage\",\"reset\",\"refresh\",\"configure\", \"check\"])\n\t}\n\t\n    preferences { \n\t\tinput \"energyReporting\", \"boolean\", \n\t\t\ttitle: \"Energy usage reports\",\n\t\t\tdefaultValue: true,\n\t\t\tdisplayDuringSetup: true\n\n\t\tinput \"reportInterval\", \"integer\", \n\t\t\ttitle: \"Energy report interval\", \n\t\t\tdescription: \"The time interval in seconds for sending energy usage reports\", \n\t\t\tdefaultValue: 300, \n            range: \"1..4294967295‬\",\n\t\t\trequired: false, \n\t\t\tdisplayDuringSetup: false\n\n\t\tinput \"reportThreshold\", \"integer\",\n\t\t\ttitle: \"Reporting threshold\", \n\t\t\tdescription: \"The percentage of change required for sending energy usage reports\", \n\t\t\tdefaultValue: 5, \n            range: \"1..99\",\n\t\t\trequired: false, \n\t\t\tdisplayDuringSetup: false\n\t\t\t\n\t\tinput \"loadWarning\", \"integer\",\n\t\t\ttitle: \"Load warning AMPs\",\n\t\t\tdescription: \"Set to a value in AMPs to provide heavy load warning notification.\",\n\t\t\tdefaultValue: 12,\n\t\t\trange: \"1..12\",\n\t\t\trequired: false,\n\t\t\tdisplayDuringSetup: false\n\t\t\n\t\tinput \"overloadProtection\", \"integer\",\n\t\t\ttitle: \"Overload protection AMPs\",\n\t\t\tdescription: \"Must be higher than heavy load warning value. When this value is reached, the plug shuts down and must be reset.\",\n\t\t\tdefaultValue: 13,\n\t\t\trange: \"1..15\",\n\t\t\trequired: false,\n\t\t\tdisplayDuringSetup: false\n\n\t\tinput \"manualOverride\", \"boolean\", \n\t\t\ttitle: \"Switch manual control\",\n\t\t\tdescription: \"Enable or disable the switch on the plug. Good for tamper protection.\",\n\t\t\tdefaultValue: true,\n\t\t\tdisplayDuringSetup: false\n\n\t\tinput \"stateRecvovery\", \"boolean\",\n\t\t\ttitle: \"Return to last state after power failure?\",\n\t\t\tdefaultValue: true,\n\t\t\tdisplayDuringSetup: false\n\t\t\t\t\t\t\n\t\tinput \"ledNotifications\", \"boolean\", \n\t\t\ttitle: \"LED Notifications?\",\n\t\t\tdescription: \"Enables or disables LED color change for heavy and overload notifications.\",\n\t\t\tdefaultValue: true,\n\t\t\tdisplayDuringSetup: false\n\n\t\tinput \"debugOutput\", \"boolean\", \n\t\t\ttitle: \"Enable debug logging?\",\n\t\t\tdefaultValue: false,\n\t\t\tdisplayDuringSetup: true\n\t}\n}\n\ndef updated() {\n\tupdateDataValue(\"configured\", \"false\")\n\tstate.debug = (\"true\" == debugOutput)\n    configure()\n}\n\ndef parse(String description) {\n    def result = null\n    def cmd = zwave.parse(description)\n    if (cmd) {\n        result = zwaveEvent(cmd)\n        if (state.debug) log.debug \"Parsed ${cmd} to ${result.inspect()}\"\n    } else {\n        log.debug \"Non-parsed event: ${description}\"\n    }\n    return result\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.configurationv1.ConfigurationReport cmd) {\n\tlog.debug(\"ConfigurationReportv1 ${cmd.inspect()}\")\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.configurationv2.ConfigurationReport cmd) {\n\tstate.configParams << [(cmd.parameterNumber) : (cmd.configurationValue)]\n    log.debug state.configParams\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.configurationv2.ConfigurationBulkReport cmd)\n{\n\tlog.debug \"Got a bulk report, but don't know what to do with it.\"\n}\n \ndef zwaveEvent(physicalgraph.zwave.commands.powerlevelv1.PowerlevelTestNodeReport cmd) {\n\tlog.debug \"===Power level test node report received=== ${device.displayName}: statusOfOperation: ${cmd.statusOfOperation} testFrameCount: ${cmd.testFrameCount} testNodeid: ${cmd.testNodeid}\"\n\tdef request = [\n        physicalgraph.zwave.commands.powerlevelv1.PowerlevelGet()\n    ]\n    response(commands(request))\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.versionv1.VersionReport cmd) {\n\tdef fw = \"${cmd.applicationVersion}.${cmd.applicationSubVersion}\"\n\tupdateDataValue(\"fw\", fw)\n\tlog.debug \"---VERSION REPORT V1--- ${device.displayName} is running firmware version: $fw, Z-Wave version: ${cmd.zWaveProtocolVersion}.${cmd.zWaveProtocolSubVersion}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.manufacturerspecificv2.ManufacturerSpecificReport cmd) {\n\tlog.debug \"manufacturerId:   ${cmd.manufacturerId}\"\n\tlog.debug \"manufacturerName: ${cmd.manufacturerName}\"\n\tlog.debug \"productId:        ${cmd.productId}\"\n\tlog.debug \"productTypeId:    ${cmd.productTypeId}\"\n\tdef msr = String.format(\"%04X-%04X-%04X\", cmd.manufacturerId, cmd.productTypeId, cmd.productId)\n\tupdateDataValue(\"MSR\", msr)\n\tcreateEvent([descriptionText: \"$device.displayName MSR: $msr\", isStateChange: false], displayed = true)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.meterv3.MeterReport cmd) {\n    def meterTypes = [\"Unknown\", \"Electric\", \"Gas\", \"Water\"]\n    def electricNames = [\"energy\", \"energy\", \"power\", \"count\",  \"voltage\", \"current\", \"powerFactor\",  \"unknown\"]\n    def electricUnits = [\"kWh\",    \"kVAh\",   \"W\",     \"pulses\", \"V\",       \"A\",       \"Power Factor\", \"\"]\n\n    //NOTE ScaledPreviousMeterValue does not always contain a value\n    def previousValue = cmd.scaledPreviousMeterValue ?: 0\n\n    def map = [ name: electricNames[cmd.scale], unit: electricUnits[cmd.scale], displayed: state.display]\n    switch(cmd.scale) {\n        case 0: //kWh\n\t    previousValue = device.currentValue(\"energy\") ?: cmd.scaledPreviousMeterValue ?: 0\n            map.value = cmd.scaledMeterValue\n            break;\n        case 1: //kVAh\n            map.value = cmd.scaledMeterValue\n            break;\n        case 2: //Watts\n            previousValue = device.currentValue(\"power\") ?: cmd.scaledPreviousMeterValue ?: 0\n            map.value = cmd.scaledMeterValue\n            break;\n        case 4: //Volts\n            previousValue = device.currentValue(\"voltage\") ?: cmd.scaledPreviousMeterValue ?: 0\n            map.value = cmd.scaledMeterValue\n            break;\n        case 5: //Amps\n            previousValue = device.currentValue(\"current\") ?: cmd.scaledPreviousMeterValue ?: 0\n            map.value = cmd.scaledMeterValue\n            break;\n    }\n\tmap.isStateChange = true\n\tmap.displayed = true\n    createEvent(map)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicReport cmd) {\n\tdef value = (cmd.value ? \"on\" : \"off\")\n\tdef result = [createEvent(name: \"switch\", value: value, type: \"physical\", displayed: true, isStateChange: true)]\n\treturn result\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.switchbinaryv1.SwitchBinaryReport cmd) {\n\tdef value = (cmd.value ? \"on\" : \"off\")\n\tdef result = [createEvent(name: \"switch\", value: value, type: \"digital\", displayed: true, isStateChange: true)]\n\treturn result\n}\n\ndef zwaveEvent(physicalgraph.zwave.Command cmd) {\n\tlog.debug \"Unhandled: $cmd\"\n    createEvent(descriptionText: cmd.toString(), isStateChange: false)\n}\n\ndef on() {\n\tdef request = [\n\t\tzwave.basicV1.basicSet(value: 0xFF),\n\t\tzwave.switchBinaryV1.switchBinaryGet()\n\t]\n    commands(request)\n}\n\ndef off() {\n\tdef request = [\n\t\tzwave.basicV1.basicSet(value: 0x00),\n\t\tzwave.switchBinaryV1.switchBinaryGet()\n\t]\n    commands(request)\n}\n\ndef checkstate() {\n\t// check our config state map\n\tlog.debug \"settings: ${settings.inspect()}, state: ${state.inspect()}\"\n}\n\ndef getPower() {\n\tzwave.meterV3.meterGet(scale: 2).format()\t//Wattage\n}\n\ndef getVoltage() {\n\tzwave.meterV3.meterGet(scale: 4).format()\t//Volts\n}\n\ndef getEnergy() {\n\tzwave.meterV3.meterGet(scale: 0).format()\t//kWh\n}\n\ndef getCurrent() {\n\tzwave.meterV3.meterGet(scale: 5).format()\t//Amps\n}\n\ndef poll() {\n\tdef request = [\n\t\tzwave.switchBinaryV1.switchBinaryGet(),\n        zwave.basicV1.basicGet(),\n\t\tzwave.meterV3.meterGet(scale: 0),\t//kWh\n        zwave.meterV3.meterGet(scale: 1),\t//kVAh\n\t\tzwave.meterV3.meterGet(scale: 2),\t//Wattage\n\t\tzwave.meterV3.meterGet(scale: 4),\t//Volts\n\t\tzwave.meterV3.meterGet(scale: 5),\t//Amps\n        zwave.meterV3.meterGet(scale: 6)\t//Power Factor\n\t]\n    commands(request)\n}\n\ndef refresh() {\n\tdef request = [\n        zwave.basicV1.basicGet(),\n\t\tzwave.switchBinaryV1.switchBinaryGet(),\n        zwave.meterV3.meterGet(scale: 0),\t//kWh\n        zwave.meterV3.meterGet(scale: 1),\t//kVAh\n\t\tzwave.meterV3.meterGet(scale: 2),\t//Wattage\n\t\tzwave.meterV3.meterGet(scale: 4),\t//Volts\n\t\tzwave.meterV3.meterGet(scale: 5),\t//Amps\n        zwave.meterV3.meterGet(scale: 6)\t//Power Factor\n\t]\n    commands(request)\n}\n\ndef reset() {\n\tdef request = [\n\t\tzwave.meterV3.meterReset(),\n\t\tzwave.meterV3.meterGet(scale: 0),\t//kWh\n        zwave.meterV3.meterGet(scale: 1),\t//kVAh\n\t\tzwave.meterV3.meterGet(scale: 2),\t//Wattage\n\t\tzwave.meterV3.meterGet(scale: 4),\t//Volts\n\t\tzwave.meterV3.meterGet(scale: 5)\t//Amps\n\t]\n    commands(request)\n}\n\ndef configure() {\n    def request = [\n    \t// Get version and firmware info\n\t\tzwave.versionV1.versionGet(),\n        zwave.firmwareUpdateMdV2.firmwareMdGet(),\n        \n        // get all the config values\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0x01),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0x02),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0x03),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0x04),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0x05),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0x06),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0x07),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0x08),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0x09),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0x0A),\n        \n        //this doesn't seem to work in ST...\n        //zwave.configurationV2.configurationBulkGet (parameterOffset: 0x0001, numberOfParameters: 10),\n        \n        // enable or disable energy metering reports 0=disabled 1=enabled\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x01, size: 1, scaledConfigurationValue: 1),\n\n\t\t// Interval in seconds for sending energy metering reports\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x02, size: 2, scaledConfigurationValue: 300),\n\n\t\t// Overload protection - set the number of AMPS you want to limit the plug to. 13 is what it is designed for.\n\t\t// when this value is hit, overload notification messages are sent and you have to press the button on the plug to reset it.\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x03, size: 1, scaledConfigurationValue: 13),\n\t\t\n\t\t// Heavy load warning AMP threshold - the plug led will turn yellow when you reach this AMP value. must be less than parameter 3/\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x04, size: 1, scaledConfigurationValue: 12),\n\n\t\t//  LED Notifications - 0=disabled 1=enabled\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x05, size: 1, scaledConfigurationValue: 1),\n\t\t\t\t\n\t\t// percentage of change in any energy metric for a report to be sent - threshold reporting\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x06, size: 1, scaledConfigurationValue: 5),\n\n\t\t// power failure recovery state - 0=remain off when power restored 1=return to last state when power restored\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x07, size: 1, scaledConfigurationValue: 1),\n\t\t\n\t\t// auto power off timer - 0=disabled 1=enabled\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x08, size: 1, scaledConfigurationValue: 12),\n\n\t\t// auto power off timer duration - a value in minutes 1-65535\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x09, size: 2, scaledConfigurationValue: 150),\n\n\t\t// manual control power on/off control - 0=disable action button 1=enable action button\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x0A, size: 1, scaledConfigurationValue: 1),\n\t\t\n\t\t// Can use the zwaveHubNodeId variable to add the hub to the device's associations:\n\t\tzwave.associationV1.associationSet(groupingIdentifier:2, nodeId:zwaveHubNodeId)\n    ]\n\tcommands(request) + setConfigured()\n}\n\nprivate setConfigured() {\n\tupdateDataValue(\"configured\", \"true\")\n}\n\nprivate isConfigured() {\n\tgetDataValue(\"configured\") == \"true\"\n}\n\nprivate command(physicalgraph.zwave.Command cmd) {\n\tcmd.format()\n}\n\nprivate commands(commands, delay=1250) {\n\tdelayBetween(commands.collect{ command(it) }, delay)\n}"
  },
  {
    "path": "zooZ-MiniPlug-ZEN07/device_type-zooZ-MiniPlug-ZEN07-v1.2.groovy",
    "content": "/*\nzooZ MiniPlug ZEN07 device handler for SmartThings version 1.0 by Robert Vandervoort 10/10/2016\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except\nin compliance with the License. You may obtain a copy of the License at:\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under the License is distributed\non an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License\nfor the specific language governing permissions and limitations under the License.\n\nsome code used from various SmartThings device type and metering code from ElasticDev\n\n*/\n\nmetadata {\n\tdefinition (name: \"zooZ MiniPlug ZEN07 - RV v1.2\", namespace: \"robertvandervoort\", author: \"Robert Vandervoort\") {\n\t\tcapability \"Energy Meter\"\n\t\tcapability \"Power Meter\"\n\t\tcapability \"Actuator\"\n        capability \"Indicator\"\n\t\tcapability \"Switch\"\n\t\tcapability \"Configuration\"\n\t\tcapability \"Polling\"\n\t\tcapability \"Refresh\"\n\t\tcapability \"Sensor\"\n\n\t\tcommand \"reset\"\n        command \"getPower\"\n        command \"getEnergy\"\n        command \"getVoltage\"\n        command \"getCurrent\"\n        command \"checkstate\"\n        command \"timerOn\"\n        command \"timerOff\"\n\n\t\tattribute \"timerStatus\", \"enum\", [\"On\", \"Off\"]\n\t\t\n\t// RAW 0 0 0x1001 0 0 0 d 0x5E 0x72 0x86 0x85 0x59 0x5A 0x73 0x70 0x25 0x27 0x71 0x32 0x20\n\t// MSR 027A-0003-0087\n\t\n\t\tfingerprint deviceId: \"0x1001\", inClusters: \"0x5E,0x72,0x86,0x85,0x59,0x5A,0x73,0x70,0x25,0x27,0x71,0x32,0x20\"\n\t}\n\t// simulator metadata\n\tsimulator {\n\t\tstatus \"on\":  \"command: 2003, payload: FF\"\n\t\tstatus \"off\": \"command: 2003, payload: 00\"\n\n\tfor (int i = 0; i <= 10000; i += 1000) {\n\t    status \"power  ${i} W\": \n\t\t    new physicalgraph.zwave.Zwave().meterV3.meterReport(scaledMeterValue: i, precision: 3, meterType: 4, scale: 2, size: 4).incomingMessage()\n\t}\n\tfor (int i = 0; i <= 100; i += 10) {\n\t    status \"energy  ${i} kWh\":\n\t\t    new physicalgraph.zwave.Zwave().meterV3.meterReport(scaledMeterValue: i, precision: 3, meterType: 0, scale: 0, size: 4).incomingMessage()\n\t}\n\t\t// reply messages\n\t\treply \"2001FF,delay 100,2502\": \"command: 2503, payload: FF\"\n\t\treply \"200100,delay 100,2502\": \"command: 2503, payload: 00\"\n\t}\n\n\t// tile definitions\n\ttiles (scale: 2) {\n    \tstandardTile(\"main\", \"device.switch\", width:4, height:4, canChangeIcon: true) {\n\t\t\tstate \"on\", label: '${name}', action: \"switch.off\", icon: \"st.switches.switch.on\", backgroundColor: \"#79b821\"\n\t\t\tstate \"off\", label: '${name}', action: \"switch.on\", icon: \"st.switches.switch.off\", backgroundColor: \"#ffffff\"\n\t\t}\n        valueTile(\"power\", \"device.power\", decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'${currentValue} W', action:\"getPower\"\n\t\t}\n\t\tvalueTile(\"energy\", \"device.energy\", decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'${currentValue} kWh', action:\"getEnergy\"\n\t\t}\n\t\tvalueTile(\"current\", \"device.current\", decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'${currentValue} A', action:\"getCurrent\"\n\t\t}\n        valueTile(\"voltage\", \"device.voltage\", decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'${currentValue} V', action:\"getVoltage\"\n\t\t}\n\t\tstandardTile(\"reset\", \"device.energy\", inactiveLabel: false, decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'reset kWh', action:\"reset\"\n\t\t}\n\t\tstandardTile(\"refresh\", \"device.power\", inactiveLabel: false, decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'', action:\"refresh.refresh\", icon:\"st.secondary.refresh\"\n\t\t} \n\t\tstandardTile(\"configure\", \"device.configure\", inactiveLabel: false, decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'config', action:\"configure\", icon:\"st.secondary.refresh\"\n\t\t}\n        standardTile(\"check\", \"device.configure\", inactiveLabel: false, decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'check', action:\"checkstate\"\n\t\t}\n\t\tstandardTile(\"timer\", \"device.timerStatus\", inactiveLabel: false, decoration: \"flat\", width:2, height:2) {\n        \tstate \"off\", label:'TIMER', action:\"timerOn\", icon: \"st.illuminance.illuminance.dark\"\n            state \"on\", label:'TIMER', action:\"timerOff\", icon: \"st.illuminance.illuminance.bright\"\n\t\t}\n\t\tstandardTile(\"indicator\", \"device.indicatorStatus\", inactiveLabel: false, decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"never\", label:'LED', action:\"indicator.indicatorWhenOn\", icon: \"st.illuminance.illuminance.dark\"\n\t\t\tstate \"when on\", label:'LED', action:\"indicator.indicatorNever\", icon: \"st.illuminance.illuminance.bright\"\n\t\t}\n\t\tmain \"main\"\n\t\tdetails([\"main\",\"energy\",\"reset\",\"voltage\",\"power\",\"current\",\"refresh\",\"timer\",\"indicator\"])\n\t}\n\t\n    preferences { \n\t\tinput \"energyReporting\", \"boolean\", \n\t\t\ttitle: \"Energy usage reports\",\n\t\t\tdefaultValue: true,\n\t\t\tdisplayDuringSetup: true\n\n\t\tinput \"reportInterval\", \"integer\", \n\t\t\ttitle: \"Energy report interval\", \n\t\t\tdescription: \"The time interval in seconds for sending energy usage reports\", \n\t\t\tdefaultValue: 300, \n            range: \"1..4294967295‬\",\n\t\t\trequired: false, \n\t\t\tdisplayDuringSetup: false\n\n\t\tinput \"reportThreshold\", \"integer\",\n\t\t\ttitle: \"Reporting threshold\", \n\t\t\tdescription: \"The percentage of change required for sending energy usage reports\", \n\t\t\tdefaultValue: 5, \n            range: \"1..99\",\n\t\t\trequired: false, \n\t\t\tdisplayDuringSetup: false\n\t\t\t\n\t\tinput \"loadWarning\", \"integer\",\n\t\t\ttitle: \"Load warning AMPs\",\n\t\t\tdescription: \"Set to a value in AMPs to provide heavy load warning notification.\",\n\t\t\tdefaultValue: 12,\n\t\t\trange: \"1..12\",\n\t\t\trequired: false,\n\t\t\tdisplayDuringSetup: false\n\t\t\n\t\tinput \"overloadProtection\", \"integer\",\n\t\t\ttitle: \"Overload protection AMPs\",\n\t\t\tdescription: \"Must be higher than heavy load warning value. When this value is reached, the plug shuts down and must be reset.\",\n\t\t\tdefaultValue: 13,\n\t\t\trange: \"1..15\",\n\t\t\trequired: false,\n\t\t\tdisplayDuringSetup: false\n\n\t\tinput \"manualOverride\", \"boolean\", \n\t\t\ttitle: \"Switch manual control\",\n\t\t\tdescription: \"Enable or disable the switch on the plug. Good for tamper protection.\",\n\t\t\tdefaultValue: true,\n\t\t\tdisplayDuringSetup: false\n\n\t\tinput \"stateRecvovery\", \"boolean\",\n\t\t\ttitle: \"Return to last state after power failure?\",\n\t\t\tdefaultValue: true,\n\t\t\tdisplayDuringSetup: false\n\t\t\t\t\t\t\n\t\tinput \"ledNotifications\", \"boolean\", \n\t\t\ttitle: \"LED Notifications?\",\n\t\t\tdescription: \"Enables or disables LED color change for heavy and overload notifications.\",\n\t\t\tdefaultValue: true,\n\t\t\tdisplayDuringSetup: false\n\n\t\tinput \"debugOutput\", \"boolean\", \n\t\t\ttitle: \"Enable debug logging?\",\n\t\t\tdefaultValue: false,\n\t\t\tdisplayDuringSetup: true\n\t}\n}\n\ndef updated() {\n\tupdateDataValue(\"configured\", \"false\")\n\tstate.debug = (\"true\" == debugOutput)\n    configure()\n}\n\ndef parse(String description) {\n    def result = null\n    def cmd = zwave.parse(description)\n    if (cmd) {\n        result = zwaveEvent(cmd)\n        if (state.debug) log.debug \"Parsed ${cmd} to ${result.inspect()}\"\n    } else {\n        log.debug \"Non-parsed event: ${description}\"\n    }\n    return result\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.configurationv1.ConfigurationReport cmd) {\n\tlog.debug(\"ConfigurationReportv1 ${cmd.inspect()}\")\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.configurationv2.ConfigurationReport cmd) {\n\t//state.configParams.clear()\n\t// calculate decimal values for returned multibyte values\n    def fullValue = 0\n    switch(cmd.size) {\n        case 1: //1 byte\n        \tfullValue = cmd.configurationValue * 1\n            break;\n        case 2: //2 byte\n\t\t\tfullValue = cmd.configurationValue[1] + (cmd.configurationValue[0] * 0x100)\n            break;\n\t\tcase 3: //3 byte\n        \tfullValue = cmd.configurationValue[2] + (cmd.configurationValue[1] * 0x100) + (cmd.configurationValue[0] * 0x10000)\n            break;        \t\n        case 4: //4 byte\n        \tfullValue = cmd.configurationValue[3] + (cmd.configurationValue[2] * 0x100) + (cmd.configurationValue[1] * 0x10000) + (cmd.configurationValue[0] * 0x1000000)\n            break;\n\t}\n\tstate.configParams << [(cmd.parameterNumber) : (fullValue)]\n\n    // set states for any values coming in used for tiles\n\tdef statusValue = [:]\n\tswitch(cmd.parameterNumber) {\n        case 5: //LED Indicator\n           \tstatusValue.name = \"indicatorStatus\"\n\t\t\tif (cmd.configurationValue == [0]) {\n                statusValue.value = \"never\"\n                } else\n\t\t\tif (cmd.configurationValue == [1]) {\n                statusValue.value = \"when on\"\n                }\n\t\t\tbreak;\n        case 8: //Automatic shutoff timer\n\t\t\tstatusValue.name = \"timerStatus\"\n\t\t\tif (cmd.configurationValue == [0]) {\n                statusValue.value = \"off\"\n                } else\n\t\t\tif (cmd.configurationValue == [1]) {\n                statusValue.value = \"on\"\n                }\n            break;\n\t\t}\n\tstatusValue.displayed = true\n\tcreateEvent(statusValue)\n\t//log.debug state.configParams\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.configurationv2.ConfigurationBulkReport cmd)\n{\n\tlog.debug \"Got a bulk report, but don't know what to do with it.\"\n}\n \ndef zwaveEvent(physicalgraph.zwave.commands.powerlevelv1.PowerlevelTestNodeReport cmd) {\n\tlog.debug \"===Power level test node report received=== ${device.displayName}: statusOfOperation: ${cmd.statusOfOperation} testFrameCount: ${cmd.testFrameCount} testNodeid: ${cmd.testNodeid}\"\n\tdef request = [\n        physicalgraph.zwave.commands.powerlevelv1.PowerlevelGet()\n    ]\n    response(commands(request))\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.versionv1.VersionReport cmd) {\n\tdef fw = \"${cmd.applicationVersion}.${cmd.applicationSubVersion}\"\n\tupdateDataValue(\"fw\", fw)\n\tlog.debug \"---VERSION REPORT V1--- ${device.displayName} is running firmware version: $fw, Z-Wave version: ${cmd.zWaveProtocolVersion}.${cmd.zWaveProtocolSubVersion}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.manufacturerspecificv2.ManufacturerSpecificReport cmd) {\n\tlog.debug \"manufacturerId:   ${cmd.manufacturerId}\"\n\tlog.debug \"manufacturerName: ${cmd.manufacturerName}\"\n\tlog.debug \"productId:        ${cmd.productId}\"\n\tlog.debug \"productTypeId:    ${cmd.productTypeId}\"\n\tdef msr = String.format(\"%04X-%04X-%04X\", cmd.manufacturerId, cmd.productTypeId, cmd.productId)\n\tupdateDataValue(\"MSR\", msr)\n\tcreateEvent([descriptionText: \"$device.displayName MSR: $msr\", isStateChange: false], displayed = true)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.meterv3.MeterReport cmd) {\n    def meterTypes = [\"Unknown\", \"Electric\", \"Gas\", \"Water\"]\n    def electricNames = [\"energy\", \"energy\", \"power\", \"count\",  \"voltage\", \"current\", \"powerFactor\",  \"unknown\"]\n    def electricUnits = [\"kWh\",    \"kVAh\",   \"W\",     \"pulses\", \"V\",       \"A\",       \"Power Factor\", \"\"]\n\n    //NOTE ScaledPreviousMeterValue does not always contain a value\n    def previousValue = cmd.scaledPreviousMeterValue ?: 0\n\n    def map = [ name: electricNames[cmd.scale], unit: electricUnits[cmd.scale], displayed: state.display]\n    switch(cmd.scale) {\n        case 0: //kWh\n\t    previousValue = device.currentValue(\"energy\") ?: cmd.scaledPreviousMeterValue ?: 0\n            map.value = cmd.scaledMeterValue\n            break;\n        case 1: //kVAh\n            map.value = cmd.scaledMeterValue\n            break;\n        case 2: //Watts\n            previousValue = device.currentValue(\"power\") ?: cmd.scaledPreviousMeterValue ?: 0\n            map.value = cmd.scaledMeterValue\n            break;\n        case 4: //Volts\n            previousValue = device.currentValue(\"voltage\") ?: cmd.scaledPreviousMeterValue ?: 0\n            map.value = cmd.scaledMeterValue\n            break;\n        case 5: //Amps\n            previousValue = device.currentValue(\"current\") ?: cmd.scaledPreviousMeterValue ?: 0\n            map.value = cmd.scaledMeterValue\n            break;\n    }\n\tmap.isStateChange = true\n\tmap.displayed = true\n    createEvent(map)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicReport cmd) {\n\tdef value = (cmd.value ? \"on\" : \"off\")\n\tdef result = [createEvent(name: \"switch\", value: value, type: \"physical\", displayed: true, isStateChange: true)]\n\treturn result\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.switchbinaryv1.SwitchBinaryReport cmd) {\n\tdef value = (cmd.value ? \"on\" : \"off\")\n\tdef result = [createEvent(name: \"switch\", value: value, type: \"digital\", displayed: true, isStateChange: true)]\n\treturn result\n}\n// parse the unhandled\ndef zwaveEvent(physicalgraph.zwave.Command cmd) {\n\tlog.debug \"Unhandled: $cmd\"\n    createEvent(descriptionText: cmd.toString(), isStateChange: false)\n}\n\n// Commands follow\ndef on() {\n\tdef request = [\n\t\tzwave.basicV1.basicSet(value: 0xFF),\n\t\tzwave.switchBinaryV1.switchBinaryGet()\n\t]\n    commands(request)\n}\ndef off() {\n\tdef request = [\n\t\tzwave.basicV1.basicSet(value: 0x00),\n\t\tzwave.switchBinaryV1.switchBinaryGet()\n\t]\n    commands(request)\n}\ndef checkstate() {\n\t// check our config state map\n\tlog.debug \"settings: ${settings.inspect()}, state: ${state.inspect()}\"\n\tstate.configParams.each {parameter, value -> log.debug \"Parameter ${parameter} = ${value}\"}\t\n    //  LED Notifications - 0=disabled 1=enabled\n\tzwave.configurationV1.configurationSet(parameterNumber: 0x05, size: 1, scaledConfigurationValue: 0).format()\n    /*\n    if (state.configParams.(4) == [12]) {\n    \tlog.debug \"this was true\" }\n    \t\telse log.debug \"This was false :(\"\n    */\n}\ndef getEnergy() {\n\tzwave.meterV3.meterGet(scale: 0).format()\t//kWh\n}\ndef getPower() {\n\tzwave.meterV3.meterGet(scale: 2).format()\t//Wattage\n}\ndef getVoltage() {\n\tzwave.meterV3.meterGet(scale: 4).format()\t//Volts\n}\ndef getCurrent() {\n\tzwave.meterV3.meterGet(scale: 5).format()\t//Amps\n}\ndef poll() {\n\tdef request = [\n\t\tzwave.switchBinaryV1.switchBinaryGet(),\n\t\tzwave.meterV3.meterGet(scale: 0),\t//kWh\n\t\tzwave.meterV3.meterGet(scale: 2),\t//Wattage\n\t\tzwave.meterV3.meterGet(scale: 4),\t//Volts\n\t\tzwave.meterV3.meterGet(scale: 5),\t//Amps\n\t]\n    commands(request)\n}\ndef refresh() {\n\tdef request = [\n\t\tzwave.switchBinaryV1.switchBinaryGet(),\n        zwave.meterV3.meterGet(scale: 0),\t//kWh\n\t\tzwave.meterV3.meterGet(scale: 2),\t//Wattage\n\t\tzwave.meterV3.meterGet(scale: 4),\t//Volts\n\t\tzwave.meterV3.meterGet(scale: 5),\t//Amps\n\t]\n    commands(request)\n}\n\ndef reset() {\n\tdef request = [\n\t\tzwave.meterV3.meterReset(),\n\t\tzwave.meterV3.meterGet(scale: 0),\t//kWh\n        zwave.meterV3.meterGet(scale: 1),\t//kVAh\n\t\tzwave.meterV3.meterGet(scale: 2),\t//Wattage\n\t\tzwave.meterV3.meterGet(scale: 4),\t//Volts\n\t\tzwave.meterV3.meterGet(scale: 5)\t//Amps\n\t]\n    commands(request)\n}\n\ndef indicatorWhenOn() {\n\tdef request = [\n\tzwave.configurationV1.configurationSet(configurationValue: [1], parameterNumber: 0x05, size: 1),\n\tzwave.configurationV1.configurationGet(parameterNumber: 0x05)\n\t]\n\tcommands(request)\n}\n\ndef indicatorNever() {\n\tdef request = [\n\tzwave.configurationV1.configurationSet(configurationValue: [0], parameterNumber: 5, size: 1),\n    zwave.configurationV1.configurationGet(parameterNumber: 0x05)\n\t]\n    commands(request)\n}\n\ndef timerOn() {\n\tdef request = [\n    zwave.configurationV1.configurationSet(parameterNumber: 0x08, size: 1, scaledConfigurationValue: 1),\n    zwave.configurationV1.configurationGet(parameterNumber: 0x08)\n\t]\n    commands(request)\n}\n\ndef timerOff() {\n\tdef request = [\n\tzwave.configurationV1.configurationSet(parameterNumber: 0x08, size: 1, scaledConfigurationValue: 0),\n    zwave.configurationV1.configurationGet(parameterNumber: 0x08)\n\t]\n    commands(request)\n}\n\ndef configure() {\n/*\t['1':[1],'2':[1, 44],'3':[13],  '4':[12], '5':[1], '6':[5],'7':[1], '8':[0]],'9':[0, 150],'10':[1] \n\tif (energyReporting\t!= state.configParams[1]) {\n    \tconfParam = energyReporting\n\tloadWarning\tinteger\t12\n\tmanualOverride\tboolean\ttrue\n\toverloadProtection\tinteger\t13\n\treportInterval\tinteger\t300\n\treportThreshold\tinteger\t5\n\tstateRecvovery\n*/\n\n    def request = [\n    \t// Get version and firmware info\n\t\tzwave.versionV1.versionGet(),\n        zwave.firmwareUpdateMdV2.firmwareMdGet(),\n        \n        // get all the config values\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0x01),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0x02),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0x03),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0x04),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0x05),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0x06),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0x07),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0x08),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0x09),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0x0A),\n  /*      \n        //this doesn't seem to work in ST...\n        //zwave.configurationV2.configurationBulkGet (parameterOffset: 0x0001, numberOfParameters: 10),\n        \n        // enable or disable energy metering reports 0=disabled 1=enabled\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x01, size: 1, scaledConfigurationValue: confParam1),\n\n\t\t// Interval in seconds for sending energy metering reports\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x02, size: 2, scaledConfigurationValue: confParam2),\n\n\t\t// Overload protection - set the number of AMPS you want to limit the plug to. 13 is what it is designed for.\n\t\t// when this value is hit, overload notification messages are sent and you have to press the button on the plug to reset it.\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x03, size: 1, scaledConfigurationValue: confParam3),\n\t\t\n\t\t// Heavy load warning AMP threshold - the plug led will turn yellow when you reach this AMP value. must be less than parameter 3/\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x04, size: 1, scaledConfigurationValue: confParam4),\n\n\t\t//  LED Notifications - 0=disabled 1=enabled\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x05, size: 1, scaledConfigurationValue: confParam5),\n\t\t\t\t\n\t\t// percentage of change in any energy metric for a report to be sent - threshold reporting\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x06, size: 1, scaledConfigurationValue: confParam6),\n\n\t\t// power failure recovery state - 0=remain off when power restored 1=return to last state when power restored\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x07, size: 1, scaledConfigurationValue: confParam7),\n\t\t\n\t\t// auto power off timer - 0=disabled 1=enabled\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x08, size: 1, scaledConfigurationValue: confParam8),\n\n\t\t// auto power off timer duration - a value in minutes 1-65535\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x09, size: 2, scaledConfigurationValue: confParam9),\n\n\t\t// manual control power on/off control - 0=disable action button 1=enable action button\n\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x0A, size: 1, scaledConfigurationValue: confParam10),\n\t\t\n\t\t// Can use the zwaveHubNodeId variable to add the hub to the device's associations:\n\t\tzwave.associationV1.associationSet(groupingIdentifier:2, nodeId:zwaveHubNodeId)\n    */]\n\tcommands(request) + setConfigured()\n}\n\nprivate setConfigured() {\n\tupdateDataValue(\"configured\", \"true\")\n}\n\nprivate isConfigured() {\n\tgetDataValue(\"configured\") == \"true\"\n}\n\nprivate command(physicalgraph.zwave.Command cmd) {\n\tcmd.format()\n}\n\nprivate commands(commands, delay=1250) {\n\tdelayBetween(commands.collect{ command(it) }, delay)\n}"
  },
  {
    "path": "zooZ-MiniPlug-ZEN07/device_type-zooZ-MiniPlug-ZEN07-v1.3.groovy",
    "content": "/*\nzooZ MiniPlug ZEN07 device handler for SmartThings version 1.0 by Robert Vandervoort 10/10/2016\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except\nin compliance with the License. You may obtain a copy of the License at:\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under the License is distributed\non an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License\nfor the specific language governing permissions and limitations under the License.\n\nsome code used from various SmartThings device type and metering code from ElasticDev\n\n*/\n\nmetadata {\n\tdefinition (name: \"zooZ MiniPlug ZEN07 - RV v1.2\", namespace: \"robertvandervoort\", author: \"Robert Vandervoort\") {\n\t\tcapability \"Energy Meter\"\n\t\tcapability \"Power Meter\"\n\t\tcapability \"Actuator\"\n        capability \"Indicator\"\n\t\tcapability \"Switch\"\n\t\tcapability \"Configuration\"\n\t\tcapability \"Polling\"\n\t\tcapability \"Refresh\"\n\t\tcapability \"Sensor\"\n\n\t\tcommand \"reset\"\n        command \"getPower\"\n        command \"getEnergy\"\n        command \"getVoltage\"\n        command \"getCurrent\"\n        command \"checkstate\"\n        command \"timerOn\"\n        command \"timerOff\"\n\n\t\tattribute \"timerStatus\", \"enum\", [\"On\", \"Off\"]\n\t\t\n\t// RAW 0 0 0x1001 0 0 0 d 0x5E 0x72 0x86 0x85 0x59 0x5A 0x73 0x70 0x25 0x27 0x71 0x32 0x20\n\t// MSR 027A-0003-0087\n\t\n\t\tfingerprint deviceId: \"0x1001\", inClusters: \"0x5E,0x72,0x86,0x85,0x59,0x5A,0x73,0x70,0x25,0x27,0x71,0x32,0x20\"\n\t}\n\t// simulator metadata\n\tsimulator {\n\t\tstatus \"on\":  \"command: 2003, payload: FF\"\n\t\tstatus \"off\": \"command: 2003, payload: 00\"\n\n\tfor (int i = 0; i <= 10000; i += 1000) {\n\t    status \"power  ${i} W\": \n\t\t    new physicalgraph.zwave.Zwave().meterV3.meterReport(scaledMeterValue: i, precision: 3, meterType: 4, scale: 2, size: 4).incomingMessage()\n\t}\n\tfor (int i = 0; i <= 100; i += 10) {\n\t    status \"energy  ${i} kWh\":\n\t\t    new physicalgraph.zwave.Zwave().meterV3.meterReport(scaledMeterValue: i, precision: 3, meterType: 0, scale: 0, size: 4).incomingMessage()\n\t}\n\t\t// reply messages\n\t\treply \"2001FF,delay 100,2502\": \"command: 2503, payload: FF\"\n\t\treply \"200100,delay 100,2502\": \"command: 2503, payload: 00\"\n\t}\n\n\t// tile definitions\n\ttiles (scale: 2) {\n    \tstandardTile(\"main\", \"device.switch\", width:4, height:4, canChangeIcon: true) {\n\t\t\tstate \"on\", label: '${name}', action: \"switch.off\", icon: \"st.switches.switch.on\", backgroundColor: \"#79b821\"\n\t\t\tstate \"off\", label: '${name}', action: \"switch.on\", icon: \"st.switches.switch.off\", backgroundColor: \"#ffffff\"\n\t\t}\n        valueTile(\"power\", \"device.power\", decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'${currentValue} W', action:\"getPower\"\n\t\t}\n\t\tvalueTile(\"energy\", \"device.energy\", decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'${currentValue} kWh', action:\"getEnergy\"\n\t\t}\n\t\tvalueTile(\"current\", \"device.current\", decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'${currentValue} A', action:\"getCurrent\"\n\t\t}\n        valueTile(\"voltage\", \"device.voltage\", decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'${currentValue} V', action:\"getVoltage\"\n\t\t}\n\t\tstandardTile(\"reset\", \"device.energy\", inactiveLabel: false, decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'reset kWh', action:\"reset\"\n\t\t}\n\t\tstandardTile(\"refresh\", \"device.power\", inactiveLabel: false, decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'', action:\"refresh.refresh\", icon:\"st.secondary.refresh\"\n\t\t} \n\t\tstandardTile(\"configure\", \"device.configure\", inactiveLabel: false, decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'config', action:\"configure\", icon:\"st.secondary.refresh\"\n\t\t}\n        standardTile(\"check\", \"device.configure\", inactiveLabel: false, decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'check', action:\"checkstate\"\n\t\t}\n\t\tstandardTile(\"timer\", \"device.timerStatus\", inactiveLabel: false, decoration: \"flat\", width:2, height:2) {\n        \tstate \"off\", label:'TIMER', action:\"timerOn\", icon: \"st.illuminance.illuminance.dark\"\n            state \"on\", label:'TIMER', action:\"timerOff\", icon: \"st.illuminance.illuminance.bright\"\n\t\t}\n\t\tstandardTile(\"indicator\", \"device.indicatorStatus\", inactiveLabel: false, decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"never\", label:'LED', action:\"indicator.indicatorWhenOn\", icon: \"st.illuminance.illuminance.dark\"\n\t\t\tstate \"when on\", label:'LED', action:\"indicator.indicatorNever\", icon: \"st.illuminance.illuminance.bright\"\n\t\t}\n\t\tmain \"main\"\n\t\tdetails([\"main\",\"energy\",\"reset\",\"voltage\",\"power\",\"current\",\"refresh\",\"timer\",\"indicator\",\"check\"])\n\t}\n\t\n    preferences { \n\t\tinput \"energyReporting\", \"boolean\", \n\t\t\ttitle: \"Energy usage reports\",\n\t\t\tdefaultValue: true,\n\t\t\tdisplayDuringSetup: true\n\n\t\tinput \"reportInterval\", \"integer\", \n\t\t\ttitle: \"Energy report interval\", \n\t\t\tdescription: \"The time interval in seconds for sending energy usage reports\", \n\t\t\tdefaultValue: 300, \n            range: \"1..4294967295‬\",\n\t\t\trequired: false, \n\t\t\tdisplayDuringSetup: false\n\n\t\tinput \"reportThreshold\", \"integer\",\n\t\t\ttitle: \"Reporting threshold\", \n\t\t\tdescription: \"The percentage of change required for sending energy usage reports\", \n\t\t\tdefaultValue: 5, \n            range: \"1..99\",\n\t\t\trequired: false, \n\t\t\tdisplayDuringSetup: false\n\t\t\t\n\t\tinput \"loadWarning\", \"integer\",\n\t\t\ttitle: \"Load warning AMPs\",\n\t\t\tdescription: \"Set to a value in AMPs to provide heavy load warning notification.\",\n\t\t\tdefaultValue: 12,\n\t\t\trange: \"1..12\",\n\t\t\trequired: false,\n\t\t\tdisplayDuringSetup: false\n\t\t\n\t\tinput \"overloadProtection\", \"integer\",\n\t\t\ttitle: \"Overload protection AMPs\",\n\t\t\tdescription: \"Must be higher than heavy load warning value. When this value is reached, the plug shuts down and must be reset.\",\n\t\t\tdefaultValue: 13,\n\t\t\trange: \"1..15\",\n\t\t\trequired: false,\n\t\t\tdisplayDuringSetup: false\n\n\t\tinput \"manualOverride\", \"boolean\", \n\t\t\ttitle: \"Switch manual control\",\n\t\t\tdescription: \"Enable or disable the switch on the plug. Good for tamper protection.\",\n\t\t\tdefaultValue: true,\n\t\t\tdisplayDuringSetup: false\n\n\t\tinput \"stateRecvovery\", \"boolean\",\n\t\t\ttitle: \"Return to last state after power failure?\",\n\t\t\tdefaultValue: true,\n\t\t\tdisplayDuringSetup: false\n\t\t\t\t\t\t\n\t\tinput \"ledNotifications\", \"boolean\", \n\t\t\ttitle: \"LED Notifications?\",\n\t\t\tdescription: \"Enables or disables LED color change for heavy and overload notifications.\",\n\t\t\tdefaultValue: true,\n\t\t\tdisplayDuringSetup: false\n\n\t\tinput \"debugOutput\", \"boolean\", \n\t\t\ttitle: \"Enable debug logging?\",\n\t\t\tdefaultValue: false,\n\t\t\tdisplayDuringSetup: true\n\t}\n}\n\ndef updated() {\n\t//state.configParams.clear()\n\tupdateDataValue(\"configured\", \"false\")\n\tstate.debug = (\"true\" == debugOutput)\n    configure()\n}\n\ndef parse(String description) {\n    def result = null\n    def cmd = zwave.parse(description)\n    if (cmd) {\n        result = zwaveEvent(cmd)\n        if (state.debug) log.debug \"Parsed ${cmd} to ${result.inspect()}\"\n    } else {\n        log.debug \"Non-parsed event: ${description}\"\n    }\n    return result\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.configurationv1.ConfigurationReport cmd) {\n\tlog.debug(\"ConfigurationReportv1 ${cmd.inspect()}\")\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.configurationv2.ConfigurationReport cmd) {\n\t// calculate decimal values for returned multibyte values\n    def fullValue = 0\n    switch(cmd.size) {\n        case 1: //1 byte\n        \tfullValue = cmd.configurationValue * 1\n            break;\n        case 2: //2 byte\n\t\t\tfullValue = cmd.configurationValue[1] + (cmd.configurationValue[0] * 0x100)\n            break;\n\t\tcase 3: //3 byte\n        \tfullValue = cmd.configurationValue[2] + (cmd.configurationValue[1] * 0x100) + (cmd.configurationValue[0] * 0x10000)\n            break;        \t\n        case 4: //4 byte\n        \tfullValue = cmd.configurationValue[3] + (cmd.configurationValue[2] * 0x100) + (cmd.configurationValue[1] * 0x10000) + (cmd.configurationValue[0] * 0x1000000)\n            break;\n\t}\n\tstate.configParams << [(cmd.parameterNumber) : (fullValue)]\n    \n    // set states for any values coming in used for tiles\n\tdef statusValue = [:]\n\tswitch(cmd.parameterNumber) {\n        case 5: //LED Indicator\n           \tstatusValue.name = \"indicatorStatus\"\n\t\t\tif (cmd.configurationValue == [0]) {\n                statusValue.value = \"never\"\n                } else\n\t\t\tif (cmd.configurationValue == [1]) {\n                statusValue.value = \"when on\"\n                }\n\t\t\tbreak;\n        case 8: //Automatic shutoff timer\n\t\t\tstatusValue.name = \"timerStatus\"\n\t\t\tif (cmd.configurationValue == [0]) {\n                statusValue.value = \"off\"\n                } else\n\t\t\tif (cmd.configurationValue == [1]) {\n                statusValue.value = \"on\"\n                }\n            break;\n\t\t}\n\tstatusValue.displayed = true\n\tcreateEvent(statusValue)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.configurationv2.ConfigurationBulkReport cmd)\n{\n\tlog.debug \"Got a bulk report, but don't know what to do with it.\"\n}\n \ndef zwaveEvent(physicalgraph.zwave.commands.powerlevelv1.PowerlevelTestNodeReport cmd) {\n\tlog.debug \"===Power level test node report received=== ${device.displayName}: statusOfOperation: ${cmd.statusOfOperation} testFrameCount: ${cmd.testFrameCount} testNodeid: ${cmd.testNodeid}\"\n\tdef request = [\n        physicalgraph.zwave.commands.powerlevelv1.PowerlevelGet()\n    ]\n    response(commands(request))\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.versionv1.VersionReport cmd) {\n\tdef fw = \"${cmd.applicationVersion}.${cmd.applicationSubVersion}\"\n\tupdateDataValue(\"fw\", fw)\n\tlog.debug \"---VERSION REPORT V1--- ${device.displayName} is running firmware version: $fw, Z-Wave version: ${cmd.zWaveProtocolVersion}.${cmd.zWaveProtocolSubVersion}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.manufacturerspecificv2.ManufacturerSpecificReport cmd) {\n\tlog.debug \"manufacturerId:   ${cmd.manufacturerId}\"\n\tlog.debug \"manufacturerName: ${cmd.manufacturerName}\"\n\tlog.debug \"productId:        ${cmd.productId}\"\n\tlog.debug \"productTypeId:    ${cmd.productTypeId}\"\n\tdef msr = String.format(\"%04X-%04X-%04X\", cmd.manufacturerId, cmd.productTypeId, cmd.productId)\n\tupdateDataValue(\"MSR\", msr)\n\tcreateEvent([descriptionText: \"$device.displayName MSR: $msr\", isStateChange: false], displayed = true)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.meterv3.MeterReport cmd) {\n    def meterTypes = [\"Unknown\", \"Electric\", \"Gas\", \"Water\"]\n    def electricNames = [\"energy\", \"energy\", \"power\", \"count\",  \"voltage\", \"current\", \"powerFactor\",  \"unknown\"]\n    def electricUnits = [\"kWh\",    \"kVAh\",   \"W\",     \"pulses\", \"V\",       \"A\",       \"Power Factor\", \"\"]\n\n    //NOTE ScaledPreviousMeterValue does not always contain a value\n    def previousValue = cmd.scaledPreviousMeterValue ?: 0\n\n    def map = [ name: electricNames[cmd.scale], unit: electricUnits[cmd.scale], displayed: state.display]\n    switch(cmd.scale) {\n        case 0: //kWh\n\t    previousValue = device.currentValue(\"energy\") ?: cmd.scaledPreviousMeterValue ?: 0\n            map.value = cmd.scaledMeterValue\n            break;\n        case 1: //kVAh\n            map.value = cmd.scaledMeterValue\n            break;\n        case 2: //Watts\n            previousValue = device.currentValue(\"power\") ?: cmd.scaledPreviousMeterValue ?: 0\n            map.value = cmd.scaledMeterValue\n            break;\n        case 4: //Volts\n            previousValue = device.currentValue(\"voltage\") ?: cmd.scaledPreviousMeterValue ?: 0\n            map.value = cmd.scaledMeterValue\n            break;\n        case 5: //Amps\n            previousValue = device.currentValue(\"current\") ?: cmd.scaledPreviousMeterValue ?: 0\n            map.value = cmd.scaledMeterValue\n            break;\n    }\n\tmap.isStateChange = true\n\tmap.displayed = true\n    createEvent(map)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicReport cmd) {\n\tdef value = (cmd.value ? \"on\" : \"off\")\n\tdef result = [createEvent(name: \"switch\", value: value, type: \"physical\", displayed: true, isStateChange: true)]\n\treturn result\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.switchbinaryv1.SwitchBinaryReport cmd) {\n\tdef value = (cmd.value ? \"on\" : \"off\")\n\tdef result = [createEvent(name: \"switch\", value: value, type: \"digital\", displayed: true, isStateChange: true)]\n\treturn result\n}\n// parse the unhandled\ndef zwaveEvent(physicalgraph.zwave.Command cmd) {\n\tlog.debug \"Unhandled: $cmd\"\n    createEvent(descriptionText: cmd.toString(), isStateChange: false)\n}\n\n// Commands follow\ndef on() {\n\tdef request = [\n\t\tzwave.basicV1.basicSet(value: 0xFF),\n\t\tzwave.switchBinaryV1.switchBinaryGet()\n\t]\n    commands(request)\n}\ndef off() {\n\tdef request = [\n\t\tzwave.basicV1.basicSet(value: 0x00),\n\t\tzwave.switchBinaryV1.switchBinaryGet()\n\t]\n    commands(request)\n}\ndef checkstate() {\n\t// check our config state map\n\tlog.debug \"settings: ${settings.inspect()}, state: ${state.inspect()}\"\n\tstate.configParams.each {parameter, value -> log.debug \"Parameter ${parameter} = ${value}\"}\t\n    //  LED Notifications - 0=disabled 1=enabled\n\t// zwave.configurationV1.configurationSet(parameterNumber: 0x05, size: 1, scaledConfigurationValue: 0).format()\n    /*\n    if (state.configParams.(4) == [12]) {\n    \tlog.debug \"this was true\" }\n    \t\telse log.debug \"This was false :(\"\n    */\n}\ndef getEnergy() {\n\tzwave.meterV3.meterGet(scale: 0).format()\t//kWh\n}\ndef getPower() {\n\tzwave.meterV3.meterGet(scale: 2).format()\t//Wattage\n}\ndef getVoltage() {\n\tzwave.meterV3.meterGet(scale: 4).format()\t//Volts\n}\ndef getCurrent() {\n\tzwave.meterV3.meterGet(scale: 5).format()\t//Amps\n}\ndef poll() {\n\tdef request = [\n\t\tzwave.switchBinaryV1.switchBinaryGet(),\n\t\tzwave.meterV3.meterGet(scale: 0),\t//kWh\n\t\tzwave.meterV3.meterGet(scale: 2),\t//Wattage\n\t\tzwave.meterV3.meterGet(scale: 4),\t//Volts\n\t\tzwave.meterV3.meterGet(scale: 5),\t//Amps\n\t]\n    commands(request)\n}\ndef refresh() {\n\tdef request = [\n\t\tzwave.switchBinaryV1.switchBinaryGet(),\n        zwave.meterV3.meterGet(scale: 0),\t//kWh\n\t\tzwave.meterV3.meterGet(scale: 2),\t//Wattage\n\t\tzwave.meterV3.meterGet(scale: 4),\t//Volts\n\t\tzwave.meterV3.meterGet(scale: 5),\t//Amps\n\t]\n    commands(request)\n}\n\ndef reset() {\n\tdef request = [\n\t\tzwave.meterV3.meterReset(),\n\t\tzwave.meterV3.meterGet(scale: 0),\t//kWh\n        zwave.meterV3.meterGet(scale: 1),\t//kVAh\n\t\tzwave.meterV3.meterGet(scale: 2),\t//Wattage\n\t\tzwave.meterV3.meterGet(scale: 4),\t//Volts\n\t\tzwave.meterV3.meterGet(scale: 5)\t//Amps\n\t]\n    commands(request)\n}\n\ndef indicatorWhenOn() {\n\tdef request = [\n\tzwave.configurationV1.configurationSet(configurationValue: [1], parameterNumber: 0x05, size: 1),\n\tzwave.configurationV1.configurationGet(parameterNumber: 0x05)\n\t]\n\tcommands(request)\n}\n\ndef indicatorNever() {\n\tdef request = [\n\tzwave.configurationV1.configurationSet(configurationValue: [0], parameterNumber: 5, size: 1),\n    zwave.configurationV1.configurationGet(parameterNumber: 0x05)\n\t]\n    commands(request)\n}\n\ndef timerOn() {\n\tdef request = [\n    zwave.configurationV1.configurationSet(parameterNumber: 0x08, size: 1, scaledConfigurationValue: 1),\n    zwave.configurationV1.configurationGet(parameterNumber: 0x08)\n\t]\n    commands(request)\n}\n\ndef timerOff() {\n\tdef request = [\n\tzwave.configurationV1.configurationSet(parameterNumber: 0x08, size: 1, scaledConfigurationValue: 0),\n    zwave.configurationV1.configurationGet(parameterNumber: 0x08)\n\t]\n    commands(request)\n}\n\ndef configure() {\n    def request = [\n\t\t//this doesn't seem to work in ST...\n        //zwave.configurationV2.configurationBulkGet (parameterOffset: 0x0001, numberOfParameters: 10),\n    \n    \t// Get version and firmware info\n\t\tzwave.versionV1.versionGet(),\n\t    zwave.firmwareUpdateMdV2.firmwareMdGet(),\n\t       \n\t    // get all the config values\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0x01),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0x02),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0x03),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0x04),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0x05),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0x06),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0x07),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0x08),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0x09),\n\t\tzwave.configurationV1.configurationGet(parameterNumber: 0x0A)\n    ]\n\tcommands(request) + setConfigured()\n/*\n// set things that need to be set because their setting doesn't match what we want it to be set to\n    def configSend = [:]\n    \n// enable or disable energy metering reports 0=disabled 1=enabled\n    int energyReportingInt = energyReporting? 1 : 0;\n    log.debug energyReportingInt\n    if (state.configParams.(1) != energyReportingInt) {\n        configSend << zwave.configurationV1.configurationSet(parameterNumber: 0x01, size: 1, scaledConfigurationValue: energyReporting)\n        }\n// Interval in seconds for sending energy metering reports\n\tif (state.configParams.(2) != reportInterval) {\n    \tconfigSend << zwave.configurationV1.configurationSet(parameterNumber: 0x02, size: 2, scaledConfigurationValue: reportInterval)\n        }\n// Overload protection - set the number of AMPS you want to limit the plug to. 13 is what it is designed for.\n// when this value is hit, overload notification messages are sent and you have to press the button on the plug to reset it.\n\tif (state.configParams.(3) != overloadProtection) {\n    \tconfigSend << zwave.configurationV1.configurationSet(parameterNumber: 0x03, size: 1, scaledConfigurationValue: overloadProtection)\n\t\t}\n// Heavy load warning AMP threshold - the plug led will turn yellow when you reach this AMP value. must be less than parameter 3/\n\tif (state.configParams.(4) != loadWarning) {\n    \tconfigSend << zwave.configurationV1.configurationSet(parameterNumber: 0x04, size: 1, scaledConfigurationValue: loadWarning)\n        }\n\n//  LED Notifications - 0=disabled 1=enabled\n//\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x05, size: 1, scaledConfigurationValue: confParam5),\n\n// percentage of change in any energy metric for a report to be sent - threshold reporting\n\tif (state.configParams.(6) != reportThreshold) {\n\t\tconfigSend << zwave.configurationV1.configurationSet(parameterNumber: 0x06, size: 1, scaledConfigurationValue: reportThreshold)\n        }\n// power failure recovery state - 0=remain off when power restored 1=return to last state when power restored\n\tif (state.configParams.(7) != stateRecvovery) {\n    \tconfigSend << zwave.configurationV1.configurationSet(parameterNumber: 0x07, size: 1, scaledConfigurationValue: stateRecvovery)\n\t\t}\n\n// auto power off timer - 0=disabled 1=enabled\n//\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x08, size: 1, scaledConfigurationValue: confParam8),\n// auto power off timer duration - a value in minutes 1-65535\n//\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x09, size: 2, scaledConfigurationValue: confParam9),\n\n// manual control power on/off control - 0=disable action button 1=enable action button\n\tif (state.configParams.(10) != manualOverride) {\n\t\tconfigSend << zwave.configurationV1.configurationSet(parameterNumber: 0x0A, size: 1, scaledConfigurationValue: manualOverride)\n        }\t\t\n// Can use the zwaveHubNodeId variable to add the hub to the device's associations:\n\t\trequest << zwave.associationV1.associationSet(groupingIdentifier:2, nodeId:zwaveHubNodeId)\n\tcommands(configSend) + setConfigured()\n    */\n}\n\nprivate setConfigured() {\n\tupdateDataValue(\"configured\", \"true\")\n}\n\nprivate isConfigured() {\n\tgetDataValue(\"configured\") == \"true\"\n}\n\nprivate command(physicalgraph.zwave.Command cmd) {\n\tcmd.format()\n}\n\nprivate commands(commands, delay=1250) {\n\tdelayBetween(commands.collect{ command(it) }, delay)\n}"
  },
  {
    "path": "zooZ-MiniPlug-ZEN07/device_type-zooZ-MiniPlug-ZEN07-v1.4.groovy",
    "content": "/*\nzooZ MiniPlug ZEN07 device handler for SmartThings version 1.0 by Robert Vandervoort 10/10/2016\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except\nin compliance with the License. You may obtain a copy of the License at:\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under the License is distributed\non an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License\nfor the specific language governing permissions and limitations under the License.\n\nsome code used from various SmartThings device type and metering code from ElasticDev\n\n*/\n\nmetadata {\n\tdefinition (name: \"zooZ MiniPlug ZEN07 - RV v1.2\", namespace: \"robertvandervoort\", author: \"Robert Vandervoort\") {\n\t\tcapability \"Energy Meter\"\n\t\tcapability \"Power Meter\"\n\t\tcapability \"Actuator\"\n        capability \"Indicator\"\n\t\tcapability \"Switch\"\n\t\tcapability \"Configuration\"\n\t\tcapability \"Polling\"\n\t\tcapability \"Refresh\"\n\t\tcapability \"Sensor\"\n\n\t\tcommand \"reset\"\n        command \"getPower\"\n        command \"getEnergy\"\n        command \"getVoltage\"\n        command \"getCurrent\"\n        command \"checkstate\"\n        command \"timerOn\"\n        command \"timerOff\"\n\n\t\tattribute \"timerStatus\", \"enum\", [\"On\", \"Off\"]\n\t\t\n\t// RAW 0 0 0x1001 0 0 0 d 0x5E 0x72 0x86 0x85 0x59 0x5A 0x73 0x70 0x25 0x27 0x71 0x32 0x20\n\t// MSR 027A-0003-0087\n\t\n\t\tfingerprint deviceId: \"0x1001\", inClusters: \"0x5E,0x72,0x86,0x85,0x59,0x5A,0x73,0x70,0x25,0x27,0x71,0x32,0x20\"\n\t}\n\t// simulator metadata\n\tsimulator {\n\t\tstatus \"on\":  \"command: 2003, payload: FF\"\n\t\tstatus \"off\": \"command: 2003, payload: 00\"\n\n\tfor (int i = 0; i <= 10000; i += 1000) {\n\t    status \"power  ${i} W\": \n\t\t    new physicalgraph.zwave.Zwave().meterV3.meterReport(scaledMeterValue: i, precision: 3, meterType: 4, scale: 2, size: 4).incomingMessage()\n\t}\n\tfor (int i = 0; i <= 100; i += 10) {\n\t    status \"energy  ${i} kWh\":\n\t\t    new physicalgraph.zwave.Zwave().meterV3.meterReport(scaledMeterValue: i, precision: 3, meterType: 0, scale: 0, size: 4).incomingMessage()\n\t}\n\t\t// reply messages\n\t\treply \"2001FF,delay 100,2502\": \"command: 2503, payload: FF\"\n\t\treply \"200100,delay 100,2502\": \"command: 2503, payload: 00\"\n\t}\n\n\t// tile definitions\n\ttiles (scale: 2) {\n    \tstandardTile(\"main\", \"device.switch\", width:4, height:4, canChangeIcon: true) {\n\t\t\tstate \"on\", label: '${name}', action: \"switch.off\", icon: \"st.switches.switch.on\", backgroundColor: \"#79b821\"\n\t\t\tstate \"off\", label: '${name}', action: \"switch.on\", icon: \"st.switches.switch.off\", backgroundColor: \"#ffffff\"\n\t\t}\n        valueTile(\"power\", \"device.power\", decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'${currentValue} W', action:\"getPower\"\n\t\t}\n\t\tvalueTile(\"energy\", \"device.energy\", decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'${currentValue} kWh', action:\"getEnergy\"\n\t\t}\n\t\tvalueTile(\"current\", \"device.current\", decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'${currentValue} A', action:\"getCurrent\"\n\t\t}\n        valueTile(\"voltage\", \"device.voltage\", decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'${currentValue} V', action:\"getVoltage\"\n\t\t}\n\t\tstandardTile(\"reset\", \"device.energy\", inactiveLabel: false, decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'reset kWh', action:\"reset\"\n\t\t}\n\t\tstandardTile(\"refresh\", \"device.power\", inactiveLabel: false, decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'', action:\"refresh.refresh\", icon:\"st.secondary.refresh\"\n\t\t} \n\t\tstandardTile(\"configure\", \"device.configure\", inactiveLabel: false, decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'config', action:\"configure\", icon:\"st.secondary.refresh\"\n\t\t}\n        standardTile(\"check\", \"device.configure\", inactiveLabel: false, decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"default\", label:'check', action:\"checkstate\"\n\t\t}\n\t\tstandardTile(\"timer\", \"device.timerStatus\", inactiveLabel: false, decoration: \"flat\", width:2, height:2) {\n        \tstate \"off\", label:'TIMER', action:\"timerOn\", icon: \"st.illuminance.illuminance.dark\"\n            state \"on\", label:'TIMER', action:\"timerOff\", icon: \"st.illuminance.illuminance.bright\"\n\t\t}\n\t\tstandardTile(\"indicator\", \"device.indicatorStatus\", inactiveLabel: false, decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"never\", label:'LED', action:\"indicator.indicatorWhenOn\", icon: \"st.illuminance.illuminance.dark\"\n\t\t\tstate \"when on\", label:'LED', action:\"indicator.indicatorNever\", icon: \"st.illuminance.illuminance.bright\"\n\t\t}\n\t\tmain \"main\"\n\t\tdetails([\"main\",\"energy\",\"reset\",\"voltage\",\"power\",\"current\",\"refresh\",\"timer\",\"indicator\",\"check\",\"configure\"])\n\t}\n\t\n    preferences { \n\t\tinput \"energyReporting\", \"boolean\", \n\t\t\ttitle: \"Energy usage reports\",\n\t\t\tdefaultValue: true,\n\t\t\tdisplayDuringSetup: true\n\n\t\tinput \"reportInterval\", \"integer\", \n\t\t\ttitle: \"Energy report interval\", \n\t\t\tdescription: \"The time interval in seconds for sending energy usage reports\", \n\t\t\tdefaultValue: 300, \n            range: \"1..4294967295‬\",\n\t\t\trequired: false, \n\t\t\tdisplayDuringSetup: false\n\n\t\tinput \"reportThreshold\", \"integer\",\n\t\t\ttitle: \"Reporting threshold\", \n\t\t\tdescription: \"The percentage of change required for sending energy usage reports\", \n\t\t\tdefaultValue: 5, \n            range: \"1..99\",\n\t\t\trequired: false, \n\t\t\tdisplayDuringSetup: false\n\t\t\t\n\t\tinput \"loadWarning\", \"integer\",\n\t\t\ttitle: \"Load warning AMPs\",\n\t\t\tdescription: \"Set to a value in AMPs to provide heavy load warning notification.\",\n\t\t\tdefaultValue: 12,\n\t\t\trange: \"1..12\",\n\t\t\trequired: false,\n\t\t\tdisplayDuringSetup: false\n\t\t\n\t\tinput \"overloadProtection\", \"integer\",\n\t\t\ttitle: \"Overload protection AMPs\",\n\t\t\tdescription: \"Must be higher than heavy load warning value. When this value is reached, the plug shuts down and must be reset.\",\n\t\t\tdefaultValue: 13,\n\t\t\trange: \"1..15\",\n\t\t\trequired: false,\n\t\t\tdisplayDuringSetup: false\n\n\t\tinput \"manualOverride\", \"boolean\", \n\t\t\ttitle: \"Switch manual control\",\n\t\t\tdescription: \"Enable or disable the switch on the plug. Good for tamper protection.\",\n\t\t\tdefaultValue: true,\n\t\t\tdisplayDuringSetup: false\n\n\t\tinput \"stateRecvovery\", \"boolean\",\n\t\t\ttitle: \"Return to last state after power failure?\",\n\t\t\tdefaultValue: true,\n\t\t\tdisplayDuringSetup: false\n\t\t\t\t\t\t\n\t\tinput \"ledNotifications\", \"boolean\", \n\t\t\ttitle: \"LED Notifications?\",\n\t\t\tdescription: \"Enables or disables LED color change for heavy and overload notifications.\",\n\t\t\tdefaultValue: true,\n\t\t\tdisplayDuringSetup: false\n\n\t\tinput \"debugOutput\", \"boolean\", \n\t\t\ttitle: \"Enable debug logging?\",\n\t\t\tdefaultValue: false,\n\t\t\tdisplayDuringSetup: true\n\t}\n}\n\ndef updated() {\n\t//state.configParams.clear()\n\tupdateDataValue(\"configured\", \"false\")\n\tstate.debug = (\"true\" == debugOutput)\n    configure()\n}\n\ndef parse(String description) {\n    def result = null\n    def cmd = zwave.parse(description)\n    if (cmd) {\n        result = zwaveEvent(cmd)\n        if (state.debug) log.debug \"Parsed ${cmd} to ${result.inspect()}\"\n    } else {\n        log.debug \"Non-parsed event: ${description}\"\n    }\n    return result\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.configurationv1.ConfigurationReport cmd) {\n\tlog.debug(\"ConfigurationReportv1 ${cmd.inspect()}\")\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.configurationv2.ConfigurationReport cmd) {\n\t// calculate decimal values for returned multibyte values\n\tdef fullValue = 0\n    switch(cmd.size) {\n        case 1: //1 byte\n        \tfullValue = cmd.configurationValue[0] * 1\n            break;\n        case 2: //2 byte\n\t\t\tfullValue = cmd.configurationValue[1] + (cmd.configurationValue[0] * 0x100)\n            break;\n\t\tcase 3: //3 byte\n        \tfullValue = cmd.configurationValue[2] + (cmd.configurationValue[1] * 0x100) + (cmd.configurationValue[0] * 0x10000)\n            break;        \t\n        case 4: //4 byte\n        \tfullValue = cmd.configurationValue[3] + (cmd.configurationValue[2] * 0x100) + (cmd.configurationValue[1] * 0x10000) + (cmd.configurationValue[0] * 0x1000000)\n            break;\n\t}\n\tstate.configParams << [(cmd.parameterNumber) : (fullValue)]\n    log.debug state.configParams\n\n    // set states for any values coming in used for tiles\n\tdef statusValue = [:]\n\tswitch(cmd.parameterNumber) {\n        case 5: //LED Indicator\n           \tstatusValue.name = \"indicatorStatus\"\n\t\t\tif (cmd.configurationValue == [0]) {\n                statusValue.value = \"never\"\n                } else\n\t\t\tif (cmd.configurationValue == [1]) {\n                statusValue.value = \"when on\"\n                }\n\t\t\tbreak;\n        case 8: //Automatic shutoff timer\n\t\t\tstatusValue.name = \"timerStatus\"\n\t\t\tif (cmd.configurationValue == [0]) {\n                statusValue.value = \"off\"\n                } else\n\t\t\tif (cmd.configurationValue == [1]) {\n                statusValue.value = \"on\"\n                }\n            break;\n\t\t}\n\tstatusValue.displayed = true\n\tcreateEvent(statusValue)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.configurationv2.ConfigurationBulkReport cmd)\n{\n\tlog.debug \"Got a bulk report, but don't know what to do with it.\"\n}\n \ndef zwaveEvent(physicalgraph.zwave.commands.powerlevelv1.PowerlevelTestNodeReport cmd) {\n\tlog.debug \"===Power level test node report received=== ${device.displayName}: statusOfOperation: ${cmd.statusOfOperation} testFrameCount: ${cmd.testFrameCount} testNodeid: ${cmd.testNodeid}\"\n\tdef request = [\n        physicalgraph.zwave.commands.powerlevelv1.PowerlevelGet()\n    ]\n    response(commands(request))\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.versionv1.VersionReport cmd) {\n\tdef fw = \"${cmd.applicationVersion}.${cmd.applicationSubVersion}\"\n\tupdateDataValue(\"fw\", fw)\n\tlog.debug \"---VERSION REPORT V1--- ${device.displayName} is running firmware version: $fw, Z-Wave version: ${cmd.zWaveProtocolVersion}.${cmd.zWaveProtocolSubVersion}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.manufacturerspecificv2.ManufacturerSpecificReport cmd) {\n\tlog.debug \"manufacturerId:   ${cmd.manufacturerId}\"\n\tlog.debug \"manufacturerName: ${cmd.manufacturerName}\"\n\tlog.debug \"productId:        ${cmd.productId}\"\n\tlog.debug \"productTypeId:    ${cmd.productTypeId}\"\n\tdef msr = String.format(\"%04X-%04X-%04X\", cmd.manufacturerId, cmd.productTypeId, cmd.productId)\n\tupdateDataValue(\"MSR\", msr)\n\tcreateEvent([descriptionText: \"$device.displayName MSR: $msr\", isStateChange: false], displayed = true)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.meterv3.MeterReport cmd) {\n    def meterTypes = [\"Unknown\", \"Electric\", \"Gas\", \"Water\"]\n    def electricNames = [\"energy\", \"energy\", \"power\", \"count\",  \"voltage\", \"current\", \"powerFactor\",  \"unknown\"]\n    def electricUnits = [\"kWh\",    \"kVAh\",   \"W\",     \"pulses\", \"V\",       \"A\",       \"Power Factor\", \"\"]\n\n    //NOTE ScaledPreviousMeterValue does not always contain a value\n    def previousValue = cmd.scaledPreviousMeterValue ?: 0\n\n    def map = [ name: electricNames[cmd.scale], unit: electricUnits[cmd.scale], displayed: state.display]\n    switch(cmd.scale) {\n        case 0: //kWh\n\t    previousValue = device.currentValue(\"energy\") ?: cmd.scaledPreviousMeterValue ?: 0\n            map.value = cmd.scaledMeterValue\n            break;\n        case 1: //kVAh\n            map.value = cmd.scaledMeterValue\n            break;\n        case 2: //Watts\n            previousValue = device.currentValue(\"power\") ?: cmd.scaledPreviousMeterValue ?: 0\n            map.value = cmd.scaledMeterValue\n            break;\n        case 4: //Volts\n            previousValue = device.currentValue(\"voltage\") ?: cmd.scaledPreviousMeterValue ?: 0\n            map.value = cmd.scaledMeterValue\n            break;\n        case 5: //Amps\n            previousValue = device.currentValue(\"current\") ?: cmd.scaledPreviousMeterValue ?: 0\n            map.value = cmd.scaledMeterValue\n            break;\n    }\n\tmap.isStateChange = true\n\tmap.displayed = true\n    createEvent(map)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicReport cmd) {\n\tdef value = (cmd.value ? \"on\" : \"off\")\n\tdef result = [createEvent(name: \"switch\", value: value, type: \"physical\", displayed: true, isStateChange: true)]\n\treturn result\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.switchbinaryv1.SwitchBinaryReport cmd) {\n\tdef value = (cmd.value ? \"on\" : \"off\")\n\tdef result = [createEvent(name: \"switch\", value: value, type: \"digital\", displayed: true, isStateChange: true)]\n\treturn result\n}\n// parse the unhandled\ndef zwaveEvent(physicalgraph.zwave.Command cmd) {\n\tlog.debug \"Unhandled: $cmd\"\n    createEvent(descriptionText: cmd.toString(), isStateChange: false)\n}\n\n// Commands follow\ndef on() {\n\tdef request = [\n\t\tzwave.basicV1.basicSet(value: 0xFF),\n\t\tzwave.switchBinaryV1.switchBinaryGet()\n\t]\n    commands(request)\n}\ndef off() {\n\tdef request = [\n\t\tzwave.basicV1.basicSet(value: 0x00),\n\t\tzwave.switchBinaryV1.switchBinaryGet()\n\t]\n    commands(request)\n}\ndef getEnergy() {\n\tzwave.meterV3.meterGet(scale: 0).format()\t//kWh\n}\ndef getPower() {\n\tzwave.meterV3.meterGet(scale: 2).format()\t//Wattage\n}\ndef getVoltage() {\n\tzwave.meterV3.meterGet(scale: 4).format()\t//Volts\n}\ndef getCurrent() {\n\tzwave.meterV3.meterGet(scale: 5).format()\t//Amps\n}\ndef poll() {\n\tdef request = [\n\t\tzwave.switchBinaryV1.switchBinaryGet(),\n\t\tzwave.meterV3.meterGet(scale: 0),\t//kWh\n\t\tzwave.meterV3.meterGet(scale: 2),\t//Wattage\n\t\tzwave.meterV3.meterGet(scale: 4),\t//Volts\n\t\tzwave.meterV3.meterGet(scale: 5),\t//Amps\n\t]\n    commands(request)\n}\ndef refresh() {\n\tstate.configParams.clear()\n\tdef request = [\n\t\tzwave.switchBinaryV1.switchBinaryGet(),\n        zwave.meterV3.meterGet(scale: 0),\t//kWh\n\t\tzwave.meterV3.meterGet(scale: 2),\t//Wattage\n\t\tzwave.meterV3.meterGet(scale: 4),\t//Volts\n\t\tzwave.meterV3.meterGet(scale: 5),\t//Amps\n\t]\n    commands(request)\n}\n\ndef reset() {\n\tdef request = [\n\t\tzwave.meterV3.meterReset(),\n\t\tzwave.meterV3.meterGet(scale: 0),\t//kWh\n        zwave.meterV3.meterGet(scale: 1),\t//kVAh\n\t\tzwave.meterV3.meterGet(scale: 2),\t//Wattage\n\t\tzwave.meterV3.meterGet(scale: 4),\t//Volts\n\t\tzwave.meterV3.meterGet(scale: 5)\t//Amps\n\t]\n    commands(request)\n}\n\ndef indicatorWhenOn() {\n\tdef request = [\n\tzwave.configurationV1.configurationSet(configurationValue: [1], parameterNumber: 0x05, size: 1),\n\tzwave.configurationV1.configurationGet(parameterNumber: 0x05)\n\t]\n\tcommands(request)\n}\n\ndef indicatorNever() {\n\tdef request = [\n\tzwave.configurationV1.configurationSet(configurationValue: [0], parameterNumber: 5, size: 1),\n    zwave.configurationV1.configurationGet(parameterNumber: 0x05)\n\t]\n    commands(request)\n}\n\ndef timerOn() {\n\tdef request = [\n    zwave.configurationV1.configurationSet(parameterNumber: 0x08, size: 1, scaledConfigurationValue: 1),\n    zwave.configurationV1.configurationGet(parameterNumber: 0x08)\n\t]\n    commands(request)\n}\n\ndef timerOff() {\n\tdef request = [\n\tzwave.configurationV1.configurationSet(parameterNumber: 0x08, size: 1, scaledConfigurationValue: 0),\n    zwave.configurationV1.configurationGet(parameterNumber: 0x08)\n\t]\n    commands(request)\n}\ndef checkstate() {\n\t// check our config state map\n\tlog.debug \"settings: ${settings.inspect()}, state: ${state.inspect()}\"\n    state.configParams.each { parameter, value -> log.debug \"Parameter ${parameter} = ${value}\"}\t\n    //  LED Notifications - 0=disabled 1=enabled\n\t// zwave.configurationV1.configurationSet(parameterNumber: 0x05, size: 1, scaledConfigurationValue: 0).format()\n    /*\n    if (state.configParams.(4) == [12]) {\n    \tlog.debug \"this was true\" }\n    \t\telse log.debug \"This was false :(\"\n    */\n}\ndef configure() {\n\tdef request = []\n    \t// Get version and firmware info\n\t\trequest << zwave.versionV1.versionGet()\n        request << zwave.firmwareUpdateMdV2.firmwareMdGet()\n        \n        // get all the config values\n\t\trequest << zwave.configurationV1.configurationGet(parameterNumber: 0x01)\n\t\trequest << zwave.configurationV1.configurationGet(parameterNumber: 0x02)\n\t\trequest << zwave.configurationV1.configurationGet(parameterNumber: 0x03)\n\t\trequest << zwave.configurationV1.configurationGet(parameterNumber: 0x04)\n\t\trequest << zwave.configurationV1.configurationGet(parameterNumber: 0x05)\n\t\trequest << zwave.configurationV1.configurationGet(parameterNumber: 0x06)\n\t\trequest << zwave.configurationV1.configurationGet(parameterNumber: 0x07)\n\t\trequest << zwave.configurationV1.configurationGet(parameterNumber: 0x08)\n\t\trequest << zwave.configurationV1.configurationGet(parameterNumber: 0x09)\n\t\trequest << zwave.configurationV1.configurationGet(parameterNumber: 0x0A)\n        // Can use the zwaveHubNodeId variable to add the hub to the device's associations:\n\t\trequest << zwave.associationV1.associationSet(groupingIdentifier:2, nodeId:zwaveHubNodeId)\n\t\n\tcommands(request) + setConfigured()\n \n// set things that need to be set because their setting doesn't match what we want it to be set to\n\tint energyReportingInt;\n    switch (energyReporting) {\n    \tcase \"true\":\n        \tenergyReportingInt = 1\n            break;\n\t\tcase \"false\":\n        \tenergyReportingInt = 0\n            break;\n\t}\n    \n    int manualOverrideInt;\n    switch (manualOverride) {\n    \tcase \"true\":\n        \tmanualOverrideInt = 1\n            break;\n\t\tcase \"false\":\n        \tmanualOverrideInt = 0\n            break;\n\t}    \n    \n    int stateRecvoveryInt;\n    switch(stateRecvovery) {\n    \tcase \"true\":\n        \tstateRecvoveryInt = 1\n            break;\n\t\tcase \"false\":\n        \tstateRecvoveryInt = 0\n            break;\n\t}\n    \n//    log.debug \"energy reporting preference = ${energyReporting}\";\n//    log.debug \"shit I cooked up from that preference = ${energyReportingInt}\";\n    \n   \tint reportIntervalInt = Integer.parseInt(reportInterval);\n\tint overloadProtectionInt = Integer.parseInt(overloadProtection);\n    int loadWarningInt = Integer.parseInt(loadWarning);\n    int reportThresholdInt = Integer.parseInt(reportThreshold);\n\n\t\n//  int configParam1 = state.configParams.(1);\n//\tint configParam2 = state.configParams.(2);\n\tint configParam3 = state.configParams.(3);\n\tint configParam4 = state.configParams.(4);\n\tint configParam5 = state.configParams.(5);\n\tint configParam6 = state.configParams.(6);\n\tint configParam7 = state.configParams.(7);\n\tint configParam8 = state.configParams.(8);\n\tint configParam9 = state.configParams.(9);\n\tint configParam10 = state.configParams.(10);\n    \n    \n\tdef configSend = []\n   \n// enable or disable energy metering reports 0=disabled 1=enabled\n    if (state.configParams.(1) != energyReportingInt) {\n    \tlog.debug \"config ${state.configParams.(1)} != request ${energyReportingInt} Queuing configuration command...\"\n        configSend << zwave.configurationV1.configurationSet(parameterNumber: 0x01, size: 1, scaledConfigurationValue: energyReportingInt)\n        } else log.debug \"config ${state.configParams.(1)} = request ${energyReportingInt} Energy reporting setting unchanged. Skipping it...\"\n\n// Interval in seconds for sending energy metering reports\n\tif (state.configParams.(2) != reportIntervalInt) {\n    \tlog.debug \"config ${state.configParams.(2)} != request ${reportIntervalInt} Queuing configuration command...\"\n    \tconfigSend << zwave.configurationV1.configurationSet(parameterNumber: 0x02, size: 2, scaledConfigurationValue: reportIntervalInt)\n        configSend << zwave.configurationV1.configurationGet(parameterNumber: 0x02)\n        } else log.debug \"config ${state.configParams.(2)} = request ${reportIntervalInt} Energy report sending interval setting unchanged. Skipping it...\"\n\n// Overload protection - set the number of AMPS you want to limit the plug to. 13 is what it is designed for.\n// when this value is hit, overload notification messages are sent and you have to press the button on the plug to reset it.\n\tif (state.configParams.(3) != overloadProtectionInt) {\n    \tlog.debug \"config ${state.configParams.(3)} != request ${overloadProtectionInt} Queuing configuration command...\"\n    \tconfigSend << zwave.configurationV1.configurationSet(parameterNumber: 0x03, size: 1, scaledConfigurationValue: overloadProtectionInt)\n        configSend << zwave.configurationV1.configurationGet(parameterNumber: 0x03)\n\t\t} else \"config ${state.configParams.(3)} = request ${overloadProtectionInt} Current overload limit setting unchanged. Skipping it...\"\n\n// Heavy load warning AMP threshold - the plug led will turn yellow when you reach this AMP value. must be less than parameter 3/\n\tif (state.configParams.(4) != loadWarningInt) {\n    \tlog.debug \"config ${state.configParams.(4)} != request ${loadWarningInt} Queuing configuration command...\"\n    \tconfigSend << zwave.configurationV1.configurationSet(parameterNumber: 0x04, size: 1, scaledConfigurationValue: loadWarningInt)\n        configSend << zwave.configurationV1.configurationGet(parameterNumber: 0x04)\n        } else log.debug \"config ${state.configParams.(4)} = request ${loadWarningInt} Current overload warning level setting unchanged. Skipping it...\"\n\n//  LED Notifications - 0=disabled 1=enabled\n//\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x05, size: 1, scaledConfigurationValue: confParam5),\n\n// percentage of change in any energy metric for a report to be sent - threshold reporting\n\tif (state.configParams.(6) != reportThresholdInt) {\n    \tlog.debug \"config ${state.configParams.(6)} != request ${reportThresholdInt} Queuing configuration command...\"\n\t\tconfigSend << zwave.configurationV1.configurationSet(parameterNumber: 0x06, size: 1, scaledConfigurationValue: reportThresholdInt)\n        configSend << zwave.configurationV1.configurationGet(parameterNumber: 0x06)\n        } else log.debug \"config ${state.configParams.(6)} = request ${reportThresholdInt} Energy reporting threshold setting unchanged. Skipping it...\"\n\n// power failure recovery state - 0=remain off when power restored 1=return to last state when power restored\n\tif (state.configParams.(7) != stateRecvoveryInt) {\n    \tlog.debug \"config ${state.configParams.(7)} != request ${stateRecvoveryInt} Queuing configuration command...\"\n    \tconfigSend << zwave.configurationV1.configurationSet(parameterNumber: 0x07, size: 1, scaledConfigurationValue: stateRecvoveryInt)\n        configSend << zwave.configurationV1.configurationGet(parameterNumber: 0x07)\n\t\t} else log.debug \"config ${state.configParams.(7)} = request ${stateRecvoveryInt} Power failure state recovery setting unchanged. Skipping it...\"\n\n// auto power off timer - 0=disabled 1=enabled\n//\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x08, size: 1, scaledConfigurationValue: confParam8),\n// auto power off timer duration - a value in minutes 1-65535\n//\t\tzwave.configurationV1.configurationSet(parameterNumber: 0x09, size: 2, scaledConfigurationValue: confParam9),\n\n// manual control power on/off control - 0=disable action button 1=enable action button\n\tif (state.configParams.(10) != manualOverrideInt) {\n    \tlog.debug \"config ${state.configParams.(10)} != request ${manualOverrideInt} Queuing configuration command...\"\n\t\tconfigSend << zwave.configurationV1.configurationSet(parameterNumber: 0x0A, size: 1, scaledConfigurationValue: manualOverrideInt)\n        configSend << zwave.configurationV1.configurationGet(parameterNumber: 0x0A)\n        } else log.debug \"config ${state.configParams.(10)} = request ${manualOverrideInt} Manual control override setting unchanged. Skipping it...\"\n\n// send the commands we need to send if there's anythign TO send\n\tif (configSend) {\n    \tcommands(configSend) + setConfigured()\n\t}\n}\n\nprivate setConfigured() {\n\tupdateDataValue(\"configured\", \"true\")\n}\n\nprivate isConfigured() {\n\tgetDataValue(\"configured\") == \"true\"\n}\n\nprivate command(physicalgraph.zwave.Command cmd) {\n\tcmd.format()\n}\n\nprivate commands(commands, delay=1250) {\n\tdelayBetween(commands.collect{ command(it) }, delay)\n}"
  },
  {
    "path": "zooZ-Motion-Sensor-ZSE02/device_type-zooZ-Motion-Sensor-ZSE02_v1",
    "content": "/*\n * V 1.0 of zooZ motion sensor ZSE-02 code 5/7/2016\n * by Robert Vandervoort\n *\n *  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except\n *  in compliance with the License. You may obtain a copy of the License at:\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n *  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed\n *  on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License\n *  for the specific language governing permissions and limitations under the License.\n * \n---------------------------------------------------------------------------------------------------------------------------\n   INSTRUCTIONS:\n   * First you will need to create a new device handler in SmartThings. Log in to the IDE and click on Device Handlers in the top menu.\n   Then click \"from code\" below. You'l be presented with a blank area where you can copy this code and paste it in.\n   * Next, scroll to the bottom and click create. Now click save, then click publish > for me.\n   * You should now see this device type in your list of device handlers. Now we need to pair the device.\n   * Put SmartThings into inclusion mode by going through the add new device dialog.\n   On the bottom of the zooZ 4-in-1 you will see several small holes. There is a series of four holes and a hole all by itself.\n   You'll need a paperclip or something similar that fits into the hole. While holding the sensor a foot or so from the hub,\n   and with SmartThings in inclusion mode, gently depress the button inside the single hole twice rapidly. The light should blink.\n   Please wait a few moments (usually 10 seconds or so) and you should see \"zooZ 4-in-1 sensor - RV 1.0\" appear in the found devices area.\n   * Touch the \"zooZ 4-in-1 sensor - RV 1.0\" to configure. Here we will set your temperature scale preferecne and motion preferences.\n   After you make your choices, touch done in the app. \n   * Now go to your devices list in the SmartThings app and open up the newly added sensor.\n   * In order to get the configuration sent and initial sensor data, we need to wake the sensor up. Press the button on the device\n   one time while holding it close to the hub. If you pressed the button the sensor should blink yellow once. Wait about 30 seconds,\n   then refresh (drag the screen down) and you should see data on the screen for temp, humidity, illuminance, and battery.\n   ** If you do not, please wait a minute or so and refresh the screen again by sliding it down.\n   * If you still do not see anything after refreshing, touch the gear icon to enter the device preferences screen (make any adjustments or not) and then touch done.\n   This will reset the configuration state so the device can be configured again and polled for data. Once you're back at the device screen,\n   while holding the sensor close to the hub, press the small button we pressed earlier one time, making sure that the sensor blinks\n   (if it doesn't, press the button again) and wait a minute or so, then refresh the device screen in the app again.\n   You should see data on the screen now. \n   *** IF YOU STILL ARE NOT GETTING DATA, go back to the preferences screen and enable debug logging, and touch done. You do not need\n   to press the button on the sensor again at this point. Go into the SmartThings IDE and choose \"live logging\" from the top menu.\n   While on the live logging  screen and close to your hub with the sensor, press the button on the sensor, making sure it blinks, and watch the screen for results.\n   You should see several lines of data come in slowly. This should tell you all your settings and what the configuration on the sensor is actually set to.\n   It will then poll the sensors for data. If you do not ever see any data coming from the sensor, please post to the community or\n   message me via github or the SmartThings community. \n */\n \n metadata {\n\tdefinition (name: \"zooZ motion sensor - RV 1.0\", namespace: \"robertvandervoort\", author: \"Robert Vandervoort\") {\n\t\tcapability \"Motion Sensor\"\n\t\tcapability \"Acceleration Sensor\"\n\t\tcapability \"Configuration\"\n\t\tcapability \"Sensor\"\n\t\tcapability \"Battery\"\n\t\t\n        // RAW Description: 0 0 0x0701 0 0 0 a 0x5E 0x85 0x59 0x71 0x80 0x5A 0x73 0x84 0x72 0x86\n\t\tattribute \"tamper\", \"enum\", [\"detected\", \"clear\"]\n\t\tfingerprint deviceId: \"0x0701\", inClusters: \"0x5E 0x85 0x59 0x71 0x80 0x5A 0x73 0x84 0x72 0x86\"\n\t\t}\nsimulator {\n\t\tstatus \"no motion\" : \"command: 9881, payload: 00300300\"\n\t\tstatus \"motion\"    : \"command: 9881, payload: 003003FF\"\n        status \"clear\" : \" command: 9881, payload: 0071050000000007030000\"\n        status \"tamper\" : \"command: 9881, payload: 007105000000FF07030000\"\n        \n\t\tfor (int i in [0, 5, 10, 15, 50, 99, 100]) {\n\t\t\tstatus \"battery ${i}%\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().batteryV1.batteryReport(\n                batteryLevel: i\n                )\n\t\t\t).incomingMessage()\n\t\t}\n\t\tstatus \"low battery alert\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().batteryV1.batteryReport(\n            \tbatteryLevel: 255\n            \t)\n\t\t\t).incomingMessage()\n\t\tstatus \"wake up\": \"command: 8407, payload:\"\n\t}\n\ttiles (scale: 2) {\n\t\tmultiAttributeTile(name:\"main\", type: \"generic\", width: 6, height: 4){\n\t\t\ttileAttribute (\"device.motion\", key: \"PRIMARY_CONTROL\") {\n\t\t\t\tattributeState \"active\", label:'motion', icon:\"st.motion.motion.active\", backgroundColor:\"#53a7c0\"\n\t\t\t\tattributeState \"inactive\", label:'no motion', icon:\"st.motion.motion.inactive\", backgroundColor:\"#ffffff\"\n\t\t\t}\n\t\t}\n\t\tstandardTile(\"acceleration\", \"device.acceleration\", width: 2, height: 2) {\n\t\t\tstate(\"active\", label:'tamper', icon:\"st.motion.acceleration.active\", backgroundColor:\"#ff0000\")\n\t\t\tstate(\"inactive\", label:'clear', icon:\"st.motion.acceleration.inactive\", backgroundColor:\"#00ff00\")\n\t\t}\n\t\tvalueTile(\"battery\", \"device.battery\", decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"battery\", label:'${currentValue}% battery', unit:\"\"\n\t\t}\n\t\tmain([\"main\"])\n\t\tdetails([\"main\",\"acceleration\",\"battery\"])\n\t}\n    preferences {\n\t\tinput \"debugOutput\", \"boolean\", \n\t\t\ttitle: \"Enable debug logging?\",\n\t\t\tdefaultValue: false,\n\t\t\tdisplayDuringSetup: true\n\t\tinput \"LEDbehavior\", \"enum\",\n\t\t\ttitle: \"LED Behavior\",\n\t\t\toptions: [\"LED Off\", \"Breathing\", \"Quick Blink on Temp/PIR\"],\n            defaultValue: \"Quick Blink on Temp/PIR\",\n\t\t\trequired: false,\n\t\t\tdisplayDuringSetup: false\n\t\tinput \"PIRsensitivity\", \"number\",\n    \t    title: \"PIR motion sensitivity\",\n\t\t\tdescription: \"A value from 1-7, from high to low sensitivity (1 is highest)\",\n\t\t\trange: \"1..7\",\n\t\t\tdefaultValue: 4,\n\t\t\trequired: false,\n\t\t\tdisplayDuringSetup: true\n\t\tinput \"MotionReset\", \"number\",\n    \t    title: \"PIR reset time\",\n\t\t\tdescription: \"Number of minutes to wait to report motion cleared after a motion event if there is no motion detected.\",\n\t\t\trange: \"1..255\",\n\t\t\tdefaultValue: 3,\n\t\t\trequired: false,\n\t\t\tdisplayDuringSetup: true            \n\t}\n}\n\ndef updated()\n{\n\tupdateDataValue(\"configured\", \"false\")\n\tstate.debug = (\"true\" == debugOutput)\n}\n\ndef parse(String description)\n{\n\tdef result = null\n\tif (description.startsWith(\"Err 106\")) {\n\t\tstate.sec = 0\n\t\tresult = createEvent( name: \"secureInclusion\", value: \"failed\", isStateChange: true,\n\t\t\tdescriptionText: \"This sensor failed to complete the network security key exchange. If you are unable to control it via SmartThings, you must remove it from your network and add it again.\")\n\t} else if (description != \"updated\") {  \n\t\tdef cmd = zwave.parse(description, [0x31: 5, 0x71:3, 0x7A: 2, 0x81: 1, 0x84: 2, 0x86: 1])\n\t\tif (cmd) {\n\t\t\tresult = zwaveEvent(cmd)\n\t\t}\n\t}\n\tif (state.debug) log.debug \"Parsed '${description}' to ${result.inspect()}\"\n\treturn result\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.wakeupv2.WakeUpNotification cmd) \n{\n\tdef result = [createEvent(descriptionText: \"${device.displayName} woke up\", isStateChange: false)]\n\tif (!isConfigured()) {\n\t\t// we're still in the process of configuring a newly joined device\n\t\tif (state.debug) log.debug(\"late configure\")\n\t\tresult += response(configure())\n\t} else {\n\t\tresult += response(zwave.wakeUpV1.wakeUpNoMoreInformation())\n\t}\n\tresult\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.securityv1.SecurityMessageEncapsulation cmd) {\n\tdef encapsulatedCommand = cmd.encapsulatedCommand([0x31: 5, 0x71:3, 0x7A: 2, 0x81: 1, 0x84: 2, 0x86: 1])\n\tstate.sec = 1\n\t// if (state.debug) log.debug \"encapsulated: ${encapsulatedCommand}\"\n\tif (encapsulatedCommand) {\n\t\tzwaveEvent(encapsulatedCommand)\n\t} else {\n\t\tlog.warn \"Unable to extract encapsulated cmd from $cmd\"\n\t\tcreateEvent(descriptionText: cmd.toString())\n\t}\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.securityv1.SecurityCommandsSupportedReport cmd) {\n\tif (state.debug) log.debug \"---SECURITY COMMANDS SUPPORTED REPORT V1--- ${device.displayName} sent commandClassControl: ${cmd.commandClassControl}, commandClassSupport: ${cmd.commandClassSupport}, reportsToFollow: ${cmd.reportsToFollow}\"\n\tresponse(configure())\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.manufacturerspecificv2.DeviceSpecificReport cmd) {\n\tif (state.debug) log.debug \"---MANUFACTURER SPECIFIC REPORT V2--- ${device.displayName} sent deviceIdDataFormat: ${cmd.deviceIdDataFormat}, deviceIdDataLengthIndicator: ${cmd.deviceIdDataLengthIndicator}, deviceIdType: ${cmd.deviceIdType}, payload: ${cmd.payload}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.versionv1.VersionCommandClassReport cmd) {\n\tif (state.debug) log.debug \"---COMMAND CLASS VERSION REPORT V1--- ${device.displayName} has command class version: ${cmd.commandClassVersion} - payload: ${cmd.payload}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.versionv1.VersionReport cmd) {\n\tdef fw = \"${cmd.applicationVersion}.${cmd.applicationSubVersion}\"\n\tupdateDataValue(\"fw\", fw)\n\tif (state.debug) log.debug \"---VERSION REPORT V1--- ${device.displayName} is running firmware version: $fw, Z-Wave version: ${cmd.zWaveProtocolVersion}.${cmd.zWaveProtocolSubVersion}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.configurationv1.ConfigurationReport cmd) {\n    if (state.debug) log.debug \"---CONFIGURATION REPORT V1--- ${device.displayName} parameter ${cmd.parameterNumber} with a byte size of ${cmd.size} is set to ${cmd.configurationValue}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.configurationv2.ConfigurationReport cmd) {\n    if (state.debug) log.debug \"---CONFIGURATION REPORT V2--- ${device.displayName} parameter ${cmd.parameterNumber} with a byte size of ${cmd.size} is set to ${cmd.configurationValue}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.batteryv1.BatteryReport cmd) {\n\tdef map = [ name: \"battery\", unit: \"%\" ]\n\tif (cmd.batteryLevel == 0xFF) {\n\t\tmap.value = 1\n\t\tmap.descriptionText = \"${device.displayName} battery is low\"\n\t\tmap.isStateChange = true\n\t} else {\n\t\tmap.value = cmd.batteryLevel\n\t}\n\tstate.lastbatt = now()\n\tcreateEvent(map)\n}\n\ndef motionEvent(value) {\n\tdef map = [name: \"motion\"]\n\tif (value != 0) {\n\t\tmap.value = \"active\"\n\t\tmap.descriptionText = \"$device.displayName detected motion\"\n\t} else {\n\t\tmap.value = \"inactive\"\n\t\tmap.descriptionText = \"$device.displayName motion has stopped\"\n\t}\n\tcreateEvent(map)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.sensorbinaryv2.SensorBinaryReport cmd) {\n\tif (state.debug) log.debug \"---SENSOR BINARY REPORT V2--- ${device.displayName} sent value: ${cmd.sensorValue}\"\n\tmotionEvent(cmd.sensorValue)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicSet cmd) {\n\tif (state.debug) log.debug \"---BASIC SET REPORT V1--- ${device.displayName} sent value: ${cmd.value}\"\n\tmotionEvent(cmd.value)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.notificationv3.NotificationReport cmd) {\nif (state.debug) log.debug \"---NOTIFICATION REPORT V3--- ${device.displayName} sent eventParametersLength: ${cmd.eventParametersLength} eventParameter: ${cmd.eventParameter} notificationType: ${cmd.notificationType} event: ${cmd.event}\"\t\ndef result = []\nif (cmd.notificationType == 7) {\n\tif (cmd.event == 0x00 && cmd.eventParameter == 0x08) {\n\t\tresult << motionEvent(0)\n        }\n    else if (cmd.event == 0x03) {\n    \tresult << createEvent(name: \"acceleration\", value: \"active\", descriptionText: \"$device.displayName cover is open.\")\n\t\t}\n\telse if (cmd.event == 0X00 || cmd.eventParameter == 0x03) {\n\t\tresult << createEvent(name: \"acceleration\", value: \"inactive\", descriptionText: \"$device.displayName cover has been closed.\")\n    }\n\telse if (cmd.event == 0x08) {\n    \tresult << motionEvent(255)\n\t}\n}\nelse {\n\tresult << createEvent(descriptionText: cmd.toString(), isStateChange: false)\n}\n\tresult\n}\n\ndef zwaveEvent(physicalgraph.zwave.Command cmd) {\n\tcreateEvent(descriptionText: cmd.toString(), isStateChange: false)\n}\n\ndef configure() {\n\t// This sensor joins as a secure device if you double-click the button to include it\n\t//if (device.device.rawDescription =~ /98/ && !state.sec) {\n\t//\tif (state.debug) log.debug \"4-in-1 sensor not sending configure until secure\"\n\t//\treturn []\n\t//}\n\tif (state.debug) log.debug \"--Sending configuration commands to zooZ 4-in-1 sensor--\"\n    //if (state.debug) log.debug \"Prefernces settings: PIRsensitivity: $PIRsensitivity, Temp offset: $tempoffset, Humidity offset: $humidityoffset, Luminance offset: $luminanceoffset\"\n\tdef LEDbehav = 3\n\tif (LEDbehavior == \"LED Off\") {\n    \tLEDbehav=1\n    }\n\telse if (LEDbehavior == \"Breathing\") {\n    \tLEDbehav=2\n\t}\n\telse {\n\t\tLEDbehav=3\n\t}\t\n\tdef PIRsens = 4\n\tif (PIRsensitivity) {\n\t\tPIRsens=PIRsensitivity\n\t}\n\telse {\n\t\tPIRsens = 4\n\t}\n    def MotionRst = 3\n\tif (MotionReset) {\n\t\tMotionRst=MotionReset\n\t}\n\telse {\n\t\tMotionRst = 3\n\t}\n    if (state.debug) log.debug \"settings: ${settings.inspect()}, state: ${state.inspect()}\"\n    setConfigured()\n\tdef request = [\n\t\t// set wakeup interval to 20 mins\n\t\tzwave.wakeUpV1.wakeUpIntervalSet(seconds:1200, nodeid:zwaveHubNodeId),\n\t\t\n\t\t// Get Version information\n        zwave.versionV1.versionGet(),\n        zwave.firmwareUpdateMdV2.firmwareMdGet(),\n\t\t\n\t\t// send no-motion report x minutes after motion stops\n\t\t//zwave.configurationV1.configurationSet(parameterNumber: 0x05, size: 1, scaledConfigurationValue: MotionRst),\n\t\t//zwave.configurationV1.configurationGet(parameterNumber: 0x05),\n    \t\n\t\t// set motion sensor sensitivity\n        //zwave.configurationV1.configurationSet(parameterNumber: 0x06, size: 1, scaledConfigurationValue: PIRsens),\n\t\t//zwave.configurationV1.configurationGet(parameterNumber: 0x06),\n\t\t\n        // set LED behavior\n        //zwave.configurationV1.configurationSet(parameterNumber: 0x07, size: 1, scaledConfigurationValue: LEDbehav),\n        //zwave.configurationV1.configurationGet(parameterNumber: 0x07),\n\t\t\n\t\t// get updated battery data\n        zwave.batteryV1.batteryGet(),\n        \n\t\t// Can use the zwaveHubNodeId variable to add the hub to the device's associations:\n\t\tzwave.associationV1.associationSet(groupingIdentifier:2, nodeId:zwaveHubNodeId)\n    ]\n\tcommands(request) + [\"delay 20000\", zwave.wakeUpV1.wakeUpNoMoreInformation().format()]\n}\n\nprivate setConfigured() {\n\tupdateDataValue(\"configured\", \"true\")\n    return []\n}\n\nprivate isConfigured() {\n\tgetDataValue(\"configured\") == \"true\"\n}\n\nprivate command(physicalgraph.zwave.Command cmd) {\n\tif (state.sec) {\n\t\tzwave.securityV1.securityMessageEncapsulation().encapsulate(cmd).format()\n\t} else {\n\t\tcmd.format()\n\t}\n}\n\nprivate commands(commands, delay=1000) {\n\tdelayBetween(commands.collect{ command(it) }, delay)\n}"
  },
  {
    "path": "zooZ-Motion-Sensor-ZSE02/device_type-zooZ-Motion-Sensor-ZSE02_v1.1",
    "content": "/*\n * V 1.1 of zooZ motion sensor ZSE-02 code 5/13/16\n * by Robert Vandervoort\n *\n *  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except\n *  in compliance with the License. You may obtain a copy of the License at:\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n *  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed\n *  on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License\n *  for the specific language governing permissions and limitations under the License.\n * \n---------------------------------------------------------------------------------------------------------------------------\n   INSTRUCTIONS:\n   * First you will need to create a new device handler in SmartThings. Log in to the IDE and click on Device Handlers in the top menu.\n   Then click \"from code\" below. You'l be presented with a blank area where you can copy this code and paste it in.\n   * Next, scroll to the bottom and click create. Now click save, then click publish > for me.\n   * You should now see this device type in your list of device handlers. Now we need to pair the device.\n   * Put SmartThings into inclusion mode by going through the add new device dialog.\n   On the bottom of the zooZ 4-in-1 you will see several small holes. There is a series of four holes and a hole all by itself.\n   You'll need a paperclip or something similar that fits into the hole. While holding the sensor a foot or so from the hub,\n   and with SmartThings in inclusion mode, gently depress the button inside the single hole twice rapidly. The light should blink.\n   Please wait a few moments (usually 10 seconds or so) and you should see \"zooZ 4-in-1 sensor - RV 1.0\" appear in the found devices area.\n   * Touch the \"zooZ 4-in-1 sensor - RV 1.0\" to configure. Here we will set your temperature scale preferecne and motion preferences.\n   After you make your choices, touch done in the app. \n   * Now go to your devices list in the SmartThings app and open up the newly added sensor.\n   * In order to get the configuration sent and initial sensor data, we need to wake the sensor up. Press the button on the device\n   one time while holding it close to the hub. If you pressed the button the sensor should blink yellow once. Wait about 30 seconds,\n   then refresh (drag the screen down) and you should see data on the screen for temp, humidity, illuminance, and battery.\n   ** If you do not, please wait a minute or so and refresh the screen again by sliding it down.\n   * If you still do not see anything after refreshing, touch the gear icon to enter the device preferences screen (make any adjustments or not) and then touch done.\n   This will reset the configuration state so the device can be configured again and polled for data. Once you're back at the device screen,\n   while holding the sensor close to the hub, press the small button we pressed earlier one time, making sure that the sensor blinks\n   (if it doesn't, press the button again) and wait a minute or so, then refresh the device screen in the app again.\n   You should see data on the screen now. \n   *** IF YOU STILL ARE NOT GETTING DATA, go back to the preferences screen and enable debug logging, and touch done. You do not need\n   to press the button on the sensor again at this point. Go into the SmartThings IDE and choose \"live logging\" from the top menu.\n   While on the live logging  screen and close to your hub with the sensor, press the button on the sensor, making sure it blinks, and watch the screen for results.\n   You should see several lines of data come in slowly. This should tell you all your settings and what the configuration on the sensor is actually set to.\n   It will then poll the sensors for data. If you do not ever see any data coming from the sensor, please post to the community or\n   message me via github or the SmartThings community. \n */\n \n metadata {\n\tdefinition (name: \"zooZ motion sensor ZSE-02 - RV 1.1\", namespace: \"robertvandervoort\", author: \"Robert Vandervoort\") {\n\t\tcapability \"Motion Sensor\"\n\t\tcapability \"Acceleration Sensor\"\n\t\tcapability \"Sensor\"\n\t\tcapability \"Battery\"\n\t\t\n        // RAW Description: 0 0 0x0701 0 0 0 a 0x5E 0x85 0x59 0x71 0x80 0x5A 0x73 0x84 0x72 0x86\n\t\tattribute \"tamper\", \"enum\", [\"detected\", \"clear\"]\n\t\tfingerprint deviceId: \"0x0701\", inClusters: \"0x5E 0x85 0x59 0x71 0x80 0x5A 0x73 0x84 0x72 0x86\"\n\t\t}\nsimulator {\n\t\tstatus \"no motion\" : \"command: 9881, payload: 00300300\"\n\t\tstatus \"motion\"    : \"command: 9881, payload: 003003FF\"\n        status \"clear\" : \" command: 9881, payload: 0071050000000007030000\"\n        status \"tamper\" : \"command: 9881, payload: 007105000000FF07030000\"\n        \n\t\tfor (int i in [0, 5, 10, 15, 50, 99, 100]) {\n\t\t\tstatus \"battery ${i}%\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().batteryV1.batteryReport(\n                batteryLevel: i\n                )\n\t\t\t).incomingMessage()\n\t\t}\n\t\tstatus \"low battery alert\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().batteryV1.batteryReport(\n            \tbatteryLevel: 255\n            \t)\n\t\t\t).incomingMessage()\n\t\tstatus \"wake up\": \"command: 8407, payload:\"\n\t}\n\ttiles (scale: 2) {\n\t\tmultiAttributeTile(name:\"main\", type: \"generic\", width: 6, height: 4){\n\t\t\ttileAttribute (\"device.motion\", key: \"PRIMARY_CONTROL\") {\n\t\t\t\tattributeState \"active\", label:'motion', icon:\"st.motion.motion.active\", backgroundColor:\"#53a7c0\"\n\t\t\t\tattributeState \"inactive\", label:'no motion', icon:\"st.motion.motion.inactive\", backgroundColor:\"#ffffff\"\n\t\t\t}\n\t\t}\n\t\tstandardTile(\"acceleration\", \"device.acceleration\", width: 2, height: 2) {\n\t\t\tstate(\"active\", label:'DISABLED', backgroundColor:\"#ff0000\")\n\t\t\tstate(\"inactive\", label:'ENABLED', backgroundColor:\"#00ff00\")\n\t\t}\n\t\tvalueTile(\"battery\", \"device.battery\", decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"battery\", label:'${currentValue}% battery', unit:\"\"\n\t\t}\n\t\tmain([\"main\"])\n\t\tdetails([\"main\",\"acceleration\",\"battery\"])\n\t}\n    preferences {\n\t\tinput \"debugOutput\", \"boolean\", \n\t\t\ttitle: \"Enable debug logging?\",\n\t\t\tdefaultValue: false,\n\t\t\tdisplayDuringSetup: true\n\t}\n}\n\ndef updated()\n{\n\tupdateDataValue(\"configured\", \"false\")\n\tstate.debug = (\"true\" == debugOutput)\n}\n\ndef parse(String description)\n{\n\tdef result = null\n\tif (description != \"updated\") {  \n\t\tdef cmd = zwave.parse(description, [0x31: 5, 0x71:3, 0x7A: 2, 0x81: 1, 0x84: 2, 0x86: 1])\n\t\tif (cmd) {\n\t\t\tresult = zwaveEvent(cmd)\n\t\t}\n\t}\n\tif (state.debug) log.debug \"Parsed '${description}' to ${result.inspect()}\"\n\treturn result\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.wakeupv2.WakeUpNotification cmd) \n{\n\tdef result = [createEvent(descriptionText: \"${device.displayName} woke up\", isStateChange: false)]\n\tif (!isConfigured()) {\n\t\t// we're still in the process of configuring a newly joined device\n\t\tif (state.debug) log.debug(\"late configure\")\n\t\tresult += response(configure())\n\t} else {\n\t\tresult += response(zwave.wakeUpV1.wakeUpNoMoreInformation())\n\t}\n\tresult\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.manufacturerspecificv2.DeviceSpecificReport cmd) {\n\tif (state.debug) log.debug \"---MANUFACTURER SPECIFIC REPORT V2--- ${device.displayName} sent deviceIdDataFormat: ${cmd.deviceIdDataFormat}, deviceIdDataLengthIndicator: ${cmd.deviceIdDataLengthIndicator}, deviceIdType: ${cmd.deviceIdType}, payload: ${cmd.payload}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.versionv1.VersionCommandClassReport cmd) {\n\tif (state.debug) log.debug \"---COMMAND CLASS VERSION REPORT V1--- ${device.displayName} has command class version: ${cmd.commandClassVersion} - payload: ${cmd.payload}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.versionv1.VersionReport cmd) {\n\tdef fw = \"${cmd.applicationVersion}.${cmd.applicationSubVersion}\"\n\tupdateDataValue(\"fw\", fw)\n\tif (state.debug) log.debug \"---VERSION REPORT V1--- ${device.displayName} is running firmware version: $fw, Z-Wave version: ${cmd.zWaveProtocolVersion}.${cmd.zWaveProtocolSubVersion}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.batteryv1.BatteryReport cmd) {\n\tdef map = [ name: \"battery\", unit: \"%\" ]\n\tif (cmd.batteryLevel == 0xFF) {\n\t\tmap.value = 1\n\t\tmap.descriptionText = \"${device.displayName} battery is low\"\n\t\tmap.isStateChange = true\n\t} else {\n\t\tmap.value = cmd.batteryLevel\n\t}\n\tstate.lastbatt = now()\n\tcreateEvent(map)\n}\n\ndef motionEvent(value) {\n\tdef map = [name: \"motion\"]\n\tif (value != 0) {\n\t\tmap.value = \"active\"\n\t\tmap.descriptionText = \"$device.displayName detected motion\"\n\t} else {\n\t\tmap.value = \"inactive\"\n\t\tmap.descriptionText = \"$device.displayName motion has stopped\"\n\t}\n\tcreateEvent(map)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicSet cmd) {\n\tif (state.debug) log.debug \"---BASIC SET REPORT V1--- ${device.displayName} sent value: ${cmd.value}\"\n\tmotionEvent(cmd.value)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.notificationv3.NotificationReport cmd) {\nif (state.debug) log.debug \"---NOTIFICATION REPORT V3--- ${device.displayName} sent eventParametersLength: ${cmd.eventParametersLength} eventParameter: ${cmd.eventParameter} notificationType: ${cmd.notificationType} event: ${cmd.event}\"\t\ndef result = []\nif (cmd.notificationType == 7) {\n\tif (cmd.eventParameter == [8] && cmd.event == 0x00) {\n\t\tresult << motionEvent(0)\n        }\n    else if (cmd.event == 0x03) {\n    \tresult << createEvent(name: \"acceleration\", value: \"active\", descriptionText: \"$device.displayName has been deactivated by the switch.\")\n\t\t}\n\telse if (cmd.event == 0X00 || cmd.eventParameter == 0x03) {\n\t\tresult << createEvent(name: \"acceleration\", value: \"inactive\", descriptionText: \"$device.displayName has been reactivated by the switch.\")\n    }\n\telse if (cmd.event == 0x08) {\n    \tresult << motionEvent(255)\n\t}\n}\nelse {\n\tresult << createEvent(descriptionText: cmd.toString(), isStateChange: false)\n}\n\tresult\n}\n\ndef zwaveEvent(physicalgraph.zwave.Command cmd) {\n\tcreateEvent(descriptionText: cmd.toString(), isStateChange: false)\n}\n\ndef configure() {\n\tif (state.debug) log.debug \"--Sending configuration commands to zooZ motion sensor--\"\n    if (state.debug) log.debug \"settings: ${settings.inspect()}, state: ${state.inspect()}\"\n    setConfigured()\n\tdef request = [\n\t\t// set wakeup interval to 20 mins\n\t\tzwave.wakeUpV1.wakeUpIntervalSet(seconds:1200, nodeid:zwaveHubNodeId),\n\t\t\n\t\t// Can use the zwaveHubNodeId variable to add the hub to the device's associations:\n\t\tzwave.associationV1.associationSet(groupingIdentifier:2, nodeId:zwaveHubNodeId),\n\t\t\n\t\t//Get association\n\t\tzwave.associationV1.associationGet(groupingIdentifier:1),\n        zwave.associationV1.associationGet(groupingIdentifier:2),\n\n\t\t// Get Version information\n        zwave.versionV1.versionGet(),\n\n\t\t// get updated battery and sensor data\n        zwave.batteryV1.batteryGet(),\n    ]\n\tcommands(request) + [\"delay 20000\", zwave.wakeUpV1.wakeUpNoMoreInformation().format()]\n}\n\nprivate setConfigured() {\n\tupdateDataValue(\"configured\", \"true\")\n    return []\n}\n\nprivate isConfigured() {\n\tgetDataValue(\"configured\") == \"true\"\n}\n\nprivate command(physicalgraph.zwave.Command cmd) {\n\tcmd.format()\n}\n\nprivate commands(commands, delay=1000) {\n\tdelayBetween(commands.collect{ command(it) }, delay)\n}"
  },
  {
    "path": "zooZ-Motion-Sensor-ZSE02/device_type-zooZ-Motion-Sensor-ZSE02_v1.2",
    "content": "/*\n * V 1.2 of zooZ motion sensor ZSE-02 code 5/14/16\n * by Robert Vandervoort\n *\n *  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except\n *  in compliance with the License. You may obtain a copy of the License at:\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n *  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed\n *  on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License\n *  for the specific language governing permissions and limitations under the License.\n * \n---------------------------------------------------------------------------------------------------------------------------\n   INSTRUCTIONS:\n   * First you will need to create a new device handler in SmartThings. Log in to the IDE and click on Device Handlers in the top menu.\n   Then click \"from code\" below. You'l be presented with a blank area where you can copy this code and paste it in.\n   * Next, scroll to the bottom and click create. Now click save, then click publish > for me.\n   * You should now see this device type in your list of device handlers. Now we need to pair the device.\n   * Put SmartThings into inclusion mode by going through the add new device dialog.\n   * Tap zwave sensor on the app screen to configure.\n   * Now go to your devices list in the SmartThings app and open up the newly added sensor.\n   * The configuration and battery state will get pulled by pressing the button once, waiting a couple seconds, and pressing again.\n   * From here on, each time the motion sensor wakes up it will query for battery level. That's it. If you see the red circle in the app \n\tthat says disabled, press the switch once again so it turns green and you're now monitoring for motion. Press again to disable the sensor.\n   \n */\n \n metadata {\n\tdefinition (name: \"zooZ motion sensor ZSE-02 - RV 1.2\", namespace: \"robertvandervoort\", author: \"Robert Vandervoort\") {\n\t\tcapability \"Motion Sensor\"\n\t\tcapability \"Acceleration Sensor\"\n\t\tcapability \"Sensor\"\n\t\tcapability \"Battery\"\n\t\t\n        // RAW Description: 0 0 0x0701 0 0 0 a 0x5E 0x85 0x59 0x71 0x80 0x5A 0x73 0x84 0x72 0x86\n\t\tattribute \"tamper\", \"enum\", [\"detected\", \"clear\"]\n\t\tfingerprint deviceId: \"0x0701\", inClusters: \"0x5E 0x85 0x59 0x71 0x80 0x5A 0x73 0x84 0x72 0x86\"\n\t\t}\nsimulator {\n\t\tstatus \"no motion\" : \"command: 9881, payload: 00300300\"\n\t\tstatus \"motion\"    : \"command: 9881, payload: 003003FF\"\n        status \"clear\" : \" command: 9881, payload: 0071050000000007030000\"\n        status \"tamper\" : \"command: 9881, payload: 007105000000FF07030000\"\n        \n\t\tfor (int i in [0, 5, 10, 15, 50, 99, 100]) {\n\t\t\tstatus \"battery ${i}%\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().batteryV1.batteryReport(\n                batteryLevel: i\n                )\n\t\t\t).incomingMessage()\n\t\t}\n\t\tstatus \"low battery alert\": new physicalgraph.zwave.Zwave().securityV1.securityMessageEncapsulation().encapsulate(\n\t\t\t\tnew physicalgraph.zwave.Zwave().batteryV1.batteryReport(\n            \tbatteryLevel: 255\n            \t)\n\t\t\t).incomingMessage()\n\t\tstatus \"wake up\": \"command: 8407, payload:\"\n\t}\n\ttiles (scale: 2) {\n\t\tmultiAttributeTile(name:\"main\", type: \"generic\", width: 6, height: 4){\n\t\t\ttileAttribute (\"device.motion\", key: \"PRIMARY_CONTROL\") {\n\t\t\t\tattributeState \"active\", label:'motion', icon:\"st.motion.motion.active\", backgroundColor:\"#53a7c0\"\n\t\t\t\tattributeState \"inactive\", label:'no motion', icon:\"st.motion.motion.inactive\", backgroundColor:\"#ffffff\"\n\t\t\t}\n\t\t}\n\t\tstandardTile(\"acceleration\", \"device.acceleration\", width: 2, height: 2) {\n\t\t\tstate(\"active\", label:'DISABLED', backgroundColor:\"#ff0000\")\n\t\t\tstate(\"inactive\", label:'ENABLED', backgroundColor:\"#00ff00\")\n\t\t}\n\t\tvalueTile(\"battery\", \"device.battery\", decoration: \"flat\", width: 2, height: 2) {\n\t\t\tstate \"battery\", label:'${currentValue}% battery', unit:\"\"\n\t\t}\n\t\tmain([\"main\"])\n\t\tdetails([\"main\",\"acceleration\",\"battery\"])\n\t}\n    preferences {\n\t\tinput \"debugOutput\", \"boolean\", \n\t\t\ttitle: \"Enable debug logging?\",\n\t\t\tdefaultValue: false,\n\t\t\tdisplayDuringSetup: true\n\t}\n}\n\ndef updated()\n{\n\tupdateDataValue(\"configured\", \"false\")\n\tstate.debug = (\"true\" == debugOutput)\n}\n\ndef parse(String description)\n{\n\tdef result = null\n\tif (description != \"updated\") {  \n\t\tdef cmd = zwave.parse(description, [0x31: 5, 0x71:3, 0x7A: 2, 0x81: 1, 0x84: 2, 0x86: 1])\n\t\tif (cmd) {\n\t\t\tresult = zwaveEvent(cmd)\n\t\t}\n\t}\n\tif (state.debug) log.debug \"Parsed '${description}' to ${result.inspect()}\"\n\treturn result\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.wakeupv2.WakeUpNotification cmd) {\n\tdef result = createEvent(descriptionText: \"${device.displayName} woke up\", displayed: true)\n    def cmds = []\n\tif (!isConfigured()) {\n\t\t// we're still in the process of configuring a newly joined device\n\t\tif (state.debug) log.debug(\"late configure\")\n\t\t[result, response(configure())]\n\t} else if (isConfigured()){\n\t\tcmds << zwave.batteryV1.batteryGet().format()\n\t\tcmds << \"delay 3000\"\n\t\tcmds << zwave.wakeUpV1.wakeUpNoMoreInformation().format()\n\t\t[result, response(cmds)]\n\t}\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.manufacturerspecificv2.DeviceSpecificReport cmd) {\n\tif (state.debug) log.debug \"---MANUFACTURER SPECIFIC REPORT V2--- ${device.displayName} sent deviceIdDataFormat: ${cmd.deviceIdDataFormat}, deviceIdDataLengthIndicator: ${cmd.deviceIdDataLengthIndicator}, deviceIdType: ${cmd.deviceIdType}, payload: ${cmd.payload}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.versionv1.VersionCommandClassReport cmd) {\n\tif (state.debug) log.debug \"---COMMAND CLASS VERSION REPORT V1--- ${device.displayName} has command class version: ${cmd.commandClassVersion} - payload: ${cmd.payload}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.versionv1.VersionReport cmd) {\n\tdef fw = \"${cmd.applicationVersion}.${cmd.applicationSubVersion}\"\n\tupdateDataValue(\"fw\", fw)\n\tif (state.debug) log.debug \"---VERSION REPORT V1--- ${device.displayName} is running firmware version: $fw, Z-Wave version: ${cmd.zWaveProtocolVersion}.${cmd.zWaveProtocolSubVersion}\"\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.batteryv1.BatteryReport cmd) {\n\tif (state.debug) log.debug \"---BATTERY V1 REPORT--- ${device.displayName} reports battery level of ${cmd.batteryLevel}\"\n\tdef result = []\n\tdef map = [ name: \"battery\", unit: \"%\" ]\n\tif (cmd.batteryLevel == 0xFF) {\n\t\tmap.value = 1\n\t\tmap.descriptionText = \"${device.displayName} battery is low\"\n\t\tmap.isStateChange = true\n\t} else {\n\t\tmap.value = cmd.batteryLevel\n\t\tmap.descriptionText = \"${device.displayName} battery is at ${cmd.batteryLevel}\"\n\t\tmap.isStateChange = true\n\t}\n\tstate.lastbatt = now()\n\tresult << createEvent(map)\n\tresult\n}\n\ndef motionEvent(value) {\n\tdef map = [name: \"motion\"]\n\tif (value != 0) {\n\t\tmap.value = \"active\"\n\t\tmap.descriptionText = \"$device.displayName detected motion\"\n\t} else {\n\t\tmap.value = \"inactive\"\n\t\tmap.descriptionText = \"$device.displayName motion has stopped\"\n\t}\n\tcreateEvent(map)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicSet cmd) {\n\tif (state.debug) log.debug \"---BASIC SET REPORT V1--- ${device.displayName} sent value: ${cmd.value}\"\n\tmotionEvent(cmd.value)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.notificationv3.NotificationReport cmd) {\nif (state.debug) log.debug \"---NOTIFICATION REPORT V3--- ${device.displayName} sent eventParametersLength: ${cmd.eventParametersLength} eventParameter: ${cmd.eventParameter} notificationType: ${cmd.notificationType} event: ${cmd.event}\"\t\ndef result = []\nif (cmd.notificationType == 7) {\n\tif (cmd.eventParameter == [8] && cmd.event == 0x00) {\n\t\tresult << motionEvent(0)\n        }\n    else if (cmd.event == 0x03) {\n    \tresult << createEvent(name: \"acceleration\", value: \"active\", descriptionText: \"$device.displayName has been deactivated by the switch.\")\n\t\t}\n\telse if (cmd.eventParameter == [3] && cmd.event == 0X00) {\n\t\tresult << createEvent(name: \"acceleration\", value: \"inactive\", descriptionText: \"$device.displayName has been reactivated by the switch.\")\n    }\n\telse if (cmd.event == 0x08) {\n    \tresult << motionEvent(255)\n\t}\n}\nelse {\n\tresult << createEvent(descriptionText: cmd.toString(), isStateChange: false)\n}\n\tresult\n}\n\ndef zwaveEvent(physicalgraph.zwave.Command cmd) {\n\tcreateEvent(descriptionText: cmd.toString(), isStateChange: false)\n}\n\ndef configure() {\n\tif (state.debug) log.debug \"--Sending configuration commands to zooZ motion sensor--\"\n    if (state.debug) log.debug \"settings: ${settings.inspect()}, state: ${state.inspect()}\"\n    setConfigured()\n\tdef request = [\n\t\t// set wakeup interval to 20 mins\n\t\tzwave.wakeUpV1.wakeUpIntervalSet(seconds:1200, nodeid:zwaveHubNodeId),\n\t\t\n\t\t// Can use the zwaveHubNodeId variable to add the hub to the device's associations:\n\t\tzwave.associationV1.associationSet(groupingIdentifier:2, nodeId:zwaveHubNodeId),\n\t\t\n\t\t//Get association\n\t\tzwave.associationV1.associationGet(groupingIdentifier:1),\n        zwave.associationV1.associationGet(groupingIdentifier:2),\n\n\t\t// Get Version information\n        zwave.versionV1.versionGet(),\n\n\t\t// get updated battery data\n        zwave.batteryV1.batteryGet(),\n    ]\n\tcommands(request) + [\"delay 20000\", zwave.wakeUpV1.wakeUpNoMoreInformation().format()]\n}\n\nprivate setConfigured() {\n\tupdateDataValue(\"configured\", \"true\")\n    return []\n}\n\nprivate isConfigured() {\n\tgetDataValue(\"configured\") == \"true\"\n}\n\nprivate command(physicalgraph.zwave.Command cmd) {\n\tcmd.format()\n}\n\nprivate commands(commands, delay=1000) {\n\tdelayBetween(commands.collect{ command(it) }, delay)\n}\n"
  },
  {
    "path": "zooZ-Strip-ZEN20/device_type-zooZ-strip-ZEN20_v1.0",
    "content": "/**\n *  Derived from Aeon Smart Strip code Copyright 2015 SmartThings\n *\treworked 6/2016 by Robert Vandervoort\n *\n *  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except\n *  in compliance with the License. You may obtain a copy of the License at:\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n *  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed\n *  on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License\n *  for the specific language governing permissions and limitations under the License.\n *\n */\nmetadata {\n\tdefinition (name: \"zooZ ZEN20 - Z-Wave plus power strip\", namespace: \"robertvandervoort\", author: \"Robert Vandervoort\") {\n\t\tcapability \"Switch\"\n\t\tcapability \"Refresh\"\n\t\tcapability \"Configuration\"\n\t\tcapability \"Actuator\"\n        capability \"Zw Multichannel\"\n\n\t\t(1..5).each { n ->\n\t\t\tattribute \"switch$n\", \"enum\", [\"on\", \"off\"]\n\t\t\tcommand \"on$n\"\n\t\t\tcommand \"off$n\"\n\t\t}\n        //RAW DESC 0 0 0x1004 0 0 0 b 0x5E 0x85 0x59 0x5A 0x72 0x60 0x8E 0x73 0x27 0x25 0x86\n\t\t// Device reset locally 0x5A, multi channel assoc 0x8E, powerlevel 0x73\n\t\tfingerprint deviceId: \"0x1004\", inClusters: \"0x5E,0x85,0x59,0x5A,0x72,0x60,0x8E,0x73,0x27,0x25,0x86\"\n\t}\n\n\t// simulator metadata\n\tsimulator {\n\t\tstatus \"on\":  \"command: 2003, payload: FF\"\n\t\tstatus \"off\":  \"command: 2003, payload: 00\"\n\t\tstatus \"switch1 on\": \"command: 600D, payload: 01 00 25 03 FF\"\n\t\tstatus \"switch1 off\": \"command: 600D, payload: 01 00 25 03 00\"\n\t\tstatus \"switch5 on\": \"command: 600D, payload: 05 00 25 03 FF\"\n\t\tstatus \"switch5 off\": \"command: 600D, payload: 05 00 25 03 00\"\n\t\t// reply messages\n\t\treply \"2001FF,delay 100,2502\": \"command: 2503, payload: FF\"\n\t\treply \"200100,delay 100,2502\": \"command: 2503, payload: 00\"\n\t}\n\n\t// tile definitions\n\ttiles {\n    \t(1..5).each { n ->\n\t\t\tstandardTile(\"switch$n\", \"switch$n\", width: 1, height: 1, canChangeIcon: true) {\n\t\t\t\tstate \"on\", label: '${name}', action: \"off$n\", icon: \"st.switches.switch.on\", backgroundColor: \"#79b821\"\n\t\t\t\tstate \"off\", label: '${name}', action: \"on$n\", icon: \"st.switches.switch.off\", backgroundColor: \"#ffffff\"\n\t\t\t}\n        \tvalueTile(\"label$n\", \"socket $n\", width: 2, height: 1, decoration: \"flat\") {\n           \t\tstate \"default\", label: \"$n\", defaultState: true\n        \t}\n        }\n\t\tstandardTile(\"refresh\", \"device.power\", inactiveLabel: false, decoration: \"flat\") {\n\t\t\tstate \"default\", label:'', action:\"refresh.refresh\", icon:\"st.secondary.refresh\"\n\t\t}\n\t\tmain([\"switch1\"])\n\t\tdetails([\"switch1\", \"label1\", \"switch2\", \"label2\", \"switch3\", \"label3\", \"switch4\", \"label4\", \"switch5\", \"label5\"])\n\t}\n}\n\n\ndef parse(String description) {\n\tdef result = null\n\tif (description.startsWith(\"Err\")) {\n\t\tresult = createEvent(descriptionText:description, isStateChange:true)\n\t} else if (description != \"updated\") {\n\t\tdef cmd = zwave.parse(description, [0x60: 3, 0x32: 3, 0x25: 1, 0x20: 1])\n\t\tif (cmd) {\n\t\t\tresult = zwaveEvent(cmd, null)\n\t\t}\n\t}\n\tlog.debug \"parsed '${description}' to ${result.inspect()}\"\n\tresult\n}\n\ndef endpointEvent(endpoint, map) {\n\tif (endpoint) {\n\t\tmap.name = map.name + endpoint.toString()\n\t}\n\tcreateEvent(map)\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicReport cmd, endpoint) {\n\tdef map = [name: \"switch\", type: \"physical\", value: (cmd.value ? \"on\" : \"off\")]\n\tdef events = [endpointEvent(endpoint, map)]\n\tdef cmds = []\n\tif (endpoint) {\n\t\tcmds += delayBetween([2,0].collect { s -> encap(zwave.meterV3.meterGet(scale: s), endpoint) }, 1000)\n\t\tif(endpoint < 5) cmds += [\"delay 1500\", encap(zwave.basicV1.basicGet(), endpoint + 1)]\n\t} else if (events[0].isStateChange) {\n\t\tevents += (1..5).collect { ep -> endpointEvent(ep, map.clone()) }\n\t\tcmds << \"delay 3000\"\n\t\tcmds += delayBetween((0..5).collect { ep -> encap(zwave.meterV3.meterGet(scale: 2), ep) }, 800)\n\t}\n\tif(cmds) events << response(cmds)\n\tevents\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.switchbinaryv1.SwitchBinaryReport cmd, endpoint) {\n\tdef map = [name: \"switch\", value: (cmd.value ? \"on\" : \"off\")]\n\tdef events = [endpointEvent(endpoint, map)]\n\tdef cmds = []\n\tif (!endpoint && events[0].isStateChange) {\n\t\tevents += (1..5).collect { ep -> endpointEvent(ep, map.clone()) }\n\t}\n\tevents\n}\n\ndef zwaveEvent(physicalgraph.zwave.commands.manufacturerspecificv2.ManufacturerSpecificReport cmd, ep) {\n\tupdateDataValue(\"MSR\", String.format(\"%04X-%04X-%04X\", cmd.manufacturerId, cmd.productTypeId, cmd.productId))\n\tnull\n}\n\ndef zwaveEvent(physicalgraph.zwave.Command cmd, ep) {\n\tlog.debug \"${device.displayName}: Unhandled ${cmd}\" + (ep ? \" from endpoint $ep\" : \"\")\n}\n\ndef onOffCmd(value, endpoint = null) {\n\t[\n\t\tencap(zwave.basicV1.basicSet(value: value), endpoint),\n\t\t\"delay 500\",\n\t\tencap(zwave.switchBinaryV1.switchBinaryGet(), endpoint)\n\t]\n}\n\ndef on() { onOffCmd(0xFF) }\ndef off() { onOffCmd(0x0) }\n\ndef on1() { onOffCmd(0xFF, 1) }\ndef on2() { onOffCmd(0xFF, 2) }\ndef on3() { onOffCmd(0xFF, 3) }\ndef on4() { onOffCmd(0xFF, 4) }\ndef on5() { onOffCmd(0xFF, 5) }\n\ndef off1() { onOffCmd(0, 1) }\ndef off2() { onOffCmd(0, 2) }\ndef off3() { onOffCmd(0, 3) }\ndef off4() { onOffCmd(0, 4) }\ndef off5() { onOffCmd(0, 5) }\n\ndef refresh() {\n\tdelayBetween([\n\t\tzwave.basicV1.basicGet().format(),\n\t\tencap(zwave.basicV1.basicGet(), 1)  // further gets are sent from the basic report handler\n\t])\n}\n\ndef configure() {\n\tdef cmds = [\n\t\t//zwave.configurationV1.configurationSet(parameterNumber: 101, size: 4, configurationValue: [0, 0, 0, 1]).format(),\n\t\t//zwave.configurationV1.configurationSet(parameterNumber: 102, size: 4, configurationValue: [0, 0, 0x79, 0]).format(),\n\t\t//zwave.configurationV1.configurationSet(parameterNumber: 112, size: 4, scaledConfigurationValue: 90).format(),\n\t]\n\t[5, 8, 9, 10, 11].each { p ->\n\t\tcmds << zwave.configurationV1.configurationSet(parameterNumber: p, size: 2, scaledConfigurationValue: 5).format()\n\t}\n\t[12, 15, 16, 17, 18].each { p ->\n\t\tcmds << zwave.configurationV1.configurationSet(parameterNumber: p, size: 1, scaledConfigurationValue: 50).format()\n\t}\n\tcmds += [\n\t\t//zwave.configurationV1.configurationSet(parameterNumber: 111, size: 4, scaledConfigurationValue: 15*60).format(),\n\t\t//zwave.configurationV1.configurationSet(parameterNumber: 4, size: 1, configurationValue: [1]).format(),\n\t]\n\tdelayBetween(cmds) + \"delay 5000\" + refresh()\n}\n\nprivate encap(cmd, endpoint) {\n\tif (endpoint) {\n\t\tzwave.multiChannelV3.multiChannelCmdEncap(destinationEndPoint:endpoint).encapsulate(cmd).format()\n\t} else {\n\t\tcmd.format()\n\t}\n}"
  }
]