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.
- package/converters/fromZigbee.js +7 -3
- package/lib/utils.js +2 -2
- package/npm-shrinkwrap.json +1 -1
- package/package.json +1 -1
package/converters/fromZigbee.js
CHANGED
|
@@ -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
|
-
|
|
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
|
|
2506
|
-
const
|
|
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 (
|
|
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);
|
package/npm-shrinkwrap.json
CHANGED