mirror of
https://github.com/mtan93/SmartThingsPublic.git
synced 2026-03-15 21:03:23 +00:00
Compare commits
1 Commits
master
...
MSA-1189-1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a27ca03edd |
@@ -1,118 +1,118 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright 2015 SmartThings
|
* Copyright 2015 SmartThings
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
* 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:
|
* in compliance with the License. You may obtain a copy of the License at:
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
|
* 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
|
* 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.
|
* for the specific language governing permissions and limitations under the License.
|
||||||
*
|
*
|
||||||
* Aeon Home Energy Meter
|
* Aeon Home Energy Meter
|
||||||
*
|
*
|
||||||
* Author: SmartThings
|
* Author: SmartThings
|
||||||
*
|
*
|
||||||
* Date: 2013-05-30
|
* Date: 2013-05-30
|
||||||
*/
|
*/
|
||||||
metadata {
|
metadata {
|
||||||
definition (name: "Aeon Home Energy Meter", namespace: "smartthings", author: "SmartThings") {
|
definition (name: "Aeon Home Energy Meter", namespace: "smartthings", author: "SmartThings") {
|
||||||
capability "Energy Meter"
|
capability "Energy Meter"
|
||||||
capability "Power Meter"
|
capability "Power Meter"
|
||||||
capability "Configuration"
|
capability "Configuration"
|
||||||
capability "Sensor"
|
capability "Sensor"
|
||||||
|
|
||||||
command "reset"
|
command "reset"
|
||||||
|
|
||||||
fingerprint deviceId: "0x2101", inClusters: " 0x70,0x31,0x72,0x86,0x32,0x80,0x85,0x60"
|
fingerprint deviceId: "0x2101", inClusters: " 0x70,0x31,0x72,0x86,0x32,0x80,0x85,0x60"
|
||||||
}
|
}
|
||||||
|
|
||||||
// simulator metadata
|
// simulator metadata
|
||||||
simulator {
|
simulator {
|
||||||
for (int i = 0; i <= 10000; i += 1000) {
|
for (int i = 0; i <= 10000; i += 1000) {
|
||||||
status "power ${i} W": new physicalgraph.zwave.Zwave().meterV1.meterReport(
|
status "power ${i} W": new physicalgraph.zwave.Zwave().meterV1.meterReport(
|
||||||
scaledMeterValue: i, precision: 3, meterType: 4, scale: 2, size: 4).incomingMessage()
|
scaledMeterValue: i, precision: 3, meterType: 4, scale: 2, size: 4).incomingMessage()
|
||||||
}
|
}
|
||||||
for (int i = 0; i <= 100; i += 10) {
|
for (int i = 0; i <= 100; i += 10) {
|
||||||
status "energy ${i} kWh": new physicalgraph.zwave.Zwave().meterV1.meterReport(
|
status "energy ${i} kWh": new physicalgraph.zwave.Zwave().meterV1.meterReport(
|
||||||
scaledMeterValue: i, precision: 3, meterType: 0, scale: 0, size: 4).incomingMessage()
|
scaledMeterValue: i, precision: 3, meterType: 0, scale: 0, size: 4).incomingMessage()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// tile definitions
|
// tile definitions
|
||||||
tiles {
|
tiles {
|
||||||
valueTile("power", "device.power", decoration: "flat") {
|
valueTile("power", "device.power", decoration: "flat") {
|
||||||
state "default", label:'${currentValue} W'
|
state "default", label:'${currentValue} W'
|
||||||
}
|
}
|
||||||
valueTile("energy", "device.energy", decoration: "flat") {
|
valueTile("energy", "device.energy", decoration: "flat") {
|
||||||
state "default", label:'${currentValue} kWh'
|
state "default", label:'${currentValue} kWh'
|
||||||
}
|
}
|
||||||
standardTile("reset", "device.energy", inactiveLabel: false, decoration: "flat") {
|
standardTile("reset", "device.energy", inactiveLabel: false, decoration: "flat") {
|
||||||
state "default", label:'reset kWh', action:"reset"
|
state "default", label:'reset kWh', action:"reset"
|
||||||
}
|
}
|
||||||
standardTile("refresh", "device.power", inactiveLabel: false, decoration: "flat") {
|
standardTile("refresh", "device.power", inactiveLabel: false, decoration: "flat") {
|
||||||
state "default", label:'', action:"refresh.refresh", icon:"st.secondary.refresh"
|
state "default", label:'', action:"refresh.refresh", icon:"st.secondary.refresh"
|
||||||
}
|
}
|
||||||
standardTile("configure", "device.power", inactiveLabel: false, decoration: "flat") {
|
standardTile("configure", "device.power", inactiveLabel: false, decoration: "flat") {
|
||||||
state "configure", label:'', action:"configuration.configure", icon:"st.secondary.configure"
|
state "configure", label:'', action:"configuration.configure", icon:"st.secondary.configure"
|
||||||
}
|
}
|
||||||
|
|
||||||
main (["power","energy"])
|
main (["power","energy"])
|
||||||
details(["power","energy", "reset","refresh", "configure"])
|
details(["power","energy", "reset","refresh", "configure"])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def parse(String description) {
|
def parse(String description) {
|
||||||
def result = null
|
def result = null
|
||||||
def cmd = zwave.parse(description, [0x31: 1, 0x32: 1, 0x60: 3])
|
def cmd = zwave.parse(description, [0x31: 1, 0x32: 1, 0x60: 3])
|
||||||
if (cmd) {
|
if (cmd) {
|
||||||
result = createEvent(zwaveEvent(cmd))
|
result = createEvent(zwaveEvent(cmd))
|
||||||
}
|
}
|
||||||
log.debug "Parse returned ${result?.descriptionText}"
|
log.debug "Parse returned ${result?.descriptionText}"
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
def zwaveEvent(physicalgraph.zwave.commands.meterv1.MeterReport cmd) {
|
def zwaveEvent(physicalgraph.zwave.commands.meterv1.MeterReport cmd) {
|
||||||
if (cmd.scale == 0) {
|
if (cmd.scale == 0) {
|
||||||
[name: "energy", value: cmd.scaledMeterValue, unit: "kWh"]
|
[name: "energy", value: cmd.scaledMeterValue, unit: "kWh"]
|
||||||
} else if (cmd.scale == 1) {
|
} else if (cmd.scale == 1) {
|
||||||
[name: "energy", value: cmd.scaledMeterValue, unit: "kVAh"]
|
[name: "energy", value: cmd.scaledMeterValue, unit: "kVAh"]
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
[name: "power", value: Math.round(cmd.scaledMeterValue), unit: "W"]
|
[name: "power", value: Math.round(cmd.scaledMeterValue), unit: "W"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def zwaveEvent(physicalgraph.zwave.Command cmd) {
|
def zwaveEvent(physicalgraph.zwave.Command cmd) {
|
||||||
// Handles all Z-Wave commands we aren't interested in
|
// Handles all Z-Wave commands we aren't interested in
|
||||||
[:]
|
[:]
|
||||||
}
|
}
|
||||||
|
|
||||||
def refresh() {
|
def refresh() {
|
||||||
delayBetween([
|
delayBetween([
|
||||||
zwave.meterV2.meterGet(scale: 0).format(),
|
zwave.meterV2.meterGet(scale: 0).format(),
|
||||||
zwave.meterV2.meterGet(scale: 2).format()
|
zwave.meterV2.meterGet(scale: 2).format()
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
def reset() {
|
def reset() {
|
||||||
// No V1 available
|
// No V1 available
|
||||||
return [
|
return [
|
||||||
zwave.meterV2.meterReset().format(),
|
zwave.meterV2.meterReset().format(),
|
||||||
zwave.meterV2.meterGet(scale: 0).format()
|
zwave.meterV2.meterGet(scale: 0).format()
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
def configure() {
|
def configure() {
|
||||||
def cmd = delayBetween([
|
def cmd = delayBetween([
|
||||||
zwave.configurationV1.configurationSet(parameterNumber: 101, size: 4, scaledConfigurationValue: 4).format(), // combined power in watts
|
zwave.configurationV1.configurationSet(parameterNumber: 101, size: 4, scaledConfigurationValue: 4).format(), // combined power in watts
|
||||||
zwave.configurationV1.configurationSet(parameterNumber: 111, size: 4, scaledConfigurationValue: 300).format(), // every 5 min
|
zwave.configurationV1.configurationSet(parameterNumber: 111, size: 4, scaledConfigurationValue: 300).format(), // every 5 min
|
||||||
zwave.configurationV1.configurationSet(parameterNumber: 102, size: 4, scaledConfigurationValue: 8).format(), // combined energy in kWh
|
zwave.configurationV1.configurationSet(parameterNumber: 102, size: 4, scaledConfigurationValue: 8).format(), // combined energy in kWh
|
||||||
zwave.configurationV1.configurationSet(parameterNumber: 112, size: 4, scaledConfigurationValue: 300).format(), // every 5 min
|
zwave.configurationV1.configurationSet(parameterNumber: 112, size: 4, scaledConfigurationValue: 300).format(), // every 5 min
|
||||||
zwave.configurationV1.configurationSet(parameterNumber: 103, size: 4, scaledConfigurationValue: 0).format(), // no third report
|
zwave.configurationV1.configurationSet(parameterNumber: 103, size: 4, scaledConfigurationValue: 0).format(), // no third report
|
||||||
zwave.configurationV1.configurationSet(parameterNumber: 113, size: 4, scaledConfigurationValue: 300).format() // every 5 min
|
zwave.configurationV1.configurationSet(parameterNumber: 113, size: 4, scaledConfigurationValue: 300).format() // every 5 min
|
||||||
])
|
])
|
||||||
log.debug cmd
|
log.debug cmd
|
||||||
cmd
|
cmd
|
||||||
}
|
}
|
||||||
@@ -1,150 +1,149 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright 2015 SmartThings
|
* Copyright 2015 SmartThings
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
* 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:
|
* in compliance with the License. You may obtain a copy of the License at:
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
|
* 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
|
* 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.
|
* for the specific language governing permissions and limitations under the License.
|
||||||
*
|
*
|
||||||
* The Flasher
|
* The Flasher
|
||||||
*
|
*
|
||||||
* Author: bob
|
* Author: bob
|
||||||
* Date: 2013-02-06
|
* Date: 2013-02-06
|
||||||
*/
|
*/
|
||||||
definition(
|
definition(
|
||||||
name: "The Flasher",
|
name: "The Flasher",
|
||||||
namespace: "smartthings",
|
namespace: "smartthings",
|
||||||
author: "SmartThings",
|
author: "SmartThings",
|
||||||
description: "Flashes a set of lights in response to motion, an open/close event, or a switch.",
|
description: "Flashes a set of lights in response to motion, an open/close event, or a switch.",
|
||||||
category: "Convenience",
|
category: "Convenience",
|
||||||
iconUrl: "https://s3.amazonaws.com/smartapp-icons/Meta/light_motion-outlet-contact.png",
|
iconUrl: "https://s3.amazonaws.com/smartapp-icons/Meta/light_motion-outlet-contact.png",
|
||||||
iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Meta/light_motion-outlet-contact@2x.png"
|
iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Meta/light_motion-outlet-contact@2x.png"
|
||||||
)
|
)
|
||||||
|
|
||||||
preferences {
|
preferences {
|
||||||
section("When any of the following devices trigger..."){
|
section("When any of the following devices trigger..."){
|
||||||
input "motion", "capability.motionSensor", title: "Motion Sensor?", required: false
|
input "motion", "capability.motionSensor", title: "Motion Sensor?", required: false
|
||||||
input "contact", "capability.contactSensor", title: "Contact Sensor?", required: false
|
input "contact", "capability.contactSensor", title: "Contact Sensor?", required: false
|
||||||
input "acceleration", "capability.accelerationSensor", title: "Acceleration Sensor?", required: false
|
input "acceleration", "capability.accelerationSensor", title: "Acceleration Sensor?", required: false
|
||||||
input "mySwitch", "capability.switch", title: "Switch?", required: false
|
input "mySwitch", "capability.switch", title: "Switch?", required: false
|
||||||
input "myPresence", "capability.presenceSensor", title: "Presence Sensor?", required: false
|
input "myPresence", "capability.presenceSensor", title: "Presence Sensor?", required: false
|
||||||
}
|
}
|
||||||
section("Then flash..."){
|
section("Then flash..."){
|
||||||
input "switches", "capability.switch", title: "These lights", multiple: true
|
input "switches", "capability.switch", title: "These lights", multiple: true
|
||||||
input "numFlashes", "number", title: "This number of times (default 3)", required: false
|
input "numFlashes", "number", title: "This number of times (default 3)", required: false
|
||||||
}
|
}
|
||||||
section("Time settings in milliseconds (optional)..."){
|
section("Time settings in milliseconds (optional)..."){
|
||||||
input "onFor", "number", title: "On for (default 1000)", required: false
|
input "onFor", "number", title: "On for (default 1000)", required: false
|
||||||
input "offFor", "number", title: "Off for (default 1000)", required: false
|
input "offFor", "number", title: "Off for (default 1000)", required: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def installed() {
|
def installed() {
|
||||||
log.debug "Installed with settings: ${settings}"
|
log.debug "Installed with settings: ${settings}"
|
||||||
|
|
||||||
subscribe()
|
subscribe()
|
||||||
}
|
}
|
||||||
|
|
||||||
def updated() {
|
def updated() {
|
||||||
log.debug "Updated with settings: ${settings}"
|
log.debug "Updated with settings: ${settings}"
|
||||||
|
|
||||||
unsubscribe()
|
unsubscribe()
|
||||||
subscribe()
|
subscribe()
|
||||||
}
|
}
|
||||||
|
|
||||||
def subscribe() {
|
def subscribe() {
|
||||||
if (contact) {
|
if (contact) {
|
||||||
subscribe(contact, "contact.open", contactOpenHandler)
|
subscribe(contact, "contact.open", contactOpenHandler)
|
||||||
}
|
}
|
||||||
if (acceleration) {
|
if (acceleration) {
|
||||||
subscribe(acceleration, "acceleration.active", accelerationActiveHandler)
|
subscribe(acceleration, "acceleration.active", accelerationActiveHandler)
|
||||||
}
|
}
|
||||||
if (motion) {
|
if (motion) {
|
||||||
subscribe(motion, "motion.active", motionActiveHandler)
|
subscribe(motion, "motion.active", motionActiveHandler)
|
||||||
}
|
}
|
||||||
if (mySwitch) {
|
if (mySwitch) {
|
||||||
subscribe(mySwitch, "switch.on", switchOnHandler)
|
subscribe(mySwitch, "switch.on", switchOnHandler)
|
||||||
}
|
}
|
||||||
if (myPresence) {
|
if (myPresence) {
|
||||||
subscribe(myPresence, "presence", presenceHandler)
|
subscribe(myPresence, "presence", presenceHandler)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def motionActiveHandler(evt) {
|
def motionActiveHandler(evt) {
|
||||||
log.debug "motion $evt.value"
|
log.debug "motion $evt.value"
|
||||||
flashLights()
|
flashLights()
|
||||||
}
|
}
|
||||||
|
|
||||||
def contactOpenHandler(evt) {
|
def contactOpenHandler(evt) {
|
||||||
log.debug "contact $evt.value"
|
log.debug "contact $evt.value"
|
||||||
flashLights()
|
flashLights()
|
||||||
}
|
}
|
||||||
|
|
||||||
def accelerationActiveHandler(evt) {
|
def accelerationActiveHandler(evt) {
|
||||||
log.debug "acceleration $evt.value"
|
log.debug "acceleration $evt.value"
|
||||||
flashLights()
|
flashLights()
|
||||||
}
|
}
|
||||||
|
|
||||||
def switchOnHandler(evt) {
|
def switchOnHandler(evt) {
|
||||||
log.debug "switch $evt.value"
|
log.debug "switch $evt.value"
|
||||||
flashLights()
|
flashLights()
|
||||||
}
|
}
|
||||||
|
|
||||||
def presenceHandler(evt) {
|
def presenceHandler(evt) {
|
||||||
log.debug "presence $evt.value"
|
log.debug "presence $evt.value"
|
||||||
if (evt.value == "present") {
|
if (evt.value == "present") {
|
||||||
flashLights()
|
flashLights()
|
||||||
} else if (evt.value == "not present") {
|
} else if (evt.value == "not present") {
|
||||||
flashLights()
|
flashLights()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private flashLights() {
|
private flashLights() {
|
||||||
def doFlash = true
|
def doFlash = true
|
||||||
def onFor = onFor ?: 1000
|
def onFor = onFor ?: 1000
|
||||||
def offFor = offFor ?: 1000
|
def offFor = offFor ?: 1000
|
||||||
def numFlashes = numFlashes ?: 3
|
def numFlashes = numFlashes ?: 3
|
||||||
|
|
||||||
log.debug "LAST ACTIVATED IS: ${state.lastActivated}"
|
log.debug "LAST ACTIVATED IS: ${state.lastActivated}"
|
||||||
if (state.lastActivated) {
|
if (state.lastActivated) {
|
||||||
def elapsed = now() - state.lastActivated
|
def elapsed = now() - state.lastActivated
|
||||||
def sequenceTime = (numFlashes + 1) * (onFor + offFor)
|
def sequenceTime = (numFlashes + 1) * (onFor + offFor)
|
||||||
doFlash = elapsed > sequenceTime
|
doFlash = elapsed > sequenceTime
|
||||||
log.debug "DO FLASH: $doFlash, ELAPSED: $elapsed, LAST ACTIVATED: ${state.lastActivated}"
|
log.debug "DO FLASH: $doFlash, ELAPSED: $elapsed, LAST ACTIVATED: ${state.lastActivated}"
|
||||||
}
|
}
|
||||||
|
|
||||||
if (doFlash) {
|
if (doFlash) {
|
||||||
log.debug "FLASHING $numFlashes times"
|
log.debug "FLASHING $numFlashes times"
|
||||||
state.lastActivated = now()
|
state.lastActivated = now()
|
||||||
log.debug "LAST ACTIVATED SET TO: ${state.lastActivated}"
|
log.debug "LAST ACTIVATED SET TO: ${state.lastActivated}"
|
||||||
def initialActionOn = switches.collect{it.currentSwitch != "on"}
|
def initialActionOn = switches.collect{it.currentSwitch != "on"}
|
||||||
def delay = 0L
|
def delay = 0L
|
||||||
numFlashes.times {
|
numFlashes.times {
|
||||||
log.trace "Switch on after $delay msec"
|
log.trace "Switch on after $delay msec"
|
||||||
switches.eachWithIndex {s, i ->
|
switches.eachWithIndex {s, i ->
|
||||||
if (initialActionOn[i]) {
|
if (initialActionOn[i]) {
|
||||||
s.on(delay: delay)
|
s.on(delay: delay)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
s.off(delay:delay)
|
s.off(delay:delay)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delay += onFor
|
delay += onFor
|
||||||
log.trace "Switch off after $delay msec"
|
log.trace "Switch off after $delay msec"
|
||||||
switches.eachWithIndex {s, i ->
|
switches.eachWithIndex {s, i ->
|
||||||
if (initialActionOn[i]) {
|
if (initialActionOn[i]) {
|
||||||
s.off(delay: delay)
|
s.off(delay: delay)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
s.on(delay:delay)
|
s.on(delay:delay)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delay += offFor
|
delay += offFor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user