Optimise onewire sensor update method (#42690)
This commit is contained in:
parent
abe6f552f6
commit
c8735edb7f
1 changed files with 4 additions and 3 deletions
|
@ -33,8 +33,6 @@ class OneWire(Entity):
|
||||||
@property
|
@property
|
||||||
def state(self) -> StateType:
|
def state(self) -> StateType:
|
||||||
"""Return the state of the sensor."""
|
"""Return the state of the sensor."""
|
||||||
if "count" in self._unit_of_measurement:
|
|
||||||
return int(self._state)
|
|
||||||
return self._state
|
return self._state
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -84,6 +82,9 @@ class OneWireProxy(OneWire):
|
||||||
except protocol.Error as exc:
|
except protocol.Error as exc:
|
||||||
_LOGGER.error("Owserver failure in read(), got: %s", exc)
|
_LOGGER.error("Owserver failure in read(), got: %s", exc)
|
||||||
if value_read:
|
if value_read:
|
||||||
|
if "count" in self._unit_of_measurement:
|
||||||
|
value = int(value_read)
|
||||||
|
else:
|
||||||
value = round(float(value_read), 1)
|
value = round(float(value_read), 1)
|
||||||
self._value_raw = float(value_read)
|
self._value_raw = float(value_read)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue