Simplified offset handling

Change is somehow dependent dependent on issue #68 with corresponding change in dataclasses.py.
But this is an example on how the change in dataclasses.py would allow to simplify the props handling in case of empty values.
This commit is contained in:
avollkopf 2021-04-11 12:30:34 +02:00
parent 55953539da
commit 0828aeacac

View file

@ -64,13 +64,8 @@ class OneWire(CBPiSensor):
await super().start() await super().start()
self.name = self.props.get("Sensor") self.name = self.props.get("Sensor")
self.interval = self.props.get("Interval", 60) self.interval = self.props.get("Interval", 60)
self.offset = self.props.get("offset") self.offset = float(self.props.get("offset",0))
if self.offset == "" or self.offset is None:
self.offset = 0
else:
self.offset = float(self.offset)
print(self.offset)
self.t = ReadThread(self.name) self.t = ReadThread(self.name)
self.t.daemon = True self.t.daemon = True
def shudown(): def shudown():