Compare commits

..

1 Commits

Author SHA1 Message Date
Vinay Rao
a17971d68c Merge pull request #1583 from SmartThingsCommunity/staging
Rolling up staging to production for deploy
2017-01-10 15:01:44 -08:00
8 changed files with 261 additions and 564 deletions

View File

@@ -22,10 +22,9 @@ metadata {
capability "Sensor" capability "Sensor"
capability "Health Check" capability "Health Check"
fingerprint mfr:"0063", prod:"4457", deviceJoinName: "GE In-Wall Smart Dimmer " fingerprint mfr:"0063", prod:"4457", deviceJoinName: "Z-Wave Wall Dimmer"
fingerprint mfr:"0063", prod:"4944", deviceJoinName: "GE In-Wall Smart Dimmer " fingerprint mfr:"0063", prod:"4944", deviceJoinName: "Z-Wave Wall Dimmer"
fingerprint mfr:"0063", prod:"5044", deviceJoinName: "GE Plug-In Smart Dimmer " fingerprint mfr:"0063", prod:"5044", deviceJoinName: "Z-Wave Plug-In Dimmer"
fingerprint mfr:"0063", prod:"4944", model:"3034", deviceJoinName: "GE In-Wall Smart Fan Control"
} }
simulator { simulator {

View File

@@ -86,7 +86,7 @@ def parse(String description) {
def bodyString = msg.body def bodyString = msg.body
if (bodyString) { if (bodyString) {
unschedule("setOffline") unschedule("setOffline")
def body = new XmlSlurper().parseText(bodyString.replaceAll("[^\\x20-\\x7e]", "")) def body = new XmlSlurper().parseText(bodyString)
if (body?.property?.TimeSyncRequest?.text()) { if (body?.property?.TimeSyncRequest?.text()) {
log.trace "Got TimeSyncRequest" log.trace "Got TimeSyncRequest"

View File

@@ -78,7 +78,7 @@ def parse(String description) {
def bodyString = msg.body def bodyString = msg.body
if (bodyString) { if (bodyString) {
unschedule("setOffline") unschedule("setOffline")
def body = new XmlSlurper().parseText(bodyString.replaceAll("[^\\x20-\\x7e]", "")) def body = new XmlSlurper().parseText(bodyString)
if (body?.property?.TimeSyncRequest?.text()) { if (body?.property?.TimeSyncRequest?.text()) {
log.trace "Got TimeSyncRequest" log.trace "Got TimeSyncRequest"
result << timeSyncResponse() result << timeSyncResponse()

View File

@@ -84,7 +84,7 @@ def parse(String description) {
def bodyString = msg.body def bodyString = msg.body
if (bodyString) { if (bodyString) {
unschedule("setOffline") unschedule("setOffline")
def body = new XmlSlurper().parseText(bodyString.replaceAll("[^\\x20-\\x7e]", "")) def body = new XmlSlurper().parseText(bodyString)
if (body?.property?.TimeSyncRequest?.text()) { if (body?.property?.TimeSyncRequest?.text()) {
log.trace "Got TimeSyncRequest" log.trace "Got TimeSyncRequest"
result << timeSyncResponse() result << timeSyncResponse()

View File

@@ -24,10 +24,6 @@ metadata {
fingerprint inClusters: "0x26", deviceJoinName: "Z-Wave Dimmer" fingerprint inClusters: "0x26", deviceJoinName: "Z-Wave Dimmer"
fingerprint mfr:"001D", prod:"1902", deviceJoinName: "Z-Wave Dimmer" fingerprint mfr:"001D", prod:"1902", deviceJoinName: "Z-Wave Dimmer"
fingerprint mfr:"001D", prod:"1B03", model:"0334", deviceJoinName: "Leviton Universal Dimmer" fingerprint mfr:"001D", prod:"1B03", model:"0334", deviceJoinName: "Leviton Universal Dimmer"
fingerprint mfr:"011A", prod:"0102", model:"0201", deviceJoinName: "Enerwave In-Wall Dimmer"
fingerprint mfr:"001D", prod:"1001", model:"0334", deviceJoinName: "Leviton 3-Speed Fan Controller"
fingerprint mfr:"001D", prod:"0602", model:"0334", deviceJoinName: "Leviton Magnetic Low Voltage Dimmer"
fingerprint mfr:"001D", prod:"0401", model:"0334", deviceJoinName: "Leviton 600W Incandescent Dimmer"
} }
simulator { simulator {

View File

@@ -28,7 +28,6 @@ metadata {
fingerprint mfr: "0060", prod: "0001", model: "0002", deviceJoinName: "Everspring Motion Sensor" // Everspring SP814 fingerprint mfr: "0060", prod: "0001", model: "0002", deviceJoinName: "Everspring Motion Sensor" // Everspring SP814
fingerprint mfr: "0060", prod: "0001", model: "0003", deviceJoinName: "Everspring Motion Sensor" // Everspring HSP02 fingerprint mfr: "0060", prod: "0001", model: "0003", deviceJoinName: "Everspring Motion Sensor" // Everspring HSP02
fingerprint mfr: "011A", prod: "0601", model: "0901", deviceJoinName: "Enerwave Motion Sensor" // Enerwave ZWN-BPC fingerprint mfr: "011A", prod: "0601", model: "0901", deviceJoinName: "Enerwave Motion Sensor" // Enerwave ZWN-BPC
fingerprint mfr: "0063", prod: "4953", model: "3133", deviceJoinName: "GE Smart Motion Sensor"
} }
simulator { simulator {

View File

@@ -25,9 +25,6 @@ metadata {
fingerprint mfr:"0063", prod:"4F50", model:"3031", deviceJoinName: "GE Plug-in Outdoor Switch" fingerprint mfr:"0063", prod:"4F50", model:"3031", deviceJoinName: "GE Plug-in Outdoor Switch"
fingerprint mfr:"001D", prod:"1D04", model:"0334", deviceJoinName: "Leviton Outlet" fingerprint mfr:"001D", prod:"1D04", model:"0334", deviceJoinName: "Leviton Outlet"
fingerprint mfr:"001D", prod:"1C02", model:"0334", deviceJoinName: "Leviton Switch" fingerprint mfr:"001D", prod:"1C02", model:"0334", deviceJoinName: "Leviton Switch"
fingerprint mfr:"001D", prod:"0301", model:"0334", deviceJoinName: "Leviton 15A Switch"
fingerprint mfr:"011A", prod:"0101", model:"0102", deviceJoinName: "Enerwave On/Off Switch"
fingerprint mfr:"011A", prod:"0101", model:"0603", deviceJoinName: "Enerwave Duplex Receptacle"
} }
// simulator metadata // simulator metadata

View File

@@ -16,55 +16,33 @@
definition( definition(
name: "Gideon", name: "Gideon",
namespace: "gideon.api", namespace: "gideon.api",
author: "Braindrain Solutions ltd", author: "Braindrain Solutions",
description: "Gideon Smart Home SmartApp allows you to connect and control all of your SmartThings devices through the Gideon app, making your SmartThings devices even smarter.", description: "Gideon AI Smart app allows you to connect and control all of your SmartThings devices through the Gideon AI app, making your SmartThings devices even smarter.",
category: "Family", category: "Family",
iconUrl: "http://s33.postimg.org/t77u7y7v3/logo.png", iconUrl: "http://s33.postimg.org/t77u7y7v3/logo.png",
iconX2Url: "http://s33.postimg.org/t77u7y7v3/logo.png", iconX2Url: "http://s33.postimg.org/t77u7y7v3/logo.png",
iconX3Url: "http://s33.postimg.org/t77u7y7v3/logo.png", iconX3Url: "http://s33.postimg.org/t77u7y7v3/logo.png",
oauth: [displayName: "Gideon Smart Home API app", displayLink: "gideon.ai"]) oauth: [displayName: "Gideon AI API", displayLink: "gideon.ai"])
preferences { preferences {
section("Control these contact sensors...") {
input "contact", "capability.contactSensor", multiple:true, required:false
}
section("Control these switches...") { section("Control these switches...") {
input "switches", "capability.switch", multiple:true, required:false input "switches", "capability.switch", multiple:true
}
section("Control these smoke alarms...") {
input "smoke_alarms", "capability.smokeDetector", multiple:true, required:false
}
section("Control these window shades...") {
input "shades", "capability.windowShade", multiple:true, required:false
}
section("Control these garage doors...") {
input "garage", "capability.garageDoorControl", multiple:true, required:false
}
section("Control these water sensors...") {
input "water_sensors", "capability.waterSensor", multiple:true, required:false
} }
section("Control these motion sensors...") { section("Control these motion sensors...") {
input "motions", "capability.motionSensor", multiple:true, required:false input "motions", "capability.motionSensor", multiple:true
} }
section("Control these presence sensors...") { section("Control these presence sensors...") {
input "presence_sensors", "capability.presenceSensor", multiple:true, required:false input "presence_sensors", "capability.presenceSensor", multiple:true
} }
/** section("Control these outlets...") { section("Control these outlets...") {
input "outlets", "capability.switch", multiple:true, required:false input "outlets", "capability.switch", multiple:true
}
*/
section("Control these power meters...") {
input "meters", "capability.powerMeter", multiple:true, required:false
} }
section("Control these locks...") { section("Control these locks...") {
input "locks", "capability.lock", multiple:true, required:false input "locks", "capability.lock", multiple:true
} }
section("Control these temperature sensors...") { section("Control these locks...") {
input "temperature_sensors", "capability.temperatureMeasurement", multiple:true, required:false input "temperature_sensors", "capability.temperatureMeasurement"
}
section("Control these batteries...") {
input "batteries", "capability.battery", multiple:true, required:false
} }
} }
@@ -82,98 +60,43 @@ def updated() {
} }
def initialize() { def initialize() {
// TODO: subscribe to attributes, devices, locations, etc.
subscribe(outlet, "energy", outletHandler)
subscribe(outlet, "switch", outletHandler)
} }
// TODO: implement event handlers
def outletHandler(evt) {
log.debug "$outlet.currentEnergy"
//TODO call G API
}
private device(it, type) { private device(it, type) {
it ? [id: it.id, label: it.label, type: type] : null it ? [id: it.id, label: it.label, type: type] : null
} }
//API Mapping //API Mapping
mappings { mappings {
path("/getalldevices") { path("/getalldevices") {
action: [ action: [
GET: "getAllDevices" GET: "getAllDevices"
]
}
path("/doorlocks/lock/:id") {
action: [
GET: "lockDoorLock"
]
}
path("/doorlocks/unlock/:id") {
action: [
GET: "unlockDoorLock"
]
}
path("/doorlocks/:id") {
action: [
GET: "getDoorLockStatus"
]
}
path("/contacts/:id") {
action: [
GET: "getContactStatus"
]
}
path("/smoke/:id") {
action: [
GET: "getSmokeStatus"
] ]
} }
path("/shades/open/:id") { path("/doorlocks/:id/:command") {
action: [ action: [
GET: "openShade" GET: "updateDoorLock"
] ]
} }
path("/shades/preset/:id") { path("/doorlocks/:id") {
action: [ action: [
GET: "presetShade" GET: "getDoorLockStatus"
]
}
path("/shades/close/:id") {
action: [
GET: "closeShade"
]
}
path("/shades/:id") {
action: [
GET: "getShadeStatus"
]
}
path("/garage/open/:id") {
action: [
GET: "openGarage"
]
}
path("/garage/close/:id") {
action: [
GET: "closeGarage"
]
}
path("/garage/:id") {
action: [
GET: "getGarageStatus"
]
}
path("/watersensors/:id") {
action: [
GET: "getWaterSensorStatus"
] ]
} }
path("/tempsensors/:id") { path("/tempsensors/:id") {
action: [ action: [
GET: "getTempSensorsStatus" GET: "getTempSensorsStatus"
] ]
}
path("/meters/:id") {
action: [
GET: "getMeterStatus"
]
}
path("/batteries/:id") {
action: [
GET: "getBatteryStatus"
]
} }
path("/presences/:id") { path("/presences/:id") {
action: [ action: [
@@ -185,35 +108,19 @@ mappings {
GET: "getMotionStatus" GET: "getMotionStatus"
] ]
} }
/** path("/outlets/:id") { path("/outlets/:id") {
action: [ action: [
GET: "getOutletStatus" GET: "getOutletStatus"
] ]
} }
path("/outlets/turnon/:id") { path("/outlets/:id/:command") {
action: [ action: [
GET: "turnOnOutlet" GET: "updateOutlet"
] ]
} }
path("/outlets/turnoff/:id") { path("/switches/:command") {
action: [ action: [
GET: "turnOffOutlet" PUT: "updateSwitch"
]
}
*/
path("/switches/turnon/:id") {
action: [
GET: "turnOnSwitch"
]
}
path("/switches/turnoff/:id") {
action: [
GET: "turnOffSwitch"
]
}
path("/switches/:id") {
action: [
GET: "getSwitchStatus"
] ]
} }
} }
@@ -221,149 +128,12 @@ mappings {
//API Methods //API Methods
def getAllDevices() { def getAllDevices() {
def locks_list = locks.collect{device(it,"Lock")} def locks_list = locks.collect{device(it,"Lock")}
def contact_list = contact.collect{device(it,"Contact Sensor")}
def smokes_list = smoke_alarms.collect{device(it,"Smoke Alarm")}
def shades_list = shades.collect{device(it,"Window Shade")}
def garage_list = garage.collect{device(it,"Garage Door")}
def water_sensors_list = water_sensors.collect{device(it,"Water Sensor")}
def presences_list = presence_sensors.collect{device(it,"Presence")} def presences_list = presence_sensors.collect{device(it,"Presence")}
def motions_list = motions.collect{device(it,"Motion")} def motions_list = motions.collect{device(it,"Motion")}
/** def outlets_list = outlets.collect{device(it,"Outlet")} */ def outlets_list = outlets.collect{device(it,"Outlet")}
def switches_list = switches.collect{device(it,"Switch")} def switches_list = switches.collect{device(it,"Switch")}
def temp_list = temperature_sensors.collect{device(it,"Temperature")} def temp_list = temperature_sensors.collect{device(it,"Temperature")}
def meters_list = meters.collect{device(it,"Power Meters")} return [Locks: locks_list, Presences: presences_list, Motions: motions_list, Outlets: outlets_list, Switches: switches_list, Temperatures: temp_list]
def battery_list = batteries.collect{device(it,"Batteries")}
return smokes_list + contact_list + water_sensors_list + shades_list + garage_list + locks_list + presences_list + motions_list + switches_list + temp_list + meters_list + battery_list
}
//contact sensors
def getContactStatus() {
def device = contact.find { it.id == params.id }
if (!device) {
httpError(404, "Device not found")
} else {
def args = getTempSensorsStatus(device.id)
return [Device_state: device.currentValue('contact')] + args
}
}
//smoke detectors
def getSmokeStatus() {
def device = smoke_alarms.find { it.id == params.id }
if (!device) {
httpError(404, "Device not found")
} else {
def bat = getBatteryStatus(device.id)
return [Device_state: device.currentValue('smoke')] + bat
}
}
//garage
def getGarageStatus() {
def device = garage.find { it.id == params.id }
if (!device) {
httpError(404, "Device not found")
} else {
return [Device_state: device.currentValue('door')]
}
}
def openGarage() {
def device = garage.find { it.id == params.id }
if (!device) {
httpError(404, "Device not found")
} else {
device.open();
return [Device_id: params.id, result_action: "200"]
}
}
def closeGarage() {
def device = garage.find { it.id == params.id }
if (!device) {
httpError(404, "Device not found")
} else {
device.close();
return [Device_id: params.id, result_action: "200"]
}
}
//shades
def getShadeStatus() {
def device = shades.find { it.id == params.id }
if (!device) {
httpError(404, "Device not found")
} else {
return [Device_state: device.currentValue('windowShade')]
}
}
def openShade() {
def device = shades.find { it.id == params.id }
if (!device) {
httpError(404, "Device not found")
} else {
device.open();
return [Device_id: params.id, result_action: "200"]
}
}
def presetShade() {
def device = shades.find { it.id == params.id }
if (!device) {
httpError(404, "Device not found")
} else {
device.presetPosition();
return [Device_id: params.id, result_action: "200"]
}
}
def closeShade() {
def device = shades.find { it.id == params.id }
if (!device) {
httpError(404, "Device not found")
} else {
device.close();
return [Device_id: params.id, result_action: "200"]
}
}
//water sensor
def getWaterSensorStatus() {
def device = water_sensors.find { it.id == params.id }
if (!device) {
httpError(404, "Device not found")
} else {
def bat = getBatteryStatus(device.id)
return [Device_state: device.currentValue('water')] + bat
}
}
//batteries
def getBatteryStatus() {
def device = batteries.find { it.id == params.id }
if (!device) {
httpError(404, "Device not found")
} else {
return [Device_state: device.latestValue("battery")]
}
}
def getBatteryStatus(id) {
def device = batteries.find { it.id == id }
if (!device) {
return []
} else {
return [battery_state: device.latestValue("battery")]
}
} }
//LOCKS //LOCKS
@@ -372,34 +142,30 @@ def getDoorLockStatus() {
if (!device) { if (!device) {
httpError(404, "Device not found") httpError(404, "Device not found")
} else { } else {
def bat = getBatteryStatus(device.id) return [Device_state: device.currentValue('lock')]
return [Device_state: device.currentValue('lock')] + bat
} }
} }
def lockDoorLock() { def updateDoorLock() {
def command = params.command
def device = locks.find { it.id == params.id } def device = locks.find { it.id == params.id }
if (!device) { if (command){
if (!device) {
httpError(404, "Device not found") httpError(404, "Device not found")
} else { } else {
if(command == "toggle")
{
if(device.currentValue('lock') == "locked")
device.unlock();
else
device.lock();
device.lock(); return [Device_id: params.id, result_action: "200"]
return [Device_id: params.id, result_action: "200"]
} }
}
} }
}
def unlockDoorLock() {
def device = locks.find { it.id == params.id }
if (!device) {
httpError(404, "Device not found")
} else {
device.unlock();
return [Device_id: params.id, result_action: "200"]
}
}
//PRESENCE //PRESENCE
def getPresenceStatus() { def getPresenceStatus() {
@@ -407,8 +173,7 @@ def getPresenceStatus() {
if (!device) { if (!device) {
httpError(404, "Device not found") httpError(404, "Device not found")
} else { } else {
def bat = getBatteryStatus(device.id) return [Device_state: device.currentValue('presence')]
return [Device_state: device.currentValue('presence')] + bat
} }
} }
@@ -419,111 +184,63 @@ def getMotionStatus() {
if (!device) { if (!device) {
httpError(404, "Device not found") httpError(404, "Device not found")
} else { } else {
def args = getTempSensorsStatus(device.id) return [Device_state: device.currentValue('motion')]
return [Device_state: device.currentValue('motion')] + args
} }
} }
//OUTLET //OUTLET
/**
def getOutletStatus() { def getOutletStatus() {
def device = outlets.find { it.id == params.id } def device = outlets.find { it.id == params.id }
if (!device) { if (!device) {
httpError(404, "Device not found") httpError(404, "Device not found")
} else { } else {
def watt = getMeterStatus(device.id) return [Device_state: device.currentSwitch, Current_watt: device.currentValue("energy")]
return [Device_state: device.currentSwitch] + watt
}
}
*/
def getMeterStatus() {
def device = meters.find { it.id == params.id }
if (!device) {
httpError(404, "Device not found")
} else {
return [Device_id: device.id, Device_type: device.type, Current_watt: device.currentValue("power")]
} }
} }
def getMeterStatus(id) { def updateOutlet() {
def device = meters.find { it.id == id } def command = params.command
if (!device) {
return []
} else {
return [Current_watt: device.currentValue("power")]
}
}
/**
def turnOnOutlet() {
def device = outlets.find { it.id == params.id } def device = outlets.find { it.id == params.id }
if (command){ if (command){
if (!device) { if (!device) {
httpError(404, "Device not found") httpError(404, "Device not found")
} else { } else {
if(command == "toggle")
{
if(device.currentSwitch == "on")
device.off();
else
device.on();
device.on(); return [Device_id: params.id, result_action: "200"]
}
return [Device_id: params.id, result_action: "200"]
} }
} }
} }
def turnOffOutlet() {
def device = outlets.find { it.id == params.id }
if (command){
if (!device) {
httpError(404, "Device not found")
} else {
device.off();
return [Device_id: params.id, result_action: "200"]
}
}
}
*/
//SWITCH //SWITCH
def getSwitchStatus() { def updateSwitch() {
def device = switches.find { it.id == params.id } def command = params.command
if (!device) {
httpError(404, "Device not found")
} else {
return [Device_state: device.currentValue('switch')]
}
}
def turnOnSwitch() {
def device = switches.find { it.id == params.id } def device = switches.find { it.id == params.id }
if (command){ if (command){
if (!device) { if (!device) {
httpError(404, "Device not found") httpError(404, "Device not found")
} else { } else {
if(command == "toggle")
{
if(device.currentSwitch == "on")
device.off();
else
device.on();
device.on(); return [Device_id: params.id, result_action: "200"]
}
return [Device_id: params.id, result_action: "200"]
} }
} }
} }
def turnOffSwitch() {
def device = switches.find { it.id == params.id }
if (command){
if (!device) {
httpError(404, "Device not found")
} else {
device.on();
return [Device_id: params.id, result_action: "200"]
}
}
}
//TEMPERATURE //TEMPERATURE
def getTempSensorsStatus() { def getTempSensorsStatus() {
@@ -531,17 +248,6 @@ def getTempSensorsStatus() {
if (!device) { if (!device) {
httpError(404, "Device not found") httpError(404, "Device not found")
} else { } else {
def bat = getBatteryStatus(device.id) return [Device_state: device.currentValue('temperature')]
return [Device_state: device.currentValue('temperature')] + bat
} }
} }
def getTempSensorsStatus(id) {
def device = temperature_sensors.find { it.id == id }
if (!device) {
return []
} else {
def bat = getBatteryStatus(device.id)
return [temperature: device.currentValue('temperature')] + bat
}
}