From bc7a31f20a95aefe0f2448801cb4b2dd42a14b4e Mon Sep 17 00:00:00 2001 From: Aldarande <72162771+Aldarande@users.noreply.github.com> Date: Fri, 8 May 2026 10:03:21 +0200 Subject: [PATCH] feat: add temperatureOffsetPercent and humidityOffsetPercent config options Add percentage-based offset options to complement the existing fixed offsets. - `temperatureOffsetPercent` (default: `0`): percentage applied to raw temperature - `humidityOffsetPercent` (default: `0`): percentage applied to raw humidity Both fixed and percentage offsets can be combined: final value = raw * (1 + offsetPercent / 100) + offset --- MMM-DHT-Sensor.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/MMM-DHT-Sensor.js b/MMM-DHT-Sensor.js index 06b3823..342cc6e 100755 --- a/MMM-DHT-Sensor.js +++ b/MMM-DHT-Sensor.js @@ -15,6 +15,10 @@ Module.register("MMM-DHT-Sensor", { debug: false, sensorPin: 2, sensorType: 22, + temperatureOffset: 0, + temperatureOffsetPercent: 0, + humidityOffset: 0, + humidityOffsetPercent: 0, }, start: function () { @@ -77,8 +81,8 @@ Module.register("MMM-DHT-Sensor", { } const roundToTwo = (value) => Math.round(value * 100) / 100; - const celsius = roundToTwo(rawTemp); - const humidity = roundToTwo(rawHumidity); + const celsius = roundToTwo(rawTemp * (1 + this.config.temperatureOffsetPercent / 100) + this.config.temperatureOffset); + const humidity = roundToTwo(rawHumidity * (1 + this.config.humidityOffsetPercent / 100) + this.config.humidityOffset); this.temperature = this.config.units === "imperial" ? roundToTwo((celsius * 9) / 5 + 32)