/* groovylint-disable CouldBeSwitchStatement, IfStatementBraces, ImplementationAsType, ImplicitReturnStatement, LineLength, MethodReturnTypeRequired, NestedBlockDepth, NoDouble, NoFloat, NoJavaUtilDate, NoWildcardImports, ParameterName, ReturnNullFromCatchBlock, StaticMethodsBeforeInstanceMethods, UnusedPrivateMethod, VariableName, VariableTypeRequired */
/**
* Tuya Multi Sensor 4 In 1 driver for Hubitat
*
* https://community.hubitat.com/t/alpha-tuya-zigbee-multi-sensor-4-in-1/92441
*
* 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. 1.0.0 2022-04-16 kkossev - Inital test version
* ver. 1.0.1 2022-04-18 kkossev - IAS cluster multiple TS0202, TS0210 and RH3040 Motion Sensors fingerprints; ignore repeated motion inactive events
* ver. 1.0.2 2022-04-21 kkossev - setMotion command; state.HashStringPars; advancedOptions: ledEnable (4in1); all DP info logs for 3in1!; _TZ3000_msl6wxk9 and other TS0202 devices inClusters correction
* ver. 1.0.3 2022-05-05 kkossev - '_TZE200_ztc6ggyl' 'Tuya ZigBee Breath Presence Sensor' tests; Illuminance unit changed to 'lx'
* ver. 1.0.4 2022-05-06 kkossev - DeleteAllStatesAndJobs; added isHumanPresenceSensorAIR(); isHumanPresenceSensorScene(); isHumanPresenceSensorFall(); convertTemperatureIfNeeded
* ver. 1.0.5 2022-06-11 kkossev - _TZE200_3towulqd +battery; 'Reset Motion to Inactive' made explicit option; sensitivity and keepTime for IAS sensors (TS0202-tested OK) and TS0601(not tested); capability "PowerSource" used as presence
* ver. 1.0.6 2022-07-10 kkossev - battery set to 0% and motion inactive when the device goes OFFLINE;
* ver. 1.0.7 2022-07-17 kkossev - _TZE200_ikvncluo (MOES) and _TZE200_lyetpprm radars; scale fadingTime and detectionDelay by 10; initialize() will resets to defaults; radar parameters update bug fix; removed unused states and attributes for radars
* ver. 1.0.8 2022-07-24 kkossev - _TZE200_auin8mzr (HumanPresenceSensorAIR) unacknowledgedTime; setLEDMode; setDetectionMode commands and vSensitivity; oSensitivity, vacancyDelay preferences; _TZE200_9qayzqa8 (black sensor) Attributes: motionType; preferences: inductionTime; targetDistance.
* ver. 1.0.9 2022-08-11 kkossev - degrees Celsius symbol bug fix; added square black radar _TZE200_0u3bj3rc support, temperatureOffset bug fix; decimal/number type prferences bug fix
* ver. 1.0.10 2022-08-15 kkossev - added Lux threshold parameter; square black radar LED configuration is resent back when device is powered on; round black PIR sensor powerSource is set to DC; added OWON OCP305 Presence Sensor
* ver. 1.0.11 2022-08-22 kkossev - IAS devices initialization improvements; presence threshold increased to 4 hours; 3in1 exceptions bug fixes; 3in1 and 4in1 exceptions bug fixes;
* ver. 1.0.12 2022-09-05 kkossev - added _TZE200_wukb7rhc MOES radar
* ver. 1.0.13 2022-09-25 kkossev - added _TZE200_jva8ink8 AUBESS radar; 2-in-1 Sensitivity setting bug fix
* ver. 1.0.14 2022-10-31 kkossev - added Bond motion sensor ZX-BS-J11W fingerprint for tests
* ver. 1.0.15 2022-12-03 kkossev - OWON 0x0406 cluster binding; added _TZE204_ztc6ggyl _TZE200_ar0slwnd _TZE200_sfiy5tfs _TZE200_mrf6vtua (was wrongly 3in1) mmWave radards;
* ver. 1.0.16 2022-12-10 kkossev - _TZE200_3towulqd (2-in-1) motion detection inverted; excluded from IAS group;
* ver. 1.1.0 2022-12-25 kkossev - SetPar() command; added 'Send Event when parameters change' option; code cleanup; added _TZE200_holel4dk; added 4-in-1 _TZ3210_rxqls8v0, _TZ3210_wuhzzfqg
* ver. 1.1.1 2023-01-08 kkossev - illuminance event bug fix; fadingTime minimum value 0.5; SetPar command shows in the UI the list of all possible parameters; _TZ3000_6ygjfyll bug fix;
* ver. 1.2.0 2023-02-07 kkossev - healthStatus; supressed repetative Radar detection delay and Radar fading time Info messages in the logs; logsOff missed when hub is restarted bug fix; capability 'Health Check'; _TZE200_3towulqd (2in1) new firmware versions fix for motion;
* ver. 1.2.1 2023-02-10 kkossev - reverted the unsuccessful changes made in the latest 1.2.0 version for _TZE200_3towulqd (2in1); added _TZE200_v6ossqfy as BlackSquareRadar; removed the wrongly added TUYATEC T/H sensor...
* ver. 1.2.2 2023-03-18 kkossev - typo in a log transaction fixed; added TS0202 _TZ3000_kmh5qpmb as a 3-in-1 type device'; added _TZE200_xpq2rzhq radar; bug fix in setMotion()
* ver. 1.3.0 2023-03-22 kkossev -'_TYST11_7hfcudw5' moved to 3-in-1 group; added deviceProfiles; fixed initializaiton missing on the first pairing; added batteryVoltage; added tuyaVersion; added delayed battery event;
* removed state.lastBattery; caught sensitivity par exception; fixed forcedProfile was not set automatically on Initialize;
* ver. 1.3.1 2023-03-29 kkossev - added 'invertMotion' option; 4in1 (Fantem) Refresh Tuya Magic; invertMotion is set to true by default for _TZE200_3towulqd;
* ver. 1.3.2 2023-04-17 kkossev - 4-in-1 parameter for adjusting the reporting time; supressed debug logs when ignoreDistance is flipped on; 'Send Event when parameters change' parameter is removed (events are always sent when there is a change); fadingTime and detectionDelay change was not logged and not sent as an event;
* ver. 1.3.3 2023-05-14 kkossev - code cleanup; added TS0202 _TZ3210_cwamkvua [Motion Sensor and Scene Switch]; added _TZE204_sooucan5 radar in a new TS0601_YXZBRB58_RADAR group (for tests); added reportingTime4in1 to setPar command options;
* ver. 1.3.4 2023-05-19 kkossev - added _TZE204_sxm7l9xa mmWave radar to TS0601_YXZBRB58_RADAR group; isRadar() bug fix;
* ver. 1.3.5 2023-05-28 kkossev - fixes for _TZE200_lu01t0zlTS0601_RADAR_MIR-TY-FALL mmWave radar (only the basic Motion and radarSensitivity is supported for now).
* ver. 1.3.6 2023-06-25 kkossev - chatty radars excessive debug logging bug fix
* ver. 1.3.7 2023-07-27 kkossev - fixes for _TZE204_sooucan5; moved _TZE204_sxm7l9xa to a new Device Profile TS0601_SXM7L9XA_RADAR; added TS0202 _TZ3040_bb6xaihh _TZ3040_wqmtjsyk; added _TZE204_qasjif9e radar;
* ver. 1.4.0 2023-08-06 kkossev - added new TS0225 _TZE200_hl0ss9oa 24GHz radar (TS0225_HL0SS9OA_RADAR); added basic support for the new TS0601 _TZE204_sbyx0lm6 radar w/ relay; added Hive MOT003; added sendCommand; added TS0202 _TZ3040_6ygjfyll
* ver. 1.4.1 2023-08-15 kkossev - TS0225_HL0SS9OA_RADAR ignoring ZCL illuminance and IAS motion reports; added radarAlarmMode, radarAlarmVolume, radarAlarmTime, Radar Static Detection Minimum Distance; added TS0225_AWARHUSB_RADAR TS0225_EGNGMRZH_RADAR
* ver. 1.4.2 2023-08-15 kkossev - 'Tuya Motion Sensor and Scene Switch' driver clone (Button capabilities enabled)
* ver. 1.4.3 2023-08-17 kkossev - TS0225 _TZ3218_awarhusb device profile changed to TS0225_LINPTECH_RADAR; cluster 0xE002 parser; added TS0601 _TZE204_ijxvkhd0 to TS0601_IJXVKHD0_RADAR; added _TZE204_dtzziy1e, _TZE200_ypprdwsl _TZE204_xsm7l9xa; YXZBRB58 radar illuminance and fadingTime bug fixes; added new TS0225_2AAELWXK_RADAR profile
* ver. 1.4.4 2023-08-18 kkossev - Method too large: Script1.processTuyaCluster ... :( TS0225_LINPTECH_RADAR: myParseDescriptionAsMap & swapOctets(); deleteAllCurrentStates(); TS0225_2AAELWXK_RADAR preferences configuration and commands; added Illuminance correction coefficient; code cleanup
* ver. 1.4.5 2023-08-26 kkossev - reduced debug logs;
* ver. 1.5.0 2023-08-27 kkossev - added TS0601 _TZE204_yensya2c radar; refactoring: deviceProfilesV2: tuyaDPs; unknownDPs; added _TZE204_clrdrnya; _TZE204_mhxn2jso; 2in1: _TZE200_1ibpyhdc, _TZE200_bh3n6gk8; added TS0202 _TZ3000_jmrgyl7o _TZ3000_hktqahrq _TZ3000_kmh5qpmb _TZ3040_usvkzkyn; added TS0601 _TZE204_kapvnnlk new device profile TS0601_KAPVNNLK_RADAR
* ver. 1.5.1 2023-09-09 kkossev - _TZE204_kapvnnlk fingerprint and DPs correction; added 2AAELWXK preferences; TS0225_LINPTECH_RADAR known preferences using E002 cluster
* ver. 1.5.2 2023-09-14 kkossev - TS0601_IJXVKHD0_RADAR ignore dp1 dp2; Distance logs changed to Debug; Refresh() updates driver version;
* ver. 1.5.3 2023-09-30 kkossev - humanMotionState re-enabled for TS0225_HL0SS9OA_RADAR; tuyaVersion is updated on Refresh; LINPTECH: added existance_time event; illuminance parsing exception changed to debug level; leave_time changed to fadingTime; fadingTime configuration
*
* ver. 1.6.0 2023-10-08 kkossev - major refactoring of the preferences input; all preference settings are reset to defaults when changing device profile; added 'all' attribute; present state 'motionStarted' in a human-readable form.
* setPar and sendCommand major refactoring +parameters changed from enum to string; TS0601_KAPVNNLK_RADAR parameters support;
* ver. 1.6.1 2023-10-12 kkossev - TS0601_KAPVNNLK_RADAR TS0225_HL0SS9OA_RADAR TS0225_2AAELWXK_RADAR TS0601_RADAR_MIR-HE200-TY TS0601_YXZBRB58_RADAR TS0601_SXM7L9XA_RADAR TS0601_IJXVKHD0_RADAR TS0601_YENSYA2C_RADAR TS0601_SBYX0LM6_RADAR TS0601_PIR_AIR TS0601_PIR_PRESENCE refactoring; radar enum preferences;
* ver. 1.6.2 2023-10-14 kkossev - LINPTECH preferences changed to enum type; enum preferences - set defVal; TS0601_PIR_PRESENCE - preference inductionTime changed to fadingTime, humanMotionState sent as event; TS0225_2AAELWXK_RADAR - preferences setting; _TZE204_ijxvkhd0 fixes; Linptech fixes; added radarAlarmMode radarAlarmVolume;
* ver. 1.6.3 2023-10-15 kkossev - setPar() and preferences updates bug fixes; automatic fix for preferences which type was changed between the versions, including bool;
* ver. 1.6.4 2023-10-18 kkossev - added TS0601 _TZE204_e5m9c5hl to SXM7L9XA profile; added a bunch of new manufacturers to SBYX0LM6 profile;
* ver. 1.6.5 2023-10-23 kkossev - bugfix: setPar decimal values for enum types; added SONOFF_SNZB-06P_RADAR; added SIHAS_USM-300Z_4_IN_1; added SONOFF_MOTION_IAS; TS0202_MOTION_SWITCH _TZ3210_cwamkvua refactoring; luxThreshold hardcoded to 0 and not configurable!; do not try to input preferences of a type bool
* TS0601_2IN1 refactoring; added keepTime and sensitivity attributes for PIR sensors; added _TZE200_ppuj1vem 3-in-1; TS0601_3IN1 refactoring; added _TZ3210_0aqbrnts 4in1;
* ver. 1.6.6 2023-11-02 kkossev - _TZE204_ijxvkhd0 staticDetectionSensitivity bug fix; SONOFF radar clusters binding; assign profile UNKNOWN for unknown devices; SONOFF radar cluster FC11 attr 2001 processing as occupancy; TS0601_IJXVKHD0_RADAR sensitivity as number; number type pars are scalled also!; _TZE204_ijxvkhd0 sensitivity settings changes; added preProc function; TS0601_IJXVKHD0_RADAR - removed multiplying by 10
* ver. 1.6.7 2023-11-09 kkossev - divideBy10 fix for TS0601_IJXVKHD0_RADAR; added new TS0202_MOTION_IAS_CONFIGURABLE group
* ver. 1.6.8 2023-11-20 kkossev - SONOFF SNZB-06P RADAR bug fixes; added radarSensitivity and fadingTime preferences; update parameters for Tuya radars bug fix;
* ver. 1.7.0 2024-01-14 kkossev - Groovy linting; added TS0225_O7OE4N9A_RADAR TS0225 _TZFED8_o7oe4n9a for tests; TS0601 _TZE200_3towulqd new fingerprint @JdThomas24
* ver. 1.8.0 2024-03-23 kkossev - more Groovy linting; fixed 'This driver requires HE version 2.2.7 (May 2021) or newer!' bug; device.latestState('battery') exception bug fixes;
* ver. 1.8.1 2024-04-16 kkossev - tuyaDPs list of maps bug fixes; added _TZE204_kyhbrfyl; added smallMotionDetectionSensitivity;
* ver. 1.9.0 2024-05-06 kkossev - depricated all radars except Linptech;
* ver. 1.9.1 2024-05-25 kkossev - preferences are not sent for depricated devices.
* ver. 1.9.2 2024-06-15 kkossev - (dev.branch) deviceProfile drop-down list bug fix; added quickRef link to GitHub WiKi page for PIR sensors;
*
* TODO: Implement ping() for all devices
* TODO: transit to V3 (W.I.P)
*/
static String version() { '1.9.2' }
static String timeStamp() { '2024/06/15 9:01 AM' }
import groovy.json.*
import groovy.transform.Field
import hubitat.zigbee.clusters.iaszone.ZoneStatus
import hubitat.zigbee.zcl.DataType
import java.util.concurrent.ConcurrentHashMap
@Field static final Boolean _DEBUG = false
@Field static final Boolean _TRACE_ALL = false // trace all messages, including the spammy ones
metadata {
definition(name: 'Tuya Multi Sensor 4 In 1', namespace: 'kkossev', author: 'Krassimir Kossev', importUrl: 'https://raw.githubusercontent.com/kkossev/Hubitat/development/Drivers/Tuya%20Multi%20Sensor%204%20In%201/Tuya%20Multi%20Sensor%204%20In%201.groovy', singleThreaded: true ) {
capability 'Sensor'
//capability "Configuration"
capability 'Battery'
capability 'MotionSensor'
capability 'TemperatureMeasurement'
capability 'RelativeHumidityMeasurement'
capability 'IlluminanceMeasurement'
capability 'TamperAlert'
capability 'PowerSource'
capability 'HealthCheck'
capability 'Refresh'
//capability "PushableButton" // uncomment for TS0202 _TZ3210_cwamkvua [Motion Sensor and Scene Switch]
//capability "DoubleTapableButton"
//capability "HoldableButton"
//attribute "occupancy", "enum", ["occupied", "unoccupied"] // https://developer.smartthings.com/docs/devices/capabilities/capabilities-reference // https://developer.smartthings.com/capabilities/occupancySensor
attribute 'all', 'string'
attribute 'batteryVoltage', 'number'
attribute 'healthStatus', 'enum', ['offline', 'online']
attribute 'distance', 'number' // Tuya Radar
attribute 'unacknowledgedTime', 'number' // AIR models
attribute 'existance_time', 'number' // BlackSquareRadar & LINPTECH
attribute 'leave_time', 'number' // BlackSquareRadar only
attribute' pushed', 'number' // TS0202 _TZ3210_cwamkvua [Motion Sensor and Scene Switch]
attribute 'keepTime', 'enum', ['10 seconds', '30 seconds', '60 seconds', '120 seconds']
attribute 'sensitivity', 'enum', ['low', 'medium', 'high']
attribute 'radarSensitivity', 'number'
attribute 'staticDetectionSensitivity', 'number' // added 10/29/2023
attribute 'smallMotionDetectionSensitivity', 'number' // added 04/16/2024
attribute 'detectionDelay', 'decimal'
attribute 'fadingTime', 'decimal'
attribute 'minimumDistance', 'decimal'
attribute 'maximumDistance', 'decimal'
attribute 'radarStatus', 'enum', ['checking', 'check_success', 'check_failure', 'others', 'comm_fault', 'radar_fault']
attribute 'humanMotionState', 'enum', ['none', 'moving', 'small_move', 'stationary', 'presence', 'peaceful', 'large_move']
attribute 'radarAlarmMode', 'enum', ['0 - arm', '1 - off', '2 - alarm', '3 - doorbell']
attribute 'radarAlarmVolume', 'enum', ['0 - low', '1 - medium', '2 - high', '3 - mute']
command 'configure', [[name: 'Configure the sensor after switching drivers']]
command 'initialize', [[name: 'Initialize the sensor after switching drivers. \n\r ***** Will load device default values! *****' ]]
command 'setMotion', [[name: 'setMotion', type: 'ENUM', constraints: ['No selection', 'active', 'inactive'], description: 'Force motion active/inactive (for tests)']]
command 'refresh', [[name: 'May work for some DC/mains powered sensors only']]
command 'setPar', [
[name:'par', type: 'STRING', description: 'preference parameter name', constraints: ['STRING']],
[name:'val', type: 'STRING', description: 'preference parameter value', constraints: ['STRING']]
]
command 'sendCommand', [[name: 'sendCommand', type: 'STRING', constraints: ['STRING'], description: 'send Tuya Radar commands']]
if (_DEBUG == true) {
command 'testTuyaCmd', [
[name:'dpCommand', type: 'STRING', description: 'Tuya DP Command', constraints: ['STRING']],
[name:'dpValue', type: 'STRING', description: 'Tuya DP value', constraints: ['STRING']],
[name:'dpType', type: 'ENUM', constraints: ['DP_TYPE_VALUE', 'DP_TYPE_BOOL', 'DP_TYPE_ENUM'], description: 'DP data type']
]
command 'testParse', [[name:'val', type: 'STRING', description: 'description', constraints: ['STRING']]]
command 'test', [[name:'val', type: 'STRING', description: 'preference parameter value', constraints: ['STRING']]]
}
deviceProfilesV2.each { profileName, profileMap ->
if (profileMap.fingerprints != null) {
if (profileMap.device?.isDepricated != true) {
profileMap.fingerprints.each {
fingerprint it
}
}
}
}
}
preferences {
if (device) {
if (DEVICE?.device.isDepricated == true) {
input(name: 'depricated', type: 'hidden', title: "$ttStyleStrThis driver is depricated
for use with ${state.deviceProfile} devices!
Please change to the new driver as per the instructions in this link!")
}
else {
input(name: 'info', type: 'hidden', title: "For more info, click on this link to visit the WiKi page")
}
input(name: 'txtEnable', type: 'bool', title: 'Description text logging', description: 'Display sensor states on HE log page. The recommended value is true', defaultValue: true)
input(name: 'logEnable', type: 'bool', title: 'Debug logging', description: 'Debug information, useful for troubleshooting. The recommended value is false', defaultValue: true)
if (('motionReset' in DEVICE?.preferences) && (DEVICE?.preferences.motionReset == true)) {
input(name: 'motionReset', type: 'bool', title: 'Reset Motion to Inactive', description: 'Software Reset Motion to Inactive after timeout. Recommended value is false', defaultValue: false)
if (motionReset.value == true) {
input('motionResetTimer', 'number', title: 'Motion Reset Timer', description: 'After motion is detected, wait ___ second(s) until resetting to inactive state. Default = 60 seconds', range: '0..7200', defaultValue: 60)
}
}
}
if (('reportingTime4in1' in DEVICE?.preferences)) { // 4in1()
input('reportingTime4in1', 'number', title: '4-in-1 Reporting Time', description: '4-in-1 Reporting Time configuration, minutes.
0 will enable real-time (10 seconds) reporting!', range: '0..7200', defaultValue: DEFAULT_REPORTING_4IN1)
}
if (('ledEnable' in DEVICE?.preferences)) { // 4in1()
input(name: 'ledEnable', type: 'bool', title: 'Enable LED', description: 'Enable LED blinking when motion is detected (4in1 only)', defaultValue: true)
}
if (device && !(DEVICE?.device.isDepricated == true)) {
if ((DEVICE?.capabilities?.IlluminanceMeasurement == true) && (DEVICE?.preferences?.luxThreshold != false)) {
input('luxThreshold', 'number', title: 'Lux threshold', description: 'Minimum change in the lux which will trigger an event', range: '0..999', defaultValue: 5)
input name: 'illuminanceCoeff', type: 'decimal', title: 'Illuminance Correction Coefficient', description: 'Illuminance correction coefficient, range (0.10..10.00)', range: '0.10..10.00', defaultValue: 1.00
}
if (('DistanceMeasurement' in DEVICE?.capabilities)) {
input(name: 'ignoreDistance', type: 'bool', title: 'Ignore distance reports', description: 'If not used, ignore the distance reports received every 1 second!', defaultValue: true)
}
}
// itterate over DEVICE.preferences map and inputIt all!
if (device && DEVICE?.device.isDepricated != true) {
(DEVICE?.preferences).each { key, value ->
Map map = inputIt(key)
if (map != null && map != [:]) {
input map
}
}
}
/* groovylint-disable-next-line ConstantIfExpression */
if (false) {
if ('textLargeMotion' in DEVICE?.preferences) {
input(name: 'textLargeMotion', type: 'text', title: 'Motion Detection Settigs ⇨', description: 'Settings for movement types such as walking, trotting, fast running, circling, jumping and other movements ')
}
if ('textSmallMotion' in DEVICE?.preferences) {
input(name: 'textSmallMotion', type: 'text', title: 'Small Motion Detection Settigs ⇒', description: 'Settings for small movement types such as tilting the head, waving, raising the hand, flicking the body, playing with the mobile phone, turning over the book, etc.. ')
}
if ('textStaticDetection' in DEVICE?.preferences) {
input(name: 'textStaticDetection', type: 'text', title: 'Static Detection Settigs ⇨', description: 'The sensor can detect breathing within a certain range to determine people presence in the detection area (for example, while sleeping or reading).')
}
}
input(name: 'advancedOptions', type: 'bool', title: 'Advanced Options', description: 'Enables showing the advanced options/preferences. Hit F5 in the browser to refresh the Preferences list
.May not work for all device types!', defaultValue: false)
if (advancedOptions == true) {
input(name: 'forcedProfile', type: 'enum', title: 'Device Profile', description: 'Forcely change the Device Profile, if the model/manufacturer was not recognized automatically.
Warning! Manually setting a device profile may not always work!',
options: getDeviceProfilesMap())
if ('Battery' in DEVICE?.capabilities) {
input(name: 'batteryDelay', type: 'enum', title: 'Battery Events Delay', description:'Select the Battery Events Delay
(default is no delay)', options: delayBatteryOpts.options, defaultValue: delayBatteryOpts.defaultValue)
}
if ('invertMotion' in DEVICE?.preferences) {
input(name: 'invertMotion', type: 'bool', title: 'Invert Motion Active/Not Active', description: 'Some Tuya motion sensors may report the motion active/inactive inverted...', defaultValue: false)
}
}
input(name: 'allStatusTextEnable', type: 'bool', title: "Enable 'all' Status Attribute Creation?", description: 'Status attribute for Devices/Rooms', defaultValue: false)
}
}
@Field static final Boolean _IGNORE_ZCL_REPORTS = true
@Field static final String UNKNOWN = 'UNKNOWN'
@Field static final Map blackRadarLedOptions = [ '0' : 'Off', '1' : 'On' ] // HumanPresenceSensorAIR
@Field static final Map TS0225humanMotionState = [ '0': 'none', '1': 'moving', '2': 'small_move', '3': 'stationary' ]
@Field static String ttStyleStr = ''
// TODO - remove all the usused sensitivity and keepTime static maps!
@Field static final Map sensitivityOpts = [ defaultValue: 2, options: [0: 'low', 1: 'medium', 2: 'high']]
@Field static final Map keepTime4in1Opts = [ defaultValue: 0, options: [0: '10 seconds', 1: '30 seconds', 2: '60 seconds', 3: '120 seconds', 4: '240 seconds', 5: '480 seconds']]
@Field static final Map keepTime2in1Opts = [ defaultValue: 0, options: [0: '10 seconds', 1: '30 seconds', 2: '60 seconds', 3: '120 seconds']]
@Field static final Map keepTime3in1Opts = [ defaultValue: 0, options: [0: '30 seconds', 1: '60 seconds', 2: '120 seconds']]
@Field static final Map keepTimeIASOpts = [ defaultValue: 0, options: [0: '30 seconds', 1: '60 seconds', 2: '120 seconds']]
@Field static final Map powerSourceOpts = [ defaultValue: 0, options: [0: 'unknown', 1: 'mains', 2: 'mains', 3: 'battery', 4: 'dc', 5: 'emergency mains', 6: 'emergency mains']]
@Field static final Map delayBatteryOpts = [ defaultValue: 0, options: [0: 'No delay', 30: '30 seconds', 3600: '1 hour', 14400: '4 hours', 28800: '8 hours', 43200: '12 hours']]
Map getKeepTimeOpts() { return is4in1() ? keepTime4in1Opts : is3in1() ? keepTime3in1Opts : is2in1() ? keepTime2in1Opts : keepTimeIASOpts }
@Field static final Integer presenceCountTreshold = 4
@Field static final Integer defaultPollingInterval = 3600
@Field static final Integer DEFAULT_REPORTING_4IN1 = 5 // time in minutes
String getDeviceProfile() { state.deviceProfile ?: 'UNKNOWN' }
Map getDEVICE() { deviceProfilesV2[getDeviceProfile()] }
List getDeviceProfiles() { deviceProfilesV2.keySet() }
List getDeviceProfilesMap() {
List activeProfiles = []
deviceProfilesV2.each { profileName, profileMap ->
if ((profileMap.device?.isDepricated ?: false) != true) {
activeProfiles.add(profileMap.description ?: '---')
}
}
return activeProfiles
}
boolean is4in1() { return getDeviceProfile().contains('TS0202_4IN1') }
boolean is3in1() { return getDeviceProfile().contains('TS0601_3IN1') }
boolean is2in1() { return getDeviceProfile().contains('TS0601_2IN1') }
boolean isMotionSwitch() { return getDeviceProfile().contains('TS0202_MOTION_SWITCH') }
boolean isIAS() { DEVICE?.device?.isIAS == true }
BigDecimal getTemperatureDiv() { isSiHAS() ? 100.0 : 10.0 } // temperatureEvent
BigDecimal getHumidityDiv() { isSiHAS() ? 100.0 : 1.0 } // humidityEvent
boolean isZY_M100Radar() { return getDeviceProfile().contains('TS0601_TUYA_RADAR') }
boolean isBlackPIRsensor() { return getDeviceProfile().contains('TS0601_PIR_PRESENCE') }
boolean isBlackSquareRadar() { return getDeviceProfile().contains('TS0601_BLACK_SQUARE_RADAR') }
boolean isHumanPresenceSensorAIR() { return getDeviceProfile().contains('TS0601_PIR_AIR') } // isHumanPresenceSensorScene() removed in version 1.6.1
boolean isYXZBRB58radar() { return getDeviceProfile().contains('TS0601_YXZBRB58_RADAR') }
boolean isSXM7L9XAradar() { return getDeviceProfile().contains('TS0601_SXM7L9XA_RADAR') }
boolean isIJXVKHD0radar() { return getDeviceProfile().contains('TS0601_IJXVKHD0_RADAR') }
boolean isHL0SS9OAradar() { return getDeviceProfile().contains('TS0225_HL0SS9OA_RADAR') }
boolean is2AAELWXKradar() { return getDeviceProfile().contains('TS0225_2AAELWXK_RADAR') } // same as HL0SS9OA, but another set of DPs
boolean isSBYX0LM6radar() { return getDeviceProfile().contains('TS0601_SBYX0LM6_RADAR') }
boolean isLINPTECHradar() { return getDeviceProfile().contains('TS0225_LINPTECH_RADAR') }
boolean isEGNGMRZHradar() { return getDeviceProfile().contains('TS0225_EGNGMRZH_RADAR') }
boolean isKAPVNNLKradar() { return getDeviceProfile().contains('TS0601_KAPVNNLK_RADAR') }
boolean isSONOFF() { return getDeviceProfile().contains('SONOFF_SNZB-06P_RADAR') }
boolean isSiHAS() { return getDeviceProfile().contains('SIHAS_USM-300Z_4_IN_1') }
// TODO - check if DPs are declared in the device profiles and remove this function
boolean isChattyRadarReport(final Map descMap) {
if ((isZY_M100Radar() || isSBYX0LM6radar()) && (settings?.ignoreDistance == true)) {
return (descMap?.clusterId == 'EF00' && (descMap.command in ['01', '02']) && descMap.data?.size > 2 && descMap.data[2] == '09')
}
else if ((isYXZBRB58radar() || isSXM7L9XAradar()) && (settings?.ignoreDistance == true)) {
return (descMap?.clusterId == 'EF00' && (descMap.command in ['01', '02']) && descMap.data?.size > 2 && descMap.data[2] == '6D')
}
return false
}
@Field static final Map deviceProfilesV2 = [
// is4in1()
'TS0202_4IN1' : [
description : 'Tuya 4in1 (motion/temp/humi/lux) sensor',
models : ['TS0202'], // model: 'ZB003-X' vendor: 'Fantem'
device : [type: 'PIR', isIAS:true, powerSource: 'dc', isSleepy:false], // check powerSource
capabilities : ['MotionSensor': true, 'TemperatureMeasurement': true, 'RelativeHumidityMeasurement': true, 'IlluminanceMeasurement': true, 'tamper': true, 'Battery': true],
preferences : ['motionReset':true, 'reportingTime4in1':true, 'ledEnable':true, 'keepTime':true, 'sensitivity':true],
commands : ['reportingTime4in1':'reportingTime4in1', 'resetStats':'resetStats', 'refresh':'refresh', 'initialize':'initialize', 'updateAllPreferences': 'updateAllPreferences', 'resetPreferencesToDefaults':'resetPreferencesToDefaults', 'validateAndFixPreferences':'validateAndFixPreferences'],
fingerprints : [
[profileId:'0104', endpointId:'01', inClusters:'0000,0001,0500,EF00', outClusters:'0019,000A', model:'TS0202', manufacturer:'_TZ3210_zmy9hjay', deviceJoinName: 'Tuya TS0202 Multi Sensor 4 In 1'], // pairing: double click!
[profileId:'0104', endpointId:'01', inClusters:'0000,0001,0500,EF00', outClusters:'0019,000A', model:'5j6ifxj', manufacturer:'_TYST11_i5j6ifxj', deviceJoinName: 'Tuya TS0202 Multi Sensor 4 In 1'],
[profileId:'0104', endpointId:'01', inClusters:'0000,0001,0500,EF00', outClusters:'0019,000A', model:'hfcudw5', manufacturer:'_TYST11_7hfcudw5', deviceJoinName: 'Tuya TS0202 Multi Sensor 4 In 1'],
[profileId:'0104', endpointId:'01', inClusters:'0000,0001,0500,EF00', outClusters:'0019,000A', model:'TS0202', manufacturer:'_TZ3210_rxqls8v0', deviceJoinName: 'Tuya TS0202 Multi Sensor 4 In 1'], // not tested
[profileId:'0104', endpointId:'01', inClusters:'0000,0001,0500,EF00', outClusters:'0019,000A', model:'TS0202', manufacturer:'_TZ3210_wuhzzfqg', deviceJoinName: 'Tuya TS0202 Multi Sensor 4 In 1'], // https://community.hubitat.com/t/release-tuya-zigbee-multi-sensor-4-in-1-pir-motion-sensors-and-mmwave-presence-radars/92441/282?u=kkossev
[profileId:'0104', endpointId:'01', inClusters:'0000,0001,0500,EF00', outClusters:'0019,000A', model:'TS0202', manufacturer:'_TZ3210_0aqbrnts', deviceJoinName: 'Tuya TS0202 Multi Sensor 4 In 1 is-thpl-zb']
],
tuyaDPs: [
[dp:1, name:'motion', type:'enum', rw: 'ro', min:0, max:1 , defVal:'0', scale:1, map:[0:'inactive', 1:'active'] , unit:'', description:'Motion'],
[dp:5, name:'tamper', type:'enum', rw: 'ro', min:0, max:1 , defVal:'0', scale:1, map:[0:'clear', 1:'detected'] , unit:'', description:'Tamper detection'],
[dp:9, name:'sensitivity', type:'enum', rw: 'rw', min:0, max:2, defVal:'2', unit:'', map:[0:'low', 1:'medium', 2:'high'], title:'Sensitivity', description:'PIR sensor sensitivity (update at the time motion is activated)'],
[dp:10, name:'keepTime', type:'enum', rw: 'rw', min:0, max:5, defVal:'0', unit:'seconds', map:[0:'0 seconds', 1:'30 seconds', 2:'60 seconds', 3:'120 seconds', 4:'240 seconds', 5:'480 seconds'], title:'Keep Time', description:'PIR keep time in seconds (update at the time motion is activated)'],
[dp:25, name:'battery2', type:'number', rw: 'ro', min:0, max:100, defVal:100, scale:1, unit:'%', description:'Remaining battery 2 in %'],
[dp:102, name:'reportingTime4in1', type:'number', rw: 'ro', min:0, max:1440, defVal:10, step:5, scale:1, unit:'minutes', title:'Reporting Interval', description:'Reporting interval in minutes'],
[dp:104, name:'tempCalibration', type:'decimal', rw:'ro', min:-2.0, max:2.0, defVal:0.0, scale:10, unit:'deg.', title:'Temperature Calibration', description:'Temperature calibration (-2.0...2.0)'],
[dp:105, name:'humiCalibration', type:'number', rw: 'ro', min:-15, max:15, defVal:0, scale:1, unit:'%RH', title:'Huidity Calibration', description:'Humidity Calibration'],
[dp:106, name:'illumCalibration', type:'number', rw: 'ro', min:-20, max:20, defVal:0, scale:1, unit:'Lx', title:'Illuminance Calibration', description:'Illuminance calibration in lux/i>'],
[dp:107, name:'temperature', type:'decimal', rw: 'ro', min:-20.0, max:80.0, defVal:0.0, scale:10, unit:'deg.', description:'Temperature'],
[dp:108, name:'humidity', type:'number', rw: 'ro', min:1, max:100, defVal:100, scale:1, unit:'%RH', description:'Humidity'],
[dp:109, name:'pirSensorEnable', type:'enum', rw: 'ro', min:0, max:1 , defVal:'1', scale:1, map:[0:'disabled', 1:'enabled'] , unit:'', title:'MoPIR Sensor Enable', description:'Enable PIR sensor'],
[dp:110, name:'battery', type:'number', rw: 'ro', min:0, max:100, defVal:100, scale:1, unit:'%', description:'Battery level'],
[dp:111, name:'ledEnable', type:'enum', rw: 'ro', min:0, max:1 , defVal:'0', scale:1, map:[0:'disabled', 1:'enabled'] , unit:'', title:'LED Enable', description:'Enable LED'],
[dp:112, name:'reportingEnable', type:'enum', rw: 'ro', min:0, max:1 , defVal:'0', scale:1, map:[0:'disabled', 1:'enabled'] , unit:'', title:'Reporting Enable', description:'Enable reporting'],
],
deviceJoinName: 'Tuya Multi Sensor 4 In 1',
configuration : ['battery': false]
],
// is3in1()
'TS0601_3IN1' : [ // https://szneo.com/en/products/show.php?id=239 // https://www.banggood.com/Tuya-Smart-Linkage-ZB-Motion-Sensor-Human-Infrared-Detector-Mobile-Phone-Remote-Monitoring-PIR-Sensor-p-1858413.html?cur_warehouse=CN
description : 'Tuya 3in1 (Motion/Temp/Humi) sensor',
models : ['TS0601'],
device : [type: 'PIR', powerSource: 'dc', isSleepy:false], // powerSource changes batt/DC dynamically!
capabilities : ['MotionSensor': true, 'TemperatureMeasurement': true, 'RelativeHumidityMeasurement': true, 'tamper': true, 'Battery': true],
preferences : ['motionReset':true],
commands : ['resetStats':'resetStats', 'refresh':'refresh', 'initialize':'initialize', 'updateAllPreferences': 'updateAllPreferences', 'resetPreferencesToDefaults':'resetPreferencesToDefaults', 'validateAndFixPreferences':'validateAndFixPreferences'],
fingerprints : [
[profileId:'0104', endpointId:'01', inClusters:'0000,0004,0005,EF00', outClusters:'0019,000A', model:'TS0601', manufacturer:'_TZE200_7hfcudw5', deviceJoinName: 'Tuya NAS-PD07 Multi Sensor 3 In 1'],
[profileId:'0104', endpointId:'01', inClusters:'0000,0004,0005,EF00', outClusters:'0019,000A', model:'TS0601', manufacturer:'_TZE200_ppuj1vem', deviceJoinName: 'Tuya NAS-PD07 Multi Sensor 3 In 1']
],
tuyaDPs: [
[dp:101, name:'motion', type:'enum', rw: 'ro', min:0, max:1 , defVal:'0', scale:1, map:[0:'inactive', 1:'active'] , unit:'', description:'Motion'],
[dp:102, name:'battery', type:'number', rw: 'ro', min:0, max:100, defVal:100, scale:1, unit:'%', description:'Battery level'],
// ^^^TODO^^^
[dp:103, name:'tamper', type:'enum', rw: 'ro', min:0, max:1 , defVal:'0', scale:1, map:[0:'clear', 1:'detected'] , unit:'', description:'Tamper detection'],
[dp:104, name:'temperature', type:'decimal', rw: 'ro', min:-20.0, max:80.0, defVal:0.0, scale:10, unit:'deg.', description:'Temperature'],
[dp:105, name:'humidity', type:'number', rw: 'ro', min:1, max:100, defVal:100, scale:1, unit:'%RH', description:'Humidity'],
[dp:106, name:'tempScale', type:'enum', rw: 'ro', min:0, max:1 , defVal:'0', scale:1, map:[0:'Celsius', 1:'Fahrenheit'] , unit:'', description:'Temperature scale'],
[dp:107, name:'minTemp', type:'number', rw: 'ro', min:-20, max:80, defVal:0, scale:1, unit:'deg.', description:'Minimal temperature'],
[dp:108, name:'maxTemp', type:'number', rw: 'ro', min:-20, max:80, defVal:0, scale:1, unit:'deg.', description:'Maximal temperature'],
[dp:109, name:'minHumidity', type:'number', rw: 'ro', min:0, max:100, defVal:0, scale:1, unit:'%RH', description:'Minimal humidity'],
[dp:110, name:'maxHumidity', type:'number', rw: 'ro', min:0, max:100, defVal:0, scale:1, unit:'%RH', description:'Maximal humidity'],
[dp:111, name:'tempAlarm', type:'enum', rw: 'ro', min:0, max:1 , defVal:'0', scale:1, map:[0:'inactive', 1:'active'] , unit:'', description:'Temperature alarm'],
[dp:112, name:'humidityAlarm', type:'enum', rw: 'ro', min:0, max:1 , defVal:'0', scale:1, map:[0:'inactive', 1:'active'] , unit:'', description:'Humidity alarm'],
[dp:113, name:'alarmType', type:'enum', rw: 'ro', min:0, max:1 , defVal:'0', scale:1, map:[0:'type0', 1:'type1'] , unit:'', description:'Alarm type'],
],
deviceJoinName: 'Tuya Multi Sensor 3 In 1',
configuration : ['battery': false]
],
// is2in1()
'TS0601_2IN1' : [ // https://github.com/Koenkk/zigbee-herdsman-converters/blob/bf32ce2b74689328048b407e56ca936dc7a54a0b/src/devices/tuya.ts#L4568
description : 'Tuya 2in1 (Motion and Illuminance) sensor',
models : ['TS0601'],
device : [type: 'PIR', isIAS:false, powerSource: 'battery', isSleepy:true],
capabilities : ['MotionSensor': true, 'IlluminanceMeasurement': true, 'Battery': true],
preferences : ['motionReset':true, 'invertMotion':true, 'keepTime':'10', 'sensitivity':'9'],
commands : ['resetStats':'resetStats', 'refresh':'refresh', 'initialize':'initialize', 'updateAllPreferences': 'updateAllPreferences', 'resetPreferencesToDefaults':'resetPreferencesToDefaults', 'validateAndFixPreferences':'validateAndFixPreferences'],
fingerprints : [
[profileId:'0104', endpointId:'01', inClusters:'0001,0500,0000', outClusters:'0019,000A', model:'TS0601', manufacturer:'_TZE200_3towulqd', deviceJoinName: 'Tuya 2 in 1 Zigbee Mini PIR Motion Detector + Bright Lux ZG-204ZL'], // https://www.aliexpress.com/item/1005004095233195.html
[profileId:'0104', endpointId:'01', inClusters:'0000,0500,0001,0400', outClusters:'0019,000A', model:'TS0601', manufacturer:'_TZE200_3towulqd', deviceJoinName: 'Tuya 2 in 1 Zigbee Mini PIR Motion Detector + Bright Lux ZG-204ZL'], // https://community.hubitat.com/t/release-tuya-zigbee-multi-sensor-4-in-1-pir-motion-sensors-and-mmwave-presence-radars-w-healthstatus/92441/934?u=kkossev
[profileId:'0104', endpointId:'01', inClusters:'0001,0500,0000', outClusters:'0019,000A', model:'TS0601', manufacturer:'_TZE200_bh3n6gk8', deviceJoinName: 'Tuya 2 in 1 Zigbee Mini PIR Motion Detector + Bright Lux ZG-204ZL'], // https://community.hubitat.com/t/tze200-bh3n6gk8-motion-sensor-not-working/123213?u=kkossev
[profileId:'0104', endpointId:'01', inClusters:'0001,0500,0000', outClusters:'0019,000A', model:'TS0601', manufacturer:'_TZE200_1ibpyhdc', deviceJoinName: 'Tuya 2 in 1 Zigbee Mini PIR Motion Detector + Bright Lux ZG-204ZL'] //
],
tuyaDPs: [
[dp:1, name:'motion', type:'enum', rw: 'ro', min:0, max:1 , defVal:'0', scale:1, map:[0:'inactive', 1:'active'] , unit:'', description:'Motion'],
[dp:4, name:'battery', type:'number', rw: 'ro', min:0, max:100, defVal:100, scale:1, unit:'%', title:'Battery level', description:'Battery level'],
[dp:9, name:'sensitivity', type:'enum', rw: 'rw', min:0, max:2, defVal:'2', unit:'', map:[0:'low', 1:'medium', 2:'high'], title:'Sensitivity', description:'PIR sensor sensitivity (update at the time motion is activated)'],
[dp:10, name:'keepTime', type:'enum', rw: 'rw', min:0, max:3, defVal:'0', unit:'seconds', map:[0:'10 seconds', 1:'30 seconds', 2:'60 seconds', 3:'120 seconds'], title:'Keep Time', description:'PIR keep time in seconds (update at the time motion is activated)'],
[dp:12, name:'illuminance', type:'number', rw: 'ro', min:0, max:1000, defVal:0, scale:1, unit:'lx', title:'illuminance', description:'illuminance'],
[dp:102, name:'illuminance_interval', type:'number', rw: 'rw', min:1, max:720, defVal:1, scale:1, unit:'minutes', title:'Illuminance Interval', description:'Brightness acquisition interval (update at the time motion is activated)'],
],
deviceJoinName: 'Tuya Multi Sensor 2 In 1',
configuration : ['battery': false]
],
'TS0202_MOTION_IAS' : [
description : 'Tuya TS0202 Motion sensor (IAS)',
models : ['TS0202', 'RH3040'],
device : [type: 'PIR', isIAS:true, powerSource: 'battery', isSleepy:true],
capabilities : ['MotionSensor': true, 'Battery': true],
preferences : ['motionReset':true, 'keepTime':false, 'sensitivity':false],
fingerprints : [
[profileId:'0104', endpointId:'01', inClusters:'0000,0003,0001,0500', outClusters:'0000,0003,0001,0500', model:'TS0202', manufacturer:'_TYZB01_dl7cejts', deviceJoinName: 'Tuya TS0202 Motion Sensor'], // KK model: 'ZM-RT201'// 5 seconds (!) reset period for testing
[profileId:'0104', endpointId:'01', inClusters:'0001,0500,0003,0000', outClusters:'1000,0006,0019,000A', model:'TS0202', manufacturer:'_TZ3000_mmtwjmaq', deviceJoinName: 'Tuya TS0202 Motion Sensor'],
[profileId:'0104', endpointId:'01', inClusters:'0001,0500,0003,0000', outClusters:'1000,0006,0019,000A', model:'TS0202', manufacturer:'_TZ3000_otvn3lne', deviceJoinName: 'Tuya TS0202 Motion Sensor'],
[profileId:'0104', endpointId:'01', inClusters:'0001,0500,0003,0000', outClusters:'1000,0006,0019,000A', model:'TS0202', manufacturer:'_TYZB01_jytabjkb', deviceJoinName: 'Tuya TS0202 Motion Sensor'],
[profileId:'0104', endpointId:'01', inClusters:'0001,0500,0003,0000', outClusters:'1000,0006,0019,000A', model:'TS0202', manufacturer:'_TYZB01_ef5xlc9q', deviceJoinName: 'Tuya TS0202 Motion Sensor'],
[profileId:'0104', endpointId:'01', inClusters:'0001,0500,0003,0000', outClusters:'1000,0006,0019,000A', model:'TS0202', manufacturer:'_TYZB01_vwqnz1sn', deviceJoinName: 'Tuya TS0202 Motion Sensor'],
[profileId:'0104', endpointId:'01', inClusters:'0001,0500,0003,0000', outClusters:'1000,0006,0019,000A', model:'TS0202', manufacturer:'_TYZB01_2b8f6cio', deviceJoinName: 'Tuya TS0202 Motion Sensor'],
[profileId:'0104', endpointId:'01', inClusters:'0001,0500,0003,0000', outClusters:'1000,0006,0019,000A', model:'TS0202', manufacturer:'_TZE200_bq5c8xfe', deviceJoinName: 'Tuya TS0202 Motion Sensor'],
[profileId:'0104', endpointId:'01', inClusters:'0001,0500,0003,0000', outClusters:'1000,0006,0019,000A', model:'TS0202', manufacturer:'_TYZB01_qjqgmqxr', deviceJoinName: 'Tuya TS0202 Motion Sensor'],
[profileId:'0104', endpointId:'01', inClusters:'0001,0500,0003,0000', outClusters:'1000,0006,0019,000A', model:'TS0202', manufacturer:'_TYZB01_zwvaj5wy', deviceJoinName: 'Tuya TS0202 Motion Sensor'],
[profileId:'0104', endpointId:'01', inClusters:'0001,0500,0003,0000', outClusters:'1000,0006,0019,000A', model:'TS0202', manufacturer:'_TZ3000_bsvqrxru', deviceJoinName: 'Tuya TS0202 Motion Sensor'],
[profileId:'0104', endpointId:'01', inClusters:'0001,0500,0003,0000', outClusters:'1000,0006,0019,000A', model:'TS0202', manufacturer:'_TYZB01_tv3wxhcz', deviceJoinName: 'Tuya TS0202 Motion Sensor'],
[profileId:'0104', endpointId:'01', inClusters:'0001,0500,0003,0000', outClusters:'1000,0006,0019,000A', model:'TS0202', manufacturer:'_TYZB01_hqbdru35', deviceJoinName: 'Tuya TS0202 Motion Sensor'],
[profileId:'0104', endpointId:'01', inClusters:'0001,0500,0003,0000', outClusters:'1000,0006,0019,000A', model:'TS0202', manufacturer:'_TZ3000_tiwq83wk', deviceJoinName: 'Tuya TS0202 Motion Sensor'],
[profileId:'0104', endpointId:'01', inClusters:'0001,0500,0003,0000', outClusters:'1000,0006,0019,000A', model:'TS0202', manufacturer:'_TZ3000_ykwcwxmz', deviceJoinName: 'Tuya TS0202 Motion Sensor'],
[profileId:'0104', endpointId:'01', inClusters:'0001,0500,0003,0000', outClusters:'1000,0006,0019,000A', model:'TS0202', manufacturer:'_TZ3000_hgu1dlak', deviceJoinName: 'Tuya TS0202 Motion Sensor'],
[profileId:'0104', endpointId:'01', inClusters:'0001,0500,0003,0000', outClusters:'1000,0006,0019,000A', model:'TS0202', manufacturer:'_TZ3000_hktqahrq', deviceJoinName: 'Tuya TS0202 Motion Sensor'],
[profileId:'0104', endpointId:'01', inClusters:'0001,0500,0003,0000', outClusters:'1000,0006,0019,000A', model:'TS0202', manufacturer:'_TZ3000_jmrgyl7o', deviceJoinName: 'Tuya TS0202 Motion Sensor'], // not tested! //https://zigbee.blakadder.com/Luminea_ZX-5311.html
[profileId:'0104', endpointId:'01', inClusters:'0001,0500,0003,0000', outClusters:'1000,0006,0019,000A', model:'WHD02', manufacturer:'_TZ3000_kmh5qpmb', deviceJoinName: 'Tuya TS0202 Motion Sensor'],
[profileId:'0104', endpointId:'01', inClusters:'0001,0500,0003,0000', outClusters:'1000,0006,0019,000A', model:'TS0202', manufacturer:'_TZ3000_kmh5qpmb', deviceJoinName: 'Tuya TS0202 Motion Sensor'], // https://community.hubitat.com/t/release-tuya-zigbee-multi-sensor-4-in-1-pir-motion-sensors-w-healthstatus/92441/1059?u=kkossev
[profileId:'0104', endpointId:'01', inClusters:'0001,0500,0003,0000', outClusters:'1000,0006,0019,000A', model:'TS0202', manufacturer:'_TZ3040_usvkzkyn', deviceJoinName: 'Tuya TS0202 Motion Sensor'], // not tested // https://www.amazon.ae/Rechargeable-Detector-Security-Devices-Required/dp/B0BKKJ48QH
[profileId:'0104', endpointId:'01', inClusters:'0000,0001,0003,0500', model:'RH3040', manufacturer:'TUYATEC-53o41joc', deviceJoinName: 'TUYATEC RH3040 Motion Sensor'], // 60 seconds reset period
[profileId:'0104', endpointId:'01', inClusters:'0000,0001,0003,0500', model:'RH3040', manufacturer:'TUYATEC-b5g40alm', deviceJoinName: 'TUYATEC RH3040 Motion Sensor'],
[profileId:'0104', endpointId:'01', inClusters:'0000,0001,0003,0500', model:'RH3040', manufacturer:'TUYATEC-deetibst', deviceJoinName: 'TUYATEC RH3040 Motion Sensor'],
[profileId:'0104', endpointId:'01', inClusters:'0000,0001,0003,0500', model:'RH3040', manufacturer:'TUYATEC-bd5faf9p', deviceJoinName: 'Nedis/Samotech RH3040 Motion Sensor'],
[profileId:'0104', endpointId:'01', inClusters:'0000,0001,0003,0500', model:'RH3040', manufacturer:'TUYATEC-zn9wyqtr', deviceJoinName: 'Samotech RH3040 Motion Sensor'], // vendor: 'Samotech', model: 'SM301Z'
[profileId:'0104', endpointId:'01', inClusters:'0000,0001,0003,0500', model:'RH3040', manufacturer:'TUYATEC-b3ov3nor', deviceJoinName: 'Zemismart RH3040 Motion Sensor'], // vendor: 'Nedis', model: 'ZBSM10WT'
[profileId:'0104', endpointId:'01', inClusters:'0000,0001,0003,0500', model:'RH3040', manufacturer:'TUYATEC-2gn2zf9e', deviceJoinName: 'TUYATEC RH3040 Motion Sensor'],
[profileId:'0104', endpointId:'01', inClusters:'0000,0001,0003,0500,0B05', outClusters:'0019', model:'TY0202', manufacturer:'_TZ1800_fcdjzz3s', deviceJoinName: 'Lidl TY0202 Motion Sensor'],
[profileId:'0104', endpointId:'01', inClusters:'0000,0001,0003,0500,0B05,FCC0', outClusters:'0019,FCC0', model:'TY0202', manufacturer:'_TZ3000_4ggd8ezp', deviceJoinName: 'Bond motion sensor ZX-BS-J11W'], // https://community.hubitat.com/t/what-driver-to-use-for-this-motion-sensor-zx-bs-j11w-or-ty0202/103953/4
[profileId:'0104', endpointId:'01', inClusters:'0001,0003,0004,0500,0000', outClusters:'0004,0006,1000,0019,000A', model:'TS0202', manufacturer:'_TZ3040_bb6xaihh', deviceJoinName: 'Tuya TS0202 Motion Sensor'], // https://github.com/Koenkk/zigbee2mqtt/issues/17364
[profileId:'0104', endpointId:'01', inClusters:'0001,0003,0004,0500,0000', outClusters:'0004,0006,1000,0019,000A', model:'TS0202', manufacturer:'_TZ3040_wqmtjsyk', deviceJoinName: 'Tuya TS0202 Motion Sensor'], // not tested
[profileId:'0104', endpointId:'01', inClusters:'0001,0003,0004,0500,0000', outClusters:'0004,0006,1000,0019,000A', model:'TS0202', manufacturer:'_TZ3000_h4wnrtck', deviceJoinName: 'Tuya TS0202 Motion Sensor'] // not tested
],
deviceJoinName: 'Tuya TS0202 Motion Sensor',
configuration : ['battery': false]
],
'TS0202_MOTION_IAS_CONFIGURABLE' : [
description : 'Tuya TS0202 Motion sensor (IAS) configurable',
models : ['TS0202'],
device : [type: 'PIR', isIAS:true, powerSource: 'battery', isSleepy:true],
capabilities : ['MotionSensor': true, 'Battery': true],
preferences : ['motionReset':true, 'keepTime':'0x0500:0xF001', 'sensitivity':'0x0500:0x0013'],
fingerprints : [
[profileId:'0104', endpointId:'01', inClusters:'0001,0500,0003,0000', outClusters:'1000,0006,0019,000A', model:'TS0202', manufacturer:'_TZ3000_mcxw5ehu', deviceJoinName: 'Tuya TS0202 ZM-35H-Q Motion Sensor'], // TODO: PIR sensor sensitivity and PIR keep time in seconds ['30', '60', '120']
[profileId:'0104', endpointId:'01', inClusters:'0001,0500,0003,0000', outClusters:'1000,0006,0019,000A', model:'TS0202', manufacturer:'_TZ3000_msl6wxk9', deviceJoinName: 'Tuya TS0202 ZM-35H-Q Motion Sensor'], // TODO: fz.ZM35HQ_attr ['30', '60', '120']
[profileId:'0104', endpointId:'01', inClusters:'0001,0500,0003,0000', outClusters:'1000,0006,0019,000A', model:'TS0202', manufacturer:'_TZ3040_msl6wxk9', deviceJoinName: 'Tuya TS0202 ZM-35H-Q Motion Sensor'],
[profileId:'0104', endpointId:'01', inClusters:'0001,0500,0003,0000', outClusters:'1000,0006,0019,000A', model:'TS0202', manufacturer:'_TZ3040_fwxuzcf4', deviceJoinName: 'Tuya TS0202 ZM-35H-Q Motion Sensor'],
[profileId:'0104', endpointId:'01', inClusters:'0001,0500,0003,0000', outClusters:'1000,0006,0019,000A', model:'TS0202', manufacturer:'_TZ3000_6ygjfyll', deviceJoinName: 'Tuya TS0202 Motion Sensor'], // https://community.hubitat.com/t/release-tuya-zigbee-multi-sensor-4-in-1-pir-motion-sensors-and-mmwave-presence-radars/92441/289?u=kkossev
[profileId:'0104', endpointId:'01', inClusters:'0001,0500,0003,0000', outClusters:'1000,0006,0019,000A', model:'TS0202', manufacturer:'_TZ3040_6ygjfyll', deviceJoinName: 'Tuya TS0202 Motion Sensor'], // https://community.hubitat.com/t/tuya-motion-sensor-driver/72000/54?u=kkossev
],
attributes: [
[at:'0x0500:0x0013', name:'sensitivity', type:'enum', rw: 'rw', min:0, max:2, defVal:'2', unit:'', map:[0:'low', 1:'medium', 2:'high'], title:'Sensitivity', description:'PIR sensor sensitivity (update at the time motion is activated)'],
[at:'0x0500:0xF001', name:'keepTime', type:'enum', rw: 'rw', min:0, max:2, defVal:'0', unit:'seconds', map:[0:'30 seconds', 1:'60 seconds', 2:'120 seconds'], title:'Keep Time', description:'PIR keep time in seconds (update at the time motion is activated)'],
],
deviceJoinName: 'Tuya TS0202 Motion Sensor configurable',
configuration : ['battery': false]
],
// isMotionSwitch()
'TS0202_MOTION_SWITCH': [
description : 'Tuya Motion Sensor and Scene Switch',
models : ['TS0202'],
device : [type: 'PIR', isIAS:true, powerSource: 'battery', isSleepy:true],
capabilities : ['MotionSensor':true, 'IlluminanceMeasurement':true, 'switch':true, 'Battery':true],
preferences : ['motionReset':true, 'keepTime':false, 'sensitivity':false, 'luxThreshold':false], // keepTime is hardcoded 60 seconds, no sensitivity configuration
fingerprints : [
[profileId:'0104', endpointId:'01', inClusters:'0001,0500,EF00,0000', outClusters:'0019,000A', model:'TS0202', manufacturer:'_TZ3210_cwamkvua', deviceJoinName: 'Tuya Motion Sensor and Scene Switch'] // vendor: 'Linkoze', model: 'LKMSZ001'
],
tuyaDPs: [
[dp:101, name:'pushed', type:'enum', rw: 'ro', min:0, max:2, defVal:'0', scale:1, map:[0:'pushed', 1:'doubleTapped', 2:'held'] , unit:'', title:'Presence state', description:'Presence state'],
[dp:102, name:'illuminance', type:'number', rw: 'ro', min:0, max:1, defVal:0, scale:1, unit:'lx', title:'illuminance', description:'illuminance'],
],
deviceJoinName: 'Tuya Motion Sensor and Scene Switch',
configuration : ['battery': false]
],
'TS0601_PIR_PRESENCE' : [ // isBlackPIRsensor() // https://github.com/zigpy/zha-device-handlers/issues/1618
description : 'Tuya PIR Human Motion Presence Sensor (Black)',
models : ['TS0601'],
device : [type: 'radar', powerSource: 'dc', isSleepy:false],
capabilities : ['MotionSensor': true, 'Battery': true],
preferences : ['fadingTime':'102', 'targetDistance':'105'],
commands : ['resetStats':'resetStats', 'resetPreferencesToDefaults':'resetPreferencesToDefaults'],
fingerprints : [
[profileId:'0104', endpointId:'01', inClusters:'0004,0005,EF00,0000', outClusters:'0019,000A', model:'TS0601', manufacturer:'_TZE200_9qayzqa8', deviceJoinName: 'Smart PIR Human Motion Presence Sensor (Black)'] // https://www.aliexpress.com/item/1005004296422003.html
],
tuyaDPs: [ // TODO - defaults !!
[dp:102, name:'fadingTime', type:'number', rw: 'rw', min:24, max:300 , defVal:24, scale:1, unit:'seconds', title:'Fading time', description:'Fading(Induction) time'],
[dp:105, name:'targetDistance', type:'enum', rw: 'rw', min:0, max:9 , defVal:'6', scale:1, map:[0:'0.5 m', 1:'1.0 m', 2:'1.5 m', 3:'2.0 m', 4:'2.5 m', 5:'3.0 m', 6:'3.5 m', 7:'4.0 m', 8:'4.5 m', 9:'5.0 m'] , unit:'meters', title:'Target Distance', description:'Target Distance'],
[dp:119, name:'motion', type:'enum', rw: 'ro', min:0, max:1 , defVal:'0', scale:1, map:[0:'inactive', 1:'active'] , unit:'', title:'Presence state', description:'Presence state'],
[dp:141, name:'humanMotionState', type:'enum', rw: 'ro', min:0, max:4 , defVal:'0', scale:1, map:[0:'none', 1:'presence', 2:'peaceful', 3:'small_move', 4:'large_move'] , unit:'', title:'Presence state', description:'Presence state'],
],
deviceJoinName: 'Tuya PIR Human Motion Presence Sensor LQ-CG01-RDR',
configuration : ['battery': false]
],
'TS0601_PIR_AIR' : [ // isHumanPresenceSensorAIR() - Human presence sensor AIR (PIR sensor!) - o_sensitivity, v_sensitivity, led_status, vacancy_delay, light_on_luminance_prefer, light_off_luminance_prefer, mode, luminance_level, reference_luminance, vacant_confirm_time
description : 'Tuya PIR Human Motion Presence Sensor AIR',
models : ['TS0601'],
device : [type: 'radar', powerSource: 'dc', isSleepy:false],
capabilities : ['MotionSensor': true, 'IlluminanceMeasurement': true, 'Battery': true], // TODO - check if battery powered?
preferences : ['vacancyDelay':'103', 'ledStatusAIR':'110', 'detectionMode':'104', 'vSensitivity':'101', 'oSensitivity':'102', 'lightOnLuminance':'107', 'lightOffLuminance':'108' ],
commands : ['resetStats':'resetStats'],
fingerprints : [
[profileId:'0104', endpointId:'01', inClusters:'0000,0004,0005,EF00', outClusters:'0019,000A', model:'TS0601', manufacturer:'_TZE200_auin8mzr', deviceJoinName: 'Tuya PIR Human Motion Presence Sensor AIR'] // Tuya LY-TAD-K616S-ZB
],
tuyaDPs: [ // TODO - defaults !!
[dp:101, name:'vSensitivity', type:'enum', rw: 'rw', min:0, max:1, defVal:'0', scale:1, map:[0:'Speed Priority', 1:'Standard', 2:'Accuracy Priority'] , unit:'-', title:'vSensitivity options', description:'V-Sensitivity mode'],
[dp:102, name:'oSensitivity', type:'enum', rw: 'rw', min:0, max:1, defVal:'0', scale:1, map:[0:'Sensitive', 1:'Normal', 2:'Cautious'] , unit:'', title:'oSensitivity options', description:'O-Sensitivity mode'],
[dp:103, name:'vacancyDelay', type:'number', rw: 'rw', min:0, max:1000, defVal:10, scale:1, unit:'seconds', title:'Vacancy Delay', description:'Vacancy Delay'],
[dp:104, name:'detectionMode', type:'enum', rw: 'rw', min:0, max:1 , defVal:'0', scale:1, map:[0:'General Model', 1:'Temporary Stay', 2:'Basic Detecton', 3:'PIR Sensor Test'] , unit:'', title:'Detection Mode', description:'Detection Mode'],
[dp:105, name:'unacknowledgedTime', type:'number', rw: 'ro', min:0, max:9 , defVal:7, scale:1, unit:'seconds', description:'unacknowledgedTime'],
[dp:106, name:'illuminance', type:'number', rw: 'ro', min:0, max:2000, defVal:0, scale:1, unit:'lx', title:'illuminance', description:'illuminance'],
[dp:107, name:'lightOnLuminance', type:'number', rw: 'rw', min:0, max:2000, defVal:0, scale:1, unit:'lx', title:'lightOnLuminance', description:'lightOnLuminance'], // Ligter, Medium, ... ?// TODO =- check range 0 - 10000 ?
[dp:108, name:'lightOffLuminance', type:'number', rw: 'rw', min:0, max:2000, defVal:0, scale:1, unit:'lx', title:'lightOffLuminance', description:'lightOffLuminance'],
[dp:109, name:'luminanceLevel', type:'number', rw: 'ro', min:0, max:2000, defVal:0, scale:1, unit:'lx', title:'luminanceLevel', description:'luminanceLevel'], // Ligter, Medium, ... ?
[dp:110, name:'ledStatusAIR', type:'enum', rw: 'rw', min:0, max:1 , defVal:'0', scale:1, map:[0: 'Switch On', 1:'Switch Off', 2: 'Default'] , unit:'', title:'LED status', description:'Led status switch'],
],
deviceJoinName: 'Tuya PIR Human Motion Presence Sensor AIR',
configuration : ['battery': false]
],
'SONOFF_MOTION_IAS' : [
description : 'Sonoff/eWeLink Motion sensor',
models : ['eWeLink'],
device : [type: 'PIR', isIAS:true, powerSource: 'battery', isSleepy:true], // very sleepy !!
capabilities : ['MotionSensor': true, 'Battery': true],
preferences : ['motionReset':true, 'keepTime':false, 'sensitivity':false], // just enable or disable showing the motionReset preference, no link to tuyaDPs or attributes map!
fingerprints : [
[profileId:'0104', endpointId:'01', inClusters:'0000,0003,0500,0001', outClusters:'0003', model:'ms01', manufacturer:'eWeLink', deviceJoinName: 'eWeLink Motion Sensor'], // for testL 60 seconds re-triggering period!
[profileId:'0104', endpointId:'01', inClusters:'0000,0003,0500,0001', outClusters:'0003', model:'msO1', manufacturer:'eWeLink', deviceJoinName: 'eWeLink Motion Sensor'], // second variant
[profileId:'0104', endpointId:'01', inClusters:'0000,0003,0500,0001', outClusters:'0003', model:'MS01', manufacturer:'eWeLink', deviceJoinName: 'eWeLink Motion Sensor'] // third variant
],
deviceJoinName: 'Sonoff/eWeLink Motion sensor',
configuration : [
'0x0001':[['bind':true], ['reporting':'0x21, 0x20, 3600, 7200, 0x02']], // TODO - use the reproting values
'0x0500':[['bind':false], ['sensitivity':false], ['keepTime':false]], // TODO - use in update function
] // battery percentage, min 3600, max 7200, UINT8, delta 2
],
// isSiHAS()
'SIHAS_USM-300Z_4_IN_1' : [
description : 'SiHAS USM-300Z 4-in-1',
models : ['ShinaSystem'],
device : [type: 'radar', powerSource: 'battery', isIAS:false, isSleepy:false],
capabilities : ['MotionSensor': true, 'TemperatureMeasurement': true, 'RelativeHumidityMeasurement': true, 'IlluminanceMeasurement': true, 'Battery': true],
preferences : [:],
fingerprints : [
[profileId:'0104', endpointId:'01', inClusters:'0000,0400,0003,0406,0402,0001,0405,0500', outClusters:'0004,0003,0019', model:'USM-300Z', manufacturer:'ShinaSystem', deviceJoinName: 'SiHAS MultiPurpose Sensor']
],
commands : ['resetStats':'resetStats', 'refresh':'refresh', 'initialize':'initialize', 'updateAllPreferences': 'updateAllPreferences', 'resetPreferencesToDefaults':'resetPreferencesToDefaults', 'validateAndFixPreferences':'validateAndFixPreferences'],
tuyaDPs : [:],
attributes : [:],
deviceJoinName: 'SiHAS USM-300Z 4-in-1',
//configuration : ["0x0406":"bind"] // TODO !!
configuration : [:]
],
'NONTUYA_MOTION_IAS' : [
description : 'Other OEM Motion sensors (IAS)',
models : ['MOT003', 'XXX'],
device : [type: 'PIR', isIAS:true, powerSource: 'battery', isSleepy:true],
capabilities : ['MotionSensor': true, 'Battery': true],
preferences : ['motionReset':true, 'keepTime':'0x0500:0xF001', 'sensitivity':'0x0500:0x0013'],
fingerprints : [
[profileId:'0104', endpointId:'01', inClusters:'0000,0001,0003,0020,0400,0402,0500', outClusters:'0019', model:'MOT003', manufacturer:'HiveHome.com', deviceJoinName: 'Hive Motion Sensor'] // https://community.hubitat.com/t/hive-motion-sensors-can-we-get-custom-driver-sorted/108177?u=kkossev
],
attributes: [
[at:'0x0500:0x0013', name:'sensitivity', type:'enum', rw: 'rw', min:0, max:2, defVal:'2', unit:'', map:[0:'low', 1:'medium', 2:'high'], title:'Sensitivity', description:'PIR sensor sensitivity (update at the time motion is activated)'],
[at:'0x0500:0xF001', name:'keepTime', type:'enum', rw: 'rw', min:0, max:2, defVal:'0', unit:'seconds', map:[0:'30 seconds', 1:'60 seconds', 2:'120 seconds'], title:'Keep Time', description:'PIR keep time in seconds (update at the time motion is activated)'],
],
deviceJoinName: 'Other OEM Motion sensor (IAS)',
configuration : ['battery': false]
],
'UNKNOWN' : [ // the Device Profile key (shown in the State Variables)
description : 'Unknown device', // the Device Profile description (shown in the Preferences)
models : ['UNKNOWN'], // used to match a Device profile if the individuak fingerprints do not match
device : [
type: 'PIR', // 'PIR' or 'radar'
isIAS:true, // define it for PIR sensors only!
powerSource: 'dc', // determines the powerSource value - can be 'battery', 'dc', 'mains'
isSleepy:false // determines the update and ping behaviour
],
capabilities : ['MotionSensor': true, 'IlluminanceMeasurement': true, 'Battery': true],
preferences : ['motionReset':true],
commands : ['resetSettings':'resetSettings', 'resetStats':'resetStats', 'initialize':'initialize', 'updateAllPreferences': 'updateAllPreferences', 'resetPreferencesToDefaults':'resetPreferencesToDefaults', 'validateAndFixPreferences':'validateAndFixPreferences' \
],
//fingerprints : [
// [profileId:"0104", endpointId:"01", inClusters:"0000,0003,0406", outClusters:"0003", model:"model", manufacturer:"manufacturer"]
//],
tuyaDPs: [
[
dp:1,
name:'motion',
type:'enum',
rw: 'ro',
min:0,
max:1,
map:[0:'inactive', 1:'active'],
description:'Motion state'
]
],
deviceJoinName: 'Unknown device', // used during the inital pairing, if no individual fingerprint deviceJoinName was found
configuration : ['battery': true],
batteries : 'unknown'
],
'---' : [
description : '---------------------------------------------------------------------------------------',
models : [],
fingerprints : [],
],
'----' : [
description : 'Tuya radars are supported in the new Tuya mmWave Sensor driver',
models : [],
fingerprints : [],
],
// ------------------------------------------- mmWave Radars - OBSOLETE !------------------------------------------------//
'TS0601_TUYA_RADAR' : [ // isZY_M100Radar() // spammy devices!
description : 'Tuya Human Presence mmWave Radar ZY-M100',
models : ['TS0601'],
device : [isDepricated: true, type: 'radar', powerSource: 'dc', isSleepy:false],
capabilities : ['MotionSensor': true, 'IlluminanceMeasurement': true, 'DistanceMeasurement':true],
fingerprints : [
[manufacturer:'_TZE200_ztc6ggyl'], [manufacturer:'_TZE204_ztc6ggyl'], [manufacturer:'_TZE200_ikvncluo'], [manufacturer:'_TZE200_lyetpprm'], [manufacturer:'_TZE200_wukb7rhc'],
[manufacturer:'_TZE200_jva8ink8'], [manufacturer:'_TZE200_mrf6vtua'], [manufacturer:'_TZE200_ar0slwnd'], [manufacturer:'_TZE200_sfiy5tfs'], [manufacturer:'_TZE200_holel4dk'],
[manufacturer:'_TZE200_xpq2rzhq'], [manufacturer:'_TZE204_qasjif9e'], [manufacturer:'_TZE204_xsm7l9xa']
],
tuyaDPs: [
[dp:1, name:'motion', type:'enum', rw: 'ro', min:0, max:1 , defVal:'0', scale:1, map:[0:'inactive', 1:'active'] , unit:'', title:'Presence state', description:'Presence state'],
[dp:9, name:'distance', type:'decimal', rw: 'ro', min:0.0, max:10.0 , defVal:0.0, scale:100, unit:'meters', title:'Distance', description:'detected distance'],
[dp:103, name:'debugCLI', type:'number', rw: 'ro', min:0, max:99999, defVal:0, scale:1, unit:'?', title:'debugCLI', description:'debug CLI'],
[dp:104, name:'illuminance', type:'number', rw: 'ro', min:0, max:2000, defVal:0, scale:1, unit:'lx', title:'illuminance', description:'illuminance'],
],
spammyDPsToIgnore : [9], spammyDPsToNotTrace : [9, 103]
],
'TS0601_KAPVNNLK_RADAR' : [ // 24GHz spammy radar w/ battery backup - depricated
description : 'Tuya TS0601_KAPVNNLK 24GHz Radar',
models : ['TS0601'],
device : [isDepricated: true, type: 'radar', powerSource: 'dc', isSleepy:false],
capabilities : ['MotionSensor': true, 'DistanceMeasurement':true],
fingerprints : [[manufacturer:'_TZE204_kapvnnlk'], [manufacturer:'_TZE204_kyhbrfyl']],
tuyaDPs: [
[dp:1, name:'motion', type:'enum', rw: 'ro', min:0, max:1, defVal:'0', scale:1, map:[0:'inactive', 1:'active'] , unit:'', title:'Presence state', description:'Presence state'],
[dp:19, name:'distance', type:'decimal', rw: 'ro', min:0.0, max:10.0, defVal:0.0, scale:100, unit:'meters', title:'Distance', description:'detected distance']
],
spammyDPsToIgnore : [19], spammyDPsToNotTrace : [19]
],
'TS0601_RADAR_MIR-HE200-TY' : [
description : 'Tuya Human Presence Sensor MIR-HE200-TY', // deprecated
models : ['TS0601'],
device : [isDepricated:true, type: 'radar', powerSource: 'dc', isSleepy:false],
capabilities : ['MotionSensor': true, 'IlluminanceMeasurement': true],
fingerprints : [[manufacturer:'_TZE200_vrfecyku'], [manufacturer:'_TZE200_lu01t0zl'], [manufacturer:'_TZE200_ypprdwsl']],
tuyaDPs: [
[dp:1, name:'motion', type:'enum', rw: 'ro', min:0, max:1, defVal:'0', scale:1, map:[0:'inactive', 1:'active'] , unit:'', title:'Presence state', description:'Presence state'],
[dp:102, name:'motionState', type:'enum', rw: 'ro', min:0, max:1, defVal:'0', scale:1, map:[0:'inactive', 1:'active'] , unit:'', title:'Motion state', description:'Motion state (occupancy)'],
]
],
'TS0601_BLACK_SQUARE_RADAR' : [
description : 'Tuya Black Square Radar',
models : ['TS0601'],
device : [isDepricated:true, type: 'radar', powerSource: 'dc', isSleepy:false],
capabilities : ['MotionSensor':true],
fingerprints : [[manufacturer:'_TZE200_0u3bj3rc'], [manufacturer:'_TZE200_v6ossqfy'], [manufacturer:'_TZE200_mx6u6l4y']],
tuyaDPs: [
[dp:1, name:'motion', type:'enum', rw: 'ro', min:0, max:1, defVal: '0', map:[0:'inactive', 1:'active'], description:'Presence'],
],
spammyDPsToIgnore : [103], spammyDPsToNotTrace : [1, 101, 102, 103]
],
'TS0601_YXZBRB58_RADAR' : [
description : 'Tuya YXZBRB58 Radar',
models : ['TS0601'],
device : [isDepricated: true, type: 'radar', powerSource: 'dc', isSleepy: false],
capabilities : ['MotionSensor': true, 'IlluminanceMeasurement': true, 'DistanceMeasurement':true],
fingerprints : [[manufacturer:'_TZE204_sooucan5']],
tuyaDPs: [
[dp:1, name:'motion', type:'enum', rw: 'ro', min:0, max:2, defVal:'0', map:[0:'inactive', 1:'active'], description:'Presence state'],
[dp:101, name:'illuminance', type:'number', rw: 'ro', scale:1, unit:'lx', description:'Illuminance'],
[dp:105, name:'distance', type:'decimal', rw: 'ro', min:0.0, max:10.0, scale:100, unit:'meters', description:'Distance']
],
spammyDPsToIgnore : [105], spammyDPsToNotTrace : [105]
],
'TS0601_SXM7L9XA_RADAR' : [
description : 'Tuya Human Presence Detector SXM7L9XA',
models : ['TS0601'],
device : [isDepricated: true, type: 'radar', powerSource: 'dc', isSleepy:false],
capabilities : ['MotionSensor': true, 'IlluminanceMeasurement': true, 'DistanceMeasurement':true],
fingerprints : [
[manufacturer:'_TZE204_sxm7l9xa'], [manufacturer:'_TZE204_e5m9c5hl']
],
tuyaDPs: [
[dp:104, name:'illuminance', type:'number', rw: 'ro', scale:1, unit:'lx', description:'illuminance'],
[dp:105, name:'motion', type:'enum', rw: 'ro', min:0, max:1, defVal:'0', map:[0:'inactive', 1:'active'], description:'Presence state'],
[dp:109, name:'distance', type:'decimal', rw: 'ro', min:0.0, max:10.0, scale:100, unit:'meters', description:'Distance']
],
spammyDPsToIgnore : [109], spammyDPsToNotTrace : [109]
],
'TS0601_IJXVKHD0_RADAR' : [
description : 'Tuya Human Presence Detector IJXVKHD0',
models : ['TS0601'],
device : [isDepricated: true, type: 'radar', powerSource: 'dc', isSleepy:false],
capabilities : ['MotionSensor': true, 'IlluminanceMeasurement': true, 'DistanceMeasurement':true],
fingerprints : [[manufacturer:'_TZE204_ijxvkhd0']],
tuyaDPs: [
[dp:104, name:'illuminance', type:'number', rw: 'ro', scale:1, unit:'lx', description:'illuminance'],
[dp:105, name:'humanMotionState', type:'enum', rw: 'ro', min:0, max:2, defVal:'0', map:[0:'none', 1:'present', 2:'moving'], description:'Presence state'],
[dp:109, name:'distance', type:'decimal', rw: 'ro', min:0.0, max:10.0, defVal:0.0, scale:100, unit:'meters', description:'Target distance'],
[dp:112, name:'motion', type:'enum', rw: 'ro', min:0, max:1, defVal:'0', scale:1, map:[0:'inactive', 1:'active'] , unit:'', title:'Presence state', description:'Presence state'],
[dp:123, name:'presence', type:'enum', rw: 'ro', min:0, max:1, defVal:'0', map:[0:'none', 1:'presence'], description:'Presence'] // TODO -- check if used?
],
spammyDPsToIgnore : [109, 9], spammyDPsToNotTrace : [109, 104]
],
'TS0601_YENSYA2C_RADAR' : [
description : 'Tuya Human Presence Detector YENSYA2C',
models : ['TS0601'],
device : [isDepricated: true, type: 'radar', powerSource: 'dc', isSleepy: false],
capabilities : ['MotionSensor': true, 'IlluminanceMeasurement': true, 'DistanceMeasurement':true],
fingerprints : [[manufacturer:'_TZE204_yensya2c'], [manufacturer:'_TZE204_mhxn2jso']],
tuyaDPs: [
[dp:1, name:'motion', type:'enum', rw: 'ro', min:0, max:1, defVal:'0', scale:1, map:[0:'inactive', 1:'active'] , unit:'', title:'Presence state', description:'Presence state'],
[dp:19, name:'distance', type:'decimal', rw: 'ro', min:0.0, max:10.0, defVal:0.0, scale:100, unit:'meters', description:'Distance'],
[dp:20, name:'illuminance', type:'number', rw: 'ro', min:0, max:10000, scale:1, unit:'lx', description:'illuminance']
],
spammyDPsToIgnore : [19], spammyDPsToNotTrace : [19]
],
'TS0225_HL0SS9OA_RADAR' : [
description : 'Tuya TS0225_HL0SS9OA Radar',
models : ['TS0225'],
device : [isDepricated: true, type: 'radar', powerSource: 'dc', isSleepy:false],
capabilities : ['MotionSensor': true, 'IlluminanceMeasurement': true, 'HumanMotionState':true],
fingerprints : [[manufacturer:'_TZE200_hl0ss9oa']],
tuyaDPs: [
[dp:1, name:'motion', type:'enum', rw: 'ro', min:0, max:1, defVal:'0', scale:1, map:[0:'inactive', 1:'active'] , unit:'', title:'Presence state', description:'Presence state'],
[dp:11, name:'humanMotionState', type:'enum', rw: 'ro', min:0, max:3, defVal:'0', map:[0:'none', 1:'large', 2:'small', 3:'static'], description:'Human motion state'],
[dp:20, name:'illuminance', type:'number', rw: 'ro', scale:10, unit:'lx', description:'Illuminance']
],
spammyDPsToIgnore : [], spammyDPsToNotTrace : [11]
],
'TS0225_2AAELWXK_RADAR' : [
description : 'Tuya TS0225_2AAELWXK 5.8 GHz Radar',
models : ['TS0225'],
device : [isDepricated: true, type: 'radar', powerSource: 'dc', isSleepy:false],
capabilities : ['MotionSensor': true, 'IlluminanceMeasurement': true, 'HumanMotionState':true],
fingerprints : [[manufacturer:'_TZE200_2aaelwxk']],
tuyaDPs: [
[dp:1, name:'motion', type:'enum', rw: 'ro', min:0, max:1, defVal:'0', scale:1, map:[0:'inactive', 1:'active'] , unit:'', title:'Presence state', description:'Presence state'],
[dp:101, name:'humanMotionState', type:'enum', rw: 'ro', min:0, max:3, defVal:'0', map:[0:'none', 1:'large', 2:'small', 3:'static'], description:'Human motion state'],
[dp:106, name:'illuminance', type:'number', rw: 'ro', scale:10, unit:'lx', description:'Illuminance']
]
],
'TS0601_SBYX0LM6_RADAR' : [
description : 'Tuya Human Presence Detector SBYX0LM6',
models : ['TS0601'],
device : [isDepricated: true, type: 'radar', powerSource: 'dc', isSleepy:false],
capabilities : ['MotionSensor': true, 'IlluminanceMeasurement': true, 'DistanceMeasurement':true],
fingerprints : [
[manufacturer:'_TZE204_sbyx0lm6'], [manufacturer:'_TZE200_sbyx0lm6'], [manufacturer:'_TZE204_dtzziy1e'], [manufacturer:'_TZE200_dtzziy1e'], [manufacturer:'_TZE204_clrdrnya'], [manufacturer:'_TZE200_clrdrnya'],
[manufacturer:'_TZE204_cfcznfbz'], [manufacturer:'_TZE204_iaeejhvf'], [manufacturer:'_TZE204_mtoaryre'], [manufacturer:'_TZE204_8s6jtscb'], [manufacturer:'_TZE204_rktkuel1'], [manufacturer:'_TZE204_mp902om5'],
[manufacturer:'_TZE200_w5y5slkq'], [manufacturer:'_TZE204_w5y5slkq'], [manufacturer:'_TZE200_xnaqu2pc'], [manufacturer:'_TZE204_xnaqu2pc'], [manufacturer:'_TZE200_wk7seszg'], [manufacturer:'_TZE204_wk7seszg'],
[manufacturer:'_TZE200_0wfzahlw'], [manufacturer:'_TZE204_0wfzahlw'], [manufacturer:'_TZE200_pfayrzcw'], [manufacturer:'_TZE204_pfayrzcw'], [manufacturer:'_TZE200_z4tzr0rg'], [manufacturer:'_TZE204_z4tzr0rg']
],
tuyaDPs: [
[dp:1, name:'motion', type:'enum', rw: 'ro', min:0, max:1, defVal:'0', scale:1, map:[0:'inactive', 1:'active'] , unit:'', title:'Presence state', description:'Presence state'],
[dp:9, name:'distance', type:'decimal', rw: 'ro', min:0.0, max:10.0, defVal:0.0, scale:100, unit:'meters', description:'detected distance'],
[dp:104, name:'illuminance', type:'number', rw: 'ro', min:0, max:2000, defVal:0, scale:10, unit:'lx', title:'illuminance', description:'illuminance']
],
spammyDPsToIgnore : [9], spammyDPsToNotTrace : [9]
],
// isLINPTECHradar()
'TS0225_LINPTECH_RADAR' : [
description : 'Tuya TS0225_LINPTECH 24GHz Radar',
models : ['TS0225'],
device : [isDepricated: true, type: 'radar', powerSource: 'dc', isSleepy:false],
capabilities : ['MotionSensor': true, 'IlluminanceMeasurement': true, 'DistanceMeasurement':true],
preferences : ['fadingTime':'101', 'motionDetectionDistance':'0xE002:0xE00B', 'motionDetectionSensitivity':'0xE002:0xE004', 'staticDetectionSensitivity':'0xE002:0xE005'],
fingerprints : [
[profileId:'0104', endpointId:'01', inClusters:'0000,0003,0004,0005,E002,4000,EF00,0500', outClusters:'0019,000A', model:'TS0225', manufacturer:'_TZ3218_awarhusb', deviceJoinName: 'Tuya TS0225_LINPTECH 24Ghz Human Presence Detector'] // https://www.aliexpress.com/item/1005004788260949.html // https://community.hubitat.com/t/release-tuya-zigbee-multi-sensor-4-in-1-pir-motion-sensors-and-mmwave-presence-radars-w-healthstatus/92441/539?u=kkossev
],
commands : ['resetStats':'resetStats', 'refresh':'refresh', 'initialize':'initialize', 'updateAllPreferences': 'updateAllPreferences', 'resetPreferencesToDefaults':'resetPreferencesToDefaults', 'validateAndFixPreferences':'validateAndFixPreferences'],
tuyaDPs: [ // the tuyaDPs revealed from iot.tuya.com are actually not used by the device! The only exception is dp:101
[dp:101, name:'fadingTime', type:'number', rw: 'rw', min:1, max:9999, defVal:10, scale:1, unit:'seconds', title: 'Fading time', description:'Presence inactivity timer, seconds'] // aka 'nobody time'
],
attributes: [ // LINPTECH / MOES are using a custom cluster 0xE002 for the settings (except for the fadingTime), ZCL cluster 0x0400 for illuminance (malformed reports!) and the IAS cluster 0x0500 for motion detection
[at:'0xE002:0xE001', name:'existance_time', type:'number', dt: 'UINT16', rw: 'ro', min:0, max:65535, scale:1, unit:'minutes', title: 'Existance time/b>', description:'existance (presence) time, recommended value is > 10 seconds!'], // aka Presence Time
[at:'0xE002:0xE004', name:'motionDetectionSensitivity', type:'enum', dt: 'UINT8', rw: 'rw', min:1, max:5, defVal:'4', scale:1, map:[1: '1 - low', 2: '2 - medium low', 3: '3 - medium', 4: '4 - medium high', 5: '5 - high'], unit:'', title: 'Motion Detection Sensitivity', description:'Large motion detection sensitivity'], // aka Motionless Detection Sensitivity
[at:'0xE002:0xE005', name:'staticDetectionSensitivity', type:'enum', dt: 'UINT8', rw: 'rw', min:1, max:5, defVal:'3', scale:1, map:[1: '1 - low', 2: '2 - medium low', 3: '3 - medium', 4: '4 - medium high', 5: '5 - high'], unit:'', title: 'Static Detection Sensitivity', description:'Static detection sensitivity'], // aka Motionless Detection Sensitivity
[at:'0xE002:0xE00A', name:'distance', type:'decimal', dt: 'UINT16', rw: 'ro', min:0.0, max:6.0, defVal:0.0, scale:100, unit:'meters', title: 'Distance', description:'Measured distance'], // aka Current Distance
[at:'0xE002:0xE00B', name:'motionDetectionDistance', type:'enum', dt: 'UINT16', rw: 'rw', min:0.75, max:6.0, defVal:'4.50', step:75, scale:100, map:['0.75': '0.75 meters', '1.50': '1.50 meters', '2.25': '2.25 meters', '3.00': '3.00 meters', '3.75': '3.75 meters', '4.50': '4.50 meters', '5.25': '5.25 meters', '6.00' : '6.00 meters'], unit:'meters', title: 'Motion Detection Distance', description:'Large motion detection distance, meters'] // aka Far Detection
],
spammyDPsToIgnore : [19],
spammyDPsToNotTrace : [19],
deviceJoinName: 'Tuya TS0225_LINPTECH 24Ghz Human Presence Detector',
configuration : [:]
],
'TS0225_EGNGMRZH_RADAR' : [
description : 'Tuya TS0225_EGNGMRZH 24GHz Radar',
models : ['TS0225'],
device : [isDepricated: true, type: 'radar', powerSource: 'dc', isSleepy:false],
capabilities : ['MotionSensor': true, 'IlluminanceMeasurement': true, 'DistanceMeasurement':true],
fingerprints : [[manufacturer:'_TZFED8_egngmrzh']],
// uses IAS for occupancy!
tuyaDPs: [
[dp:101, name:'illuminance', type:'number', rw: 'ro', min:0, max:10000, scale:1, unit:'lx'],
[dp:103, name:'distance', type:'decimal', rw: 'ro', min:0.0, max:10.0, defVal:0.0, scale:10, unit:'meters']
],
spammyDPsToIgnore : [103], spammyDPsToNotTrace : [103]
],
'TS0225_O7OE4N9A_RADAR' : [ // Aubess Zigbee-Human Presence Detector, Smart PIR Human Body Sensor, Wifi Radar, Microwave Motion Sensors, Tuya, 1/24/5G
description : 'Tuya Human Presence Detector YENSYA2C',
models : ['TS0225'],
device : [isDepricated: true, type: 'radar', powerSource: 'dc', isSleepy:false],
capabilities : ['MotionSensor': true, 'IlluminanceMeasurement': true, 'DistanceMeasurement':true],
fingerprints : [[manufacturer:'_TZFED8_o7oe4n9a']],
tuyaDPs: [
[dp:1, name:'motion', type:'enum', rw: 'ro', min:0, max:1, defVal:'0', scale:1, map:[0:'inactive', 1:'active'] , unit:'', title:'Presence state', description:'Presence state'],
[dp:181, name:'illuminance', type:'number', rw: 'ro', min:0, max:10000, scale:1, unit:'lx', description:'illuminance'],
[dp:182, name:'distance', type:'decimal', rw: 'ro', min:0.0, max:10.0, defVal:0.0, scale:100, unit:'meters', description:'Distance to target']
]
//spammyDPsToIgnore : [182], //spammyDPsToNotTrace : [182],
],
'OWON_OCP305_RADAR' : [ // depricated
description : 'OWON OCP305 Radar',
models : ['OCP305'],
device : [isDepricated:true, type: 'radar', powerSource: 'dc', isSleepy:false],
capabilities : ['MotionSensor': true, 'Battery': true],
fingerprints : [
[manufacturer:'OWON'] // depricated
]
],
'SONOFF_SNZB-06P_RADAR' : [ // Depricated
description : 'SONOFF SNZB-06P RADAR',
models : ['SNZB-06P'],
device : [isDepricated:true, type: 'radar', powerSource: 'dc', isIAS:false, isSleepy:false],
capabilities : ['MotionSensor': true],
fingerprints : [
[manufacturer:'SONOFF'] // Depricated!
]
]
]
// ---------------------------------- deviceProfilesV2 helper functions --------------------------------------------
String getProfileKey(final String valueStr) {
String key = deviceProfilesV2.find { _, profileMap -> profileMap.description == valueStr }?.key
return key
}
/**
* Finds the preferences map for the given parameter.
* @param param The parameter to find the preferences map for.
* @param debug Whether or not to output debug logs.
* @return returns either tuyaDPs or attributes map, depending on where the preference (param) is found
* @return empty map [:] if param is not defined for this device.
*/
Map getPreferencesMap(final String param, boolean debug=false) {
Map foundMap = [:]
if (!(param in DEVICE?.preferences)) {
if (debug) { logWarn "getPreferencesMap: preference ${param} not defined for this device!" }
return [:]
}
/* groovylint-disable-next-line NoDef */
def preference
try {
preference = DEVICE?.preferences["$param"]
if (debug) logDebug "getPreferencesMap: preference ${param} found. value is ${preference}"
if (preference in [true, false]) {
// find the preference in the tuyaDPs map
logDebug "getPreferencesMap: preference ${param} is boolean"
return [:] // no maps for predefined preferences !
}
if (preference.isNumber()) {
// find the preference in the tuyaDPs map
int dp = safeToInt(preference)
List