mirror of
https://github.com/mtan93/SmartThingsPublic.git
synced 2026-03-29 22:04:19 +01:00
Compare commits
5 Commits
MSA-1321-1
...
lange-ecob
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d6b98c2e7b | ||
|
|
d44dac448b | ||
|
|
67c20abcba | ||
|
|
0c1208928f | ||
|
|
d17cadc4c7 |
@@ -18,7 +18,6 @@ metadata {
|
|||||||
definition (name: "Ecobee Sensor", namespace: "smartthings", author: "SmartThings") {
|
definition (name: "Ecobee Sensor", namespace: "smartthings", author: "SmartThings") {
|
||||||
capability "Sensor"
|
capability "Sensor"
|
||||||
capability "Temperature Measurement"
|
capability "Temperature Measurement"
|
||||||
capability "Motion Sensor"
|
|
||||||
capability "Refresh"
|
capability "Refresh"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
.st-ignore
|
||||||
|
README.md
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
# Smartsense Motion Sensor
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Works with:
|
||||||
|
|
||||||
|
* [Samsung SmartThings Motion Sensor](https://shop.smartthings.com/#!/products/samsung-smartthings-motion-sensor)
|
||||||
|
|
||||||
|
## Table of contents
|
||||||
|
|
||||||
|
* [Capabilities](#capabilities)
|
||||||
|
* [Health]($health)
|
||||||
|
|
||||||
|
## Capabilities
|
||||||
|
|
||||||
|
* **Configuration** - _configure()_ command called when device is installed or device preferences updated
|
||||||
|
* **Motion Sensor** - can detect motion
|
||||||
|
* **Battery** - defines device uses a battery
|
||||||
|
* **Refresh** - _refresh()_ command for status updates
|
||||||
|
* **Health Check** - indicates ability to get device health notifications
|
||||||
|
|
||||||
|
## Device Health
|
||||||
|
|
||||||
|
A Category C2 motion sensor that has 120min check-in interval
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -45,17 +45,28 @@ metadata {
|
|||||||
}
|
}
|
||||||
|
|
||||||
preferences {
|
preferences {
|
||||||
input title: "Temperature Offset", description: "This feature allows you to correct any temperature variations by selecting an offset. Ex: If your sensor consistently reports a temp that's 5 degrees too warm, you'd enter \"-5\". If 3 degrees too cold, enter \"+3\".", displayDuringSetup: false, type: "paragraph", element: "paragraph"
|
section {
|
||||||
input "tempOffset", "number", title: "Degrees", description: "Adjust temperature by this many degrees", range: "*..*", displayDuringSetup: false
|
input description: "This feature allows you to correct any temperature variations by selecting an offset. Ex: If your sensor consistently reports a temp that's 5 degrees too warm, you'd enter \"-5\". If 3 degrees too cold, enter \"+3\".", displayDuringSetup: false, type: "paragraph", element: "paragraph"
|
||||||
|
input "tempOffset", "number", title: "Temperature Offset", description: "Adjust temperature by this many degrees", range: "*..*", displayDuringSetup: false
|
||||||
|
}
|
||||||
|
section {
|
||||||
|
input("garageSensor", "enum", title: "Do you want to use this sensor on a garage door?", options: ["Yes", "No"], defaultValue: "No", required: false, displayDuringSetup: false)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tiles(scale: 2) {
|
tiles(scale: 2) {
|
||||||
multiAttributeTile(name:"contact", type: "generic", width: 6, height: 4){
|
multiAttributeTile(name:"status", type: "generic", width: 6, height: 4){
|
||||||
tileAttribute ("device.contact", key: "PRIMARY_CONTROL") {
|
tileAttribute ("device.status", key: "PRIMARY_CONTROL") {
|
||||||
attributeState "open", label:'${name}', icon:"st.contact.contact.open", backgroundColor:"#ffa81e"
|
|
||||||
attributeState "closed", label:'${name}', icon:"st.contact.contact.closed", backgroundColor:"#79b821"
|
attributeState "closed", label:'${name}', icon:"st.contact.contact.closed", backgroundColor:"#79b821"
|
||||||
|
attributeState "open", label:'${name}', icon:"st.contact.contact.open", backgroundColor:"#ffa81e"
|
||||||
|
attributeState "garage-closed", label:'Closed', icon:"st.doors.garage.garage-closed", backgroundColor:"#79b821"
|
||||||
|
attributeState "garage-open", label:'Open', icon:"st.doors.garage.garage-open", backgroundColor:"#ffa81e"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
standardTile("contact", "device.contact", width: 2, height: 2) {
|
||||||
|
state("open", label:'${name}', icon:"st.contact.contact.open", backgroundColor:"#ffa81e")
|
||||||
|
state("closed", label:'${name}', icon:"st.contact.contact.closed", backgroundColor:"#79b821")
|
||||||
|
}
|
||||||
|
|
||||||
standardTile("acceleration", "device.acceleration", width: 2, height: 2) {
|
standardTile("acceleration", "device.acceleration", width: 2, height: 2) {
|
||||||
state("active", label:'${name}', icon:"st.motion.acceleration.active", backgroundColor:"#53a7c0")
|
state("active", label:'${name}', icon:"st.motion.acceleration.active", backgroundColor:"#53a7c0")
|
||||||
@@ -78,8 +89,8 @@ metadata {
|
|||||||
state "battery", label:'${currentValue}% battery', unit:""
|
state "battery", label:'${currentValue}% battery', unit:""
|
||||||
}
|
}
|
||||||
|
|
||||||
main(["contact", "acceleration", "temperature"])
|
main(["status", "acceleration", "temperature"])
|
||||||
details(["contact", "acceleration", "temperature", "battery"])
|
details(["status", "acceleration", "temperature", "battery"])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,7 +98,9 @@ def parse(String description) {
|
|||||||
def results
|
def results
|
||||||
|
|
||||||
if (!isSupportedDescription(description) || zigbee.isZoneType19(description)) {
|
if (!isSupportedDescription(description) || zigbee.isZoneType19(description)) {
|
||||||
results = parseSingleMessage(description)
|
if (garageSensor != "Yes") {
|
||||||
|
results = parseSingleMessage(description)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (description == 'updated') {
|
else if (description == 'updated') {
|
||||||
//TODO is there a better way to handle this like the other device types?
|
//TODO is there a better way to handle this like the other device types?
|
||||||
@@ -203,7 +216,9 @@ private List parseContactMessage(String description) {
|
|||||||
parts.each { part ->
|
parts.each { part ->
|
||||||
part = part.trim()
|
part = part.trim()
|
||||||
if (part.startsWith('contactState:')) {
|
if (part.startsWith('contactState:')) {
|
||||||
results.addAll(getContactResult(part, description))
|
if (garageSensor != "Yes") {
|
||||||
|
results.addAll(getContactResult(part, description))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (part.startsWith('accelerationState:')) {
|
else if (part.startsWith('accelerationState:')) {
|
||||||
results << getAccelerationResult(part, description)
|
results << getAccelerationResult(part, description)
|
||||||
@@ -225,6 +240,29 @@ private List parseContactMessage(String description) {
|
|||||||
results
|
results
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def updated() {
|
||||||
|
log.debug "updated called"
|
||||||
|
log.info "garage value : $garageSensor"
|
||||||
|
if (garageSensor == "Yes") {
|
||||||
|
def descriptionText = "Updating device to garage sensor"
|
||||||
|
if (device.latestValue("status") == "open") {
|
||||||
|
sendEvent(name: 'status', value: 'garage-open', descriptionText: descriptionText)
|
||||||
|
}
|
||||||
|
else if (device.latestValue("status") == "closed") {
|
||||||
|
sendEvent(name: 'status', value: 'garage-closed', descriptionText: descriptionText)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
def descriptionText = "Updating device to open/close sensor"
|
||||||
|
if (device.latestValue("status") == "garage-open") {
|
||||||
|
sendEvent(name: 'status', value: 'open', descriptionText: descriptionText)
|
||||||
|
}
|
||||||
|
else if (device.latestValue("status") == "garage-closed") {
|
||||||
|
sendEvent(name: 'status', value: 'closed', descriptionText: descriptionText)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private List parseOrientationMessage(String description) {
|
private List parseOrientationMessage(String description) {
|
||||||
def results = []
|
def results = []
|
||||||
def xyzResults = [x: 0, y: 0, z: 0]
|
def xyzResults = [x: 0, y: 0, z: 0]
|
||||||
@@ -254,7 +292,34 @@ private List parseOrientationMessage(String description) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
results << getXyzResult(xyzResults, description)
|
def xyz = getXyzResult(xyzResults, description)
|
||||||
|
results << xyz
|
||||||
|
|
||||||
|
if (garageSensor == "Yes") {
|
||||||
|
// Looks for Z-axis orientation as virtual contact state
|
||||||
|
def a = xyz.value.split(',').collect{it.toInteger()}
|
||||||
|
def absValueXY = Math.max(Math.abs(a[0]), Math.abs(a[1]))
|
||||||
|
def absValueZ = Math.abs(a[2])
|
||||||
|
log.debug "absValueXY: $absValueXY, absValueZ: $absValueZ"
|
||||||
|
|
||||||
|
def contactValue = null
|
||||||
|
def garageValue = null
|
||||||
|
|
||||||
|
if (absValueZ > 825 && absValueXY < 175) {
|
||||||
|
contactValue = 'open'
|
||||||
|
garageValue = 'garage-open'
|
||||||
|
log.debug "STATUS: open"
|
||||||
|
}
|
||||||
|
else if (absValueZ < 75 && absValueXY > 825) {
|
||||||
|
contactValue = 'closed'
|
||||||
|
garageValue = 'garage-closed'
|
||||||
|
log.debug "STATUS: closed"
|
||||||
|
}
|
||||||
|
def linkText = getLinkText(device)
|
||||||
|
def descriptionText = "${linkText} was ${contactValue == 'open' ? 'opened' : 'closed'}"
|
||||||
|
results << createEvent(name: "contact", value: contactValue, descriptionText: descriptionText, unit: "", displayed: false)
|
||||||
|
results << createEvent(name: "status", value: garageValue, descriptionText: descriptionText, unit: "")
|
||||||
|
}
|
||||||
|
|
||||||
results
|
results
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,170 +0,0 @@
|
|||||||
/**
|
|
||||||
* Lights Flash on Door Knock
|
|
||||||
*
|
|
||||||
* Copyright 2016 Andrew Cornforth
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
definition(
|
|
||||||
name: "Lights Flash on Door Knock",
|
|
||||||
namespace: "com.stormwave.doorknock",
|
|
||||||
author: "Andrew Cornforth",
|
|
||||||
description: "Flashes lights when activity is noticed at the door.",
|
|
||||||
category: "Safety & Security",
|
|
||||||
iconUrl: "http://cdn.device-icons.smartthings.com/Lighting/light10-icn.png",
|
|
||||||
iconX2Url: "http://cdn.device-icons.smartthings.com/Lighting/light10-icn@2x.png",
|
|
||||||
iconX3Url: "http://cdn.device-icons.smartthings.com/Lighting/light10-icn@2x.png")
|
|
||||||
|
|
||||||
|
|
||||||
preferences {
|
|
||||||
section("Things")
|
|
||||||
{
|
|
||||||
input "doorsensor", "capability.accelerationSensor", title: "Door Sensor", required: true, multiple: true
|
|
||||||
input "lights", "capability.switch", title:"Lights", required:true, multiple:true
|
|
||||||
}
|
|
||||||
section("Settings")
|
|
||||||
{
|
|
||||||
input "numFlashes", "number", title:"Number of Flashes", required:true, defaultValue:"5"
|
|
||||||
input "onFor", "number", title:"Time On (ms)", required:true, defaultValue:"1000"
|
|
||||||
input "offFor", "number", title:"Time Off (ms)", required:true, defaultValue:"1000"
|
|
||||||
}
|
|
||||||
section("Only If")
|
|
||||||
{
|
|
||||||
input "switcheson", "capability.switch", title:"Switches Are On", required:false, multiple:true
|
|
||||||
input "switchesoff", "capability.switch", title:"Switches Are Off", required:false, multiple:true
|
|
||||||
input "sleepon", "capability.sleepSensor", title:"Thing Is Asleep", required:false, multiple:true
|
|
||||||
input "sleepoff", "capability.sleepSensor", title:"Thing Is Awake", required:false, multiple:true
|
|
||||||
}
|
|
||||||
section("Or If")
|
|
||||||
{
|
|
||||||
input "or_switcheson", "capability.switch", title:"Switches Are On", required:false, multiple:true
|
|
||||||
input "or_switchesoff", "capability.switch", title:"Switches Are Off", required:false, multiple:true
|
|
||||||
input "or_sleepon", "capability.sleepSensor", title:"Thing Is Asleep", required:false, multiple:true
|
|
||||||
input "or_sleepoff", "capability.sleepSensor", title:"Thing Is Awake", required:false, multiple:true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def flashLights()
|
|
||||||
{
|
|
||||||
lights.each
|
|
||||||
{
|
|
||||||
light ->
|
|
||||||
def delay = 0L
|
|
||||||
if (light.latestValue("switch")=="on")
|
|
||||||
{
|
|
||||||
numFlashes.times
|
|
||||||
{
|
|
||||||
light.off(delay: delay)
|
|
||||||
delay += offFor
|
|
||||||
light.on(delay: delay)
|
|
||||||
delay += onFor
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
numFlashes.times
|
|
||||||
{
|
|
||||||
light.on(delay: delay)
|
|
||||||
delay += onFor
|
|
||||||
light.off(delay: delay)
|
|
||||||
delay += offFor
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def installed() {
|
|
||||||
log.debug "Installed with settings: ${settings}"
|
|
||||||
|
|
||||||
initialize()
|
|
||||||
}
|
|
||||||
|
|
||||||
def updated() {
|
|
||||||
log.debug "Updated with settings: ${settings}"
|
|
||||||
|
|
||||||
unsubscribe()
|
|
||||||
initialize()
|
|
||||||
}
|
|
||||||
|
|
||||||
def unsubcribe()
|
|
||||||
{
|
|
||||||
unsubscribe(doorsensor)
|
|
||||||
}
|
|
||||||
|
|
||||||
def initialize()
|
|
||||||
{
|
|
||||||
subscribe(doorsensor, "acceleration", activityHandler)
|
|
||||||
}
|
|
||||||
|
|
||||||
def activityHandler(evt)
|
|
||||||
{
|
|
||||||
if (evt.value=="active")
|
|
||||||
{
|
|
||||||
// Check conditions
|
|
||||||
def valid = true
|
|
||||||
switcheson.each
|
|
||||||
{
|
|
||||||
device ->
|
|
||||||
if (device.latestValue("switch")=="off") { valid = false; }
|
|
||||||
}
|
|
||||||
if (valid)
|
|
||||||
switchesoff.each
|
|
||||||
{
|
|
||||||
device ->
|
|
||||||
if (device.latestValue("switch")=="on") { valid = false; }
|
|
||||||
}
|
|
||||||
if (valid)
|
|
||||||
sleepon.each
|
|
||||||
{
|
|
||||||
device ->
|
|
||||||
if (device.latestValue("sleeping")=="not sleeping") { valid = false; }
|
|
||||||
}
|
|
||||||
if (valid)
|
|
||||||
sleepoff.each
|
|
||||||
{
|
|
||||||
device ->
|
|
||||||
if (device.latestValue("sleeping")=="sleeping") { valid = false; }
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check for "or" values if failed first step
|
|
||||||
if (!valid)
|
|
||||||
{
|
|
||||||
valid = true
|
|
||||||
or_switcheson.each
|
|
||||||
{
|
|
||||||
device ->
|
|
||||||
if (device.latestValue("switch")=="off") { valid = false; }
|
|
||||||
}
|
|
||||||
if (valid)
|
|
||||||
or_switchesoff.each
|
|
||||||
{
|
|
||||||
device ->
|
|
||||||
if (device.latestValue("switch")=="on") { valid = false; }
|
|
||||||
}
|
|
||||||
if (valid)
|
|
||||||
or_sleepon.each
|
|
||||||
{
|
|
||||||
device ->
|
|
||||||
if (device.latestValue("sleeping")=="not sleeping") { valid = false; }
|
|
||||||
}
|
|
||||||
if (valid)
|
|
||||||
or_sleepoff.each
|
|
||||||
{
|
|
||||||
device ->
|
|
||||||
if (device.latestValue("sleeping")=="sleeping") { valid = false; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (valid)
|
|
||||||
{
|
|
||||||
flashLights()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user