Skip to content

Commit 807ff53

Browse files
authored
Merge pull request SmartThingsCommunity#2036 from SmartThingsCommunity/master
Rolling up master to staging
2 parents 5242780 + f95319c commit 807ff53

File tree

11 files changed

+440
-26
lines changed

11 files changed

+440
-26
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
/**
2+
* Copyright 2017 SmartThings
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5+
* in compliance with the License. You may obtain a copy of the License at:
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
10+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
11+
* for the specific language governing permissions and limitations under the License.
12+
*
13+
* Everspring ST815 Illuminance Sensor
14+
*
15+
* Author: SmartThings
16+
* Date: 2017-3-4
17+
*/
18+
19+
metadata {
20+
definition (name: "Everspring Illuminance Sensor", namespace: "smartthings", author: "SmartThings") {
21+
capability "Illuminance Measurement"
22+
capability "Battery"
23+
capability "Configuration"
24+
capability "Sensor"
25+
capability "Health Check"
26+
27+
fingerprint mfr:"0060", prod:"0007", model:"0001"
28+
}
29+
30+
simulator {
31+
for( int i = 0; i <= 100; i += 20 ) {
32+
status "illuminace ${i} lux": new physicalgraph.zwave.Zwave().sensorMultilevelV2.sensorMultilevelReport(
33+
scaledSensorValue: i, precision: 0, sensorType: 3, scale: 1).incomingMessage()
34+
}
35+
36+
for( int i = 0; i <= 100; i += 20 ) {
37+
status "battery ${i}%": new physicalgraph.zwave.Zwave().batteryV1.batteryReport(
38+
batteryLevel: i).incomingMessage()
39+
}
40+
41+
status "wakeup": "command: 8407, payload: "
42+
}
43+
44+
tiles(scale: 2) {
45+
valueTile("temperature", "device.temperature", inactiveLabel: false, width: 2, height: 2) {
46+
state "temperature", label:'${currentValue}°',
47+
backgroundColors:[
48+
[value: 32, color: "#153591"],
49+
[value: 44, color: "#1e9cbb"],
50+
[value: 59, color: "#90d2a7"],
51+
[value: 74, color: "#44b621"],
52+
[value: 84, color: "#f1d801"],
53+
[value: 92, color: "#d04e00"],
54+
[value: 98, color: "#bc2323"]
55+
]
56+
}
57+
valueTile("humidity", "device.humidity", inactiveLabel: false, width: 2, height: 2) {
58+
state "humidity", label:'${currentValue}% humidity', unit:""
59+
}
60+
valueTile("battery", "device.battery", inactiveLabel: false, decoration: "flat", width: 2, height: 2) {
61+
state "battery", label:'${currentValue}% battery', unit:""
62+
}
63+
64+
main( ["temperature", "humidity"] )
65+
details( ["temperature", "humidity", "battery"] )
66+
}
67+
}
68+
69+
def updated() {
70+
state.configured = false
71+
}
72+
73+
def parse(String description) {
74+
def result = []
75+
76+
def cmd = zwave.parse(description, [0x20: 1, 0x31: 2, 0x70: 1, 0x71: 1, 0x80: 1, 0x84: 2, 0x85: 2])
77+
78+
if (cmd) {
79+
result = zwaveEvent(cmd)
80+
}
81+
82+
if (result instanceof List) {
83+
log.debug "Parsed '$description' to ${result.collect { it.respondsTo("toHubAction") ? it.toHubAction() : it }}"
84+
} else {
85+
log.debug "Parsed '$description' to ${result}"
86+
}
87+
return result
88+
}
89+
90+
def zwaveEvent(physicalgraph.zwave.commands.wakeupv2.WakeUpNotification cmd) {
91+
def result = [
92+
createEvent(descriptionText: "${device.displayName} woke up", isStateChange: false)
93+
]
94+
if (state.configured) {
95+
result << response(zwave.batteryV1.batteryGet())
96+
} else {
97+
result << response(configure())
98+
}
99+
return result
100+
}
101+
102+
def zwaveEvent(physicalgraph.zwave.commands.alarmv1.AlarmReport cmd) {
103+
if (cmd.alarmType == 1 && cmd.alarmType == 0xFF) {
104+
return createEvent(descriptionText: "${device.displayName} battery is low", isStateChange: true)
105+
} else if (cmd.alarmType == 2 && cmd.alarmLevel == 1) {
106+
return createEvent(descriptionText: "${device.displayName} powered up", isStateChange: false)
107+
}
108+
}
109+
110+
def zwaveEvent(physicalgraph.zwave.commands.sensormultilevelv2.SensorMultilevelReport cmd) {
111+
112+
def map = [:]
113+
switch( cmd.sensorType ) {
114+
case 3:
115+
// luminance
116+
map.value = cmd.scaledSensorValue.toInteger().toString()
117+
map.unit = "lux"
118+
map.name = "illuminance"
119+
break;
120+
}
121+
122+
return createEvent(map)
123+
}
124+
125+
def zwaveEvent(physicalgraph.zwave.commands.batteryv1.BatteryReport cmd) {
126+
def map = [ name: "battery", unit: "%" ]
127+
if (cmd.batteryLevel == 0xFF) {
128+
map.value = 1
129+
map.descriptionText = "${device.displayName} has a low battery"
130+
map.isStateChange = true
131+
} else {
132+
map.value = cmd.batteryLevel
133+
}
134+
135+
def response_cmds = []
136+
if (!currentTemperature) {
137+
response_cmds << zwave.sensorMultilevelV2.sensorMultilevelGet().format()
138+
response_cmds << "delay 1000"
139+
}
140+
response_cmds << zwave.wakeUpV1.wakeUpNoMoreInformation().format()
141+
142+
return [createEvent(map), response(response_cmds)]
143+
}
144+
145+
def zwaveEvent(physicalgraph.zwave.Command cmd) {
146+
log.debug "Unhandled: ${cmd.toString()}"
147+
return [:]
148+
}
149+
150+
def configure() {
151+
state.configured = true
152+
sendEvent(name: "checkInterval", value: 8 * 60 * 60 + 2 * 60, displayed: false, data: [protocol: "zwave", hubHardwareId: device.hub.hardwareID])
153+
delayBetween([
154+
// Auto report time interval in minutes
155+
zwave.configurationV1.configurationSet(parameterNumber: 5, size: 2, scaledConfigurationValue: 20).format(),
156+
157+
// Auto report lux change threshold
158+
zwave.configurationV1.configurationSet(parameterNumber: 6, size: 2, scaledConfigurationValue: 30).format(),
159+
160+
// Get battery – report triggers WakeUpNMI
161+
zwave.batteryV1.batteryGet().format()
162+
])
163+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
/**
2+
* Copyright 2017 SmartThings
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5+
* in compliance with the License. You may obtain a copy of the License at:
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
10+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
11+
* for the specific language governing permissions and limitations under the License.
12+
*
13+
* Everspring ST814 Temperature/Humidity Sensor
14+
*
15+
* Author: SmartThings
16+
* Date: 2017-3-4
17+
*/
18+
19+
metadata {
20+
definition (name: "Everspring ST814", namespace: "smartthings", author: "SmartThings") {
21+
capability "Temperature Measurement"
22+
capability "Relative Humidity Measurement"
23+
capability "Battery"
24+
capability "Configuration"
25+
capability "Sensor"
26+
capability "Health Check"
27+
28+
fingerprint mfr:"0060", prod:"0006", model:"0001"
29+
}
30+
31+
simulator {
32+
for( int i = 0; i <= 100; i += 20 ) {
33+
status "temperature ${i}F": new physicalgraph.zwave.Zwave().sensorMultilevelV2.sensorMultilevelReport(
34+
scaledSensorValue: i, precision: 1, sensorType: 1, scale: 1).incomingMessage()
35+
}
36+
37+
for( int i = 0; i <= 100; i += 20 ) {
38+
status "humidity ${i}%": new physicalgraph.zwave.Zwave().sensorMultilevelV2.sensorMultilevelReport(
39+
scaledSensorValue: i, precision: 0, sensorType: 5).incomingMessage()
40+
}
41+
42+
for( int i = 0; i <= 100; i += 20 ) {
43+
status "battery ${i}%": new physicalgraph.zwave.Zwave().batteryV1.batteryReport(
44+
batteryLevel: i).incomingMessage()
45+
}
46+
status "wakeup": "command: 8407, payload: "
47+
}
48+
49+
tiles(scale: 2) {
50+
valueTile("temperature", "device.temperature", inactiveLabel: false, width: 2, height: 2) {
51+
state "temperature", label:'${currentValue}°',
52+
backgroundColors:[
53+
[value: 32, color: "#153591"],
54+
[value: 44, color: "#1e9cbb"],
55+
[value: 59, color: "#90d2a7"],
56+
[value: 74, color: "#44b621"],
57+
[value: 84, color: "#f1d801"],
58+
[value: 92, color: "#d04e00"],
59+
[value: 98, color: "#bc2323"]
60+
]
61+
}
62+
valueTile("humidity", "device.humidity", inactiveLabel: false, width: 2, height: 2) {
63+
state "humidity", label:'${currentValue}% humidity', unit:""
64+
}
65+
valueTile("battery", "device.battery", inactiveLabel: false, decoration: "flat", width: 2, height: 2) {
66+
state "battery", label:'${currentValue}% battery', unit:""
67+
}
68+
69+
main( ["temperature", "humidity"] )
70+
details( ["temperature", "humidity", "battery"] )
71+
}
72+
}
73+
74+
def updated() {
75+
state.configured = false
76+
}
77+
78+
def parse(String description) {
79+
def result = []
80+
81+
def cmd = zwave.parse(description, [0x20: 1, 0x31: 2, 0x70: 1, 0x71: 1, 0x80: 1, 0x84: 2, 0x85: 2])
82+
83+
if (cmd) {
84+
result = zwaveEvent(cmd)
85+
}
86+
87+
if (result instanceof List) {
88+
log.debug "Parsed '$description' to ${result.collect { it.respondsTo("toHubAction") ? it.toHubAction() : it }}"
89+
} else {
90+
log.debug "Parsed '$description' to ${result}"
91+
}
92+
return result
93+
}
94+
95+
def zwaveEvent(physicalgraph.zwave.commands.wakeupv2.WakeUpNotification cmd) {
96+
def result = [
97+
createEvent(descriptionText: "${device.displayName} woke up", isStateChange: false)
98+
]
99+
if (state.configured) {
100+
result << response(zwave.batteryV1.batteryGet())
101+
} else {
102+
result << response(configure())
103+
}
104+
return result
105+
}
106+
107+
def zwaveEvent(physicalgraph.zwave.commands.alarmv1.AlarmReport cmd) {
108+
if (cmd.alarmType == 1 && cmd.alarmType == 0xFF) {
109+
return createEvent(descriptionText: "${device.displayName} battery is low", isStateChange: true)
110+
} else if (cmd.alarmType == 2 && cmd.alarmLevel == 1) {
111+
return createEvent(descriptionText: "${device.displayName} powered up", isStateChange: false)
112+
}
113+
}
114+
115+
def zwaveEvent(physicalgraph.zwave.commands.sensormultilevelv2.SensorMultilevelReport cmd) {
116+
117+
def map = [:]
118+
switch( cmd.sensorType ) {
119+
case 1:
120+
/* temperature */
121+
def cmdScale = cmd.scale == 1 ? "F" : "C"
122+
map.value = convertTemperatureIfNeeded(cmd.scaledSensorValue, cmdScale, cmd.precision)
123+
map.unit = getTemperatureScale()
124+
map.name = "temperature"
125+
break
126+
case 5:
127+
/* humidity */
128+
map.value = cmd.scaledSensorValue.toInteger().toString()
129+
map.unit = "%"
130+
map.name = "humidity"
131+
break
132+
}
133+
134+
return createEvent(map)
135+
}
136+
137+
def zwaveEvent(physicalgraph.zwave.commands.batteryv1.BatteryReport cmd) {
138+
def map = [ name: "battery", unit: "%" ]
139+
if (cmd.batteryLevel == 0xFF) {
140+
map.value = 1
141+
map.descriptionText = "${device.displayName} has a low battery"
142+
map.isStateChange = true
143+
} else {
144+
map.value = cmd.batteryLevel
145+
}
146+
147+
def response_cmds = []
148+
if (!currentTemperature) {
149+
response_cmds << zwave.sensorMultilevelV2.sensorMultilevelGet().format()
150+
response_cmds << "delay 1000"
151+
}
152+
response_cmds << zwave.wakeUpV1.wakeUpNoMoreInformation().format()
153+
154+
return [createEvent(map), response(response_cmds)]
155+
}
156+
157+
def zwaveEvent(physicalgraph.zwave.commands.multichannelv3.MultiChannelCmdEncap cmd) {
158+
def result = null
159+
def encapsulatedCommand = cmd.encapsulatedCommand([0x20: 1, 0x31: 2, 0x70: 1, 0x71: 1, 0x80: 1, 0x84: 2, 0x85: 2])
160+
log.debug ("Command from endpoint ${cmd.sourceEndPoint}: ${encapsulatedCommand}")
161+
if (encapsulatedCommand) {
162+
result = zwaveEvent(encapsulatedCommand)
163+
}
164+
result
165+
}
166+
167+
def zwaveEvent(physicalgraph.zwave.Command cmd) {
168+
log.debug "Unhandled: ${cmd.toString()}"
169+
return [:]
170+
}
171+
172+
def configure() {
173+
state.configured = true
174+
sendEvent(name: "checkInterval", value: 8 * 60 * 60 + 2 * 60, displayed: false, data: [protocol: "zwave", hubHardwareId: device.hub.hardwareID])
175+
delayBetween([
176+
// Auto report time interval in minutes
177+
zwave.configurationV1.configurationSet(parameterNumber: 6, size: 2, scaledConfigurationValue: 20).format(),
178+
179+
// Auto report temperature change threshold
180+
zwave.configurationV1.configurationSet(parameterNumber: 7, size: 1, scaledConfigurationValue: 2).format(),
181+
182+
// Auto report humidity change threshold
183+
zwave.configurationV1.configurationSet(parameterNumber: 8, size: 1, scaledConfigurationValue: 5).format(),
184+
185+
// Get battery – report triggers WakeUpNMI
186+
zwave.batteryV1.batteryGet().format()
187+
])
188+
}

devicetypes/smartthings/fortrezz-water-valve.src/fortrezz-water-valve.groovy

+12-9
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,22 @@ metadata {
3434
}
3535

3636
// tile definitions
37-
tiles {
38-
standardTile("contact", "device.contact", width: 2, height: 2, canChangeIcon: true) {
39-
state "open", label: '${name}', action: "valve.close", icon: "st.valves.water.open", backgroundColor: "#00A0DC", nextState:"closing"
40-
state "closed", label: '${name}', action: "valve.open", icon: "st.valves.water.closed", backgroundColor: "#ffffff", nextState:"opening"
41-
state "opening", label: '${name}', action: "valve.close", icon: "st.valves.water.open", backgroundColor: "#00A0DC"
42-
state "closing", label: '${name}', action: "valve.open", icon: "st.valves.water.closed", backgroundColor: "#ffffff"
37+
tiles(scale: 2) {
38+
multiAttributeTile(name:"valve", type: "generic", width: 6, height: 4, canChangeIcon: true){
39+
tileAttribute ("device.valve", key: "PRIMARY_CONTROL") {
40+
attributeState "open", label: '${name}', action: "valve.close", icon: "st.valves.water.open", backgroundColor: "#00A0DC", nextState:"closing"
41+
attributeState "closed", label: '${name}', action: "valve.open", icon: "st.valves.water.closed", backgroundColor: "#ffffff", nextState:"opening"
42+
attributeState "opening", label: '${name}', action: "valve.close", icon: "st.valves.water.open", backgroundColor: "#00A0DC"
43+
attributeState "closing", label: '${name}', action: "valve.open", icon: "st.valves.water.closed", backgroundColor: "#ffffff"
44+
}
4345
}
44-
standardTile("refresh", "device.switch", inactiveLabel: false, decoration: "flat") {
46+
47+
standardTile("refresh", "device.valve", width: 2, height: 2, inactiveLabel: false, decoration: "flat") {
4548
state "default", label:'', action:"refresh.refresh", icon:"st.secondary.refresh"
4649
}
4750

48-
main "contact"
49-
details(["contact","refresh"])
51+
main "valve"
52+
details(["valve","refresh"])
5053
}
5154
}
5255

devicetypes/smartthings/smartsense-multi-sensor.src/smartsense-multi-sensor.groovy

+1-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ private List<Map> handleAcceleration(descMap) {
178178
result += parseAxis(descMap.additionalAttrs)
179179
}
180180
} else if (descMap.clusterInt == 0xFC02 && descMap.attrInt == 0x0012) {
181-
def addAttrs = descMap.additionalAttrs
181+
def addAttrs = descMap.additionalAttrs ?: []
182182
addAttrs << ["attrInt": descMap.attrInt, "value": descMap.value]
183183
result += parseAxis(addAttrs)
184184
}

0 commit comments

Comments
 (0)