mirror of
https://github.com/mtan93/SmartThingsPublic.git
synced 2026-03-17 13:10:52 +00:00
Compare commits
19 Commits
PROD_2016.
...
MSA-1152-2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
26ac4343ee | ||
|
|
82214e29eb | ||
|
|
bf00284c74 | ||
|
|
8de5ed77f4 | ||
|
|
4d31f8dbe8 | ||
|
|
9d378ce9a1 | ||
|
|
8abe4ac29f | ||
|
|
104fa8d616 | ||
|
|
5b5e185ef0 | ||
|
|
3a0c9c1298 | ||
|
|
4a096fc884 | ||
|
|
1736caebfe | ||
|
|
0fa363fa1a | ||
|
|
0c5840087b | ||
|
|
a6ee53641f | ||
|
|
c6818c8c2b | ||
|
|
6ac174c2f3 | ||
|
|
e5841fb3cb | ||
|
|
805b870447 |
78
build.gradle
78
build.gradle
@@ -1,13 +1,15 @@
|
|||||||
import java.nio.charset.StandardCharsets
|
import java.nio.charset.StandardCharsets
|
||||||
import java.nio.file.Paths
|
import java.nio.file.Paths
|
||||||
|
import com.smartthings.deployment.slack.FileUpload
|
||||||
|
import com.smartthings.deployment.slack.Message
|
||||||
|
|
||||||
apply plugin: 'groovy'
|
apply plugin: 'groovy'
|
||||||
apply plugin: 'smartthings-executable-deployment'
|
apply plugin: 'smartthings-executable-deployment'
|
||||||
apply plugin: 'smartthings-hipchat'
|
apply plugin: 'smartthings-slack'
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath "com.smartthings.deployment:executable-deployment-scripts:1.0.6"
|
classpath "com.smartthings.deployment:executable-deployment-scripts:1.0.7"
|
||||||
}
|
}
|
||||||
repositories {
|
repositories {
|
||||||
mavenLocal()
|
mavenLocal()
|
||||||
@@ -30,7 +32,43 @@ repositories {
|
|||||||
dependencies {
|
dependencies {
|
||||||
}
|
}
|
||||||
|
|
||||||
hipchatShareFile {
|
slackSendMessage {
|
||||||
|
String branch = project.hasProperty('branch') ? project.property('branch') : 'unknown'
|
||||||
|
String token = project.hasProperty('slackToken') ? project.property('slackToken') : null
|
||||||
|
String webhookUrl = project.hasProperty('slackWebhookUrl') ? project.property('slackWebhookUrl') : null
|
||||||
|
String channel = project.hasProperty('slackChannel') ? project.property('slackChannel') : null
|
||||||
|
String drinks = 'https://dl.dropboxusercontent.com/s/m1z5mpd3c83lwev/minion_beer.jpeg?dl=0'
|
||||||
|
String wolverine = 'https://dl.dropboxusercontent.com/s/4lbjqzvm2v033u9/minion_wolverine.jpg?dl=0'
|
||||||
|
String beach = 'https://dl.dropboxusercontent.com/s/rqrfgxk53gfng69/minion_beach.png?dl=0'
|
||||||
|
String iconUrl
|
||||||
|
String color
|
||||||
|
String messageText
|
||||||
|
String username
|
||||||
|
switch (branch) {
|
||||||
|
case 'master':
|
||||||
|
username = 'Hickory'
|
||||||
|
iconUrl = wolverine
|
||||||
|
color = '#35D0F2'
|
||||||
|
messageText = 'Began deployment of _SmartThingsPublic[master]_ branch to the _Dev_ environments.'
|
||||||
|
break
|
||||||
|
case 'staging':
|
||||||
|
username = 'Dickory'
|
||||||
|
iconUrl = beach
|
||||||
|
color = '#FFDE20'
|
||||||
|
messageText = 'Began deployment of _SmartThingsPublic[staging]_ branch to the _Staging_ environments.'
|
||||||
|
break
|
||||||
|
case 'production':
|
||||||
|
username = 'Dock'
|
||||||
|
iconUrl = drinks
|
||||||
|
color = '#FF1D23'
|
||||||
|
messageText = 'Began deployment of _SmartThingsPublic[production]_ branch to the _Prod_ environments.'
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
username = 'Hickory'
|
||||||
|
iconUrl = wolverine
|
||||||
|
color = '#35D0F2'
|
||||||
|
messageText = "Began deployment of an _SmartThingsPublic[${branch}]_ branch. Have no idea what's going on."
|
||||||
|
}
|
||||||
List<String> archives = []
|
List<String> archives = []
|
||||||
File rootDir = new File("${project.buildDir}/archives")
|
File rootDir = new File("${project.buildDir}/archives")
|
||||||
if (rootDir.exists()) {
|
if (rootDir.exists()) {
|
||||||
@@ -43,19 +81,25 @@ hipchatShareFile {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Date date = new Date()
|
||||||
|
String fileDate = date.format('yyyy-MM-dd_HH-mm-ss', TimeZone.getTimeZone('GMT'))
|
||||||
|
|
||||||
// Set task properties
|
// Required Task Arguments.
|
||||||
data = archives.join('\n').getBytes(StandardCharsets.UTF_8)
|
file = new FileUpload(
|
||||||
fileName = 'deployment-notes.txt'
|
data: archives.join('\n').getBytes(StandardCharsets.UTF_8),
|
||||||
contentType = 'text/html'
|
filename: "deployment-notes-${fileDate}.txt",
|
||||||
}
|
title: 'Deployment Notes',
|
||||||
|
channels: channel,
|
||||||
hipchatSendNotification {
|
token: token,
|
||||||
String branch = project.hasProperty('branch') ? project.property('branch') : 'unknown'
|
color: color
|
||||||
message = "Began executable deploy of SmartThingsPublic(${branch})."
|
)
|
||||||
if (branch == 'master') {
|
message = new Message(
|
||||||
message += ' (dev shards)'
|
webhookUrl: webhookUrl,
|
||||||
}
|
username: username,
|
||||||
color = branch == 'master' ? 'yellow' : 'red'
|
asUser: true,
|
||||||
notify = true
|
iconUrl: iconUrl,
|
||||||
|
channel: channel,
|
||||||
|
fallback: 'Deployment Notification',
|
||||||
|
text: messageText
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
10
circle.yml
10
circle.yml
@@ -15,13 +15,11 @@ deployment:
|
|||||||
develop:
|
develop:
|
||||||
branch: master
|
branch: master
|
||||||
commands:
|
commands:
|
||||||
- ./gradlew deployArchives -PsmartThingsArtifactoryUserName=$ARTIFACTORY_USERNAME -PsmartThingsArtifactoryPassword=$ARTIFACTORY_PASSWORD -Ps3Buckets="$S3_BUCKETS_DEV"
|
- ./gradlew deployArchives -PsmartThingsArtifactoryUserName="$ARTIFACTORY_USERNAME" -PsmartThingsArtifactoryPassword="$ARTIFACTORY_PASSWORD" -Ps3Buckets="$S3_BUCKETS_DEV"
|
||||||
- ./gradlew hipchatSendNotification -PsmartThingsArtifactoryUserName=$ARTIFACTORY_USERNAME -PsmartThingsArtifactoryPassword=$ARTIFACTORY_PASSWORD -Pbranch=$CIRCLE_BRANCH
|
- ./gradlew slackSendMessage -PsmartThingsArtifactoryUserName="$ARTIFACTORY_USERNAME" -PsmartThingsArtifactoryPassword="$ARTIFACTORY_PASSWORD" -Pbranch="$CIRCLE_BRANCH" -PslackToken="$SLACK_TOKEN" -PslackWebhookUrl="$SLACK_WEBHOOK_URL" -PslackChannel="$SLACK_CHANNEL" --stacktrace
|
||||||
- ./gradlew hipchatShareFile -PsmartThingsArtifactoryUserName=$ARTIFACTORY_USERNAME -PsmartThingsArtifactoryPassword=$ARTIFACTORY_PASSWORD
|
|
||||||
|
|
||||||
stage:
|
stage:
|
||||||
branch: staging
|
branch: staging
|
||||||
commands:
|
commands:
|
||||||
- ./gradlew deployArchives -PsmartThingsArtifactoryUserName=$ARTIFACTORY_USERNAME -PsmartThingsArtifactoryPassword=$ARTIFACTORY_PASSWORD -Ps3Buckets="$S3_BUCKETS_STAGE"
|
- ./gradlew deployArchives -PsmartThingsArtifactoryUserName="$ARTIFACTORY_USERNAME" -PsmartThingsArtifactoryPassword="$ARTIFACTORY_PASSWORD" -Ps3Buckets="$S3_BUCKETS_STAGE"
|
||||||
- ./gradlew hipchatSendNotification -PsmartThingsArtifactoryUserName=$ARTIFACTORY_USERNAME -PsmartThingsArtifactoryPassword=$ARTIFACTORY_PASSWORD -Pbranch=$CIRCLE_BRANCH
|
- ./gradlew slackSendMessage -PsmartThingsArtifactoryUserName="$ARTIFACTORY_USERNAME" -PsmartThingsArtifactoryPassword="$ARTIFACTORY_PASSWORD" -Pbranch="$CIRCLE_BRANCH" -PslackToken="$SLACK_TOKEN" -PslackWebhookUrl="$SLACK_WEBHOOK_URL" -PslackChannel="$SLACK_CHANNEL" --stacktrace
|
||||||
- ./gradlew hipchatShareFile -PsmartThingsArtifactoryUserName=$ARTIFACTORY_USERNAME -PsmartThingsArtifactoryPassword=$ARTIFACTORY_PASSWORD
|
|
||||||
|
|||||||
194
devicetypes/mitchpond/iris-smart-fob.src/iris-smart-fob.groovy
Normal file
194
devicetypes/mitchpond/iris-smart-fob.src/iris-smart-fob.groovy
Normal file
@@ -0,0 +1,194 @@
|
|||||||
|
/**
|
||||||
|
* Iris Smart Fob
|
||||||
|
*
|
||||||
|
* Copyright 2015 Mitch Pond
|
||||||
|
* Presence code adapted from SmartThings Arrival Sensor HA device type
|
||||||
|
*
|
||||||
|
* 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: "Iris Smart Fob", namespace: "mitchpond", author: "Mitch Pond") {
|
||||||
|
capability "Battery"
|
||||||
|
capability "Button"
|
||||||
|
capability "Configuration"
|
||||||
|
capability "Presence Sensor"
|
||||||
|
capability "Sensor"
|
||||||
|
|
||||||
|
//fingerprint endpointId: "01", profileId: "0104", inClusters: "0000,0001,0003,0007,0020,0B05", outClusters: "0003,0006,0019", model:"3450-L", manufacturer: "CentraLite"
|
||||||
|
}
|
||||||
|
|
||||||
|
preferences{
|
||||||
|
input ("holdTime", "number", title: "Minimum time in seconds for a press to count as \"held\"",
|
||||||
|
defaultValue: 3, displayDuringSetup: false)
|
||||||
|
input "checkInterval", "enum", title: "Presence timeout (minutes)",
|
||||||
|
defaultValue:"2", options: ["2", "3", "5"], displayDuringSetup: false
|
||||||
|
input "logging", "bool", title: "Enable debug logging",
|
||||||
|
defaultValue: false, displayDuringSetup: false
|
||||||
|
}
|
||||||
|
|
||||||
|
tiles(scale: 2) {
|
||||||
|
standardTile("presence", "device.presence", width: 4, height: 4, canChangeBackground: true) {
|
||||||
|
state "present", label: "Present", labelIcon:"st.presence.tile.present", backgroundColor:"#53a7c0"
|
||||||
|
state "not present", labelIcon:"st.presence.tile.not-present", backgroundColor:"#ffffff"
|
||||||
|
}
|
||||||
|
standardTile("button", "device.button", decoration: "flat", width: 2, height: 2) {
|
||||||
|
state "default", icon: "st.unknown.zwave.remote-controller", backgroundColor: "#ffffff"
|
||||||
|
}
|
||||||
|
valueTile("battery", "device.battery", decoration: "flat", width: 2, height: 2) {
|
||||||
|
state "battery", label:'${currentValue}% battery', unit:""
|
||||||
|
}
|
||||||
|
|
||||||
|
main (["presence"])
|
||||||
|
details(["presence","button","battery"])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def parse(String description) {
|
||||||
|
def descMap = zigbee.parseDescriptionAsMap(description)
|
||||||
|
logIt descMap
|
||||||
|
state.lastCheckin = now()
|
||||||
|
logIt "lastCheckin = ${state.lastCheckin}"
|
||||||
|
handlePresenceEvent(true)
|
||||||
|
|
||||||
|
def results = []
|
||||||
|
if (description?.startsWith('catchall:'))
|
||||||
|
results = parseCatchAllMessage(descMap)
|
||||||
|
else if (description?.startsWith('read attr -'))
|
||||||
|
results = parseReportAttributeMessage(descMap)
|
||||||
|
else logIt(descMap, "trace")
|
||||||
|
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
def updated() {
|
||||||
|
startTimer()
|
||||||
|
configure()
|
||||||
|
}
|
||||||
|
|
||||||
|
def configure(){
|
||||||
|
logIt "Configuring Smart Fob..."
|
||||||
|
[
|
||||||
|
"zdo bind 0x${device.deviceNetworkId} 1 1 6 {${device.zigbeeId}} {}", "delay 200",
|
||||||
|
"zdo bind 0x${device.deviceNetworkId} 2 1 6 {${device.zigbeeId}} {}", "delay 200",
|
||||||
|
"zdo bind 0x${device.deviceNetworkId} 3 1 6 {${device.zigbeeId}} {}", "delay 200",
|
||||||
|
"zdo bind 0x${device.deviceNetworkId} 4 1 6 {${device.zigbeeId}} {}", "delay 200",
|
||||||
|
"zdo bind 0x${device.deviceNetworkId} 1 1 1 {${device.zigbeeId}} {}", "delay 200"
|
||||||
|
] +
|
||||||
|
zigbee.configureReporting(0x0001,0x0020,0x20,20,20,0x01)
|
||||||
|
}
|
||||||
|
|
||||||
|
def parseCatchAllMessage(descMap) {
|
||||||
|
if (descMap?.clusterId == "0006" && descMap?.command == "01") //button pressed
|
||||||
|
handleButtonPress(descMap.sourceEndpoint as int)
|
||||||
|
else if (descMap?.clusterId == "0006" && descMap?.command == "00") //button released
|
||||||
|
handleButtonRelease(descMap.sourceEndpoint as int)
|
||||||
|
else logIt("Parse: Unhandled message: ${descMap}","trace")
|
||||||
|
}
|
||||||
|
|
||||||
|
def parseReportAttributeMessage(descMap) {
|
||||||
|
if (descMap?.cluster == "0001" && descMap?.attrId == "0020") createBatteryEvent(getBatteryLevel(descMap.value))
|
||||||
|
else logIt descMap
|
||||||
|
}
|
||||||
|
|
||||||
|
private createBatteryEvent(percent) {
|
||||||
|
logIt "Battery level at " + percent
|
||||||
|
return createEvent([name: "battery", value: percent])
|
||||||
|
}
|
||||||
|
|
||||||
|
//this method determines if a press should count as a push or a hold and returns the relevant event type
|
||||||
|
private handleButtonRelease(button) {
|
||||||
|
logIt "lastPress state variable: ${state.lastPress}"
|
||||||
|
def sequenceError = {logIt("Uh oh...missed a message? Dropping this event.", "error"); state.lastPress = null; return []}
|
||||||
|
|
||||||
|
if (!state.lastPress) return sequenceError()
|
||||||
|
else if (state.lastPress.button != button) return sequenceError()
|
||||||
|
|
||||||
|
def currentTime = now()
|
||||||
|
def startOfPress = state.lastPress?.time
|
||||||
|
def timeDif = currentTime - startOfPress
|
||||||
|
def holdTimeMillisec = (settings.holdTime?:3).toInteger() * 1000
|
||||||
|
|
||||||
|
state.lastPress = null //we're done with this. clear it to make error conditions easier to catch
|
||||||
|
|
||||||
|
if (timeDif < 0)
|
||||||
|
//likely a message sequence issue or dropped packet. Drop this press and wait for another.
|
||||||
|
return sequenceError()
|
||||||
|
else if (timeDif < holdTimeMillisec)
|
||||||
|
return createButtonEvent(button,"pushed")
|
||||||
|
else
|
||||||
|
return createButtonEvent(button,"held")
|
||||||
|
}
|
||||||
|
|
||||||
|
private handleButtonPress(button) {
|
||||||
|
state.lastPress = [button: button, time: now()]
|
||||||
|
}
|
||||||
|
|
||||||
|
private createButtonEvent(button,action) {
|
||||||
|
logIt "Button ${button} ${action}"
|
||||||
|
return createEvent([
|
||||||
|
name: "button",
|
||||||
|
value: action,
|
||||||
|
data:[buttonNumber: button],
|
||||||
|
descriptionText: "${device.displayName} button ${button} was ${action}",
|
||||||
|
isStateChange: true,
|
||||||
|
displayed: true])
|
||||||
|
}
|
||||||
|
|
||||||
|
private getBatteryLevel(rawValue) {
|
||||||
|
def intValue = Integer.parseInt(rawValue,16)
|
||||||
|
def min = 2.1
|
||||||
|
def max = 3.0
|
||||||
|
def vBatt = intValue / 10
|
||||||
|
return ((vBatt - min) / (max - min) * 100) as int
|
||||||
|
}
|
||||||
|
|
||||||
|
private handlePresenceEvent(present) {
|
||||||
|
def wasPresent = device.currentState("presence")?.value == "present"
|
||||||
|
if (!wasPresent && present) {
|
||||||
|
logIt "Sensor is present"
|
||||||
|
startTimer()
|
||||||
|
} else if (!present) {
|
||||||
|
logIt "Sensor is not present"
|
||||||
|
stopTimer()
|
||||||
|
}
|
||||||
|
def linkText = getLinkText(device)
|
||||||
|
def eventMap = [
|
||||||
|
name: "presence",
|
||||||
|
value: present ? "present" : "not present",
|
||||||
|
linkText: linkText,
|
||||||
|
descriptionText: "${linkText} has ${present ? 'arrived' : 'left'}",
|
||||||
|
]
|
||||||
|
logIt "Creating presence event: ${eventMap}"
|
||||||
|
sendEvent(eventMap)
|
||||||
|
}
|
||||||
|
|
||||||
|
private startTimer() {
|
||||||
|
logIt "Scheduling periodic timer"
|
||||||
|
schedule("0 * * * * ?", checkPresenceCallback)
|
||||||
|
}
|
||||||
|
|
||||||
|
private stopTimer() {
|
||||||
|
logIt "Stopping periodic timer"
|
||||||
|
unschedule()
|
||||||
|
}
|
||||||
|
|
||||||
|
def checkPresenceCallback() {
|
||||||
|
def timeSinceLastCheckin = (now() - state.lastCheckin) / 1000
|
||||||
|
def theCheckInterval = (checkInterval ? checkInterval as int : 2) * 60
|
||||||
|
logIt "Sensor checked in ${timeSinceLastCheckin} seconds ago"
|
||||||
|
if (timeSinceLastCheckin >= theCheckInterval) {
|
||||||
|
handlePresenceEvent(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ****** Utility functions ******
|
||||||
|
|
||||||
|
private logIt(str, logLevel = 'debug') {if (settings.logging) log."$logLevel"(str) }
|
||||||
@@ -1,16 +1,16 @@
|
|||||||
#==============================================================================
|
#==============================================================================
|
||||||
# Copyright 2016 SmartThings
|
# Copyright 2016 SmartThings
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
# 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
|
# use this file except in compliance with the License. You may obtain a copy
|
||||||
# of the License at:
|
# 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
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
#==============================================================================
|
#==============================================================================
|
||||||
# Purpose: Arrival Sensor HA i18n Translation File
|
# Purpose: Arrival Sensor HA i18n Translation File
|
||||||
@@ -28,6 +28,7 @@
|
|||||||
'''Presence timeout (minutes)'''.ko=시간 초과. 스마트폰 위치 정보
|
'''Presence timeout (minutes)'''.ko=시간 초과. 스마트폰 위치 정보
|
||||||
'''Tap to set'''.ko=눌러서 설정
|
'''Tap to set'''.ko=눌러서 설정
|
||||||
'''Arrival Sensor'''.ko=도착알림 센서
|
'''Arrival Sensor'''.ko=도착알림 센서
|
||||||
|
'''${currentValue}% battery'''.ko=${currentValue}% 배터리
|
||||||
# Events / Notifications
|
# Events / Notifications
|
||||||
'''{{ linkText }} battery was {{ value }}'''.ko={{ linkText }}남아있는 배터리는 {{ value }}입니다.
|
'''{{ linkText }} battery was {{ value }}'''.ko={{ linkText }}남아있는 배터리는 {{ value }}입니다.
|
||||||
'''{{ linkText }} has arrived'''.ko={{ linkText }}집에 도착했습니다.
|
'''{{ linkText }} has arrived'''.ko={{ linkText }}집에 도착했습니다.
|
||||||
|
|||||||
227
devicetypes/smartthings/hue-bloom.src/hue-bloom.groovy
Normal file
227
devicetypes/smartthings/hue-bloom.src/hue-bloom.groovy
Normal file
@@ -0,0 +1,227 @@
|
|||||||
|
/**
|
||||||
|
* Hue Bloom
|
||||||
|
*
|
||||||
|
* Philips Hue Type "Color Light"
|
||||||
|
*
|
||||||
|
* Author: SmartThings
|
||||||
|
*/
|
||||||
|
|
||||||
|
// for the UI
|
||||||
|
metadata {
|
||||||
|
// Automatically generated. Make future change here.
|
||||||
|
definition (name: "Hue Bloom", namespace: "smartthings", author: "SmartThings") {
|
||||||
|
capability "Switch Level"
|
||||||
|
capability "Actuator"
|
||||||
|
capability "Color Control"
|
||||||
|
capability "Switch"
|
||||||
|
capability "Refresh"
|
||||||
|
capability "Sensor"
|
||||||
|
|
||||||
|
command "setAdjustedColor"
|
||||||
|
command "reset"
|
||||||
|
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:"#00A0DC", nextState:"turningOff"
|
||||||
|
attributeState "off", label:'${name}', action:"switch.on", icon:"st.lights.philips.hue-single", backgroundColor:"#C6C7CC", nextState:"turningOn"
|
||||||
|
attributeState "turningOn", label:'${name}', action:"switch.off", icon:"st.lights.philips.hue-single", backgroundColor:"#00A0DC", nextState:"turningOff"
|
||||||
|
attributeState "turningOff", label:'${name}', action:"switch.on", icon:"st.lights.philips.hue-single", backgroundColor:"#C6C7CC", nextState:"turningOn"
|
||||||
|
}
|
||||||
|
tileAttribute ("device.level", key: "SLIDER_CONTROL") {
|
||||||
|
attributeState "level", action:"switch level.setLevel", range:"(0..100)"
|
||||||
|
}
|
||||||
|
tileAttribute ("device.level", key: "SECONDARY_CONTROL") {
|
||||||
|
attributeState "level", label: 'Level ${currentValue}%'
|
||||||
|
}
|
||||||
|
tileAttribute ("device.color", key: "COLOR_CONTROL") {
|
||||||
|
attributeState "color", action:"setAdjustedColor"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
standardTile("reset", "device.reset", height: 2, width: 2, inactiveLabel: false, decoration: "flat") {
|
||||||
|
state "default", label:"Reset Color", action:"reset", icon:"st.lights.philips.hue-single"
|
||||||
|
}
|
||||||
|
|
||||||
|
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", "reset", "refresh"])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// parse events into attributes
|
||||||
|
def parse(description) {
|
||||||
|
log.debug "parse() - $description"
|
||||||
|
def results = []
|
||||||
|
|
||||||
|
def map = description
|
||||||
|
if (description instanceof String) {
|
||||||
|
log.debug "Hue 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 nextLevel() {
|
||||||
|
def level = device.latestValue("level") as Integer ?: 0
|
||||||
|
if (level <= 100) {
|
||||||
|
level = Math.min(25 * (Math.round(level / 25) + 1), 100) as Integer
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
level = 25
|
||||||
|
}
|
||||||
|
setLevel(level)
|
||||||
|
}
|
||||||
|
|
||||||
|
void setLevel(percent) {
|
||||||
|
log.debug "Executing 'setLevel'"
|
||||||
|
if (verifyPercent(percent)) {
|
||||||
|
parent.setLevel(this, percent)
|
||||||
|
sendEvent(name: "level", value: percent, descriptionText: "Level has changed to ${percent}%")
|
||||||
|
sendEvent(name: "switch", value: "on")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void setSaturation(percent) {
|
||||||
|
log.debug "Executing 'setSaturation'"
|
||||||
|
if (verifyPercent(percent)) {
|
||||||
|
parent.setSaturation(this, percent)
|
||||||
|
sendEvent(name: "saturation", value: percent, displayed: false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void setHue(percent) {
|
||||||
|
log.debug "Executing 'setHue'"
|
||||||
|
if (verifyPercent(percent)) {
|
||||||
|
parent.setHue(this, percent)
|
||||||
|
sendEvent(name: "hue", value: percent, displayed: false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void setColor(value) {
|
||||||
|
log.debug "setColor: ${value}, $this"
|
||||||
|
def events = []
|
||||||
|
def validValues = [:]
|
||||||
|
|
||||||
|
if (verifyPercent(value.hue)) {
|
||||||
|
events << createEvent(name: "hue", value: value.hue, displayed: false)
|
||||||
|
validValues.hue = value.hue
|
||||||
|
}
|
||||||
|
if (verifyPercent(value.saturation)) {
|
||||||
|
events << createEvent(name: "saturation", value: value.saturation, displayed: false)
|
||||||
|
validValues.saturation = value.saturation
|
||||||
|
}
|
||||||
|
if (value.hex != null) {
|
||||||
|
if (value.hex ==~ /^\#([A-Fa-f0-9]){6}$/) {
|
||||||
|
events << createEvent(name: "color", value: value.hex)
|
||||||
|
validValues.hex = value.hex
|
||||||
|
} else {
|
||||||
|
log.warn "$value.hex is not a valid color"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (verifyPercent(value.level)) {
|
||||||
|
events << createEvent(name: "level", value: value.level, descriptionText: "Level has changed to ${value.level}%")
|
||||||
|
validValues.level = value.level
|
||||||
|
}
|
||||||
|
if (value.switch == "off" || (value.level != null && value.level <= 0)) {
|
||||||
|
events << createEvent(name: "switch", value: "off")
|
||||||
|
validValues.switch = "off"
|
||||||
|
} else {
|
||||||
|
events << createEvent(name: "switch", value: "on")
|
||||||
|
validValues.switch = "on"
|
||||||
|
}
|
||||||
|
if (!events.isEmpty()) {
|
||||||
|
parent.setColor(this, validValues)
|
||||||
|
}
|
||||||
|
events.each {
|
||||||
|
sendEvent(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void reset() {
|
||||||
|
log.debug "Executing 'reset'"
|
||||||
|
def value = [level:100, saturation:56, hue:23]
|
||||||
|
setAdjustedColor(value)
|
||||||
|
parent.poll()
|
||||||
|
}
|
||||||
|
|
||||||
|
void setAdjustedColor(value) {
|
||||||
|
if (value) {
|
||||||
|
log.trace "setAdjustedColor: ${value}"
|
||||||
|
def adjusted = value + [:]
|
||||||
|
adjusted.hue = adjustOutgoingHue(value.hue)
|
||||||
|
// Needed because color picker always sends 100
|
||||||
|
adjusted.level = null
|
||||||
|
setColor(adjusted)
|
||||||
|
} else {
|
||||||
|
log.warn "Invalid color input"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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()
|
||||||
|
}
|
||||||
|
|
||||||
|
def adjustOutgoingHue(percent) {
|
||||||
|
def adjusted = percent
|
||||||
|
if (percent > 31) {
|
||||||
|
if (percent < 63.0) {
|
||||||
|
adjusted = percent + (7 * (percent -30 ) / 32)
|
||||||
|
}
|
||||||
|
else if (percent < 73.0) {
|
||||||
|
adjusted = 69 + (5 * (percent - 62) / 10)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
adjusted = percent + (2 * (100 - percent) / 28)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log.info "percent: $percent, adjusted: $adjusted"
|
||||||
|
adjusted
|
||||||
|
}
|
||||||
|
|
||||||
|
def verifyPercent(percent) {
|
||||||
|
if (percent == null)
|
||||||
|
return false
|
||||||
|
else if (percent >= 0 && percent <= 100) {
|
||||||
|
return true
|
||||||
|
} else {
|
||||||
|
log.warn "$percent is not 0-100"
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
/**
|
/**
|
||||||
* Hue Bulb
|
* Hue Bulb
|
||||||
*
|
*
|
||||||
|
* Philips Hue Type "Extended Color Light"
|
||||||
|
*
|
||||||
* Author: SmartThings
|
* Author: SmartThings
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -69,11 +71,13 @@ metadata {
|
|||||||
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}")
|
||||||
}
|
}
|
||||||
@@ -229,4 +233,4 @@ def verifyPercent(percent) {
|
|||||||
log.warn "$percent is not 0-100"
|
log.warn "$percent is not 0-100"
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
/**
|
/**
|
||||||
* Hue Lux Bulb
|
* Hue Lux Bulb
|
||||||
*
|
*
|
||||||
|
* Philips Hue Type "Dimmable Light"
|
||||||
|
*
|
||||||
* Author: SmartThings
|
* Author: SmartThings
|
||||||
*/
|
*/
|
||||||
// for the UI
|
// for the UI
|
||||||
@@ -23,10 +25,10 @@ metadata {
|
|||||||
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:"#00A0DC", 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:"#C6C7CC", 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:"#00A0DC", 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:"#C6C7CC", 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)"
|
||||||
@@ -68,12 +70,12 @@ def parse(description) {
|
|||||||
|
|
||||||
// handle commands
|
// handle commands
|
||||||
void on() {
|
void on() {
|
||||||
parent.on(this)
|
log.trace parent.on(this)
|
||||||
sendEvent(name: "switch", value: "on")
|
sendEvent(name: "switch", value: "on")
|
||||||
}
|
}
|
||||||
|
|
||||||
void off() {
|
void off() {
|
||||||
parent.off(this)
|
log.trace parent.off(this)
|
||||||
sendEvent(name: "switch", value: "off")
|
sendEvent(name: "switch", value: "off")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,6 +84,7 @@ void setLevel(percent) {
|
|||||||
if (percent != null && percent >= 0 && percent <= 100) {
|
if (percent != null && percent >= 0 && percent <= 100) {
|
||||||
parent.setLevel(this, percent)
|
parent.setLevel(this, percent)
|
||||||
sendEvent(name: "level", value: percent)
|
sendEvent(name: "level", value: percent)
|
||||||
|
sendEvent(name: "switch", value: "on")
|
||||||
} else {
|
} else {
|
||||||
log.warn "$percent is not 0-100"
|
log.warn "$percent is not 0-100"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,8 +28,8 @@
|
|||||||
'''{{ device.displayName }} is On'''.ko={{ device.displayName }}켜졌습니다.
|
'''{{ device.displayName }} is On'''.ko={{ device.displayName }}켜졌습니다.
|
||||||
'''{{ device.displayName }} is Off'''.ko={{ device.displayName }}꺼졌습니다.
|
'''{{ device.displayName }} is Off'''.ko={{ device.displayName }}꺼졌습니다.
|
||||||
'''{{ device.displayName }} power is {{ value }} Watts'''.ko={{ device.displayName }} 전원은 {{ value }}와트입니다
|
'''{{ device.displayName }} power is {{ value }} Watts'''.ko={{ device.displayName }} 전원은 {{ value }}와트입니다
|
||||||
'''On'''.ko=켜기
|
'''On'''.ko=켜짐
|
||||||
'''Off'''.ko=끄기
|
'''Off'''.ko=꺼짐
|
||||||
'''Turning On'''.ko=켜기
|
'''Turning On'''.ko=켜기
|
||||||
'''Turning Off'''.ko=끄기
|
'''Turning Off'''.ko=끄기
|
||||||
#==============================================================================
|
#==============================================================================
|
||||||
|
|||||||
@@ -22,6 +22,8 @@
|
|||||||
#==============================================================================
|
#==============================================================================
|
||||||
# Korean (ko)
|
# Korean (ko)
|
||||||
# Device Preferences
|
# Device Preferences
|
||||||
|
'''Dry'''.ko=건조
|
||||||
|
'''Wet'''.ko=누수
|
||||||
'''dry'''.ko=건조
|
'''dry'''.ko=건조
|
||||||
'''wet'''.ko=누수
|
'''wet'''.ko=누수
|
||||||
'''battery'''.ko=배터리
|
'''battery'''.ko=배터리
|
||||||
@@ -31,6 +33,7 @@
|
|||||||
'''Adjust temperature by this many degrees'''.ko=몇 도씩 온도를 조절하십시오
|
'''Adjust temperature by this many degrees'''.ko=몇 도씩 온도를 조절하십시오
|
||||||
'''Give your device a name'''.ko=기기 이름 바꾸기
|
'''Give your device a name'''.ko=기기 이름 바꾸기
|
||||||
'''Water Leak Sensor'''.ko=누수센서
|
'''Water Leak Sensor'''.ko=누수센서
|
||||||
|
'''${currentValue}% battery'''.ko=${currentValue}% 배터리
|
||||||
# Events descriptionText
|
# Events descriptionText
|
||||||
'''{{ device.displayName }} is dry'''.ko={{ device.displayName }}가 건조
|
'''{{ device.displayName }} is dry'''.ko={{ device.displayName }}가 건조
|
||||||
'''{{ device.displayName }} is wet'''.ko={{ device.displayName }}누수
|
'''{{ device.displayName }} is wet'''.ko={{ device.displayName }}누수
|
||||||
|
|||||||
@@ -30,6 +30,9 @@
|
|||||||
'''Adjust temperature by this many degrees'''.ko=몇 도씩 온도를 조절하십시오
|
'''Adjust temperature by this many degrees'''.ko=몇 도씩 온도를 조절하십시오
|
||||||
'''Give your device a name'''.ko=기기 이름 바꾸기
|
'''Give your device a name'''.ko=기기 이름 바꾸기
|
||||||
'''Motion Sensor'''.ko=모션 센서
|
'''Motion Sensor'''.ko=모션 센서
|
||||||
|
'''motion'''.ko=동작 감지
|
||||||
|
'''no motion'''.ko=동작 없음
|
||||||
|
'''${currentValue}% battery'''.ko=${currentValue}% 배터리
|
||||||
# Events descriptionText
|
# Events descriptionText
|
||||||
'''{{ device.displayName }} detected motion'''.ko={{ device.displayName }} 가 움직임을 감지하였습니다.
|
'''{{ device.displayName }} detected motion'''.ko={{ device.displayName }} 가 움직임을 감지하였습니다.
|
||||||
'''{{ device.displayName }} motion has stopped'''.ko={{ device.displayName }}움직임이 중단되었습니다
|
'''{{ device.displayName }} motion has stopped'''.ko={{ device.displayName }}움직임이 중단되었습니다
|
||||||
|
|||||||
@@ -45,5 +45,6 @@
|
|||||||
'''Updating device to open/close sensor'''.ko=기기-열림/닫힘 센서 업데이트 중
|
'''Updating device to open/close sensor'''.ko=기기-열림/닫힘 센서 업데이트 중
|
||||||
'''Inactive'''.ko=비활성
|
'''Inactive'''.ko=비활성
|
||||||
'''Active'''.ko=활성
|
'''Active'''.ko=활성
|
||||||
'''Open'''.ko=열다
|
'''Open'''.ko=열림
|
||||||
'''Closed'''.ko=닫은
|
'''Closed'''.ko=닫힘
|
||||||
|
'''${currentValue}% battery'''.ko=${currentValue}% 배터리
|
||||||
|
|||||||
@@ -245,6 +245,7 @@ def retypeBasedOnMSR() {
|
|||||||
break
|
break
|
||||||
case "011F-0001-0001": // Schlage motion
|
case "011F-0001-0001": // Schlage motion
|
||||||
case "014A-0001-0001": // Ecolink motion
|
case "014A-0001-0001": // Ecolink motion
|
||||||
|
case "014A-0004-0001": // Ecolink motion +
|
||||||
case "0060-0001-0002": // Everspring SP814
|
case "0060-0001-0002": // Everspring SP814
|
||||||
case "0060-0001-0003": // Everspring HSP02
|
case "0060-0001-0003": // Everspring HSP02
|
||||||
case "011A-0601-0901": // Enerwave ZWN-BPC
|
case "011A-0601-0901": // Enerwave ZWN-BPC
|
||||||
|
|||||||
32
smartapps/copy-ninja/myq-connect.src/myq-connect.groovy
Normal file
32
smartapps/copy-ninja/myq-connect.src/myq-connect.groovy
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
/**
|
||||||
|
* MyQ (Connect)
|
||||||
|
*
|
||||||
|
* Copyright 2015 Jason Mok
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* Last Updated : 03/08/2016
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
definition(
|
||||||
|
name: "MyQ (Connect)",
|
||||||
|
namespace: "copy-ninja",
|
||||||
|
author: "Jason Mok",
|
||||||
|
description: "Connect MyQ to control your devices",
|
||||||
|
category: "SmartThings Labs",
|
||||||
|
iconUrl: "http://smartthings.copyninja.net/icons/MyQ@1x.png",
|
||||||
|
iconX2Url: "http://smartthings.copyninja.net/icons/MyQ@2x.png",
|
||||||
|
iconX3Url: "http://smartthings.copyninja.net/icons/MyQ@3x.png"
|
||||||
|
)
|
||||||
|
|
||||||
|
preferences {
|
||||||
|
page(name: "prefLogIn", title: "MyQ")
|
||||||
|
page(name: "prefListDevices", title: "MyQ")
|
||||||
|
}
|
||||||
@@ -289,7 +289,7 @@ def bulbListHandler(hub, data = "") {
|
|||||||
def object = new groovy.json.JsonSlurper().parseText(data)
|
def object = new groovy.json.JsonSlurper().parseText(data)
|
||||||
object.each { k,v ->
|
object.each { k,v ->
|
||||||
if (v instanceof Map)
|
if (v instanceof Map)
|
||||||
bulbs[k] = [id: k, name: v.name, type: v.type, hub:hub]
|
bulbs[k] = [id: k, name: v.name, type: v.type, modelid: v.modelid, hub:hub]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
def bridge = null
|
def bridge = null
|
||||||
@@ -300,6 +300,40 @@ def bulbListHandler(hub, data = "") {
|
|||||||
return msg
|
return msg
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private upgradeDeviceType(device, newHueType) {
|
||||||
|
def deviceType = getDeviceType(newHueType)
|
||||||
|
|
||||||
|
// Automatically change users Hue bulbs to correct device types
|
||||||
|
if (deviceType && !(device?.typeName?.equalsIgnoreCase(deviceType))) {
|
||||||
|
log.debug "Update device type: \"$device.label\" ${device?.typeName}->$deviceType"
|
||||||
|
device.setDeviceType(deviceType)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private getDeviceType(hueType) {
|
||||||
|
// Determine ST device type based on Hue classification of light
|
||||||
|
if (hueType?.equalsIgnoreCase("Dimmable light"))
|
||||||
|
return "Hue Lux Bulb"
|
||||||
|
else if (hueType?.equalsIgnoreCase("Extended Color Light"))
|
||||||
|
return "Hue Bulb"
|
||||||
|
else if (hueType?.equalsIgnoreCase("Color Light"))
|
||||||
|
return "Hue Bloom"
|
||||||
|
else
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
private addChildBulb(dni, hueType, name, hub, update=false, device = null) {
|
||||||
|
def deviceType = getDeviceType(hueType)
|
||||||
|
|
||||||
|
if (deviceType) {
|
||||||
|
return addChildDevice("smartthings", deviceType, dni, hub, ["label": name])
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
log.warn "Device type $hueType not supported"
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
def addBulbs() {
|
def addBulbs() {
|
||||||
def bulbs = getHueBulbs()
|
def bulbs = getHueBulbs()
|
||||||
selectedBulbs?.each { dni ->
|
selectedBulbs?.each { dni ->
|
||||||
@@ -309,11 +343,7 @@ def addBulbs() {
|
|||||||
if (bulbs instanceof java.util.Map) {
|
if (bulbs instanceof java.util.Map) {
|
||||||
newHueBulb = bulbs.find { (app.id + "/" + it.value.id) == dni }
|
newHueBulb = bulbs.find { (app.id + "/" + it.value.id) == dni }
|
||||||
if (newHueBulb != null) {
|
if (newHueBulb != null) {
|
||||||
if (newHueBulb?.value?.type?.equalsIgnoreCase("Dimmable light") ) {
|
d = addChildBulb(dni, newHueBulb?.value?.type, newHueBulb?.value?.name, newHueBulb?.value?.hub)
|
||||||
d = addChildDevice("smartthings", "Hue Lux Bulb", dni, newHueBulb?.value.hub, ["label":newHueBulb?.value.name])
|
|
||||||
} else {
|
|
||||||
d = addChildDevice("smartthings", "Hue Bulb", dni, newHueBulb?.value.hub, ["label":newHueBulb?.value.name])
|
|
||||||
}
|
|
||||||
log.debug "created ${d.displayName} with id $dni"
|
log.debug "created ${d.displayName} with id $dni"
|
||||||
d.refresh()
|
d.refresh()
|
||||||
} else {
|
} else {
|
||||||
@@ -322,16 +352,15 @@ def addBulbs() {
|
|||||||
} else {
|
} else {
|
||||||
//backwards compatable
|
//backwards compatable
|
||||||
newHueBulb = bulbs.find { (app.id + "/" + it.id) == dni }
|
newHueBulb = bulbs.find { (app.id + "/" + it.id) == dni }
|
||||||
d = addChildDevice("smartthings", "Hue Bulb", dni, newHueBulb?.hub, ["label":newHueBulb?.name])
|
d = addChildBulb(dni, "Extended Color Light", newHueBulb?.value?.name, newHueBulb?.value?.hub)
|
||||||
d.refresh()
|
d.refresh()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log.debug "found ${d.displayName} with id $dni already exists, type: '$d.typeName'"
|
log.debug "found ${d.displayName} with id $dni already exists, type: '$d.typeName'"
|
||||||
if (bulbs instanceof java.util.Map) {
|
if (bulbs instanceof java.util.Map) {
|
||||||
|
// Update device type if incorrect
|
||||||
def newHueBulb = bulbs.find { (app.id + "/" + it.value.id) == dni }
|
def newHueBulb = bulbs.find { (app.id + "/" + it.value.id) == dni }
|
||||||
if (newHueBulb?.value?.type?.equalsIgnoreCase("Dimmable light") && d.typeName == "Hue Bulb") {
|
upgradeDeviceType(d, newHueBulb?.value?.type)
|
||||||
d.setDeviceType("Hue Lux Bulb")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -473,7 +502,7 @@ def locationHandler(evt) {
|
|||||||
def bulbs = getHueBulbs()
|
def bulbs = getHueBulbs()
|
||||||
log.debug "Adding bulbs to state!"
|
log.debug "Adding bulbs to state!"
|
||||||
body.each { k,v ->
|
body.each { k,v ->
|
||||||
bulbs[k] = [id: k, name: v.name, type: v.type, hub:parsedEvent.hub]
|
bulbs[k] = [id: k, name: v.name, type: v.type, modelid: v.modelid, hub:parsedEvent.hub]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -836,7 +865,7 @@ def convertBulbListToMap() {
|
|||||||
if (state.bulbs instanceof java.util.List) {
|
if (state.bulbs instanceof java.util.List) {
|
||||||
def map = [:]
|
def map = [:]
|
||||||
state.bulbs.unique {it.id}.each { bulb ->
|
state.bulbs.unique {it.id}.each { bulb ->
|
||||||
map << ["${bulb.id}":["id":bulb.id, "name":bulb.name, "hub":bulb.hub]]
|
map << ["${bulb.id}":["id":bulb.id, "name":bulb.name, "type": bulb.type, "modelid": bulb.modelid, "hub":bulb.hub]]
|
||||||
}
|
}
|
||||||
state.bulbs = map
|
state.bulbs = map
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user