Skip to content

Commit

Permalink
Don't add invalid values to the result
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasbedrich committed Jun 20, 2023
1 parent ad5ceb7 commit cac6aa3
Showing 1 changed file with 30 additions and 20 deletions.
50 changes: 30 additions & 20 deletions src/converters/fromZigbee.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,26 +43,29 @@ const converters = {
const dontMapPIHeatingDemand = model.meta && model.meta.thermostat && model.meta.thermostat.dontMapPIHeatingDemand;
if (msg.data.hasOwnProperty('localTemp')) {
let value = precisionRound(msg.data['localTemp'], 2) / 100;

Check failure on line 45 in src/converters/fromZigbee.js

View workflow job for this annotation

GitHub Actions / ci

'value' is never reassigned. Use 'const' instead
value = value < -273.15 ? null : value;
result[postfixWithEndpointName('local_temperature', msg, model, meta)] = value;
if (value >= -273.15) {
result[postfixWithEndpointName('local_temperature', msg, model, meta)] = value;
}
}
if (msg.data.hasOwnProperty('localTemperatureCalibration')) {
result[postfixWithEndpointName('local_temperature_calibration', msg, model, meta)] =
precisionRound(msg.data['localTemperatureCalibration'], 2) / 10;
}
if (msg.data.hasOwnProperty('outdoorTemp')) {
let value = precisionRound(msg.data['outdoorTemp'], 2) / 100;

Check failure on line 55 in src/converters/fromZigbee.js

View workflow job for this annotation

GitHub Actions / ci

'value' is never reassigned. Use 'const' instead
value = value < -273.15 ? null : value;
result[postfixWithEndpointName('outdoor_temperature', msg, model, meta)] = value;
if (value >= -273.15) {
result[postfixWithEndpointName('outdoor_temperature', msg, model, meta)] = value;
}
}
if (msg.data.hasOwnProperty('occupancy')) {
result[postfixWithEndpointName('occupancy', msg, model, meta)] = (msg.data.occupancy % 2) > 0;
}
if (msg.data.hasOwnProperty('occupiedHeatingSetpoint')) {
let value = precisionRound(msg.data['occupiedHeatingSetpoint'], 2) / 100;

Check failure on line 64 in src/converters/fromZigbee.js

View workflow job for this annotation

GitHub Actions / ci

'value' is never reassigned. Use 'const' instead
// Stelpro will return -325.65 when set to off, value is not realistic anyway
value = value < -273.15 ? null : value;
result[postfixWithEndpointName('occupied_heating_setpoint', msg, model, meta)] = value;
if (value >= -273.15) {
result[postfixWithEndpointName('occupied_heating_setpoint', msg, model, meta)] = value;
}
}
if (msg.data.hasOwnProperty('unoccupiedHeatingSetpoint')) {
result[postfixWithEndpointName('unoccupied_heating_setpoint', msg, model, meta)] =
Expand Down Expand Up @@ -134,38 +137,45 @@ const converters = {
}
if (msg.data.hasOwnProperty('minHeatSetpointLimit')) {
let value = precisionRound(msg.data['minHeatSetpointLimit'], 2) / 100;

Check failure on line 139 in src/converters/fromZigbee.js

View workflow job for this annotation

GitHub Actions / ci

'value' is never reassigned. Use 'const' instead
value = value < -273.15 ? null : value;
result[postfixWithEndpointName('min_heat_setpoint_limit', msg, model, meta)] = value;
if (value >= -273.15) {
result[postfixWithEndpointName('min_heat_setpoint_limit', msg, model, meta)] = value;
}
}
if (msg.data.hasOwnProperty('maxHeatSetpointLimit')) {
let value = precisionRound(msg.data['maxHeatSetpointLimit'], 2) / 100;

Check failure on line 145 in src/converters/fromZigbee.js

View workflow job for this annotation

GitHub Actions / ci

'value' is never reassigned. Use 'const' instead
value = value < -273.15 ? null : value;
result[postfixWithEndpointName('max_heat_setpoint_limit', msg, model, meta)] = value;
if (value >= -273.15) {
result[postfixWithEndpointName('max_heat_setpoint_limit', msg, model, meta)] = value;
}
}
if (msg.data.hasOwnProperty('absMinHeatSetpointLimit')) {
let value = precisionRound(msg.data['absMinHeatSetpointLimit'], 2) / 100;

Check failure on line 151 in src/converters/fromZigbee.js

View workflow job for this annotation

GitHub Actions / ci

'value' is never reassigned. Use 'const' instead
value = value < -273.15 ? null : value;
result[postfixWithEndpointName('abs_min_heat_setpoint_limit', msg, model, meta)] = value;
if (value >= -273.15) {
result[postfixWithEndpointName('abs_min_heat_setpoint_limit', msg, model, meta)] = value;
}
}
if (msg.data.hasOwnProperty('absMaxHeatSetpointLimit')) {
let value = precisionRound(msg.data['absMaxHeatSetpointLimit'], 2) / 100;

Check failure on line 157 in src/converters/fromZigbee.js

View workflow job for this annotation

GitHub Actions / ci

'value' is never reassigned. Use 'const' instead
value = value < -273.15 ? null : value;
result[postfixWithEndpointName('abs_max_heat_setpoint_limit', msg, model, meta)] = value;
if (value >= -273.15) {
result[postfixWithEndpointName('abs_max_heat_setpoint_limit', msg, model, meta)] = value;
}
}
if (msg.data.hasOwnProperty('absMinCoolSetpointLimit')) {
let value = precisionRound(msg.data['absMinCoolSetpointLimit'], 2) / 100;

Check failure on line 163 in src/converters/fromZigbee.js

View workflow job for this annotation

GitHub Actions / ci

'value' is never reassigned. Use 'const' instead
value = value < -273.15 ? null : value;
result[postfixWithEndpointName('abs_min_cool_setpoint_limit', msg, model, meta)] = value;
if (value >= -273.15) {
result[postfixWithEndpointName('abs_min_cool_setpoint_limit', msg, model, meta)] = value;
}
}
if (msg.data.hasOwnProperty('absMaxCoolSetpointLimit')) {
let value = precisionRound(msg.data['absMaxCoolSetpointLimit'], 2) / 100;

Check failure on line 169 in src/converters/fromZigbee.js

View workflow job for this annotation

GitHub Actions / ci

'value' is never reassigned. Use 'const' instead
value = value < -273.15 ? null : value;
result[postfixWithEndpointName('abs_max_cool_setpoint_limit', msg, model, meta)] = value;
if (value >= -273.15) {
result[postfixWithEndpointName('abs_max_cool_setpoint_limit', msg, model, meta)] = value;
}
}
if (msg.data.hasOwnProperty('minSetpointDeadBand')) {
let value = precisionRound(msg.data['minSetpointDeadBand'], 2) / 100;

Check failure on line 175 in src/converters/fromZigbee.js

View workflow job for this annotation

GitHub Actions / ci

'value' is never reassigned. Use 'const' instead
value = value < -273.15 ? null : value;
result[postfixWithEndpointName('min_setpoint_dead_band', msg, model, meta)] = value;
if (value >= -273.15) {
result[postfixWithEndpointName('min_setpoint_dead_band', msg, model, meta)] = value;
}
}
if (msg.data.hasOwnProperty('acLouverPosition')) {
result[postfixWithEndpointName('ac_louver_position', msg, model, meta)] =
Expand Down

0 comments on commit cac6aa3

Please sign in to comment.