From c8735edb7f252a240b97a4f3dd8f3c2b23092a2c Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Sun, 1 Nov 2020 01:46:31 +0100 Subject: [PATCH] Optimise onewire sensor update method (#42690) --- homeassistant/components/onewire/onewire_entities.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/onewire/onewire_entities.py b/homeassistant/components/onewire/onewire_entities.py index 2c16094aa2d..512a6e997f0 100644 --- a/homeassistant/components/onewire/onewire_entities.py +++ b/homeassistant/components/onewire/onewire_entities.py @@ -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