Skip to content

Commit

Permalink
Cache construction of battery icon (home-assistant#102194)
Browse files Browse the repository at this point in the history
This was being built every time state was written. When
a robo vac is operating it writes state often which mean building
the icon string over and over again when it rarely changes.
  • Loading branch information
bdraco committed Oct 18, 2023
1 parent d8e541a commit e2e9c84
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions homeassistant/helpers/icon.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
"""Icon helper methods."""
from __future__ import annotations

from functools import lru_cache


@lru_cache
def icon_for_battery_level(
battery_level: int | None = None, charging: bool = False
) -> str:
Expand Down

0 comments on commit e2e9c84

Please sign in to comment.