zigbee-herdsman-converters 14.0.392 → 14.0.393

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.
@@ -699,6 +699,8 @@ const converters = {
699
699
  */
700
700
  cluster: 'haElectricalMeasurement',
701
701
  type: ['attributeReport', 'readResponse'],
702
+ options: [exposes.options.calibration('power', 'percentual'), exposes.options.calibration('current', 'percentual'),
703
+ exposes.options.calibration('voltage', 'percentual')],
702
704
  convert: (model, msg, publish, options, meta) => {
703
705
  const getFactor = (key) => {
704
706
  const multiplier = msg.endpoint.getClusterAttributeValue('haElectricalMeasurement', `${key}Multiplier`);
@@ -724,7 +726,8 @@ const converters = {
724
726
  if (msg.data.hasOwnProperty(entry.key)) {
725
727
  const factor = getFactor(entry.factor);
726
728
  const property = postfixWithEndpointName(entry.name, msg, model);
727
- payload[property] = precisionRound(msg.data[entry.key] * factor, 2);
729
+ const value = msg.data[entry.key] * factor;
730
+ payload[property] = calibrateAndPrecisionRoundOptions(value, options, entry.name);
728
731
  }
729
732
  }
730
733
  return payload;
@@ -2502,8 +2505,9 @@ const converters = {
2502
2505
  cluster: 'manuSpecificTuya',
2503
2506
  type: ['commandDataReport', 'commandDataResponse'],
2504
2507
  convert: (model, msg, publish, options, meta) => {
2505
- const dp = msg.data.dp;
2506
- const value = tuya.getDataValue(msg.data.datatype, msg.data.data);
2508
+ const dpValue = tuya.firstDpValue(msg, meta, 'neo_alarm');
2509
+ const dp = dpValue.dp;
2510
+ const value = tuya.getDataValue(dpValue);
2507
2511
 
2508
2512
  switch (dp) {
2509
2513
  case tuya.dataPoints.neoAOAlarm: // 0x13 [TRUE,FALSE]
package/lib/utils.js CHANGED
@@ -72,12 +72,12 @@ function hasAlreadyProcessedMessage(msg, ID=null, key=null) {
72
72
  return false;
73
73
  }
74
74
 
75
- const defaultPrecision = {temperature: 2, humidity: 2, pressure: 1, pm25: 0};
75
+ const defaultPrecision = {temperature: 2, humidity: 2, pressure: 1, pm25: 0, power: 2, voltage: 2, current: 2};
76
76
  function calibrateAndPrecisionRoundOptions(number, options, type) {
77
77
  // Calibrate
78
78
  const calibrateKey = `${type}_calibration`;
79
79
  let calibrationOffset = options && options.hasOwnProperty(calibrateKey) ? options[calibrateKey] : 0;
80
- if (type == 'illuminance' || type === 'illuminance_lux') {
80
+ if (['illuminance', 'illuminance_lux', 'power', 'current', 'voltage'].includes(type)) {
81
81
  // linear calibration because measured value is zero based
82
82
  // +/- percent
83
83
  calibrationOffset = Math.round(number * calibrationOffset / 100);
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zigbee-herdsman-converters",
3
- "version": "14.0.392",
3
+ "version": "14.0.393",
4
4
  "lockfileVersion": 1,
5
5
  "requires": true,
6
6
  "dependencies": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zigbee-herdsman-converters",
3
- "version": "14.0.392",
3
+ "version": "14.0.393",
4
4
  "description": "Collection of device converters to be used with zigbee-herdsman",
5
5
  "main": "index.js",
6
6
  "files": [