mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 09:17:53 +00:00
Optimise onewire sensor update method (#42690)
This commit is contained in:
parent
abe6f552f6
commit
c8735edb7f
@ -33,8 +33,6 @@ class OneWire(Entity):
|
||||
@property
|
||||
def state(self) -> StateType:
|
||||
"""Return the state of the sensor."""
|
||||
if "count" in self._unit_of_measurement:
|
||||
return int(self._state)
|
||||
return self._state
|
||||
|
||||
@property
|
||||
@ -84,7 +82,10 @@ class OneWireProxy(OneWire):
|
||||
except protocol.Error as exc:
|
||||
_LOGGER.error("Owserver failure in read(), got: %s", exc)
|
||||
if value_read:
|
||||
value = round(float(value_read), 1)
|
||||
if "count" in self._unit_of_measurement:
|
||||
value = int(value_read)
|
||||
else:
|
||||
value = round(float(value_read), 1)
|
||||
self._value_raw = float(value_read)
|
||||
|
||||
self._state = value
|
||||
|
Loading…
x
Reference in New Issue
Block a user