mirror of
https://github.com/mtan93/SmartThingsPublic.git
synced 2026-03-16 13:10:51 +00:00
Compare commits
3 Commits
MSA-1419-1
...
DEVTOOLS-1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f5c91f82b6 | ||
|
|
47183ebbff | ||
|
|
d68f70b3dd |
@@ -0,0 +1,37 @@
|
|||||||
|
/**
|
||||||
|
* Copyright 2015 SmartThings
|
||||||
|
*
|
||||||
|
* 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://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: "Beacon Capability", namespace: "capabilities", author: "SmartThings") {
|
||||||
|
capability "Beacon"
|
||||||
|
}
|
||||||
|
|
||||||
|
simulator {
|
||||||
|
status "present": "beacon: present"
|
||||||
|
status "not present": "beacon: not present"
|
||||||
|
}
|
||||||
|
|
||||||
|
tiles {
|
||||||
|
standardTile("beacon", "device.beacon", width: 2, height: 2) {
|
||||||
|
state("not present", label:'not present', icon:"st.presence.tile.not-present", backgroundColor:"#ffffff")
|
||||||
|
state("present", label:'present', icon:"st.presence.tile.present", backgroundColor:"#53a7c0")
|
||||||
|
}
|
||||||
|
main "beacon"
|
||||||
|
details "beacon"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def parse(String description) {
|
||||||
|
def pair = description.split(":")
|
||||||
|
createEvent(name: pair[0].trim(), value: pair[1].trim())
|
||||||
|
}
|
||||||
@@ -101,6 +101,12 @@ def parse(String description) {
|
|||||||
else {
|
else {
|
||||||
def descriptionText = finalResult.value == "on" ? '{{ device.displayName }} is On' : '{{ device.displayName }} is Off'
|
def descriptionText = finalResult.value == "on" ? '{{ device.displayName }} is On' : '{{ device.displayName }} is Off'
|
||||||
sendEvent(name: finalResult.type, value: finalResult.value, descriptionText: descriptionText, translatable: true)
|
sendEvent(name: finalResult.type, value: finalResult.value, descriptionText: descriptionText, translatable: true)
|
||||||
|
// Temporary fix for the case when Device is OFFLINE and is connected again
|
||||||
|
if (state.lastOnOff == null){
|
||||||
|
state.lastOnOff = now()
|
||||||
|
sendEvent(name: "deviceWatch-lastActivity", value: state.lastOnOff, description: "Last Activity is on ${new Date(state.lastOnOff)}", displayed: false, isStateChange: true)
|
||||||
|
}
|
||||||
|
state.lastOnOff = now()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -116,9 +122,24 @@ def off() {
|
|||||||
def on() {
|
def on() {
|
||||||
zigbee.on()
|
zigbee.on()
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* PING is used by Device-Watch in attempt to reach the Outlet
|
||||||
|
* */
|
||||||
|
def ping() {
|
||||||
|
|
||||||
|
// send read attribute onOFF if the last time we heard from the outlet is outside of the checkInterval
|
||||||
|
if (state.lastOnOff < (now() - (1000 * device.currentValue("checkInterval"))) ){
|
||||||
|
log.info "ping, alive=no, lastOnOff=${new Date(state.lastOnOff)}"
|
||||||
|
state.lastOnOff = null
|
||||||
|
return zigbee.onOffRefresh()
|
||||||
|
} else { // if the last onOff activity is within the checkInterval we artificially create a Device-Watch event
|
||||||
|
log.info "ping, alive=yes, lastOnOff=${new Date(state.lastOnOff)}"
|
||||||
|
sendEvent(name: "deviceWatch-lastActivity", value: state.lastOnOff, description: "Last Activity is on ${new Date(state.lastOnOff)}", displayed: false, isStateChange: true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
def refresh() {
|
def refresh() {
|
||||||
zigbee.onOffRefresh() + zigbee.refreshData("0x0B04", "0x050B")
|
zigbee.onOffRefresh() + zigbee.electricMeasurementPowerRefresh()
|
||||||
}
|
}
|
||||||
|
|
||||||
def configure() {
|
def configure() {
|
||||||
|
|||||||
Reference in New Issue
Block a user