Skip to content

Commit c38294a

Browse files
committed
cached_property
1 parent e44ae32 commit c38294a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

teslemetry_stream/const.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from enum import Enum
22
from dataclasses import dataclass
3-
3+
from functools import cached_property
44

55
class IntEnum(int, Enum):
66
"""Integer Enum"""
@@ -297,6 +297,12 @@ def lower(self, value, default: str | None = None) -> str | None:
297297
return option.lower()
298298
return default
299299

300+
@cached_property
301+
def hass_options(self) -> list[str]:
302+
"""Get options in lower case excluding 'Unknown'."""
303+
return [option.lower() for option in self.options if option != "Unknown"]
304+
305+
@cached_property
300306
def lower_options(self) -> list[str]:
301307
"""Get all options in lower case."""
302308
return [option.lower() for option in self.options]
@@ -309,6 +315,7 @@ def upper(self, value, default: str | None = None) -> str | None:
309315
return option.upper()
310316
return default
311317

318+
@cached_property
312319
def upper_options(self) -> list[str]:
313320
"""Get all options in upper case."""
314321
return [option.upper() for option in self.options]

0 commit comments

Comments
 (0)