From 139f5e8f911cbc1e1635997b219ab8ab0aacbf09 Mon Sep 17 00:00:00 2001 From: Carl Allen Date: Thu, 22 Jun 2017 23:20:32 -0500 Subject: [PATCH] Allow specifying an offset on onewire sensor --- modules/base_plugins/one_wire/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/base_plugins/one_wire/__init__.py b/modules/base_plugins/one_wire/__init__.py index 9398208..e9f3409 100644 --- a/modules/base_plugins/one_wire/__init__.py +++ b/modules/base_plugins/one_wire/__init__.py @@ -67,6 +67,7 @@ class myThread (threading.Thread): class ONE_WIRE_SENSOR(SensorPassive): sensor_name = Property.Select("Sensor", getSensors()) + offset = Property.Number("Offset", True, 0) def init(self): @@ -86,9 +87,9 @@ class ONE_WIRE_SENSOR(SensorPassive): def read(self): if self.get_config_parameter("unit", "C") == "C": - self.data_received(round(self.t.value, 2)) + self.data_received(round(self.t.value + float(self.offset), 2)) else: - self.data_received(round(9.0 / 5.0 * self.t.value + 32, 2)) + self.data_received(round(9.0 / 5.0 * self.t.value + 32 + float(self.offset), 2)) @classmethod def init_global(self):