Skip to content

Commit

Permalink
Merge pull request SmartThingsCommunity#3548 from SmartThingsCommunit…
Browse files Browse the repository at this point in the history
…y/staging

Rolling up staging changes to production
  • Loading branch information
workingmonk committed Oct 2, 2018
2 parents 0d463f3 + a74ae9c commit b66aad2
Show file tree
Hide file tree
Showing 14 changed files with 1,056 additions and 72 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/**
* Copyright 2018 SRPOL
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at:
*
* http:https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
* for the specific language governing permissions and limitations under the License.
*
*/
metadata {
definition(name: "Child Metering Switch", namespace: "smartthings", author: "SmartThings", mnmn: "SmartThings", vid: "generic-switch-power-energy") {
capability "Switch"
capability "Power Meter"
capability "Energy Meter"
capability "Refresh"
capability "Actuator"
capability "Sensor"
capability "Health Check"

command "reset"
}

tiles(scale: 2){
multiAttributeTile(name:"switch", type: "generic", width: 6, height: 4, canChangeIcon: true){
tileAttribute("device.switch", key: "PRIMARY_CONTROL") {
attributeState("on", label: '${name}', action: "switch.off", icon: "st.switches.switch.on", backgroundColor: "#00a0dc")
attributeState("off", label: '${name}', action: "switch.on", icon: "st.switches.switch.off", backgroundColor: "#ffffff")
}
}
valueTile("power", "device.power", decoration: "flat", width: 2, height: 2) {
state "default", label:'${currentValue} W'
}
valueTile("energy", "device.energy", decoration: "flat", width: 2, height: 2) {
state "default", label:'${currentValue} kWh'
}
standardTile("refresh", "device.power", inactiveLabel: false, decoration: "flat", width: 2, height: 2) {
state "default", label:'', action:"refresh.refresh", icon:"st.secondary.refresh"
}
standardTile("reset", "device.energy", inactiveLabel: false, decoration: "flat", width: 2, height: 2) {
state "default", label:'reset kWh', action:"reset"
}

main(["switch"])
details(["switch","power","energy","refresh","reset"])
}
}

def on() {
parent.childOnOff(device.deviceNetworkId, 0xFF)
}

def off() {
parent.childOnOff(device.deviceNetworkId, 0x00)
}

def refresh() {
parent.childRefresh(device.deviceNetworkId)
}

def ping() {
refresh()
}

def reset() {
parent.childReset(device.deviceNetworkId)
}

def installed() {
sendEvent(name: "checkInterval", value: 2 * 15 * 60 + 2 * 60, displayed: false, data: [protocol: "zwave", hubHardwareId: device.hub.hardwareID, offlinePingable: "1"])
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,13 @@ def parse(String description) {
}
}

def zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicReport cmd) {
def zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicReport cmd) {
//When device is plugged in, it sends BasicReport with value "0" to parent endpoint.
//It means that parent and child devices are available, but status of child devices must be updated.
createEvents(cmd.value)
if(cmd.value == 0) {
sendHubCommand(addDelay(refreshChildren()))
}
}

def zwaveEvent(physicalgraph.zwave.commands.switchbinaryv1.SwitchBinaryReport cmd) {
Expand Down Expand Up @@ -136,12 +141,22 @@ def ping() {
}

def refresh() {
def cmds = []
def cmds = []
cmds << refreshChildren()
cmds << basicGetCmd(1)
return addDelay(cmds)
}

def refreshChildren() {
def cmds = []
endPoints.each {
cmds << basicGetCmd(it)
}
cmds << basicGetCmd(1)
return delayBetween(cmds, 200)
return cmds
}

def addDelay(cmds) {
delayBetween(cmds, 200)
}

def setSirenChildrenOff() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ metadata {
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 000F, 0B04", outClusters: "0019", manufacturer: "SmartThings", model: "outletv4", deviceJoinName: "Outlet"
fingerprint profileId: "0104", inClusters: "0000,0003,0004,0005,0006,0B04,0B05", outClusters: "0019"
fingerprint profileId: "0104", inClusters: "0000,0003,0006,0009,0B04", outClusters: "0019", manufacturer: "Samjin", model: "outlet", deviceJoinName: "Outlet"
fingerprint profileId: "0010", inClusters: "0000 0003 0004 0005 0006 0008 0702 0B05", outClusters: "0019", manufacturer: "innr", model: "SP 120", deviceJoinName: "Outlet"

fingerprint profileId: "0010", inClusters: "0000 0003 0004 0005 0006 0008 0702 0B05", outClusters: "0019", manufacturer: "innr", model: "SP 120", deviceJoinName: "Outlet"
fingerprint profileId: "0104", inClusters: "0000,0002,0003,0004,0005,0006,0009,0B04,0702", outClusters: "0019,000A,0003,0406", manufacturer: "Aurora", model: "SmartPlug51AU", deviceJoinName: "Aurora SmartPlug"
}

// simulator metadata
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ metadata {

fingerprint deviceId: "0x2001", inClusters: "0x30,0x9C,0x9D,0x85,0x80,0x72,0x31,0x84,0x86"
fingerprint deviceId: "0x2101", inClusters: "0x71,0x70,0x85,0x80,0x72,0x31,0x84,0x86"
fingerprint mfr:"0084", prod:"0063", model:"010C", deviceJoinName: "FortrezZ Moisture Sensor"
fingerprint mfr:"0084", prod:"0063", model:"010C"
fingerprint mfr:"0084", prod:"0053", model:"0216", deviceJoinName: "FortrezZ Moisture Sensor"
}

simulator {
Expand All @@ -48,18 +49,18 @@ metadata {
state "overheated", icon:"st.alarm.temperature.overheat", backgroundColor:"#e86d13"
}
valueTile("temperature", "device.temperature", width: 2, height: 2) {
state("temperature", label:'${currentValue}°',
backgroundColors:[
[value: 31, color: "#153591"],
[value: 44, color: "#1e9cbb"],
[value: 59, color: "#90d2a7"],
[value: 74, color: "#44b621"],
[value: 84, color: "#f1d801"],
[value: 95, color: "#d04e00"],
[value: 96, color: "#bc2323"]
]
)
}
state("temperature", label:'${currentValue}°',
backgroundColors:[
[value: 31, color: "#153591"],
[value: 44, color: "#1e9cbb"],
[value: 59, color: "#90d2a7"],
[value: 74, color: "#44b621"],
[value: 84, color: "#f1d801"],
[value: 95, color: "#d04e00"],
[value: 96, color: "#bc2323"]
]
)
}
valueTile("battery", "device.battery", decoration: "flat", inactiveLabel: false, width: 2, height: 2) {
state "battery", label:'${currentValue}% battery', unit:""
}
Expand Down Expand Up @@ -158,12 +159,12 @@ def zwaveEvent(physicalgraph.zwave.commands.sensormultilevelv5.SensorMultilevelR
def map = [:]
if(cmd.sensorType == 1) {
map.name = "temperature"
if(cmd.scale == 0) {
map.value = getTemperature(cmd.scaledSensorValue)
} else {
map.value = cmd.scaledSensorValue
}
map.unit = location.temperatureScale
if(cmd.scale == 0) {
map.value = getTemperature(cmd.scaledSensorValue)
} else {
map.value = cmd.scaledSensorValue
}
map.unit = location.temperatureScale
}
map
}
Expand All @@ -180,9 +181,9 @@ def zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicSet cmd)
def getTemperature(value) {
if(location.temperatureScale == "C"){
return value
} else {
return Math.round(celsiusToFahrenheit(value))
}
} else {
return Math.round(celsiusToFahrenheit(value))
}
}

def zwaveEvent(physicalgraph.zwave.Command cmd)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
import physicalgraph.zigbee.clusters.iaszone.ZoneStatus
import physicalgraph.zigbee.zcl.DataType
metadata {
definition(name: "Zigbee Motion Detector", namespace: "smartthings", author: "SmartThings", runLocally: true, minHubCoreVersion: '000.018.0000', executeCommandsLocally: true, mnmn: "SmartThings", vid: "generic-motion-2") {
definition(name: "Zigbee Motion Detector", namespace: "smartthings", author: "SmartThings", runLocally: false, mnmn: "SmartThings", vid: "generic-motion-2") {
capability "Motion Sensor"
capability "Configuration"
capability "Battery"
capability "Refresh"
capability "Health Check"
capability "Sensor"
fingerprint profileId: "0104", deviceId: "0402", inClusters: "0000,0003,0500,0001", model:"895a2d80097f4ae2b2d40500d5e03dcc", deviceJoinName: "Orvibo Motion Sensor"
fingerprint profileId: "0104", deviceId: "0402", inClusters: "0000,0003,0500,0001", manufacturer:"ORVIBO", model:"895a2d80097f4ae2b2d40500d5e03dcc", deviceJoinName: "Orvibo Motion Sensor"
}
simulator {
status "active": "zone status 0x0001 -- extended status 0x00"
Expand All @@ -50,25 +50,27 @@ metadata {
details(["motion","battery", "refresh"])
}
}

def stopMotion() {
log.debug "motion inactive"
sendEvent(getMotionResult(false))
}

def installed(){
log.debug "installed"
return zigbee.readAttribute(zigbee.POWER_CONFIGURATION_CLUSTER, 0x0021) +
zigbee.readAttribute(zigbee.IAS_ZONE_CLUSTER,zigbee.ATTRIBUTE_IAS_ZONE_STATUS)

}

def parse(String description) {
log.debug "description(): $description"
def map = zigbee.getEvent(description)
if(!map){
if (description?.startsWith('zone status')) {
map = parseIasMessage(description)
motionHandler(description);
} else {
map = batteyHandler(description);
map = batteyHandler(description)
}
}
log.debug "Parse returned $map"
Expand All @@ -80,27 +82,27 @@ def parse(String description) {
}
return result
}

def batteyHandler(String description){
def descMap = zigbee.parseDescriptionAsMap(description)
def map = [:]
if (descMap?.clusterInt == zigbee.POWER_CONFIGURATION_CLUSTER && descMap.commandInt != 0x07 && descMap.value) {
map = getBatteryPercentageResult(Integer.parseInt(descMap.value, 16))
}
return map;
return map
}
def motionHandler(String description){
//inactive
def isActive = zigbee.translateStatusZoneType19(description)
if (isActive) {

def parseIasMessage(String description) {
ZoneStatus zs = zigbee.parseZoneStatus(description)
Boolean motionActive = zs.isAlarm1Set() || zs.isAlarm2Set()
if (motionActive) {
def timeout = 3
log.debug "Stopping motion in ${timeout} seconds"
runIn(timeout, stopMotion)
}
return getMotionResult(motionActive)
}
def parseIasMessage(String description) {
ZoneStatus zs = zigbee.parseZoneStatus(description)
return getMotionResult(zs.isAlarm1Set() || zs.isAlarm2Set())
}

def getBatteryPercentageResult(rawValue) {
log.debug "Battery Percentage rawValue = ${rawValue} -> ${rawValue / 2}%"
def result = [:]
Expand All @@ -112,6 +114,7 @@ def getBatteryPercentageResult(rawValue) {
}
return result
}

def getMotionResult(value) {
def descriptionText = value ? "${device.displayName} detected motion" : "${device.displayName} motion has stopped"
return [
Expand All @@ -121,19 +124,22 @@ def getMotionResult(value) {
translatable : true
]
}

/**
* PING is used by Device-Watch in attempt to reach the Device
* */
def ping() {
log.debug "ping "
return zigbee.readAttribute(zigbee.IAS_ZONE_CLUSTER, zigbee.ATTRIBUTE_IAS_ZONE_STATUS) + zigbee.readAttribute(zigbee.POWER_CONFIGURATION_CLUSTER, 0x0021)
}

def refresh() {
log.debug "Refreshing Values"
return zigbee.readAttribute(zigbee.POWER_CONFIGURATION_CLUSTER, 0x0021) +
zigbee.readAttribute(zigbee.IAS_ZONE_CLUSTER,zigbee.ATTRIBUTE_IAS_ZONE_STATUS) +
zigbee.enrollResponse()
}

def configure() {
log.debug "configure"
sendEvent(name: "checkInterval", value:20 * 60 + 2*60, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID, offlinePingable: "1"])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ metadata {
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006", outClusters: "0003, 0006, 0008, 0019, 0406", manufacturer: "Leviton", model: "DL15S", deviceJoinName: "Leviton Lumina RF Switch"
fingerprint profileId: "C05E", inClusters: "0000, 0003, 0004, 0005, 0006, 1000, 0B04, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "Plug 01", deviceJoinName: "OSRAM SMART+ Plug"
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0B05, FC01, FC08", outClusters: "0003, 0019", manufacturer: "LEDVANCE", model: "PLUG", deviceJoinName: "SYLVANIA SMART+ Smart Plug"
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0B05", outClusters: "0019", manufacturer: "sengled", model: "E1C-NB6", deviceJoinName: "Sengled Element Outlet"
}

// simulator metadata
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def updated() {

def configure() {
// Device-Watch simply pings if no device events received for checkInterval duration of 32min
sendEvent(name: "checkInterval", value: 30 * 60 + 2 * 60, displayed: false, data: [protocol: "zwave", hubHardwareId: device.hub.hardwareID, offlinePingable: "1"])
sendEvent(name: "checkInterval", value: 30 * 60 + 2 * 60, displayed: false, data: [protocol: "zwave", hubHardwareId: parent.hubID])
refresh()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ metadata {
fingerprint mfr: "001A", prod: "4449", model: "0101", deviceJoinName: "Eaton RF Master Dimmer"
fingerprint mfr: "001A", prod: "4449", model: "0003", deviceJoinName: "Eaton RF Dimming Plug-In Module"
fingerprint mfr: "014F", prod: "5744", model: "3530", deviceJoinName: "GoControl In-Wall Dimmer"
fingerprint mfr: "0307", prod: "4447", model: "3034", deviceJoinName: "Satco In-Wall Dimmer"
}

simulator {
Expand Down
Loading

0 comments on commit b66aad2

Please sign in to comment.