Compare commits

...

13 Commits

Author SHA1 Message Date
Venkata Kishore Chilakala
f5664ff0e8 MSA-2411: we would like to provide a simple mobile application where user will login and connect his/her smart hub accounts.
we authenticate that through the common process provided by the service provides like Smartthings. 
Based on the autherization, we will list the devices and provide the control and monitoring mechanism to the end user.
2017-11-28 01:53:47 -08:00
Vinay Rao
ec70532a24 Merge pull request #2553 from SmartThingsCommunity/staging
Rolling down staging to master
2017-11-22 12:03:18 -08:00
Vinay Rao
858aee5f79 Merge pull request #2552 from SmartThingsCommunity/production
Rolling down production to staging
2017-11-22 12:02:51 -08:00
Vinay Rao
1421ad508c Merge pull request #2551 from dkirker/ICP-2151-2236-2237
ICP-2151, ICP-2236, ICP-2237 Add Samsung Lock fingerprint to DTH
2017-11-22 11:20:43 -08:00
Donald Kirker
9c4e8354b5 ICP-2151, ICP-2236, ICP-2237 Add Samsung Lock fingerprint to DTH
Give generic name to handle different locks with the same fingerprint
2017-11-21 18:49:48 -08:00
Amol Mundayoor
e96b94fdec Merge pull request #2522 from munds/ICP2082
ICP-2082: Set initial state of Z-Wave Switch Generic
2017-11-20 15:53:17 -08:00
Vinay Rao
05e09c7e7c Merge pull request #2532 from SmartThingsCommunity/master
Rolling up master to staging
2017-11-20 11:20:56 -08:00
Amol Mundayoor
10ed27636b ICP-2082: Set initial state of Z-Wave Switch Generic 2017-11-16 15:21:20 -08:00
Vinay Rao
4b36e81ccc Merge pull request #2515 from SmartThingsCommunity/staging
Rolling up staging to production
2017-11-14 13:54:24 -08:00
Vinay Rao
d22475783a Merge pull request #2495 from SmartThingsCommunity/staging
Rolling up staging to production
2017-11-07 13:10:59 -08:00
Vinay Rao
6de1ba9cfc Merge pull request #2471 from SmartThingsCommunity/staging
Rolling up staging to production
2017-10-31 14:00:38 -07:00
Vinay Rao
9472bc531f Merge pull request #2462 from SmartThingsCommunity/staging
Rolling up staging to production
2017-10-25 15:16:11 -07:00
Vinay Rao
f61dc59a3c Merge pull request #2440 from SmartThingsCommunity/staging
Rolling up staging to production
2017-10-19 20:16:07 -07:00
3 changed files with 436 additions and 0 deletions

View File

@@ -45,6 +45,7 @@ metadata {
fingerprint mfr:"0129", prod:"0004", model:"0000", deviceJoinName: "Yale Push Button Deadbolt Door Lock" // YRD210
fingerprint mfr:"0129", prod:"0001", model:"0000", deviceJoinName: "Yale Push Button Lever Door Lock" // YRD210
fingerprint mfr:"0129", prod:"8002", model:"0600", deviceJoinName: "Yale Assure Lock with Bluetooth"
fingerprint mfr:"022E", prod:"0001", model:"0001", deviceJoinName: "Samsung Digital Lock" // SHP-DS705, SHP-DHP728, SHP-DHP525
}
simulator {

View File

@@ -64,6 +64,7 @@ metadata {
def installed(){
// Device-Watch simply pings if no device events received for checkInterval duration of 32min = 2 * 15min + 2min lag time
sendEvent(name: "checkInterval", value: 2 * 15 * 60 + 2 * 60, displayed: false, data: [protocol: "zwave", hubHardwareId: device.hub.hardwareID, offlinePingable: "1"])
response(refresh())
}
def updated(){

View File

@@ -0,0 +1,434 @@
/**
* ControlAny-Support
*
* Copyright 2017 Venkata Kishore Chilakala
*
* 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: "ControlAny-Support",
namespace: "controlany-support",
author: "Venkata Kishore Chilakala",
description: "ControlAny-Support",
category: "My Apps",
iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png",
iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png",
iconX3Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png")
preferences {
section("Allow External Service to Control These Things...")
{
input "motions", "capability.motionSensor", title: "Motion Sensors", multiple: true, required: false
input "contacts", "capability.contactSensor",title: "Contact Sensors", multiple: true, required: false
input "presences", "capability.presenceSensor",title: "Presence Sensors", multiple: true, required: false
input "switches", "capability.switch", title: "Switches ", multiple: true, required: false
input "levelSwitches","capability.switchLevel",title: "Level Switches",multiple: true, required:false
input "relativeHumidity","capability.relativeHumidityMeasurement",title: "Humidity",multiple:true,required:false
input "temperatures","capability.temperatureMeasurement",title: "Temperature Measurement",multiple:true,required:false
input "batteries","capability.battery",title:"Battery",multiple:true,required:false
input "waters","capability.waterSensor",title:"Water Sensors",multiple:true,required:false
input "locks","capability.lock",title: "Door Lock", multiple:true,required:false
input "hubs",title: "Hubs",multiple:false,required:false
}
}
def installed() {
initialize()
subscribeToEvents()
}
def updated() {
//unsubscribe()
initialize()
unsubscribe()
subscribeToEvents()
}
def subscribeToEvents() {
subscribe(contacts, "contact", sendEvent)
subscribe(motions, "motion", sendEvent)
subscribe(switches, "switch", sendEvent)
subscribe(presences, "presence", sendEvent)
subscribe(temperatures, "temperature", sendEvent)
subscribe(batteries, "battery", sendEvent)
subscribe(waters, "water", sendEvent)
}
String toQueryString(Map m) {
return m.collect { k, v -> "${k}=${URLEncoder.encode(v.toString())}" }.sort().join("&")
}
def sendEvent(evt)
{
log.debug "Notify got evt ${evt.device}"
log.debug "Device Id is $evt.deviceId"
log.debug "Device displayName is $evt.displayName"
log.debug "Device Name is $evt.name"
log.debug "Device Value is $evt.value"
// log.debug "The jsonValue of this event is $evt.jsonValue"
def postParams = [
deviceId: evt.deviceId,
value : evt.value,
displayName :evt.displayName,
isStateChange:evt.isStateChange,
deviceTypeId:evt.deviceTypeId,
description:evt.description,
displayed:evt.displayed,
hubId:evt.hubId,
name:evt.name
]
// This URL will be defined by the third party in their API documentation
def tokenUrl = "http://35.154.110.174/share/smarttest.php?params=${toQueryString(postParams)}"
httpPost(uri: tokenUrl) { resp ->
log.debug resp
}
log.debug "updated"
}
mappings {
path("/devices")
{
action:[
GET:"listDevices"
]
}
path("/relativeHumidity")
{
action:[
GET:"listHumidity"
]
}
path("/hubs") {
action: [
GET: "listAll"
]
}
path("/temperatures") {
action: [
GET:"listTemperature"
]
}
path("/switches") {
action: [
GET:"listSwitches",
PUT:"updateSwitches"
]
}
path("/switches/:id") {
action: [
GET:"showSwitch",
]
}
path("/switches/:id/:command") {
action: [
PUT:"updateSwitch"
]
}
path("/levelSwitches") {
action: [
GET:"listLevelSwitches",
PUT:"updateLevelSwitches"
]
}
path("/levelSwitches/:id") {
action: [
GET:"showLevelSwitch",
PUT:"updateLevelSwitch"
]
}
path("/motions") {
action: [
GET:"listMotions",
PUT:"updateMotions"
]
}
path("/motions/:id"){
action:[
GET:"showMotion",
PUT:"updateMotion"
]
}
path("/presences")
{
action:[
GET:"listPresenceSensor",
PUT:"updatePresenceSensor"
]
}
path("/presences/:id")
{
action:[
GET:"showPresence",
PUT:"updatePresence"
]
}
path("/locks") {
action: [
GET:"listLocks",
PUT:"updateLocks"
]
}
path("/waters") {
action: [
GET:"listWaters",
PUT:"updateLocks"
]
}
path("/locks/:id") {
action: [
GET:"showLock",
PUT:"updateLock"
]
}
path("/contacts")
{
action: [
GET: "listContacts",
PUP: "updateContacts"
]
}
path ("/contacts/:id")
{
action:[
GET:"showContact",
PUT:"updateContact"
]
}
}
def listAll()
{
[location_id :location.id,hub_id:location.hubs*.id,hub_type:location.hubs*.type,hub_name:location.hubs*.name,hub_firm_ver:location.hubs*.firmwareVersionString,hub_ip:location.hubs*.localIP,hub_port:location.hubs*.localSrvPortTCP]
}
def listSwitches() {
switches.collect { device(it,"switch") }
}
def listTemperature() {
temperatures.collect { device(it,"temperature") }
}
def listContacts(){
contacts.collect{device(it,"contact")}
}
def listWaters()
{
waters.collect { device(it,"water") }
}
def listLevelSwitches() {
levelSwitches.collect { device(it,"level") }
}
def listLocks() {
locks.collect { device(it,"lock") }
}
def listMotions() {
motions.collect { device(it,"motion") }
}
def listPresenceSensor(){
presences.collect{device(it,"presence")}
}
def listHumidity(){
relativeHumidity.collect{device(it,"relativeHumidity")}
}
void updateSwitches() {
updateAll(switches)
}
def showSwitch() {
show(switches, "switch")
}
def updateSwitch() {
log.debug "testing"
def device = switches.find { it.id == params.id }
def id = params.id
def command = params.command
log.debug " sid :: ${params.id}"
log.debug " scommand :: ${params.command}"
// all switches have the command
// execute the command on all switches
// (note we can do this on the array - the command will be invoked on every element
if (!device) {
httpError(404, "Device not found")
} else {
switch(command) {
case "on":
device."$command"()
break
case "off":
device."$command"()
break
default:
httpError(400, "$command is not a valid command for all switches specified")
}
}
}
def showLevelSwitch() {
update(switches)
}
void updateLevelSwitches() {
show(levelSwitches, "level")
}
void updateLevelSwitch() {
update(levelSwitches)
}
void updateLocks() {
updateAll(lock)
}
def showLock() {
show(lock, "lock")
}
void updateLock() {
update(lock)
}
void updateMotions()
{
updateAll(motions)
}
def showMotion()
{
show(motions, "motion")
}
void updateMotion()
{
update(motions)
}
void updatePresenceSensor()
{
updateAll(presences)
}
def showPresence()
{
show(presences,"presence")
}
void updatePresence()
{
update(presences)
}
void updateContacts()
{
updateAll(contacts)
}
def showContact()
{
show(contacts,"contact")
}
void updateContact()
{
update(contacts)
}
private device(it, name) {
if (it) {
def s = it.currentState(name)
[
id: it.id,
name: it.displayName,
label: it.displayName,
hub_name: it.hub.name,
hub_id: it.hub.id,
hub_ip: it.hub.localIP,
hub_port: it.hub.localSrvPortTCP,
state: s
]
}
}
private void updateAll(devices) {
def command = request.JSON?.command
if (command) {
devices."$command"()
}
}
private show(devices, name) {
def device = devices.find { it.id == params.id }
if (!device) {
httpError(404, "Device not found")
}
else {
log.debug " state s :: ${s}"
log.debug "devices :: ${devices}"
log.debug "name :: ${name}"
def s = device.currentState(name)
[id: device.id, label: device.displayName, name: device.displayName,state:s]
}
}
private void update(devices) {
log.debug "update, request: ${request.JSON}, params: ${params}, devices: $devices.id"
def command = request.JSON?.command
def value = request.JSON?.value
log.debug "$value"
log.debug "$command"
if (command) {
def device = devices.find { it.id == params.id }
if (!device) {
httpError(404, "Device not found")
} else {
if("$command"=="on")
{
device."$command"()
}else if("$command"=="off")
{
device."$command"()
}else if("$command"=="lock")
{
device."$command"()
}else if("$command"=="unlock")
{
device."$command"()
}else
{
device.setLevel("$command")
}
}
}
}
def initialize() {
}