2017-05-02 18:18:47 +02:00
|
|
|
"""Typing Helpers for Home Assistant."""
|
2022-01-12 07:56:35 +01:00
|
|
|
from collections.abc import Mapping
|
2020-12-19 13:46:27 +02:00
|
|
|
from enum import Enum
|
2022-01-12 07:56:35 +01:00
|
|
|
from typing import Any, Optional, Union
|
2016-07-31 22:56:57 +02:00
|
|
|
|
2016-08-30 18:22:52 +02:00
|
|
|
import homeassistant.core
|
2016-08-07 18:26:35 -05:00
|
|
|
|
2022-01-11 21:26:03 +01:00
|
|
|
GPSType = tuple[float, float]
|
|
|
|
ConfigType = dict[str, Any]
|
2019-06-15 01:48:21 +03:00
|
|
|
ContextType = homeassistant.core.Context
|
2022-01-11 21:26:03 +01:00
|
|
|
DiscoveryInfoType = dict[str, Any]
|
2019-04-20 00:54:48 +03:00
|
|
|
EventType = homeassistant.core.Event
|
2022-01-11 21:26:03 +01:00
|
|
|
ServiceDataType = dict[str, Any]
|
2020-08-17 22:02:43 +03:00
|
|
|
StateType = Union[None, str, int, float]
|
2020-09-10 20:41:42 +02:00
|
|
|
TemplateVarsType = Optional[Mapping[str, Any]]
|
2016-07-31 22:56:57 +02:00
|
|
|
|
2016-08-30 18:22:52 +02:00
|
|
|
# Custom type for recorder Queries
|
|
|
|
QueryType = Any
|
2020-12-19 13:46:27 +02:00
|
|
|
|
|
|
|
|
|
|
|
class UndefinedType(Enum):
|
|
|
|
"""Singleton type for use with not set sentinel values."""
|
|
|
|
|
|
|
|
_singleton = 0
|
|
|
|
|
|
|
|
|
|
|
|
UNDEFINED = UndefinedType._singleton # pylint: disable=protected-access
|
2021-05-02 00:15:27 +02:00
|
|
|
|
|
|
|
# The following types should not used and
|
|
|
|
# are not present in the core code base.
|
|
|
|
# They are kept in order not to break custom integrations
|
|
|
|
# that may rely on them.
|
|
|
|
# In due time they will be removed.
|
|
|
|
HomeAssistantType = homeassistant.core.HomeAssistant
|
|
|
|
ServiceCallType = homeassistant.core.ServiceCall
|