Skip to content

Commit

Permalink
Reduce multiple calls to calculate sensor unit in tplink (#124606)
Browse files Browse the repository at this point in the history
accessing unit on the feature is not cached and it had
to be looked up every time
  • Loading branch information
bdraco authored Aug 26, 2024
1 parent 16231da commit 743df84
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions homeassistant/components/tplink/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,5 @@ def _async_update_attrs(self) -> None:

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)

0 comments on commit 743df84

Please sign in to comment.