/*
* Copyright 2022 SmartThings
*
* Ported for Hubitat Elevation platform by kkossev
*
* 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.
*
* ver. 2.0.0 2022-10-29 kkossev - first version for HE platform
* ver. 2.0.1 2022-11-12 kkossev - analog input binding and configuration reprting OK!
* ver. 2.0.2 2022-11-13 kkossev - preferences bug fixes; added freeze off/on command; added setCounter command; info and debug logs cleanup
*
*
*/
def version() { "2.0.2" }
def timeStamp() {"2022/11/13 10:58 PM"}
import hubitat.zigbee.zcl.DataType
import hubitat.device.HubMultiAction
import groovy.transform.Field
@Field static final Boolean debug = false
metadata {
definition (name: "SiHAS People Counter", namespace: "shinasys", author: "SHINA SYSTEM") {
capability "Motion Sensor"
capability "Configuration"
capability "Battery"
capability "Refresh"
capability "Sensor"
capability "Momentary"
attribute "peopleCounter", "number"
attribute "freeze", "enum", ["off", ""]
attribute "inOutDir", "enum", ["in", "out", "ready"]
attribute "batteryVoltage", "string"
attribute "transationInterval", "number"
attribute "ledStatus", "enum", ["true", "false"]
attribute "inFastStatus", "enum", ["true", "false"]
attribute "outFastStatus", "enum", ["true", "false"]
attribute "rfStatus", "enum", ["true", "false"]
attribute "rfPairing", "enum", ["true", "false"]
attribute "distanceInit", "enum", ["true", "false"]
command "push", [[name: "Reset people counter to 0 from HE dashboard 'momentary' button tile."]]
command "freeze", [[name: "Freeze", type: "ENUM", constraints: ["off", "on"], description: "Select Freeze off/on"] ]
command "setCounter", [[name:"setCounter", type: "STRING", description: "Set People Counter, range 0..85", constraints: ["STRING"]]]
if (debug == true) {
command "test", [[name:"test", type: "STRING", description: "test", constraints: ["STRING"]]]
}
//////////////////////////////////////////////////////////////
// People Counter version description
//////////////////////////////////////////////////////////////
// application version > 10 : People Counter V2(TOF) Version (People Counter for Setting : 81~99)
// application version < 10 : People Counter Version
//////////////////////////////////////////////////////////////
fingerprint profileId:"0104", endpointId:"01", inClusters:"0000,0004,0003,0001,000C", outClusters:"0000,0004,0003,0019,0006", model:"CSM-300Z", manufacturer:"ShinaSystem", deviceJoinName: "SiHAS People Counter"
}
preferences {
section {
/* korean language
input (name: "logEnable", type: "bool", title: "Debug logging", description: "Debug information, useful for troubleshooting. Recommended value is false", defaultValue: false)
input (name: "txtEnable", type: "bool", title: "Description text logging", description: "Display sensor states in HE log page. Recommended value is true", defaultValue: true)
input (
title: "설정 설명",
description: "아래 설정은 V2(TOF) 버전에 해당하는 설정입니다.",
displayDuringSetup: false,
type: "paragraph",
element: "paragraph")
input ("ledStatus", "bool",
title: "LED 상태 표시 여부",
description: "동작 상태를 LED로 표시할지 여부를 설정합니다.",
displayDuringSetup: false,
defaultValue: true,
required: false)
input ("transationInterval", "enum",
title: "트랜잭션간 간격 설정",
description: "트랜잭션간 간격을 설정합니다. 연속으로 들어갈 일이 잦을 시 트랜잭션 인터벌을 짧게 반대의 경우 길게 설정하시면 됩니다.",
displayDuringSetup: false,
options: [0: "지연없음",
1: "0.2초",
2: "0.4초(기본값)",
3: "0.6초",
4: "0.8초",
5: "1.0초"],
defaultValue: "2",
required: false)
input ("inFastStatus", "bool",
title: "들어갈때 빠른 동작설정",
description: "카운터가 0이고 들어갈때 카운터 1로 설정하는것을 한 트랜잭션이 끝나기 전에 빠르게 설정을 할지 여부를 정할수 있습니다.",
displayDuringSetup: false,
defaultValue: true,
required: false)
input ("outFastStatus", "bool",
title: "나갈때 빠른 동작설정",
description: "카운터가 1이고 나갈때 카운터를 0으로 설정하는것을 한 트랜잭션이 끝나기 전에 빠르게 설정을 할지 여부를 정할수 있습니다.",
displayDuringSetup: false,
defaultValue: true,
required: false)
input ("rfStatus", "bool",
title: "RF 통신 동작",
description: "시하스 스위치와 연동을 위해서 RF 통신 동작 여부를 설정합니다.",
displayDuringSetup: false,
defaultValue: false,
required: false)
input ("rfPairing", "bool",
title: "RF 페어링",
description: "시하스 스위치와 RF 페어링을 시작합니다. (먼저 RF통신 동작이 활성화되어야 합니다.)",
displayDuringSetup: false,
defaultValue: false,
required: false)
input ("distanceInit", "bool",
title: "거리 재 조정",
description: "설치 위치가 바뀌면 거리 재조정을 진행해야합니다. 거리 재 조정 설정을 시작합니다. 5초동안 동작합니다.)",
displayDuringSetup: false,
defaultValue: false,
required: false)
*/
// english version
input (name: "logEnable", type: "bool", title: "Debug logging", description: "Debug information, useful for troubleshooting. Recommended value is false", defaultValue: true)
input (name: "txtEnable", type: "bool", title: "Description text logging", description: "Display sensor states in HE log page. Recommended value is true", defaultValue: true)
input (title: "Setting Description", description: "The settings below correspond to the V2 (TOF) version.", type: "paragraph", element: "paragraph")
input ("ledStatus", "bool", title: "LED status indication", description: "Sets whether the operational status is indicated by LED.", defaultValue: true, required: false)
input ("transationInterval", "enum", title: "Set transaction interval", description: "Sets the transaction interval. If you frequently enter consecutively, you can set the transaction interval to be short and long in the opposite case.",
options: [0: "No delay", 1: "0.2 seconds", 2: "0.4 seconds(default)", 3: "0.6 seconds", 4: "0.8 seconds", 5: "1.0 seconds"], defaultValue: "2", required: false)
input ("inFastStatus", "bool", title: "Set up quick action when entering", description: "When the counter is zero and enters, you can decide whether to set counter 1 quickly before one transaction ends.", defaultValue: true, required: false)
input ("outFastStatus", "bool", title: "Set up quick action when out", description: "When the counter is 1 and leaves, you can decide whether to set the counter to 0 quickly before one transaction ends.", defaultValue: true, required: false)
input ("rfStatus", "bool", title: "RF Communication Operation", description: "Set RF communication operation for interworking with SiHAS switch.", defaultValue: false, required: false)
input ("rfPairing", "bool", title: "RF Pairing", description: "Start RF pairing with the SiHAS switch. (RF communication operation must be enabled first.)", defaultValue: false, required: false)
input ("distanceInit", "bool", title: "Distance readjustment", description: "If the installation location changes, the distance must be readjusted. Start distance re-adjustment setting and operate for 5 seconds.", defaultValue: false, required: false)
}
}
}
private getOCCUPANCY_SENSING_CLUSTER() { 0x0406 }
private getANALOG_INPUT_BASIC_CLUSTER() { 0x000C }
private getPOWER_CONFIGURATION_BATTERY_VOLTAGE_ATTRIBUTE() { 0x0020 }
private getOCCUPANCY_SENSING_OCCUPANCY_ATTRIBUTE() { 0x0000 }
private getANALOG_INPUT_BASIC_PRESENT_VALUE_ATTRIBUTE() { 0x0055 }
private List