瀏覽代碼

Merge pull request #38 from carlallen/patch-3

Allow specifying an offset on onewire sensor
tags/3.1_alpha
Manuel83 GitHub 8 年之前
父節點
當前提交
3396e1b379
共有 1 個檔案被更改,包括 3 行新增2 行删除
  1. +3
    -2
      modules/base_plugins/one_wire/__init__.py

+ 3
- 2
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):


Loading…
取消
儲存