Allow blank value for offset on onewire sensor

Fixes bug caused introduced when adding the offset (temps only reading 0)
This commit is contained in:
Carl Allen
2017-06-28 09:46:28 -05:00
committed by GitHub
parent e67baeabb0
commit 4470767a1c
+6 -2
View File
@@ -87,9 +87,13 @@ class ONE_WIRE_SENSOR(SensorPassive):
def read(self):
if self.get_config_parameter("unit", "C") == "C":
self.data_received(round(self.t.value + float(self.offset), 2))
self.data_received(round(self.t.value + self.offset_value(), 2))
else:
self.data_received(round(9.0 / 5.0 * self.t.value + 32 + float(self.offset), 2))
self.data_received(round(9.0 / 5.0 * self.t.value + 32 + self.offset_value(), 2))
@cbpi.try_catch(0)
def offset_value(self):
return float(self.offset)
@classmethod
def init_global(self):