@@ -9,30 +9,46 @@ For custom domains not listed here, users should use:
99"""
1010
1111import typing
12+ from collections .abc import Iterator
13+ from typing import Generic , NamedTuple
14+
15+ from frozendict import frozendict
1216
1317from hassette .models import states
14- from hassette .models .states import BaseState , StateT
18+ from hassette .models .states import StateT
1519from hassette .resources .base import Resource
1620
1721if typing .TYPE_CHECKING :
1822 from hassette import Hassette
1923 from hassette .core .state_proxy import StateProxy
24+ from hassette .events import HassStateDict
2025
21- class _TypedStateGetter (typing .Generic [StateT ]):
22- def __init__ (self , proxy : StateProxy , model : type [StateT ]): ...
23- def __call__ (self , entity_id : str ) -> StateT : ...
24- def get (self , entity_id : str ) -> StateT | None : ...
25-
26- class _StateGetter :
27- def __init__ (self , proxy : StateProxy ): ...
28- def __getitem__ (self , model : type [StateT ]) -> _TypedStateGetter [StateT ]: ...
26+ class CacheValue (Generic [StateT ], NamedTuple ):
27+ context_id : str | None
28+ frozen_state : frozendict
29+ model : StateT
2930
3031class DomainStates (typing .Generic [StateT ]):
31- def __init__ (self , states_dict : dict [str , BaseState ], domain : str ) -> None : ...
32+ _state_proxy : StateProxy
33+ _model : type [StateT ]
34+ _domain : str
35+ _cache : dict [str , CacheValue [StateT ]]
36+
37+ def _validate_or_return_from_cache (self , entity_id : str , state : HassStateDict ) -> StateT : ...
38+ def __init__ (self , state_proxy : StateProxy , model : type [StateT ]) -> None : ...
3239 def __iter__ (self ) -> typing .Generator [tuple [str , StateT ], typing .Any , None ]: ...
3340 def __len__ (self ) -> int : ...
34- def get (self , entity_id : str ) -> StateT | None : ...
3541 def __getitem__ (self , entity_id : str ) -> StateT : ...
42+ def __contains__ (self , entity_id : str ) -> bool : ...
43+ def __repr__ (self ) -> str : ...
44+ def __bool__ (self ) -> bool : ...
45+ def get (self , entity_id : str ) -> StateT | None : ...
46+ def items (self ) -> Iterator [tuple [str , StateT ]]: ...
47+ def keys (self ) -> list [str ]: ...
48+ def iterkeys (self ) -> typing .Iterator [str ]: ...
49+ def values (self ) -> list [StateT ]: ...
50+ def itervalues (self ) -> Iterator [StateT ]: ...
51+ def to_dict (self ) -> dict [str , StateT ]: ...
3652
3753class StateManager (Resource ):
3854 """Resource for managing Home Assistant states.
0 commit comments