From e2e9c84c886726bea2ff92c15995435602b7d46f Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 17 Oct 2023 19:35:39 -1000 Subject: [PATCH] Cache construction of battery icon (#102194) 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. --- homeassistant/helpers/icon.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/homeassistant/helpers/icon.py b/homeassistant/helpers/icon.py index a289ab4a8749f2..97e0d20927c0e9 100644 --- a/homeassistant/helpers/icon.py +++ b/homeassistant/helpers/icon.py @@ -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: