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
This commit is contained in:
J. Nick Koston 2023-07-16 20:50:06 -10:00 committed by GitHub
parent 51a7df162c
commit 260e00ffb4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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