From 260e00ffb4c0229afba42096e99a2ce0de087bbd Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 16 Jul 2023 20:50:06 -1000 Subject: [PATCH] Check the registry entry in sensor unit_of_measurement instead of unique_id (#96731) The unit_of_measurement check was checking to see if the entity has a unique_id instead of a registry entry. Its much cheaper to check for the registry_entry than the unique id since some entity have to construct it every time its read --- homeassistant/components/sensor/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/sensor/__init__.py b/homeassistant/components/sensor/__init__.py index 2477e849666..e8303c12c10 100644 --- a/homeassistant/components/sensor/__init__.py +++ b/homeassistant/components/sensor/__init__.py @@ -453,7 +453,7 @@ class SensorEntity(Entity): return self._sensor_option_unit_of_measurement # Second priority, for non registered entities: unit suggested by integration - if not self.unique_id and ( + if not self.registry_entry and ( suggested_unit_of_measurement := self.suggested_unit_of_measurement ): return suggested_unit_of_measurement