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
1 changed files with 2 additions and 4 deletions
|
@ -154,7 +154,5 @@ class TPLinkSensorEntity(CoordinatedTPLinkFeatureEntity, SensorEntity):
|
|||
|
||||
self._attr_native_value = value
|
||||
# Map to homeassistant units and fallback to upstream one if none found
|
||||
if self._feature.unit is not None:
|
||||
self._attr_native_unit_of_measurement = UNIT_MAPPING.get(
|
||||
self._feature.unit, self._feature.unit
|
||||
)
|
||||
if (unit := self._feature.unit) is not None:
|
||||
self._attr_native_unit_of_measurement = UNIT_MAPPING.get(unit, unit)
|
||||
|
|
Loading…
Add table
Reference in a new issue