mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 20:27:08 +00:00
Reduce multiple calls to calculate sensor unit in tplink (#124606)
accessing unit on the feature is not cached and it had to be looked up every time
This commit is contained in:
parent
16231da5ef
commit
743df84569
@ -154,7 +154,5 @@ class TPLinkSensorEntity(CoordinatedTPLinkFeatureEntity, SensorEntity):
|
|||||||
|
|
||||||
self._attr_native_value = value
|
self._attr_native_value = value
|
||||||
# Map to homeassistant units and fallback to upstream one if none found
|
# Map to homeassistant units and fallback to upstream one if none found
|
||||||
if self._feature.unit is not None:
|
if (unit := self._feature.unit) is not None:
|
||||||
self._attr_native_unit_of_measurement = UNIT_MAPPING.get(
|
self._attr_native_unit_of_measurement = UNIT_MAPPING.get(unit, unit)
|
||||||
self._feature.unit, self._feature.unit
|
|
||||||
)
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user