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.
This commit is contained in:
J. Nick Koston 2023-10-17 19:35:39 -10:00 committed by GitHub
parent d8e541a284
commit e2e9c84c88
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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: