zigbee-herdsman-converters 14.0.363 → 14.0.367

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1690,10 +1690,11 @@ const converters = {
1690
1690
  type: ['commandDataResponse', 'commandDataReport'],
1691
1691
  convert: (model, msg, publish, options, meta) => {
1692
1692
  const multiEndpoint = model.meta && model.meta.multiEndpoint;
1693
- const dp = msg.data.dp;
1694
- const value = tuya.getDataValue(msg.data.datatype, msg.data.data);
1693
+ const dpValue = tuya.firstDpValue(msg, meta, 'moes_105_dimmer');
1694
+ const dp = dpValue.dp;
1695
+ const value = tuya.getDataValue(dpValue);
1695
1696
 
1696
- meta.logger.debug(`from moes_105_dimmer, msg.data.dp=[${dp}], msg.data.datatype=[${msg.data.datatype}], value=[${value}]`);
1697
+ meta.logger.debug(`from moes_105_dimmer, dp=[${dp}], datatype=[${dpValue.datatype}], value=[${value}]`);
1697
1698
 
1698
1699
  const state = value ? 'ON': 'OFF';
1699
1700
  const brightness = mapNumberRange(value, 0, 1000, 0, 254);
@@ -1709,7 +1710,7 @@ const converters = {
1709
1710
  return {brightness_l2: brightness};
1710
1711
  default:
1711
1712
  meta.logger.debug(`zigbee-herdsman-converters:moes_105_dimmer:` +
1712
- `NOT RECOGNIZED DP #${dp} with data ${JSON.stringify(msg.data)}`);
1713
+ `NOT RECOGNIZED DP #${dp} with data ${JSON.stringify(dpValue)}`);
1713
1714
  }
1714
1715
  },
1715
1716
  },
@@ -1785,8 +1786,9 @@ const converters = {
1785
1786
  options: [exposes.options.precision('temperature'), exposes.options.calibration('temperature'),
1786
1787
  exposes.options.precision('humidity'), exposes.options.calibration('humidity')],
1787
1788
  convert: (model, msg, publish, options, meta) => {
1788
- const dp = msg.data.dp;
1789
- const value = tuya.getDataValue(msg.data.datatype, msg.data.data);
1789
+ const dpValue = tuya.firstDpValue(msg, meta, 'tuya_temperature_humidity_sensor');
1790
+ const dp = dpValue.dp;
1791
+ const value = tuya.getDataValue(dpValue);
1790
1792
  switch (dp) {
1791
1793
  case 1:
1792
1794
  return {temperature: calibrateAndPrecisionRoundOptions(value / 10, options, 'temperature')};
@@ -1796,7 +1798,7 @@ const converters = {
1796
1798
  return {battery: value};
1797
1799
  default:
1798
1800
  meta.logger.warn(`zigbee-herdsman-converters:maa_tuya_temp_sensor: NOT RECOGNIZED ` +
1799
- `DP #${dp} with data ${JSON.stringify(msg.data)}`);
1801
+ `DP #${dp} with data ${JSON.stringify(dpValue)}`);
1800
1802
  }
1801
1803
  },
1802
1804
  },
@@ -1806,8 +1808,9 @@ const converters = {
1806
1808
  options: [exposes.options.precision('temperature'), exposes.options.calibration('temperature'),
1807
1809
  exposes.options.precision('humidity'), exposes.options.calibration('humidity')],
1808
1810
  convert: (model, msg, publish, options, meta) => {
1809
- const dp = msg.data.dp;
1810
- const value = tuya.getDataValue(msg.data.datatype, msg.data.data);
1811
+ const dpValue = tuya.firstDpValue(msg, meta, 'nous_lcd_temperature_humidity_sensor');
1812
+ const dp = dpValue.dp;
1813
+ const value = tuya.getDataValue(dpValue);
1811
1814
  switch (dp) {
1812
1815
  case tuya.dataPoints.nousTemperature:
1813
1816
  return {temperature: calibrateAndPrecisionRoundOptions(value / 10, options, 'temperature')};
@@ -1827,7 +1830,7 @@ const converters = {
1827
1830
  return {temperature_sensitivity: calibrateAndPrecisionRoundOptions(value / 10, options, 'temperature')};
1828
1831
  default:
1829
1832
  meta.logger.warn(`zigbee-herdsman-converters:nous_lcd_temperature_humidity_sensor: NOT RECOGNIZED ` +
1830
- `DP #${dp} with data ${JSON.stringify(msg.data)}`);
1833
+ `DP #${dp} with data ${JSON.stringify(dpValue)}`);
1831
1834
  }
1832
1835
  },
1833
1836
  },
@@ -1837,8 +1840,9 @@ const converters = {
1837
1840
  options: [exposes.options.precision('temperature'), exposes.options.calibration('temperature'),
1838
1841
  exposes.options.precision('humidity'), exposes.options.calibration('humidity')],
1839
1842
  convert: (model, msg, publish, options, meta) => {
1840
- const dp = msg.data.dp;
1841
- const value = tuya.getDataValue(msg.data.datatype, msg.data.data);
1843
+ const dpValue = tuya.firstDpValue(msg, meta, 'tuya_illuminance_temperature_humidity_sensor');
1844
+ const dp = dpValue.dp;
1845
+ const value = tuya.getDataValue(dpValue);
1842
1846
  switch (dp) {
1843
1847
  case tuya.dataPoints.thitTemperature:
1844
1848
  return {temperature: calibrateAndPrecisionRoundOptions(value / 10, options, 'temperature')};
@@ -1850,7 +1854,7 @@ const converters = {
1850
1854
  return {illuminance_lux: value};
1851
1855
  default:
1852
1856
  meta.logger.warn(`zigbee-herdsman-converters:tuya_illuminance_temperature_humidity_sensor: NOT RECOGNIZED ` +
1853
- `DP #${dp} with data ${JSON.stringify(msg.data)}`);
1857
+ `DP #${dp} with data ${JSON.stringify(dpValue)}`);
1854
1858
  }
1855
1859
  },
1856
1860
  },
@@ -1887,8 +1891,9 @@ const converters = {
1887
1891
  cluster: 'manuSpecificTuya',
1888
1892
  type: ['commandDataResponse', 'commandDataReport'],
1889
1893
  convert: (model, msg, publish, options, meta) => {
1890
- const dp = msg.data.dp;
1891
- const value = tuya.getDataValue(msg.data.datatype, msg.data.data);
1894
+ const dpValue = tuya.firstDpValue(msg, meta, 'tuya_thermostat_weekly_schedule');
1895
+ const dp = dpValue.dp;
1896
+ const value = tuya.getDataValue(dpValue);
1892
1897
 
1893
1898
  const thermostatMeta = getMetaValue(msg.endpoint, model, 'thermostat');
1894
1899
  const firstDayDpId = thermostatMeta.weeklyScheduleFirstDayDpId;
@@ -1936,8 +1941,9 @@ const converters = {
1936
1941
  cluster: 'manuSpecificTuya',
1937
1942
  type: ['commandDataReport', 'commandDataResponse'],
1938
1943
  convert: (model, msg, publish, options, meta) => {
1939
- const dp = msg.data.dp;
1940
- const value = tuya.getDataValue(msg.data.datatype, msg.data.data);
1944
+ const dpValue = tuya.firstDpValue(msg, meta, 'hy_thermostat');
1945
+ const dp = dpValue.dp;
1946
+ const value = tuya.getDataValue(dpValue);
1941
1947
 
1942
1948
  switch (dp) {
1943
1949
  case tuya.dataPoints.hyWorkdaySchedule1: // schedule for workdays [5,9,12,8,0,15,10,0,15]
@@ -2010,7 +2016,7 @@ const converters = {
2010
2016
  return {alarm: (value > 0) ? true : false};
2011
2017
  default: // The purpose of the codes 17 & 19 are still unknown
2012
2018
  meta.logger.warn(`zigbee-herdsman-converters:hy_thermostat: Unrecognized DP #${
2013
- dp} with data ${JSON.stringify(msg.data)}`);
2019
+ dp} with data ${JSON.stringify(dpValue)}`);
2014
2020
  }
2015
2021
  },
2016
2022
  },
@@ -2070,8 +2076,9 @@ const converters = {
2070
2076
  // Protocol description
2071
2077
  // https://github.com/Koenkk/zigbee-herdsman-converters/issues/1159#issuecomment-614659802
2072
2078
 
2073
- const dp = msg.data.dp;
2074
- const value = tuya.getDataValue(msg.data.datatype, msg.data.data);
2079
+ const dpValue = tuya.firstDpValue(msg, meta, 'tuya_cover');
2080
+ const dp = dpValue.dp;
2081
+ const value = tuya.getDataValue(dpValue);
2075
2082
 
2076
2083
  switch (dp) {
2077
2084
  case tuya.dataPoints.coverPosition: // Started moving to position (triggered from Zigbee)
@@ -2097,7 +2104,7 @@ const converters = {
2097
2104
  break;
2098
2105
  default: // Unknown code
2099
2106
  meta.logger.warn(`TuYa_cover_control: Unhandled DP #${dp} for ${meta.device.manufacturerName}:
2100
- ${JSON.stringify(msg.data)}`);
2107
+ ${JSON.stringify(dpValue)}`);
2101
2108
  }
2102
2109
  },
2103
2110
  },
@@ -2391,8 +2398,9 @@ const converters = {
2391
2398
  options: [exposes.options.precision('temperature'), exposes.options.calibration('temperature'),
2392
2399
  exposes.options.precision('humidity'), exposes.options.calibration('humidity')],
2393
2400
  convert: (model, msg, publish, options, meta) => {
2394
- const dp = msg.data.dp;
2395
- const value = tuya.getDataValue(msg.data.datatype, msg.data.data);
2401
+ const dpValue = tuya.firstDpValue(msg, meta, 'neo_nas_pd07');
2402
+ const dp = dpValue.dp;
2403
+ const value = tuya.getDataValue(dpValue);
2396
2404
 
2397
2405
  if (dp === 101) return {occupancy: value > 0 ? true : false};
2398
2406
  else if (dp === 102) {
@@ -2407,7 +2415,7 @@ const converters = {
2407
2415
  } else if (dp === 105) {
2408
2416
  return {humidity: calibrateAndPrecisionRoundOptions(value, options, 'humidity')};
2409
2417
  } else {
2410
- meta.logger.warn(`zigbee-herdsman-converters:NEO-PD07: NOT RECOGNIZED DP #${dp} with data ${JSON.stringify(msg.data)}`);
2418
+ meta.logger.warn(`zigbee-herdsman-converters:NEO-PD07: NOT RECOGNIZED DP #${dp} with data ${JSON.stringify(dpValue)}`);
2411
2419
  }
2412
2420
  },
2413
2421
  },
@@ -2415,8 +2423,9 @@ const converters = {
2415
2423
  cluster: 'manuSpecificTuya',
2416
2424
  type: ['commandDataReport', 'commandDataResponse'],
2417
2425
  convert: (model, msg, publish, options, meta) => {
2418
- const dp = msg.data.dp;
2419
- const value = tuya.getDataValue(msg.data.datatype, msg.data.data);
2426
+ const dpValue = tuya.firstDpValue(msg, meta, 'neo_t_h_alarm');
2427
+ const dp = dpValue.dp;
2428
+ const value = tuya.getDataValue(dpValue);
2420
2429
 
2421
2430
  switch (dp) {
2422
2431
  case tuya.dataPoints.neoAlarm:
@@ -2453,7 +2462,7 @@ const converters = {
2453
2462
  case tuya.dataPoints.neoVolume: // 0x0474 [0]/[1]/[2] Volume 0-max, 2-low
2454
2463
  return {volume: {2: 'low', 1: 'medium', 0: 'high'}[value]};
2455
2464
  default: // Unknown code
2456
- meta.logger.warn(`Unhandled DP #${dp}: ${JSON.stringify(msg.data)}`);
2465
+ meta.logger.warn(`Unhandled DP #${dp}: ${JSON.stringify(dpValue)}`);
2457
2466
  }
2458
2467
  },
2459
2468
  },
@@ -2560,8 +2569,9 @@ const converters = {
2560
2569
  cluster: 'manuSpecificTuya',
2561
2570
  type: 'commandDataReport',
2562
2571
  convert: (model, msg, publish, options, meta) => {
2563
- if (msg.data.dp === tuya.dataPoints.waterLeak) {
2564
- return {water_leak: tuya.getDataValue(msg.data.datatype, msg.data.data)};
2572
+ const dpValue = tuya.firstDpValue(msg, meta, 'tuya_water_leak');
2573
+ if (dpValue.dp === tuya.dataPoints.waterLeak) {
2574
+ return {water_leak: tuya.getDataValue(dpValue)};
2565
2575
  }
2566
2576
  },
2567
2577
  },
@@ -2924,8 +2934,9 @@ const converters = {
2924
2934
  cluster: 'manuSpecificTuya',
2925
2935
  type: ['commandDataResponse', 'commandDataReport'],
2926
2936
  convert: (model, msg, publish, options, meta) => {
2927
- const dp = msg.data.dp;
2928
- const value = tuya.getDataValue(msg.data.datatype, msg.data.data);
2937
+ const dpValue = tuya.firstDpValue(msg, meta, 'silvercrest_smart_led_string');
2938
+ const dp = dpValue.dp;
2939
+ const value = tuya.getDataValue(dpValue);
2929
2940
  const result = {};
2930
2941
 
2931
2942
  if (dp === tuya.dataPoints.silvercrestChangeMode) {
@@ -3547,8 +3558,9 @@ const converters = {
3547
3558
  cluster: 'manuSpecificTuya',
3548
3559
  type: ['commandDataResponse', 'commandDataReport'],
3549
3560
  convert: (model, msg, publish, options, meta) => {
3550
- const dp = msg.data.dp;
3551
- const value = tuya.getDataValue(msg.data.datatype, msg.data.data);
3561
+ const dpValue = tuya.firstDpValue(msg, meta, 'moes_thermostat');
3562
+ const dp = dpValue.dp;
3563
+ const value = tuya.getDataValue(dpValue);
3552
3564
  let temperature;
3553
3565
  /* See tuyaThermostat above for message structure comment */
3554
3566
  switch (dp) {
@@ -3612,7 +3624,7 @@ const converters = {
3612
3624
  }
3613
3625
  default: // DataPoint 17 is unknown
3614
3626
  meta.logger.warn(`zigbee-herdsman-converters:Moes BHT-002: Unrecognized DP #${
3615
- dp} with data ${JSON.stringify(msg.data)}`);
3627
+ dp} with data ${JSON.stringify(dpValue)}`);
3616
3628
  }
3617
3629
  },
3618
3630
  },
@@ -3620,8 +3632,9 @@ const converters = {
3620
3632
  cluster: 'manuSpecificTuya',
3621
3633
  type: ['commandDataResponse', 'commandDataReport'],
3622
3634
  convert: (model, msg, publish, options, meta) => {
3623
- const dp = msg.data.dp; // First we get the data point ID
3624
- const value = tuya.getDataValue(msg.data.datatype, msg.data.data);
3635
+ const dpValue = tuya.firstDpValue(msg, meta, 'moesS_thermostat');
3636
+ const dp = dpValue.dp; // First we get the data point ID
3637
+ const value = tuya.getDataValue(dpValue);
3625
3638
  const presetLookup = {0: 'programming', 1: 'manual', 2: 'temporary_manual', 3: 'holiday'};
3626
3639
  switch (dp) {
3627
3640
  case tuya.dataPoints.moesSsystemMode:
@@ -3672,7 +3685,7 @@ const converters = {
3672
3685
  }
3673
3686
  default:
3674
3687
  meta.logger.warn(`zigbee-herdsman-converters:moesS_thermostat: NOT RECOGNIZED DP #${
3675
- dp} with data ${JSON.stringify(msg.data)}`);
3688
+ dp} with data ${JSON.stringify(dpValue)}`);
3676
3689
  }
3677
3690
  },
3678
3691
  },
@@ -3680,8 +3693,9 @@ const converters = {
3680
3693
  cluster: 'manuSpecificTuya',
3681
3694
  type: ['commandDataResponse', 'commandDataReport'],
3682
3695
  convert: (model, msg, publish, options, meta) => {
3683
- const dp = msg.data.dp;
3684
- const value = tuya.getDataValue(msg.data.datatype, msg.data.data);
3696
+ const dpValue = tuya.firstDpValue(msg, meta, 'tvtwo_thermostat');
3697
+ const dp = dpValue.dp;
3698
+ const value = tuya.getDataValue(dpValue);
3685
3699
  const presetLookup = {0: 'auto', 1: 'manual', 2: 'holiday'};
3686
3700
  switch (dp) {
3687
3701
  case tuya.dataPoints.tvMode:
@@ -3823,7 +3837,7 @@ const converters = {
3823
3837
 
3824
3838
  default:
3825
3839
  meta.logger.warn(`zigbee-herdsman-converters:tvtwo_thermostat: NOT RECOGNIZED DP #${
3826
- dp} with data ${JSON.stringify(msg.data)}`);
3840
+ dp} with data ${JSON.stringify(dpValue)}`);
3827
3841
  }
3828
3842
  },
3829
3843
  },
@@ -3831,8 +3845,9 @@ const converters = {
3831
3845
  cluster: 'manuSpecificTuya',
3832
3846
  type: ['commandDataResponse', 'commandDataReport'],
3833
3847
  convert: (model, msg, publish, options, meta) => {
3834
- const dp = msg.data.dp; // First we get the data point ID
3835
- const value = tuya.getDataValue(msg.data.datatype, msg.data.data);
3848
+ const dpValue = tuya.firstDpValue(msg, meta, 'haozee_thermostat');
3849
+ const dp = dpValue.dp; // First we get the data point ID
3850
+ const value = tuya.getDataValue(dpValue);
3836
3851
  const presetLookup = {0: 'auto', 1: 'manual', 2: 'off', 3: 'on'};
3837
3852
  switch (dp) {
3838
3853
  case tuya.dataPoints.haozeeSystemMode:
@@ -3938,7 +3953,7 @@ const converters = {
3938
3953
  break;
3939
3954
  default:
3940
3955
  meta.logger.warn(`zigbee-herdsman-converters:haozee: NOT RECOGNIZED DP #${
3941
- dp} with data ${JSON.stringify(msg.data)}`);
3956
+ dp} with data ${JSON.stringify(dpValue)}`);
3942
3957
  }
3943
3958
  },
3944
3959
  },
@@ -3951,8 +3966,9 @@ const converters = {
3951
3966
  exposes.options.precision('voc'), exposes.options.calibration('voc'),
3952
3967
  exposes.options.precision('formaldehyd'), exposes.options.calibration('formaldehyd')],
3953
3968
  convert: (model, msg, publish, options, meta) => {
3954
- const dp = msg.data.dp;
3955
- const value = tuya.getDataValue(msg.data.datatype, msg.data.data);
3969
+ const dpValue = tuya.firstDpValue(msg, meta, 'tuya_air_quality');
3970
+ const dp = dpValue.dp;
3971
+ const value = tuya.getDataValue(dpValue);
3956
3972
  switch (dp) {
3957
3973
  case tuya.dataPoints.tuyaSabTemp:
3958
3974
  return {temperature: calibrateAndPrecisionRoundOptions(value / 10, options, 'temperature')};
@@ -3967,7 +3983,7 @@ const converters = {
3967
3983
  return {formaldehyd: calibrateAndPrecisionRoundOptions(value, options, 'formaldehyd')};
3968
3984
  default:
3969
3985
  meta.logger.warn(`zigbee-herdsman-converters:TuyaSmartAirBox: Unrecognized DP #${
3970
- dp} with data ${JSON.stringify(msg.data)}`);
3986
+ dp} with data ${JSON.stringify(dpValue)}`);
3971
3987
  }
3972
3988
  },
3973
3989
  },
@@ -3975,10 +3991,14 @@ const converters = {
3975
3991
  cluster: 'manuSpecificTuya',
3976
3992
  type: ['commandDataResponse', 'commandDataReport'],
3977
3993
  convert: (model, msg, publish, options, meta) => {
3978
- const dp = msg.data.dp;
3979
- const value = tuya.getDataValue(msg.data.datatype, msg.data.data);
3994
+ const dpValue = tuya.firstDpValue(msg, meta, 'saswell_thermostat');
3995
+ const dp = dpValue.dp;
3996
+ const value = tuya.getDataValue(dpValue);
3980
3997
 
3981
3998
  switch (dp) {
3999
+ case tuya.dataPoints.saswellHeating:
4000
+ // heating status 1 - heating
4001
+ return {'heating': value ? 'ON' : 'OFF'};
3982
4002
  case tuya.dataPoints.saswellWindowDetection:
3983
4003
  return {window_detection: value ? 'ON' : 'OFF'};
3984
4004
  case tuya.dataPoints.saswellFrostDetection:
@@ -4088,7 +4108,7 @@ const converters = {
4088
4108
  return {anti_scaling: value ? 'ON' : 'OFF'};
4089
4109
  default:
4090
4110
  meta.logger.warn(`zigbee-herdsman-converters:SaswellThermostat: Unrecognized DP #${
4091
- dp} with data ${JSON.stringify(msg.data)}`);
4111
+ dp} with data ${JSON.stringify(dpValue)}`);
4092
4112
  }
4093
4113
  },
4094
4114
  },
@@ -4096,8 +4116,9 @@ const converters = {
4096
4116
  cluster: 'manuSpecificTuya',
4097
4117
  type: ['commandDataResponse', 'commandDataReport'],
4098
4118
  convert: (model, msg, publish, options, meta) => {
4099
- const dp = msg.data.dp;
4100
- const value = tuya.getDataValue(msg.data.datatype, msg.data.data);
4119
+ const dpValue = tuya.firstDpValue(msg, meta, 'etop_thermostat');
4120
+ const dp = dpValue.dp;
4121
+ const value = tuya.getDataValue(dpValue);
4101
4122
 
4102
4123
  if (dp >= 101 && dp <=107) return; // handled by tuya_thermostat_weekly_schedule
4103
4124
 
@@ -4137,7 +4158,7 @@ const converters = {
4137
4158
  return {running_state: value ? 'heat' : 'idle'};
4138
4159
  default:
4139
4160
  meta.logger.warn(`zigbee-herdsman-converters:eTopThermostat: Unrecognized DP #${
4140
- dp} with data ${JSON.stringify(msg.data)}`);
4161
+ dp} with data ${JSON.stringify(dpValue)}`);
4141
4162
  }
4142
4163
  },
4143
4164
  },
@@ -4145,8 +4166,9 @@ const converters = {
4145
4166
  cluster: 'manuSpecificTuya',
4146
4167
  type: ['commandDataResponse', 'commandDataReport'],
4147
4168
  convert: (model, msg, publish, options, meta) => {
4148
- const dp = msg.data.dp;
4149
- const value = tuya.getDataValue(msg.data.datatype, msg.data.data);
4169
+ const dpValue = tuya.firstDpValue(msg, meta, 'tuya_thermostat');
4170
+ const dp = dpValue.dp;
4171
+ const value = tuya.getDataValue(dpValue);
4150
4172
 
4151
4173
  switch (dp) {
4152
4174
  case tuya.dataPoints.windowDetection:
@@ -4243,7 +4265,7 @@ const converters = {
4243
4265
  return {week: tuya.thermostatWeekFormat[value]};
4244
4266
  default: // The purpose of the dps 17 & 19 is still unknown
4245
4267
  console.log(`zigbee-herdsman-converters:tuyaThermostat: Unrecognized DP #${
4246
- dp} with data ${JSON.stringify(msg.data)}`);
4268
+ dp} with data ${JSON.stringify(dpValue)}`);
4247
4269
  }
4248
4270
  },
4249
4271
  },
@@ -4251,12 +4273,13 @@ const converters = {
4251
4273
  cluster: 'manuSpecificTuya',
4252
4274
  type: ['commandDataResponse', 'commandDataReport'],
4253
4275
  convert: (model, msg, publish, options, meta) => {
4254
- const value = tuya.getDataValue(msg.data.datatype, msg.data.data);
4255
- if (msg.data.dp === tuya.dataPoints.state) {
4276
+ const dpValue = tuya.firstDpValue(msg, meta, 'tuya_dimmer');
4277
+ const value = tuya.getDataValue(dpValue);
4278
+ if (dpValue.dp === tuya.dataPoints.state) {
4256
4279
  return {state: value ? 'ON': 'OFF'};
4257
4280
  } else if (meta.device.manufacturerName === '_TZE200_swaamsoy') {
4258
4281
  // https://github.com/Koenkk/zigbee-herdsman-converters/pull/3004
4259
- if (msg.data.dp === 2) {
4282
+ if (dpValue.dp === 2) {
4260
4283
  return {brightness: mapNumberRange(value, 10, 1000, 0, 254)};
4261
4284
  }
4262
4285
  } else { // TODO: Unknown dp, assumed value type
@@ -4277,18 +4300,22 @@ const converters = {
4277
4300
  }
4278
4301
  return hex;
4279
4302
  };
4280
- let dataStr =
4281
- Date.now().toString() + ' ' +
4282
- meta.device.ieeeAddr + ' ' +
4283
- getHex(msg.data.seq) + ' ' +
4284
- getHex(msg.data.dp) + ' ' +
4285
- getHex(msg.data.datatype) + ' ' +
4286
- getHex(msg.data.fn);
4287
-
4288
- msg.data.data.forEach((elem) => {
4289
- dataStr += ' ' + getHex(elem);
4290
- });
4291
- dataStr += '\n';
4303
+ const now = Date.now().toString();
4304
+ let dataStr = '';
4305
+ for (const [i, dpValue] of msg.data.dpValues.entries()) {
4306
+ dataStr +=
4307
+ now + ' ' +
4308
+ meta.device.ieeeAddr + ' ' +
4309
+ getHex(msg.data.seq) + ' ' +
4310
+ getHex(i) + ' ' +
4311
+ getHex(dpValue.dp) + ' ' +
4312
+ getHex(dpValue.datatype);
4313
+
4314
+ dpValue.data.forEach((elem) => {
4315
+ dataStr += ' ' + getHex(elem);
4316
+ });
4317
+ dataStr += '\n';
4318
+ }
4292
4319
  const fs = require('fs');
4293
4320
  fs.appendFile('data/tuya.dump.txt', dataStr, (err) => {
4294
4321
  if (err) throw err;
@@ -4333,7 +4360,8 @@ const converters = {
4333
4360
  cluster: 'manuSpecificTuya',
4334
4361
  type: 'commandDataResponse',
4335
4362
  convert: (model, msg, publish, options, meta) => {
4336
- msg.data.occupancy = msg.data.dp === tuya.dataPoints.occupancy ? 1 : 0;
4363
+ const dpValue = tuya.firstDpValue(msg, meta, 'blitzwolf_occupancy_with_timeout');
4364
+ msg.data.occupancy = dpValue.dp === tuya.dataPoints.occupancy ? 1 : 0;
4337
4365
  return converters.occupancy_with_timeout.convert(model, msg, publish, options, meta);
4338
4366
  },
4339
4367
  },
@@ -4630,8 +4658,9 @@ const converters = {
4630
4658
  cluster: 'manuSpecificTuya',
4631
4659
  type: ['commandDataResponse', 'commandDataReport', 'commandActiveStatusReport'],
4632
4660
  convert: (model, msg, publish, options, meta) => {
4633
- const value = tuya.getDataValue(msg.data.datatype, msg.data.data);
4634
- const dp = msg.data.dp;
4661
+ const dpValue = tuya.firstDpValue(msg, meta, 'frankever_valve');
4662
+ const value = tuya.getDataValue(dpValue);
4663
+ const dp = dpValue.dp;
4635
4664
  switch (dp) {
4636
4665
  case tuya.dataPoints.state: {
4637
4666
  return {state: value ? 'ON': 'OFF'};
@@ -4644,7 +4673,7 @@ const converters = {
4644
4673
  }
4645
4674
  default: {
4646
4675
  meta.logger.warn(`zigbee-herdsman-converters:FrankeverValve: NOT RECOGNIZED DP ` +
4647
- `#${dp} with data ${JSON.stringify(msg.data)}`);
4676
+ `#${dp} with data ${JSON.stringify(dpValue)}`);
4648
4677
  }
4649
4678
  }
4650
4679
  },
@@ -4653,13 +4682,14 @@ const converters = {
4653
4682
  cluster: 'manuSpecificTuya',
4654
4683
  type: ['commandDataResponse'],
4655
4684
  convert: (model, msg, publish, options, meta) => {
4656
- const dp = msg.data.dp;
4657
- const value = tuya.getDataValue(msg.data.datatype, msg.data.data);
4685
+ const dpValue = tuya.firstDpValue(msg, meta, 'tuya_smoke');
4686
+ const dp = dpValue.dp;
4687
+ const value = tuya.getDataValue(dpValue);
4658
4688
  switch (dp) {
4659
4689
  case tuya.dataPoints.state:
4660
4690
  return {smoke: value === 0};
4661
4691
  default:
4662
- meta.logger.warn(`zigbee-herdsman-converters:tuya_smoke: Unrecognized DP #${ dp} with data ${JSON.stringify(msg.data)}`);
4692
+ meta.logger.warn(`zigbee-herdsman-converters:tuya_smoke: Unrecognized DP #${ dp} with data ${JSON.stringify(dpValue)}`);
4663
4693
  }
4664
4694
  },
4665
4695
  },
@@ -4667,8 +4697,9 @@ const converters = {
4667
4697
  cluster: 'manuSpecificTuya',
4668
4698
  type: ['commandDataResponse'],
4669
4699
  convert: (model, msg, publish, options, meta) => {
4670
- const dp = msg.data.dp;
4671
- const value = tuya.getDataValue(msg.data.datatype, msg.data.data);
4700
+ const dpValue = tuya.firstDpValue(msg, meta, 'tuya_woox_smoke');
4701
+ const dp = dpValue.dp;
4702
+ const value = tuya.getDataValue(dpValue);
4672
4703
  switch (dp) {
4673
4704
  case tuya.dataPoints.wooxBattery:
4674
4705
  return {battery_low: value === 0};
@@ -4677,7 +4708,7 @@ const converters = {
4677
4708
  case tuya.dataPoints.wooxSmokeTest:
4678
4709
  return {smoke: value};
4679
4710
  default:
4680
- meta.logger.warn(`zigbee-herdsman-converters:tuya_smoke: Unrecognized DP #${ dp} with data ${JSON.stringify(msg.data)}`);
4711
+ meta.logger.warn(`zigbee-herdsman-converters:tuya_smoke: Unrecognized DP #${ dp} with data ${JSON.stringify(dpValue)}`);
4681
4712
  }
4682
4713
  },
4683
4714
  },
@@ -4686,8 +4717,9 @@ const converters = {
4686
4717
  type: ['commandDataReport', 'commandDataResponse', 'commandActiveStatusReport'],
4687
4718
  convert: (model, msg, publish, options, meta) => {
4688
4719
  const multiEndpoint = model.meta && model.meta.multiEndpoint;
4689
- const dp = msg.data.dp;
4690
- const value = tuya.getDataValue(msg.data.datatype, msg.data.data);
4720
+ const dpValue = tuya.firstDpValue(msg, meta, 'tuya_switch');
4721
+ const dp = dpValue.dp;
4722
+ const value = tuya.getDataValue(dpValue);
4691
4723
  const state = value ? 'ON' : 'OFF';
4692
4724
  if (multiEndpoint) {
4693
4725
  const lookup = {1: 'l1', 2: 'l2', 3: 'l3', 4: 'l4'};
@@ -4705,8 +4737,9 @@ const converters = {
4705
4737
  cluster: 'manuSpecificTuya',
4706
4738
  type: ['commandDataReport', 'commandDataResponse', 'commandActiveStatusReport'],
4707
4739
  convert: (model, msg, publish, options, meta) => {
4708
- const dp = msg.data.dp;
4709
- const value = tuya.getDataValue(msg.data.datatype, msg.data.data);
4740
+ const dpValue = tuya.firstDpValue(msg, meta, 'tuya_dinrail_switch');
4741
+ const dp = dpValue.dp;
4742
+ const value = tuya.getDataValue(dpValue);
4710
4743
  const state = value ? 'ON' : 'OFF';
4711
4744
 
4712
4745
  switch (dp) {
@@ -4722,7 +4755,7 @@ const converters = {
4722
4755
  return {voltage: value/10};
4723
4756
  default:
4724
4757
  meta.logger.warn(`zigbee-herdsman-converters:TuyaDinRailSwitch: NOT RECOGNIZED DP ` +
4725
- `#${dp} with data ${JSON.stringify(msg.data)}`);
4758
+ `#${dp} with data ${JSON.stringify(dpValue)}`);
4726
4759
  }
4727
4760
 
4728
4761
  return null;
@@ -4982,6 +5015,11 @@ const converters = {
4982
5015
  value = data.readUInt16LE(i+2);
4983
5016
  i += 3;
4984
5017
  break;
5018
+ case 34:
5019
+ // 0x22 Zcl24BitUint
5020
+ value = data.readUIntLE(i+2, 3);
5021
+ i += 4;
5022
+ break;
4985
5023
  case 35:
4986
5024
  // 0x23 Zcl32BitUint
4987
5025
  value = data.readUInt32LE(i+2);
@@ -4989,9 +5027,19 @@ const converters = {
4989
5027
  break;
4990
5028
  case 36:
4991
5029
  // 0x24 Zcl40BitUint
4992
- value = [data.readUInt32LE(i+2), data.readUInt8(i+6)];
5030
+ value = data.readUIntLE(i+2, 5);
4993
5031
  i += 6;
4994
5032
  break;
5033
+ case 37:
5034
+ // 0x25 Zcl48BitUint
5035
+ value = data.readUIntLE(i+2, 6);
5036
+ i += 7;
5037
+ break;
5038
+ case 38:
5039
+ // 0x26 Zcl56BitUint
5040
+ value = data.readUIntLE(i+2, 7);
5041
+ i += 8;
5042
+ break;
4995
5043
  case 39:
4996
5044
  // 0x27 Zcl64BitUint
4997
5045
  value = data.readBigUInt64BE(i+2);
@@ -5007,11 +5055,31 @@ const converters = {
5007
5055
  value = data.readInt16LE(i+2);
5008
5056
  i += 3;
5009
5057
  break;
5058
+ case 42:
5059
+ // 0x2A Zcl24BitInt
5060
+ value = data.readIntLE(i+2, 3);
5061
+ i += 4;
5062
+ break;
5010
5063
  case 43:
5011
5064
  // 0x2B Zcl32BitInt
5012
5065
  value = data.readInt32LE(i+2);
5013
5066
  i += 5;
5014
5067
  break;
5068
+ case 44:
5069
+ // 0x2C Zcl40BitInt
5070
+ value = data.readIntLE(i+2, 5);
5071
+ i += 6;
5072
+ break;
5073
+ case 45:
5074
+ // 0x2D Zcl48BitInt
5075
+ value = data.readIntLE(i+2, 6);
5076
+ i += 7;
5077
+ break;
5078
+ case 46:
5079
+ // 0x2E Zcl56BitInt
5080
+ value = data.readIntLE(i+2, 7);
5081
+ i += 8;
5082
+ break;
5015
5083
  case 47:
5016
5084
  // 0x2F Zcl64BitInt
5017
5085
  value = data.readBigInt64BE(i+2);
@@ -6069,8 +6137,9 @@ const converters = {
6069
6137
  cluster: 'manuSpecificTuya',
6070
6138
  type: ['commandDataReport', 'commandDataResponse'],
6071
6139
  convert: (model, msg, publish, options, meta) => {
6072
- const dp = msg.data.dp;
6073
- const value = tuya.getDataValue(msg.data.datatype, msg.data.data);
6140
+ const dpValue = tuya.firstDpValue(msg, meta, 'javis_microwave_sensor');
6141
+ const dp = dpValue.dp;
6142
+ const value = tuya.getDataValue(dpValue);
6074
6143
  const lookup = {
6075
6144
  0: 'no_motion',
6076
6145
  1: 'big_motion',
@@ -6132,7 +6201,7 @@ const converters = {
6132
6201
  }
6133
6202
  default:
6134
6203
  meta.logger.warn(`zigbee-herdsman-converters:javis_microwave_sensor: NOT RECOGNIZED ` +
6135
- `DP #${dp} with data ${JSON.stringify(msg.data)}`);
6204
+ `DP #${dp} with data ${JSON.stringify(dpValue)}`);
6136
6205
  }
6137
6206
  },
6138
6207
  },
@@ -6276,8 +6345,9 @@ const converters = {
6276
6345
  cluster: 'manuSpecificTuya',
6277
6346
  type: 'commandDataResponse',
6278
6347
  convert: (model, msg, publish, options, meta) => {
6279
- const value = tuya.getDataValue(msg.data.datatype, msg.data.data);
6280
- const dp = msg.data.dp;
6348
+ const dpValue = tuya.firstDpValue(msg, meta, 'ZVG1');
6349
+ const value = tuya.getDataValue(dpValue);
6350
+ const dp = dpValue.dp;
6281
6351
  switch (dp) {
6282
6352
  case tuya.dataPoints.state: {
6283
6353
  return {state: value ? 'ON': 'OFF'};
@@ -6304,7 +6374,7 @@ const converters = {
6304
6374
  }
6305
6375
  default: {
6306
6376
  meta.logger.warn(`zigbee-herdsman-converters:RTXZVG1Valve: NOT RECOGNIZED DP ` +
6307
- `#${dp} with data ${JSON.stringify(msg.data)}`);
6377
+ `#${dp} with data ${JSON.stringify(dpValue)}`);
6308
6378
  }
6309
6379
  }
6310
6380
  },
@@ -6840,8 +6910,9 @@ const converters = {
6840
6910
  cluster: 'manuSpecificTuya',
6841
6911
  type: ['commandDataResponse', 'commandDataReport'],
6842
6912
  convert: (model, msg, publish, options, meta) => {
6843
- const dp = msg.data.dp;
6844
- const value = tuya.getDataValue(msg.data.datatype, msg.data.data);
6913
+ const dpValue = tuya.firstDpValue(msg, meta, 'SLUXZB');
6914
+ const dp = dpValue.dp;
6915
+ const value = tuya.getDataValue(dpValue);
6845
6916
  switch (dp) {
6846
6917
  case 2:
6847
6918
  return {illuminance_lux: value.toFixed(0)};
@@ -6850,7 +6921,7 @@ const converters = {
6850
6921
  case 1:
6851
6922
  return {battery_low: value.toFixed(1)};
6852
6923
  default:
6853
- meta.logger.warn(`s_lux_zb_illuminance: NOT RECOGNIZED DP #${dp} with data ${JSON.stringify(msg.data)}`);
6924
+ meta.logger.warn(`s_lux_zb_illuminance: NOT RECOGNIZED DP #${dp} with data ${JSON.stringify(dpValue)}`);
6854
6925
  }
6855
6926
  },
6856
6927
  },
@@ -6860,8 +6931,9 @@ const converters = {
6860
6931
  options: [exposes.options.precision('temperature'), exposes.options.calibration('temperature'),
6861
6932
  exposes.options.precision('humidity'), exposes.options.calibration('humidity')],
6862
6933
  convert: (model, msg, publish, options, meta) => {
6863
- const dp = msg.data.dp;
6864
- const value = tuya.getDataValue(msg.data.datatype, msg.data.data);
6934
+ const dpValue = tuya.firstDpValue(msg, meta, 'ZB003X');
6935
+ const dp = dpValue.dp;
6936
+ const value = tuya.getDataValue(dpValue);
6865
6937
 
6866
6938
  switch (dp) {
6867
6939
  case tuya.dataPoints.fantemTemp:
@@ -6890,7 +6962,7 @@ const converters = {
6890
6962
  return {reporting_enable: value};
6891
6963
  default:
6892
6964
  meta.logger.warn(`zigbee-herdsman-converters:FantemZB003X: Unrecognized DP #${
6893
- dp} with data ${JSON.stringify(msg.data)}`);
6965
+ dp} with data ${JSON.stringify(dpValue)}`);
6894
6966
  }
6895
6967
  },
6896
6968
  },
@@ -6923,15 +6995,16 @@ const converters = {
6923
6995
  cluster: 'manuSpecificTuya',
6924
6996
  type: ['commandDataResponse'],
6925
6997
  convert: (model, msg, publish, options, meta) => {
6926
- const dp = msg.data.dp;
6927
- const value = tuya.getDataValue(msg.data.datatype, msg.data.data);
6998
+ const dpValue = tuya.firstDpValue(msg, meta, 'tuya_gas');
6999
+ const dp = dpValue.dp;
7000
+ const value = tuya.getDataValue(dpValue);
6928
7001
 
6929
7002
  switch (dp) {
6930
7003
  case tuya.dataPoints.state:
6931
7004
  return {gas: value === 0 ? true : false};
6932
7005
  default:
6933
7006
  meta.logger.warn(`zigbee-herdsman-converters:tuya_gas: Unrecognized DP #${
6934
- dp} with data ${JSON.stringify(msg.data)}`);
7007
+ dp} with data ${JSON.stringify(dpValue)}`);
6935
7008
  }
6936
7009
  },
6937
7010
  },
@@ -6939,15 +7012,16 @@ const converters = {
6939
7012
  cluster: 'manuSpecificTuya',
6940
7013
  type: ['commandActiveStatusReport'],
6941
7014
  convert: (model, msg, publish, options, meta) => {
6942
- const dp = msg.data.dp;
6943
- const value = tuya.getDataValue(msg.data.datatype, msg.data.data);
7015
+ const dpValue = tuya.firstDpValue(msg, meta, 'woox_R7060');
7016
+ const dp = dpValue.dp;
7017
+ const value = tuya.getDataValue(dpValue);
6944
7018
 
6945
7019
  switch (dp) {
6946
7020
  case tuya.dataPoints.wooxSwitch:
6947
7021
  return {state: value === 2 ? 'OFF' : 'ON'};
6948
7022
  default:
6949
7023
  meta.logger.warn(`zigbee-herdsman-converters:WooxR7060: Unrecognized DP #${
6950
- dp} with data ${JSON.stringify(msg.data)}`);
7024
+ dp} with data ${JSON.stringify(dpValue)}`);
6951
7025
  }
6952
7026
  },
6953
7027
  },
@@ -7293,8 +7367,9 @@ const converters = {
7293
7367
  cluster: 'manuSpecificTuya',
7294
7368
  type: ['commandDataResponse'],
7295
7369
  convert: (model, msg, publish, options, meta) => {
7296
- const dp = msg.data.dp;
7297
- const value = tuya.getDataValue(msg.data.datatype, msg.data.data);
7370
+ const dpValue = tuya.firstDpValue(msg, meta, 'tuya_motion_sensor');
7371
+ const dp = dpValue.dp;
7372
+ const value = tuya.getDataValue(dpValue);
7298
7373
  let result = null;
7299
7374
  switch (dp) {
7300
7375
  case tuya.dataPoints.state:
@@ -7331,7 +7406,7 @@ const converters = {
7331
7406
  result = {luminance_level: value};
7332
7407
  break;
7333
7408
  default:
7334
- meta.logger.warn(`fromZigbee.tuya_motion_sensor: NOT RECOGNIZED DP ${dp} with data ${JSON.stringify(msg.data)}`);
7409
+ meta.logger.warn(`fromZigbee.tuya_motion_sensor: NOT RECOGNIZED DP ${dp} with data ${JSON.stringify(dpValue)}`);
7335
7410
  }
7336
7411
 
7337
7412
  return result;
@@ -7341,8 +7416,9 @@ const converters = {
7341
7416
  cluster: 'manuSpecificTuya',
7342
7417
  type: ['commandDataResponse', 'commandDataReport'],
7343
7418
  convert: (model, msg, publish, options, meta) => {
7344
- const dp = msg.data.dp;
7345
- const value = tuya.getDataValue(msg.data.datatype, msg.data.data);
7419
+ const dpValue = tuya.firstDpValue(msg, meta, 'tuya_radar_sensor');
7420
+ const dp = dpValue.dp;
7421
+ const value = tuya.getDataValue(dpValue);
7346
7422
  switch (dp) {
7347
7423
  case tuya.dataPoints.trsPresenceState:
7348
7424
  return {presence: {0: false, 1: true}[value]};
@@ -7365,8 +7441,9 @@ const converters = {
7365
7441
  cluster: 'manuSpecificTuya',
7366
7442
  type: ['commandDataResponse', 'commandDataReport', 'raw'],
7367
7443
  convert: (model, msg, publish, options, meta) => {
7368
- const dp = msg.data.dp;
7369
- let value = tuya.getDataValue(msg.data.datatype, msg.data.data);
7444
+ const dpValue = tuya.firstDpValue(msg, meta, 'moes_thermostat_tv');
7445
+ const dp = dpValue.dp;
7446
+ let value = tuya.getDataValue(dpValue);
7370
7447
  let result = null;
7371
7448
  switch (dp) {
7372
7449
  case tuya.dataPoints.tvMode:
@@ -7440,7 +7517,7 @@ const converters = {
7440
7517
  }
7441
7518
  break;
7442
7519
  default:
7443
- meta.logger.warn(`fromZigbee.moes_thermostat_tv: NOT RECOGNIZED DP ${dp} with data ${JSON.stringify(msg.data)}`);
7520
+ meta.logger.warn(`fromZigbee.moes_thermostat_tv: NOT RECOGNIZED DP ${dp} with data ${JSON.stringify(dpValue)}`);
7444
7521
  }
7445
7522
 
7446
7523
  return result;
@@ -7474,10 +7551,11 @@ const converters = {
7474
7551
  cluster: 'manuSpecificTuya',
7475
7552
  type: ['commandDataResponse', 'commandDataReport'],
7476
7553
  convert: (model, msg, publish, options, meta) => {
7477
- const dp = msg.data.dp;
7478
- const value = tuya.getDataValue(msg.data.datatype, msg.data.data);
7554
+ const dpValue = tuya.firstDpValue(msg, meta, 'hoch_din');
7555
+ const dp = dpValue.dp;
7556
+ const value = tuya.getDataValue(dpValue);
7479
7557
  const result = {};
7480
- meta.logger.debug(`from hoch_din, msg.data.dp=[${dp}], msg.data.datatype=[${msg.data.datatype}], value=[${value}]`);
7558
+ meta.logger.debug(`from hoch_din, dp=[${dp}], datatype=[${dpValue.datatype}], value=[${value}]`);
7481
7559
 
7482
7560
  if (dp === tuya.dataPoints.state) {
7483
7561
  result.state = value ? 'ON' : 'OFF';