mirror of
https://github.com/mtan93/SmartThingsPublic.git
synced 2026-03-09 05:11:52 +00:00
Compare commits
3 Commits
MSA-1311-1
...
MSA-1321-1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
95a1685989 | ||
|
|
ff0860cbe1 | ||
|
|
ecfb99974b |
@@ -0,0 +1,110 @@
|
||||
/**
|
||||
* Hue White Ambiance Bulb
|
||||
*
|
||||
* Philips Hue Type "Color Temperature Light"
|
||||
*
|
||||
* Author: SmartThings
|
||||
*/
|
||||
|
||||
// for the UI
|
||||
metadata {
|
||||
// Automatically generated. Make future change here.
|
||||
definition (name: "Hue White Ambiance Bulb", namespace: "smartthings", author: "SmartThings") {
|
||||
capability "Switch Level"
|
||||
capability "Actuator"
|
||||
capability "Color Temperature"
|
||||
capability "Switch"
|
||||
capability "Refresh"
|
||||
|
||||
command "refresh"
|
||||
}
|
||||
|
||||
simulator {
|
||||
// TODO: define status and reply messages here
|
||||
}
|
||||
|
||||
tiles (scale: 2){
|
||||
multiAttributeTile(name:"rich-control", type: "lighting", width: 6, height: 4, canChangeIcon: true){
|
||||
tileAttribute ("device.switch", key: "PRIMARY_CONTROL") {
|
||||
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 "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"
|
||||
}
|
||||
tileAttribute ("device.level", key: "SLIDER_CONTROL") {
|
||||
attributeState "level", action:"switch level.setLevel", range:"(0..100)"
|
||||
}
|
||||
}
|
||||
|
||||
controlTile("colorTempSliderControl", "device.colorTemperature", "slider", width: 4, height: 2, inactiveLabel: false, range:"(2000..6500)") {
|
||||
state "colorTemperature", action:"color temperature.setColorTemperature"
|
||||
}
|
||||
|
||||
valueTile("colorTemp", "device.colorTemperature", inactiveLabel: false, decoration: "flat", width: 2, height: 2) {
|
||||
state "colorTemperature", label: '${currentValue} K'
|
||||
}
|
||||
|
||||
standardTile("refresh", "device.refresh", height: 2, width: 2, inactiveLabel: false, decoration: "flat") {
|
||||
state "default", label:"", action:"refresh.refresh", icon:"st.secondary.refresh"
|
||||
}
|
||||
|
||||
main(["rich-control"])
|
||||
details(["rich-control", "colorTempSliderControl", "colorTemp", "refresh"])
|
||||
}
|
||||
}
|
||||
|
||||
// parse events into attributes
|
||||
def parse(description) {
|
||||
log.debug "parse() - $description"
|
||||
def results = []
|
||||
|
||||
def map = description
|
||||
if (description instanceof String) {
|
||||
log.debug "Hue Ambience Bulb stringToMap - ${map}"
|
||||
map = stringToMap(description)
|
||||
}
|
||||
|
||||
if (map?.name && map?.value) {
|
||||
results << createEvent(name: "${map?.name}", value: "${map?.value}")
|
||||
}
|
||||
results
|
||||
}
|
||||
|
||||
// handle commands
|
||||
void on() {
|
||||
log.trace parent.on(this)
|
||||
sendEvent(name: "switch", value: "on")
|
||||
}
|
||||
|
||||
void off() {
|
||||
log.trace parent.off(this)
|
||||
sendEvent(name: "switch", value: "off")
|
||||
}
|
||||
|
||||
void setLevel(percent) {
|
||||
log.debug "Executing 'setLevel'"
|
||||
if (percent != null && percent >= 0 && percent <= 100) {
|
||||
parent.setLevel(this, percent)
|
||||
sendEvent(name: "level", value: percent)
|
||||
sendEvent(name: "switch", value: "on")
|
||||
} else {
|
||||
log.warn "$percent is not 0-100"
|
||||
}
|
||||
}
|
||||
|
||||
void setColorTemperature(value) {
|
||||
if (value) {
|
||||
log.trace "setColorTemperature: ${value}k"
|
||||
parent.setColorTemperature(this, value)
|
||||
sendEvent(name: "colorTemperature", value: value)
|
||||
sendEvent(name: "switch", value: "on")
|
||||
} else {
|
||||
log.warn "Invalid color temperature"
|
||||
}
|
||||
}
|
||||
|
||||
void refresh() {
|
||||
log.debug "Executing 'refresh'"
|
||||
parent.manualRefresh()
|
||||
}
|
||||
|
||||
@@ -0,0 +1,170 @@
|
||||
/**
|
||||
* 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()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -323,6 +323,8 @@ private getDeviceType(hueType) {
|
||||
return "Hue Bulb"
|
||||
else if (hueType?.equalsIgnoreCase("Color Light"))
|
||||
return "Hue Bloom"
|
||||
else if (hueType?.equalsIgnoreCase("Color Temperature Light"))
|
||||
return "Hue White Ambiance Bulb"
|
||||
else
|
||||
return null
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user