mirror of
https://github.com/mtan93/SmartThingsPublic.git
synced 2026-03-10 05:11:51 +00:00
Compare commits
7 Commits
PROD_2016.
...
MSA-1214-1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d1b796491a | ||
|
|
9d83b850ca | ||
|
|
84de336a1a | ||
|
|
8b465b03b4 | ||
|
|
2f81964479 | ||
|
|
327f8dfb00 | ||
|
|
235e3f5507 |
@@ -24,6 +24,7 @@ metadata {
|
||||
command "enrollResponse"
|
||||
|
||||
|
||||
fingerprint inClusters: "0000,0001,0003,0500,0020", manufacturer: "NYCE", model: "3010", deviceJoinName: "NYCE Door Hinge Sensor"
|
||||
fingerprint inClusters: "0000,0001,0003,0406,0500,0020", manufacturer: "NYCE", model: "3011", deviceJoinName: "NYCE Door/Window Sensor"
|
||||
fingerprint inClusters: "0000,0001,0003,0500,0020", manufacturer: "NYCE", model: "3011", deviceJoinName: "NYCE Door/Window Sensor"
|
||||
fingerprint inClusters: "0000,0001,0003,0406,0500,0020", manufacturer: "NYCE", model: "3014", deviceJoinName: "NYCE Tilt Sensor"
|
||||
|
||||
@@ -824,7 +824,7 @@ def setColor(childDevice, huesettings) {
|
||||
value.bri = Math.min(Math.round(huesettings.level * 255 / 100), 255)
|
||||
}
|
||||
value.alert = huesettings.alert ? huesettings.alert : "none"
|
||||
value.transition = huesettings.transition ? huesettings.transition : 4
|
||||
value.transitiontime = huesettings.transitiontime ? huesettings.transitiontime : 4
|
||||
|
||||
// Make sure to turn off light if requested
|
||||
if (huesettings.switch == "off")
|
||||
|
||||
@@ -0,0 +1,132 @@
|
||||
/**
|
||||
* Simulated Device Manager
|
||||
*
|
||||
* Author: SmartThings (Juan Risso - juan@smartthings.com)
|
||||
*/
|
||||
|
||||
definition(
|
||||
name: "Simulated Device Manager",
|
||||
namespace: "smartthings",
|
||||
author: "SmartThings",
|
||||
description: "Allows you to create virtual devices to populate your account.",
|
||||
category: "SmartThings Labs",
|
||||
iconUrl: "https://d3abxbgmpfhmxi.cloudfront.net/assets/downloads/smartthings-logo-ring.7311e9df.png",
|
||||
iconX2Url: "https://d3abxbgmpfhmxi.cloudfront.net/assets/downloads/smartthings-logo-ring.7311e9df.png",
|
||||
singleInstance: true
|
||||
)
|
||||
|
||||
preferences {
|
||||
page(name:"selectDevices", title:"Simulated Device Manager")
|
||||
}
|
||||
|
||||
//PAGES
|
||||
def selectDevices() {
|
||||
return dynamicPage(name:"selectDevices", title:"Simulated Device Manager", nextPage:"", install:true, uninstall: true) {
|
||||
def options = [1,2,3,4,5]
|
||||
section("Please select the number of virtual devices you want to install") {
|
||||
input "selectedswitch", "enum", required:false, title:"Select number of Simulated Switches", multiple:false, options:options
|
||||
input "selectedmotion", "enum", required:false, title:"Select number of Simulated Motion Sensors", multiple:false, options:options
|
||||
input "selectedpresence", "enum", required:false, title:"Select number of Simulated Presence Sensors", multiple:false, options:options
|
||||
input "selectedsmoke", "enum", required:false, title:"Select number of Simulated Smoke Alarms", multiple:false, options:options
|
||||
input "selectedleak", "enum", required:false, title:"Select number of Simulated Water Sensors", multiple:false, options:options
|
||||
input "selectedalarm", "enum", required:false, title:"Select number of Simulated Alarms", multiple:false, options:options
|
||||
input "selectedbutton", "enum", required:false, title:"Select number of Simulated Buttons", multiple:false, options:options
|
||||
input "selectedcontact", "enum", required:false, title:"Select number of Simulated Contact Sensors", multiple:false, options:options
|
||||
input "selectedlock", "enum", required:false, title:"Select number of Simulated Locks", multiple:false, options:options
|
||||
input "selectedtemperature", "enum", required:false, title:"Select number of Simulated Temperature Sensors", multiple:false, options:options
|
||||
input "selectedthermostat", "enum", required:false, title:"Select number of Simulated Thermostats", multiple:false, options:options
|
||||
input "selectedvalve", "enum", required:false, title:"Select number of Simulated Valves", multiple:false, options:options
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def installed() {
|
||||
log.trace "Installed with settings: ${settings}"
|
||||
initialize()
|
||||
}
|
||||
|
||||
def updated() {
|
||||
log.trace "Updated with settings: ${settings}"
|
||||
initialize()
|
||||
}
|
||||
|
||||
def uninstalled() {
|
||||
def devices = getChildDevices()
|
||||
log.trace "deleting ${devices.size()} device"
|
||||
devices.each {
|
||||
deleteChildDevice(it.deviceNetworkId)
|
||||
}
|
||||
}
|
||||
|
||||
def initialize() {
|
||||
addDevice()
|
||||
}
|
||||
|
||||
//CHILD DEVICE METHODS
|
||||
def addDevice(){
|
||||
log.trace "addDevice()"
|
||||
def type = [selectedswitch: selectedswitch,selectedmotion: selectedmotion,selectedpresence: selectedpresence,selectedsmoke: selectedsmoke,selectedleak: selectedleak,selectedalarm: selectedalarm,selectedbutton: selectedbutton,selectedcontact: selectedcontact,selectedlock: selectedlock,selectedtemperature: selectedtemperature,selectedthermostat: selectedthermostat,selectedvalve: selectedvalve]
|
||||
type.each {key, value ->
|
||||
if (value > 0) {
|
||||
def deviceName = getDeviceName(key)
|
||||
log.trace "Adding ${deviceName}"
|
||||
def aux
|
||||
for (aux = 1; aux <= value; aux++) {
|
||||
def dni = "$key$aux"
|
||||
def d = getChildDevice(dni)
|
||||
if(!d) {
|
||||
d = addChildDevice("smartthings/testing", deviceName, dni, null, [label:"${deviceName} ${aux}"])
|
||||
log.trace "Created ${deviceName} with id ${dni}"
|
||||
} else {
|
||||
log.trace "${dni} already exists"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def getDeviceName(type) {
|
||||
def result
|
||||
switch (type) {
|
||||
case 'selectedswitch':
|
||||
result = 'Simulated Switch'
|
||||
break
|
||||
case 'selectedmotion':
|
||||
result = 'Simulated Motion Sensor'
|
||||
break
|
||||
case 'selectedpresence':
|
||||
result = 'Simulated Presence Sensor'
|
||||
break
|
||||
case 'selectedsmoke':
|
||||
result = 'Simulated Smoke Alarm'
|
||||
break
|
||||
case 'selectedleak':
|
||||
result = 'Simulated Water Sensor'
|
||||
break
|
||||
case 'selectedalarm':
|
||||
result = 'Simulated Alarm'
|
||||
break
|
||||
case 'selectedbutton':
|
||||
result = 'Simulated Button'
|
||||
break
|
||||
case 'selectedcontact':
|
||||
result = 'Simulated Contact Sensor'
|
||||
break
|
||||
case 'selectedlock':
|
||||
result = 'Simulated Lock'
|
||||
break
|
||||
case 'selectedtemperature':
|
||||
result = 'Simulated Temperature Sensor'
|
||||
break
|
||||
case 'selectedthermostat':
|
||||
result = 'Simulated Thermostat'
|
||||
break
|
||||
case 'selectedvalve':
|
||||
result = 'Simulated Water Valve'
|
||||
break
|
||||
default:
|
||||
result = ''
|
||||
break
|
||||
}
|
||||
result
|
||||
}
|
||||
@@ -236,23 +236,22 @@ def addSwitches() {
|
||||
d = getChildDevices()?.find {
|
||||
it.deviceNetworkId == selectedSwitch.value.mac || it.device.getDataValue("mac") == selectedSwitch.value.mac
|
||||
}
|
||||
}
|
||||
|
||||
if (!d) {
|
||||
log.debug "Creating WeMo Switch with dni: ${selectedSwitch.value.mac}"
|
||||
d = addChildDevice("smartthings", "Wemo Switch", selectedSwitch.value.mac, selectedSwitch?.value.hub, [
|
||||
"label": selectedSwitch?.value?.name ?: "Wemo Switch",
|
||||
"data": [
|
||||
"mac": selectedSwitch.value.mac,
|
||||
"ip": selectedSwitch.value.ip,
|
||||
"port": selectedSwitch.value.port
|
||||
]
|
||||
])
|
||||
def ipvalue = convertHexToIP(selectedSwitch.value.ip)
|
||||
d.sendEvent(name: "currentIP", value: ipvalue, descriptionText: "IP is ${ipvalue}")
|
||||
log.debug "Created ${d.displayName} with id: ${d.id}, dni: ${d.deviceNetworkId}"
|
||||
} else {
|
||||
log.debug "found ${d.displayName} with id $dni already exists"
|
||||
if (!d) {
|
||||
log.debug "Creating WeMo Switch with dni: ${selectedSwitch.value.mac}"
|
||||
d = addChildDevice("smartthings", "Wemo Switch", selectedSwitch.value.mac, selectedSwitch?.value.hub, [
|
||||
"label": selectedSwitch?.value?.name ?: "Wemo Switch",
|
||||
"data": [
|
||||
"mac": selectedSwitch.value.mac,
|
||||
"ip": selectedSwitch.value.ip,
|
||||
"port": selectedSwitch.value.port
|
||||
]
|
||||
])
|
||||
def ipvalue = convertHexToIP(selectedSwitch.value.ip)
|
||||
d.sendEvent(name: "currentIP", value: ipvalue, descriptionText: "IP is ${ipvalue}")
|
||||
log.debug "Created ${d.displayName} with id: ${d.id}, dni: ${d.deviceNetworkId}"
|
||||
} else {
|
||||
log.debug "found ${d.displayName} with id $dni already exists"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -267,23 +266,22 @@ def addMotions() {
|
||||
d = getChildDevices()?.find {
|
||||
it.deviceNetworkId == selectedMotion.value.mac || it.device.getDataValue("mac") == selectedMotion.value.mac
|
||||
}
|
||||
}
|
||||
|
||||
if (!d) {
|
||||
log.debug "Creating WeMo Motion with dni: ${selectedMotion.value.mac}"
|
||||
d = addChildDevice("smartthings", "Wemo Motion", selectedMotion.value.mac, selectedMotion?.value.hub, [
|
||||
"label": selectedMotion?.value?.name ?: "Wemo Motion",
|
||||
"data": [
|
||||
"mac": selectedMotion.value.mac,
|
||||
"ip": selectedMotion.value.ip,
|
||||
"port": selectedMotion.value.port
|
||||
]
|
||||
])
|
||||
def ipvalue = convertHexToIP(selectedMotion.value.ip)
|
||||
d.sendEvent(name: "currentIP", value: ipvalue, descriptionText: "IP is ${ipvalue}")
|
||||
log.debug "Created ${d.displayName} with id: ${d.id}, dni: ${d.deviceNetworkId}"
|
||||
} else {
|
||||
log.debug "found ${d.displayName} with id $dni already exists"
|
||||
if (!d) {
|
||||
log.debug "Creating WeMo Motion with dni: ${selectedMotion.value.mac}"
|
||||
d = addChildDevice("smartthings", "Wemo Motion", selectedMotion.value.mac, selectedMotion?.value.hub, [
|
||||
"label": selectedMotion?.value?.name ?: "Wemo Motion",
|
||||
"data": [
|
||||
"mac": selectedMotion.value.mac,
|
||||
"ip": selectedMotion.value.ip,
|
||||
"port": selectedMotion.value.port
|
||||
]
|
||||
])
|
||||
def ipvalue = convertHexToIP(selectedMotion.value.ip)
|
||||
d.sendEvent(name: "currentIP", value: ipvalue, descriptionText: "IP is ${ipvalue}")
|
||||
log.debug "Created ${d.displayName} with id: ${d.id}, dni: ${d.deviceNetworkId}"
|
||||
} else {
|
||||
log.debug "found ${d.displayName} with id $dni already exists"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -298,23 +296,22 @@ def addLightSwitches() {
|
||||
d = getChildDevices()?.find {
|
||||
it.deviceNetworkId == selectedLightSwitch.value.mac || it.device.getDataValue("mac") == selectedLightSwitch.value.mac
|
||||
}
|
||||
}
|
||||
|
||||
if (!d) {
|
||||
log.debug "Creating WeMo Light Switch with dni: ${selectedLightSwitch.value.mac}"
|
||||
d = addChildDevice("smartthings", "Wemo Light Switch", selectedLightSwitch.value.mac, selectedLightSwitch?.value.hub, [
|
||||
"label": selectedLightSwitch?.value?.name ?: "Wemo Light Switch",
|
||||
"data": [
|
||||
"mac": selectedLightSwitch.value.mac,
|
||||
"ip": selectedLightSwitch.value.ip,
|
||||
"port": selectedLightSwitch.value.port
|
||||
]
|
||||
])
|
||||
def ipvalue = convertHexToIP(selectedLightSwitch.value.ip)
|
||||
d.sendEvent(name: "currentIP", value: ipvalue, descriptionText: "IP is ${ipvalue}")
|
||||
log.debug "created ${d.displayName} with id $dni"
|
||||
} else {
|
||||
log.debug "found ${d.displayName} with id $dni already exists"
|
||||
if (!d) {
|
||||
log.debug "Creating WeMo Light Switch with dni: ${selectedLightSwitch.value.mac}"
|
||||
d = addChildDevice("smartthings", "Wemo Light Switch", selectedLightSwitch.value.mac, selectedLightSwitch?.value.hub, [
|
||||
"label": selectedLightSwitch?.value?.name ?: "Wemo Light Switch",
|
||||
"data": [
|
||||
"mac": selectedLightSwitch.value.mac,
|
||||
"ip": selectedLightSwitch.value.ip,
|
||||
"port": selectedLightSwitch.value.port
|
||||
]
|
||||
])
|
||||
def ipvalue = convertHexToIP(selectedLightSwitch.value.ip)
|
||||
d.sendEvent(name: "currentIP", value: ipvalue, descriptionText: "IP is ${ipvalue}")
|
||||
log.debug "created ${d.displayName} with id $dni"
|
||||
} else {
|
||||
log.debug "found ${d.displayName} with id $dni already exists"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user