mirror of
https://github.com/mtan93/SmartThingsPublic.git
synced 2026-03-17 21:03:30 +00:00
Compare commits
13 Commits
MSA-950-3
...
PROD_2016.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
024a6cb698 | ||
|
|
410e9f40cc | ||
|
|
1578c48440 | ||
|
|
7526d2b445 | ||
|
|
caf761c015 | ||
|
|
62a965d90b | ||
|
|
fb9f1dee47 | ||
|
|
3a433d3865 | ||
|
|
8f25ff4434 | ||
|
|
515b268374 | ||
|
|
9b87d39fe8 | ||
|
|
a103d437c2 | ||
|
|
bdd88deb99 |
@@ -1,97 +1,96 @@
|
|||||||
/**
|
/**
|
||||||
* Hue Lux Bulb
|
* Hue Lux Bulb
|
||||||
*
|
*
|
||||||
* Author: SmartThings
|
* Author: SmartThings
|
||||||
*/
|
*/
|
||||||
// for the UI
|
// for the UI
|
||||||
metadata {
|
metadata {
|
||||||
// Automatically generated. Make future change here.
|
// Automatically generated. Make future change here.
|
||||||
definition (name: "Hue Lux Bulb", namespace: "smartthings", author: "SmartThings") {
|
definition (name: "Hue Lux Bulb", namespace: "smartthings", author: "SmartThings") {
|
||||||
capability "Switch Level"
|
capability "Switch Level"
|
||||||
capability "Actuator"
|
capability "Actuator"
|
||||||
capability "Color Temperature"
|
capability "Switch"
|
||||||
capability "Switch"
|
capability "Refresh"
|
||||||
capability "Refresh"
|
capability "Sensor"
|
||||||
capability "Sensor"
|
|
||||||
|
command "refresh"
|
||||||
command "refresh"
|
}
|
||||||
}
|
|
||||||
|
simulator {
|
||||||
simulator {
|
// TODO: define status and reply messages here
|
||||||
// TODO: define status and reply messages here
|
}
|
||||||
}
|
|
||||||
|
tiles(scale: 2) {
|
||||||
tiles(scale: 2) {
|
multiAttributeTile(name:"rich-control", type: "lighting", canChangeIcon: true){
|
||||||
multiAttributeTile(name:"rich-control", type: "lighting", canChangeIcon: true){
|
tileAttribute ("device.switch", key: "PRIMARY_CONTROL") {
|
||||||
tileAttribute ("device.switch", key: "PRIMARY_CONTROL") {
|
attributeState "on", label:'${name}', action:"switch.off", icon:"st.lights.philips.hue-single", backgroundColor:"#79b821", nextState:"turningOff"
|
||||||
attributeState "on", label:'${name}', action:"switch.off", icon:"st.lights.philips.hue-single", backgroundColor:"#79b821", nextState:"turningOff"
|
attributeState "off", label:'${name}', action:"switch.on", icon:"st.lights.philips.hue-single", backgroundColor:"#ffffff", nextState:"turningOn"
|
||||||
attributeState "off", label:'${name}', action:"switch.on", icon:"st.lights.philips.hue-single", backgroundColor:"#ffffff", nextState:"turningOn"
|
attributeState "turningOn", label:'${name}', action:"switch.off", icon:"st.lights.philips.hue-single", backgroundColor:"#79b821", nextState:"turningOff"
|
||||||
attributeState "turningOn", label:'${name}', action:"switch.off", icon:"st.lights.philips.hue-single", backgroundColor:"#79b821", nextState:"turningOff"
|
attributeState "turningOff", label:'${name}', action:"switch.on", icon:"st.lights.philips.hue-single", backgroundColor:"#ffffff", nextState:"turningOn"
|
||||||
attributeState "turningOff", label:'${name}', action:"switch.on", icon:"st.lights.philips.hue-single", backgroundColor:"#ffffff", nextState:"turningOn"
|
}
|
||||||
}
|
tileAttribute ("device.level", key: "SLIDER_CONTROL") {
|
||||||
tileAttribute ("device.level", key: "SLIDER_CONTROL") {
|
attributeState "level", action:"switch level.setLevel", range:"(0..100)"
|
||||||
attributeState "level", action:"switch level.setLevel", range:"(0..100)"
|
}
|
||||||
}
|
tileAttribute ("device.level", key: "SECONDARY_CONTROL") {
|
||||||
tileAttribute ("device.level", key: "SECONDARY_CONTROL") {
|
attributeState "level", label: 'Level ${currentValue}%'
|
||||||
attributeState "level", label: 'Level ${currentValue}%'
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
standardTile("switch", "device.switch", width: 2, height: 2, canChangeIcon: true) {
|
||||||
standardTile("switch", "device.switch", width: 2, height: 2, canChangeIcon: true) {
|
state "on", label:'${name}', action:"switch.off", icon:"st.lights.philips.hue-single", backgroundColor:"#79b821", nextState:"turningOff"
|
||||||
state "on", label:'${name}', action:"switch.off", icon:"st.lights.philips.hue-single", backgroundColor:"#79b821", nextState:"turningOff"
|
state "off", label:'${name}', action:"switch.on", icon:"st.lights.philips.hue-single", backgroundColor:"#ffffff", nextState:"turningOn"
|
||||||
state "off", label:'${name}', action:"switch.on", icon:"st.lights.philips.hue-single", backgroundColor:"#ffffff", nextState:"turningOn"
|
state "turningOn", label:'${name}', action:"switch.off", icon:"st.lights.philips.hue-single", backgroundColor:"#79b821", nextState:"turningOff"
|
||||||
state "turningOn", label:'${name}', action:"switch.off", icon:"st.lights.philips.hue-single", backgroundColor:"#79b821", nextState:"turningOff"
|
state "turningOff", label:'${name}', action:"switch.on", icon:"st.lights.philips.hue-single", backgroundColor:"#ffffff", nextState:"turningOn"
|
||||||
state "turningOff", label:'${name}', action:"switch.on", icon:"st.lights.philips.hue-single", backgroundColor:"#ffffff", nextState:"turningOn"
|
}
|
||||||
}
|
|
||||||
|
controlTile("levelSliderControl", "device.level", "slider", height: 1, width: 2, inactiveLabel: false, range:"(0..100)") {
|
||||||
controlTile("levelSliderControl", "device.level", "slider", height: 1, width: 2, inactiveLabel: false, range:"(0..100)") {
|
state "level", action:"switch level.setLevel"
|
||||||
state "level", action:"switch level.setLevel"
|
}
|
||||||
}
|
|
||||||
|
standardTile("refresh", "device.switch", inactiveLabel: false, decoration: "flat", width: 2, height: 2) {
|
||||||
standardTile("refresh", "device.switch", inactiveLabel: false, decoration: "flat", width: 2, height: 2) {
|
state "default", label:"", action:"refresh.refresh", icon:"st.secondary.refresh"
|
||||||
state "default", label:"", action:"refresh.refresh", icon:"st.secondary.refresh"
|
}
|
||||||
}
|
|
||||||
|
main(["switch"])
|
||||||
main(["switch"])
|
details(["rich-control", "refresh"])
|
||||||
details(["rich-control", "colorTempSliderControl","refresh"])
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
// parse events into attributes
|
||||||
// parse events into attributes
|
def parse(description) {
|
||||||
def parse(description) {
|
log.debug "parse() - $description"
|
||||||
log.debug "parse() - $description"
|
def results = []
|
||||||
def results = []
|
|
||||||
|
def map = description
|
||||||
def map = description
|
if (description instanceof String) {
|
||||||
if (description instanceof String) {
|
log.debug "Hue Bulb stringToMap - ${map}"
|
||||||
log.debug "Hue Bulb stringToMap - ${map}"
|
map = stringToMap(description)
|
||||||
map = stringToMap(description)
|
}
|
||||||
}
|
|
||||||
|
if (map?.name && map?.value) {
|
||||||
if (map?.name && map?.value) {
|
results << createEvent(name: "${map?.name}", value: "${map?.value}")
|
||||||
results << createEvent(name: "${map?.name}", value: "${map?.value}")
|
}
|
||||||
}
|
results
|
||||||
results
|
}
|
||||||
}
|
|
||||||
|
// handle commands
|
||||||
// handle commands
|
void on() {
|
||||||
void on() {
|
parent.on(this)
|
||||||
parent.on(this)
|
sendEvent(name: "switch", value: "on")
|
||||||
sendEvent(name: "switch", value: "on")
|
}
|
||||||
}
|
|
||||||
|
void off() {
|
||||||
void off() {
|
parent.off(this)
|
||||||
parent.off(this)
|
sendEvent(name: "switch", value: "off")
|
||||||
sendEvent(name: "switch", value: "off")
|
}
|
||||||
}
|
|
||||||
|
void setLevel(percent) {
|
||||||
void setLevel(percent) {
|
log.debug "Executing 'setLevel'"
|
||||||
log.debug "Executing 'setLevel'"
|
parent.setLevel(this, percent)
|
||||||
parent.setLevel(this, percent)
|
sendEvent(name: "level", value: percent)
|
||||||
sendEvent(name: "level", value: percent)
|
}
|
||||||
}
|
|
||||||
|
void refresh() {
|
||||||
void refresh() {
|
log.debug "Executing 'refresh'"
|
||||||
log.debug "Executing 'refresh'"
|
parent.manualRefresh()
|
||||||
parent.manualRefresh()
|
}
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,142 +0,0 @@
|
|||||||
/**
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
* Virtual Thermostat
|
|
||||||
*
|
|
||||||
* Author: SmartThings
|
|
||||||
*/
|
|
||||||
definition(
|
|
||||||
name: "임희진",
|
|
||||||
namespace: "smartthings",
|
|
||||||
author: "SmartThings",
|
|
||||||
description: "Control a space heater or window air conditioner in conjunction with any temperature sensor, like a SmartSense Multi.",
|
|
||||||
category: "Green Living",
|
|
||||||
iconUrl: "https://s3.amazonaws.com/smartapp-icons/Meta/temp_thermo-switch.png",
|
|
||||||
iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Meta/temp_thermo-switch@2x.png"
|
|
||||||
)
|
|
||||||
|
|
||||||
preferences {
|
|
||||||
section("Choose a temperature sensor... "){
|
|
||||||
input "sensor", "capability.temperatureMeasurement", title: "Sensor"
|
|
||||||
}
|
|
||||||
section("Select the heater or air conditioner outlet(s)... "){
|
|
||||||
input "outlets", "capability.switch", title: "Outlets", multiple: true
|
|
||||||
}
|
|
||||||
section("Set the desired temperature..."){
|
|
||||||
input "setpoint", "decimal", title: "Set Temp"
|
|
||||||
}
|
|
||||||
section("When there's been movement from (optional, leave blank to not require motion)..."){
|
|
||||||
input "motion", "capability.motionSensor", title: "Motion", required: false
|
|
||||||
}
|
|
||||||
section("Within this number of minutes..."){
|
|
||||||
input "minutes", "number", title: "Minutes", required: false
|
|
||||||
}
|
|
||||||
section("But never go below (or above if A/C) this value with or without motion..."){
|
|
||||||
input "emergencySetpoint", "decimal", title: "Emer Temp", required: false
|
|
||||||
}
|
|
||||||
section("Select 'heat' for a heater and 'cool' for an air conditioner..."){
|
|
||||||
input "mode", "enum", title: "Heating or cooling?", options: ["heat","cool"]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def installed()
|
|
||||||
{
|
|
||||||
subscribe(sensor, "temperature", temperatureHandler)
|
|
||||||
if (motion) {
|
|
||||||
subscribe(motion, "motion", motionHandler)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def updated()
|
|
||||||
{
|
|
||||||
unsubscribe()
|
|
||||||
subscribe(sensor, "temperature", temperatureHandler)
|
|
||||||
if (motion) {
|
|
||||||
subscribe(motion, "motion", motionHandler)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def temperatureHandler(evt)
|
|
||||||
{
|
|
||||||
def isActive = hasBeenRecentMotion()
|
|
||||||
if (isActive || emergencySetpoint) {
|
|
||||||
evaluate(evt.doubleValue, isActive ? setpoint : emergencySetpoint)
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
outlets.off()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def motionHandler(evt)
|
|
||||||
{
|
|
||||||
if (evt.value == "active") {
|
|
||||||
def lastTemp = sensor.currentTemperature
|
|
||||||
if (lastTemp != null) {
|
|
||||||
evaluate(lastTemp, setpoint)
|
|
||||||
}
|
|
||||||
} else if (evt.value == "inactive") {
|
|
||||||
def isActive = hasBeenRecentMotion()
|
|
||||||
log.debug "INACTIVE($isActive)"
|
|
||||||
if (isActive || emergencySetpoint) {
|
|
||||||
def lastTemp = sensor.currentTemperature
|
|
||||||
if (lastTemp != null) {
|
|
||||||
evaluate(lastTemp, isActive ? setpoint : emergencySetpoint)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
outlets.off()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private evaluate(currentTemp, desiredTemp)
|
|
||||||
{
|
|
||||||
log.debug "EVALUATE($currentTemp, $desiredTemp)"
|
|
||||||
def threshold = 1.0
|
|
||||||
if (mode == "cool") {
|
|
||||||
// air conditioner
|
|
||||||
if (currentTemp - desiredTemp >= threshold) {
|
|
||||||
outlets.on()
|
|
||||||
}
|
|
||||||
else if (desiredTemp - currentTemp >= threshold) {
|
|
||||||
outlets.off()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// heater
|
|
||||||
if (desiredTemp - currentTemp >= threshold) {
|
|
||||||
outlets.on()
|
|
||||||
}
|
|
||||||
else if (currentTemp - desiredTemp >= threshold) {
|
|
||||||
outlets.off()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private hasBeenRecentMotion()
|
|
||||||
{
|
|
||||||
def isActive = false
|
|
||||||
if (motion && minutes) {
|
|
||||||
def deltaMinutes = minutes as Long
|
|
||||||
if (deltaMinutes) {
|
|
||||||
def motionEvents = motion.eventsSince(new Date(now() - (60000 * deltaMinutes)))
|
|
||||||
log.trace "Found ${motionEvents?.size() ?: 0} events in the last $deltaMinutes minutes"
|
|
||||||
if (motionEvents.find { it.value == "active" }) {
|
|
||||||
isActive = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
isActive = true
|
|
||||||
}
|
|
||||||
isActive
|
|
||||||
}
|
|
||||||
@@ -76,7 +76,7 @@ def mainPage() {
|
|||||||
}
|
}
|
||||||
section{
|
section{
|
||||||
input "actionType", "enum", title: "Action?", required: true, defaultValue: "Bell 1", options: [
|
input "actionType", "enum", title: "Action?", required: true, defaultValue: "Bell 1", options: [
|
||||||
//"Custom Message",
|
"Custom Message",
|
||||||
"Bell 1",
|
"Bell 1",
|
||||||
"Bell 2",
|
"Bell 2",
|
||||||
"Dogs Barking",
|
"Dogs Barking",
|
||||||
@@ -89,7 +89,7 @@ def mainPage() {
|
|||||||
"Someone is arriving",
|
"Someone is arriving",
|
||||||
"Piano",
|
"Piano",
|
||||||
"Lightsaber"]
|
"Lightsaber"]
|
||||||
//input "message","text",title:"Play this message", required:false, multiple: false
|
input "message","text",title:"Play this message", required:false, multiple: false
|
||||||
}
|
}
|
||||||
section {
|
section {
|
||||||
input "sonos", "capability.musicPlayer", title: "On this Speaker player", required: true
|
input "sonos", "capability.musicPlayer", title: "On this Speaker player", required: true
|
||||||
@@ -408,13 +408,15 @@ private loadText() {
|
|||||||
case "Lightsaber":
|
case "Lightsaber":
|
||||||
state.sound = [uri: "http://s3.amazonaws.com/smartapp-media/sonos/lightsaber.mp3", duration: "10"]
|
state.sound = [uri: "http://s3.amazonaws.com/smartapp-media/sonos/lightsaber.mp3", duration: "10"]
|
||||||
break;
|
break;
|
||||||
default:
|
case "Custom Message":
|
||||||
/*if (message) {
|
if (message) {
|
||||||
state.sound = textToSpeech(message instanceof List ? message[0] : message) // not sure why this is (sometimes) needed)
|
state.sound = textToSpeech(message instanceof List ? message[0] : message) // not sure why this is (sometimes) needed)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
state.sound = textToSpeech("You selected the custom message option but did not enter a message in the $app.label Smart App")
|
state.sound = textToSpeech("You selected the custom message option but did not enter a message in the $app.label Smart App")
|
||||||
}*/
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
state.sound = [uri: "http://s3.amazonaws.com/smartapp-media/sonos/bell1.mp3", duration: "10"]
|
state.sound = [uri: "http://s3.amazonaws.com/smartapp-media/sonos/bell1.mp3", duration: "10"]
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user