1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| temperature: {
cluster: 'msTemperatureMeasurement',
type: ['attributeReport', 'readResponse'],
convert: (model, msg, publish, options, meta) => {
const temperature = parseFloat(msg.data['measuredValue']) / 100.0;
const property = postfixWithEndpointName('temperature', msg, model);
return {[property]: calibrateAndPrecisionRoundOptions(temperature, options, 'temperature')};
},
},
humidity: {
cluster: 'msRelativeHumidity',
type: ['attributeReport', 'readResponse'],
convert: (model, msg, publish, options, meta) => {
const humidity = parseFloat(msg.data['measuredValue']) / 100.0;
// https://github.com/Koenkk/zigbee2mqtt/issues/798
// Sometimes the sensor publishes non-realistic vales, it should only publish message
// in the 0 - 100 range, don't produce messages beyond these values.
if (humidity >&#061; 0 && humidity <&#061; 100) {
return {humidity: calibrateAndPrecisionRoundOptions(humidity, options, &#039;humidity&#039;)};
}
},
},
battery: {
cluster: &#039;genPowerCfg&#039;,
type: [&#039;attributeReport&#039;, &#039;readResponse&#039;],
convert: (model, msg, publish, options, meta) &#061;> {
const payload &#061; {};
if (msg.data.hasOwnProperty(&#039;batteryPercentageRemaining&#039;)) {
// Some devices do not comply to the ZCL and report a
// batteryPercentageRemaining of 100 when the battery is full (should be 200).
const dontDividePercentage &#061; model.meta && model.meta.battery && model.meta.battery.dontDividePercentage;
let percentage &#061; msg.data[&#039;batteryPercentageRemaining&#039;];
percentage &#061; dontDividePercentage ? percentage : percentage / 2;
payload.battery &#061; precisionRound(percentage, 2);
} |