Compare commits

...

3 Commits

Author SHA1 Message Date
IPL_DevAccount
dbf8d80504 MSA-1854: This App is made for IJINI Robot IoT Controling system.
(The only devices that can be supported are the switches. However, we will expand support.)
2017-03-22 02:15:32 -07:00
Jack Chi
a03e8f20c5 Merge pull request #1537 from pchomal/zwave_thermostat
[CHF-480] Health Check implementation for Z-Wave Thermostat
2017-03-21 18:01:13 -07:00
piyush.c
648dee90b6 [CHF-480]
Health Check implementation for Z-Wave Thermostat
2016-12-20 12:57:13 +05:30
2 changed files with 226 additions and 0 deletions

View File

@@ -20,6 +20,7 @@ metadata {
capability "Configuration"
capability "Polling"
capability "Sensor"
capability "Health Check"
attribute "thermostatFanState", "string"
@@ -30,6 +31,7 @@ metadata {
fingerprint deviceId: "0x08"
fingerprint inClusters: "0x43,0x40,0x44,0x31"
fingerprint mfr:"0039", prod:"0011", model:"0001", deviceJoinName: "Honeywell Z-Wave Thermostat"
}
// simulator metadata
@@ -123,6 +125,11 @@ metadata {
}
}
def updated(){
// Device-Watch simply pings if no device events received for 32min(checkInterval)
sendEvent(name: "checkInterval", value: 2 * 15 * 60 + 2 * 60, displayed: false, data: [protocol: "zwave", hubHardwareId: device.hub.hardwareID])
}
def parse(String description)
{
def map = createEvent(zwaveEvent(zwave.parse(description, [0x42:1, 0x43:2, 0x31: 3])))
@@ -393,6 +400,14 @@ def setCoolingSetpoint(Double degrees, Integer delay = 30000) {
], delay)
}
/**
* PING is used by Device-Watch in attempt to reach the Device
* */
def ping() {
log.debug "ping() called"
poll()
}
def configure() {
delayBetween([
zwave.thermostatModeV2.thermostatModeSupportedGet().format(),

View File

@@ -0,0 +1,211 @@
/**
* IJINI
*
* Copyright 2017 IPL_DevAccount
*
* 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: "IJINI",
namespace: "global.ipl.IJINI",
author: "IPL_DevAccount",
description: "IJINI SUPPORTING APP",
category: "SmartThings Labs",
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 Endpoint to Control These Things...") {
input "switches", "capability.switch", title: "Which Switches?", multiple: true
//input "locks", "capability.lock", title: "Which Locks?", multiple: true
input "themotion", "capability.motionSensor", title: "Which Motions?", multiple: true
}
}
mappings {
path("/switches") {
action: [
GET: "listSwitches"
]
}
path("/switches/:id") {
action: [
GET: "showSwitch"
]
}
path("/switches/:id/:command") {
action: [
GET: "updateSwitch"
]
}
path("/locks") {
action: [
GET: "listLocks"
]
}
path("/locks/:id") {
action: [
GET: "showLock"
]
}
path("/locks/:id/:command") {
action: [
GET: "updateLock"
]
}
path("/SwitchState/:id") {
action: [
GET: "SwitchState"
]
}
}
def SwitchState()
{
GetSwitchState(switches,"switch");
}
def GetSwitchState(devices, type)
{
def device = devices.find { it.id == params.id }
if (!device) {
httpError(404, "Device not found ${devices}")
}
else
{
def attributeName = (type == "motionSensor") ? "motion" : type
def s = device.currentState(attributeName)
[value: s?.value]
}
}
def installed() {
initialize()
}
def updated()
{
unsubscribe()
}
def initialize()
{
subscribe(themotion, "motion.active", motionDetectedHandler)
subscribe(themotion, "motion.inactive", motionStoppedHandler)
}
def motionDetectedHandler(evt) {
log.debug "motionDetectedHandler called: ${evt}"
httpGet(String uri, Closure closure)
}
def motionStoppedHandler(evt) {
log.debug "motionStoppedHandler called: ${evt}"
}
//switches
def listSwitches() {
switches.collect{device(it,"switch")}
}
def showSwitch() {
show(switches, "switch")
}
void updateSwitch() {
update(switches)
}
//locks
def listLocks() {
locks.collect{device(it,"lock")}
}
def showLock() {
show(locks, "lock")
}
void updateLock() {
update(locks)
}
//Motions
def listMotion() {
log.debug "listMotions is activated...."
motion.collect{device(it,"motion")}
}
def showMotion() {
show(motion, "motionSensor")
}
void updateMotion() {
update(motion)
}
def deviceHandler(evt) {
log.debug "deviceHandler"
}
private void update(devices)
{
log.debug "update, request: params: ${params}, devices: $devices.id"
//def command = request.JSON?.command
def command = params.command
//let's create a toggle option here
if (command)
{
def device = devices.find { it.id == params.id }//it, params 상에서 같은것을 찾아내서 저장...하는듯하다.
if (!device) {
httpError(404, "Device not found")
} else {
if(command == "toggle")
{
if(device.currentValue('switch') == "on")
{
device.off();
}
else
{
device.on();
}
}
else
{
device."$command"()
}
}
}
}
private show(devices, type) {
log.debug "device = ${devices},type = ${type} "
def device = devices.find { it.id == params.id }
if (!device) {
httpError(404, "Device not found")
}
else {
def attributeName = (type == "motionSensor") ? "motion" : type
def s = device.currentState(attributeName)
[id: device.id, label: device.displayName, value: s?.value, unitTime: s?.date?.time, type: type]
}
}
private device(it, type) {
log.debug "device ctrl.. ${it}, ${type}"
it ? [id: it.id, label: it.label, type: type] : null
}