Add StrEnum for device_tracker SourceType (#75892)

Add StrEnum for device_tracker SourceType
This commit is contained in:
Marc Mueller
2022-07-29 13:09:03 +02:00
committed by GitHub
parent ab5dfb3c42
commit 2b1e1365fd
5 changed files with 35 additions and 20 deletions

View File

@@ -1,8 +1,12 @@
"""Device tracker constants."""
from __future__ import annotations
from datetime import timedelta
import logging
from typing import Final
from homeassistant.backports.enum import StrEnum
LOGGER: Final = logging.getLogger(__package__)
DOMAIN: Final = "device_tracker"
@@ -11,11 +15,23 @@ ENTITY_ID_FORMAT: Final = DOMAIN + ".{}"
PLATFORM_TYPE_LEGACY: Final = "legacy"
PLATFORM_TYPE_ENTITY: Final = "entity_platform"
# SOURCE_TYPE_* below are deprecated as of 2022.9
# use the SourceType enum instead.
SOURCE_TYPE_GPS: Final = "gps"
SOURCE_TYPE_ROUTER: Final = "router"
SOURCE_TYPE_BLUETOOTH: Final = "bluetooth"
SOURCE_TYPE_BLUETOOTH_LE: Final = "bluetooth_le"
class SourceType(StrEnum):
"""Source type for device trackers."""
GPS = "gps"
ROUTER = "router"
BLUETOOTH = "bluetooth"
BLUETOOTH_LE = "bluetooth_le"
CONF_SCAN_INTERVAL: Final = "interval_seconds"
SCAN_INTERVAL: Final = timedelta(seconds=12)