From 205a8fc752f6ae6fd34543372ddfde4cfeaf57d2 Mon Sep 17 00:00:00 2001 From: Diogo Gomes Date: Sat, 30 Apr 2022 00:16:05 +0100 Subject: [PATCH] update unit_of_measurement even if unit_of_measurement is known (#69699) --- homeassistant/components/integration/sensor.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/integration/sensor.py b/homeassistant/components/integration/sensor.py index 40229404288..8cf5da5bc7c 100644 --- a/homeassistant/components/integration/sensor.py +++ b/homeassistant/components/integration/sensor.py @@ -196,10 +196,11 @@ class IntegrationSensor(RestoreEntity, SensorEntity): # or device_class. update_state = False - if self._unit_of_measurement is None: - unit = new_state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) - if unit is not None: - self._unit_of_measurement = self._unit_template.format(unit) + unit = new_state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) + if unit is not None: + new_unit_of_measurement = self._unit_template.format(unit) + if self._unit_of_measurement != new_unit_of_measurement: + self._unit_of_measurement = new_unit_of_measurement update_state = True if (