DeviceProfilesV3 - kkossev/Hubitat GitHub Wiki
Most of my recent drivers use the 'DeviceProfiles' static data map structure to group similar devices and define their properties. **deviceProfilesV3 **is the fixed name of the data map. The previous version of the map was named deviceProfilesV2.
Sample DeviceProfile :
` @Field static final Map deviceProfilesV3 = [
'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],
capabilities : ['MotionSensor': true, 'TemperatureMeasurement': true, 'RelativeHumidityMeasurement': true, 'IlluminanceMeasurement': true, 'tamper': true, 'Battery': true],
preferences : ['motionReset':true, 'reportingTime4in1':'102', 'ledEnable':'111', 'keepTime':'0x0500:0xF001', 'sensitivity':'0x0500:0x0013'],
commands : ['reportingTime4in1':'reportingTime4in1', 'resetStats':'resetStats', 'refresh':'refresh', 'initialize':'initialize', 'updateAllPreferences': 'updateAllPreferences', 'resetPreferencesToDefaults':'resetPreferencesToDefaults', 'validateAndFixPreferences':'validateAndFixPreferences', 'printFingerprints':'printFingerprints', 'printPreferences':'printPreferences'],
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:'<i>Motion</i>'],
[dp:5, name:'tamper', type:'enum', rw: 'ro', min:0, max:1 , defVal:'0', scale:1, map:[0:'clear', 1:'detected'] , unit:'', description:'<i>Tamper detection</i>'],
[dp:25, name:'battery2', type:'number', rw: 'ro', min:0, max:100, defVal:100, scale:1, unit:'%', description:'<i>Remaining battery 2 in %</i>'],
[dp:102, name:'reportingTime4in1', dt:'02', tuyaCmd:04, type:'number', rw: 'rw', min:0, max:240, defVal:10, step:5, scale:1, unit:'minutes', title:'<b>Reporting Interval</b>', description:'<i>Reporting interval in minutes</i>'],
[dp:104, name:'tempCalibration', type:'decimal', rw: 'ro', min:-2.0, max:2.0, defVal:0.0, scale:10, unit:'deg.', title:'<b>Temperature Calibration</b>', description:'<i>Temperature calibration (-2.0...2.0)</i>'],
[dp:105, name:'humiCalibration', type:'number', rw: 'ro', min:-15, max:15, defVal:0, scale:1, unit:'%RH', title:'<b>Huidity Calibration</b>', description:'<i>Humidity Calibration</i>'],
[dp:106, name:'illumCalibration', type:'number', rw: 'ro', min:-20, max:20, defVal:0, scale:1, unit:'Lx', title:'<b>Illuminance Calibration</b>', description:'<i>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:'<i>Temperature</i>'],
[dp:108, name:'humidity', type:'number', rw: 'ro', min:1, max:100, defVal:100, scale:1, unit:'%RH', description:'<i>Humidity</i>'],
[dp:109, name:'pirSensorEnable', type:'enum', rw: 'ro', min:0, max:1 , defVal:'1', scale:1, map:[0:'disabled', 1:'enabled'] , unit:'', title:'<b>MoPIR Sensor Enable</b>', description:'<i>Enable PIR sensor</i>'],
[dp:110, name:'battery', type:'number', rw: 'ro', min:0, max:100, defVal:100, scale:1, unit:'%', description:'<i>Battery level</i>'],
[dp:111, name:'ledEnable', dt:'01', tuyaCmd:04, type:'enum', rw: 'rw', min:0, max:1 , defVal:'0', scale:1, map:[0:'disabled', 1:'enabled'] , unit:'', title:'<b>LED Enable</b>', description:'<i>Enable LED</i>'],
[dp:112, name:'reportingEnable', type:'enum', rw: 'ro', min:0, max:1 , defVal:'0', scale:1, map:[0:'disabled', 1:'enabled'] , unit:'', title:'<b>Reporting Enable</b>', description:'<i>Enable reporting</i>'],
],
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:'<b>Sensitivity</b>', description:'<i>PIR sensor sensitivity (update at the time motion is activated)</i>'],
[at:'0x0500:0xF001', 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:'<b>Keep Time</b>', description:'<i>PIR keep time in seconds (update at the time motion is activated)</i>']
],
refresh: ['refreshAllIas','sensitivity', 'keepTime', 'refreshFantem'],
configuration : ['battery': false],
deviceJoinName: 'Tuya Multi Sensor 4 In 1'
],
`
-
profile key
- 'TS0202_4IN1' - the device profile key. It is stored in the Curren Variables deviceProfile state and is used in the driver code to get fast access to all the device properties of the device group.
Example: 'TS0202_4IN1' : [
-
description
- text format description of the device profile entry, for example, 'Tuya 4in1 (motion/temp/humi/lux) sensor'. Used in the Preferences tab, 'Device Profile' dropdown list. Also used as a default deviceJ****oinName, if there is no such in the fingerprints!
Example: description : 'Tuya 4in1 (motion/temp/humi/lux) sensor',
-
models
- [obsolete[ list of the Zigbee models in this device group (currently not used in the code! - for future use / partial matching)
-
device
- powerSource - sets explicitly the powerSource attribute during the initialization
- isDepricated- the fingerprints in this device profile will not be generated (the devices are supported in another, newer driver)
- isSpammy - all messages for the devices in this group are marked as spammy, do not log trace/debug
- ignoreIAS- if set to true, all messages from the IAS cluster will be ignored!
- tuyaCmd- overwrites the default tuyaCMD (0x00) with alternative command (often 0x04) for all commands for this device profile group
- isIAS - used in the '4 In 1' driver!
- isSleepy - not used?
- type - [obsolete] -not used!
Example: device : [type: 'PIR', isIAS:true, powerSource: 'dc', isSleepy:false],
-
capabilities
- battery - [obsolete] (reads the power cluster attribute on refresh in Tuya Zigbee Valve and Tuya Contact Sensor drivers only)
- Button - enables/disables button events for switches (int Tuya Zigbee Switch driver only)
- contactSensor - not used
- MotionSensor - not used
- HumanMotionState - not used
- DistanceMeasurement - adds a preference 'ignoreDistance'
- IlluminanceMeasurement - adds these preferences :
- 'disableIlluminance'
- 'illuminanceThreshold'
- 'illuminanceCoeff' (advancedOption)
- powerOnBehaviour - [obsolete] - (shows the powerOnBehaviour preference in Tuya Zigbee Valve driver only)
- RelativeHumidityMeasurement - not used
- Switch - not used
- ThermostatHeatingSetpoint - not used
- ThermostatOperatingState - not used
- ThermostatSetpoint - not used
- ThermostatMode - not used
- valve - not used
Example: capabilities : ['MotionSensor': true, 'TemperatureMeasurement': true, 'RelativeHumidityMeasurement': true, 'IlluminanceMeasurement': true, 'tamper': true, 'Battery': true],
-
preferences
This is a list of maps of two different types : boolean keywords (motionReset:true, invertMotion:truue, etc... ):
- motionReset- enables the 'Reset Motion to Inactive' software timer preference
- invertMotion- enables the 'Invert Motion Active/Not Active' preference
- refreshOnSave- used in the 4 In 1 driver
TuyaDPs / Attributes :
- the driver will automatically create a preference (settings.name) using the matched dp/at name. The settings type, title, description, min/max value, default value will be taken from the TuyaDPs / Attributes map.
Example : preferences : ['motionReset':true, 'reportingTime4in1':'102', 'ledEnable':'111', 'keepTime':'0x0500:0xF001', 'sensitivity':'0x0500:0x0013'],
TODO: more explanations needed!
-
commands
A list of maps containing commands which can be executed from the 'sendCommand'.
Example : commands : ['reportingTime4in1':'reportingTime4in1', 'resetStats':'', 'refresh':'', 'initialize':'', 'updateAllPreferences': '', 'resetPreferencesToDefaults':'resetPreferencesToDefaults', 'validateAndFixPreferences':'validateAndFixPreferences', 'printFingerprints':'printFingerprints', 'printPreferences':'printPreferences'],
-
fingerprints
Example: 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!
-
tuyaDPs
Example: tuyaDPs: [ [dp:1, name:'motion', type:'enum', rw: 'ro', min:0, max:1 , defVal:'0', scale:1, map:[0:'inactive', 1:'active'] , unit:'', description:'<i>Motion</i>'],
-
attributes
Example: 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:'<b>Sensitivity</b>', description:'<i>PIR sensor sensitivity (update at the time motion is activated)</i>'],
-
refresh
Example: refresh: ['refreshAllIas','sensitivity', 'keepTime', 'refreshFantem'],
-
configuration
Example: configuration : ['battery': false],
-
deviceJoinName
- [obsolete] - not used anymore. The 'description' text is used as a device join name, if not defined in the particular fingerprint.