From b88f0adbe91f61b23080467fd8f928af77d17672 Mon Sep 17 00:00:00 2001 From: Diogo Gomes Date: Mon, 9 Aug 2021 18:48:01 +0100 Subject: [PATCH] Restores unit_of_measurement (#54335) --- homeassistant/components/integration/sensor.py | 4 ++++ tests/components/integration/test_sensor.py | 1 + 2 files changed, 5 insertions(+) diff --git a/homeassistant/components/integration/sensor.py b/homeassistant/components/integration/sensor.py index 2b7d89decea..9308adc622d 100644 --- a/homeassistant/components/integration/sensor.py +++ b/homeassistant/components/integration/sensor.py @@ -145,6 +145,10 @@ class IntegrationSensor(RestoreEntity, SensorEntity): ) self._attr_device_class = state.attributes.get(ATTR_DEVICE_CLASS) + self._unit_of_measurement = state.attributes.get( + ATTR_UNIT_OF_MEASUREMENT + ) + @callback def calc_integration(event): """Handle the sensor state changes.""" diff --git a/tests/components/integration/test_sensor.py b/tests/components/integration/test_sensor.py index dd6bf980d0f..36d3d4b3b30 100644 --- a/tests/components/integration/test_sensor.py +++ b/tests/components/integration/test_sensor.py @@ -73,6 +73,7 @@ async def test_restore_state(hass: HomeAssistant) -> None: { "last_reset": "2019-10-06T21:00:00", "device_class": DEVICE_CLASS_ENERGY, + "unit_of_measurement": ENERGY_KILO_WATT_HOUR, }, ), ),