129 lines
3.8 KiB
Python
129 lines
3.8 KiB
Python
|
"""Constants for the Version integration."""
|
||
|
from __future__ import annotations
|
||
|
|
||
|
from datetime import timedelta
|
||
|
from logging import Logger, getLogger
|
||
|
from typing import Any, Final
|
||
|
|
||
|
from pyhaversion.consts import HaVersionChannel, HaVersionSource
|
||
|
|
||
|
from homeassistant.const import CONF_NAME, Platform
|
||
|
|
||
|
DOMAIN: Final = "version"
|
||
|
LOGGER: Final[Logger] = getLogger(__package__)
|
||
|
PLATFORMS: Final[list[Platform]] = [Platform.SENSOR]
|
||
|
UPDATE_COORDINATOR_UPDATE_INTERVAL: Final[timedelta] = timedelta(minutes=5)
|
||
|
|
||
|
ENTRY_TYPE_SERVICE: Final = "service"
|
||
|
HOME_ASSISTANT: Final = "Home Assistant"
|
||
|
POSTFIX_CONTAINER_NAME: Final = "-homeassistant"
|
||
|
|
||
|
|
||
|
CONF_BETA: Final = "beta"
|
||
|
CONF_BOARD: Final = "board"
|
||
|
CONF_CHANNEL: Final = "channel"
|
||
|
CONF_IMAGE: Final = "image"
|
||
|
CONF_VERSION_SOURCE: Final = "version_source"
|
||
|
CONF_SOURCE: Final = "source"
|
||
|
|
||
|
ATTR_CHANNEL: Final = CONF_CHANNEL
|
||
|
ATTR_VERSION_SOURCE: Final = CONF_VERSION_SOURCE
|
||
|
ATTR_SOURCE: Final = CONF_SOURCE
|
||
|
|
||
|
SOURCE_DOKCER: Final = "docker" # Kept to not break existing configurations
|
||
|
SOURCE_HASSIO: Final = "hassio" # Kept to not break existing configurations
|
||
|
|
||
|
VERSION_SOURCE_DOCKER_HUB: Final = "Docker Hub"
|
||
|
VERSION_SOURCE_HAIO: Final = "Home Assistant Website"
|
||
|
VERSION_SOURCE_LOCAL: Final = "Local installation"
|
||
|
VERSION_SOURCE_PYPI: Final = "Python Package Index (PyPI)"
|
||
|
VERSION_SOURCE_VERSIONS: Final = "Home Assistant Versions"
|
||
|
|
||
|
DEFAULT_BETA: Final = False
|
||
|
DEFAULT_BOARD: Final = "OVA"
|
||
|
DEFAULT_CHANNEL: Final[HaVersionChannel] = HaVersionChannel.STABLE
|
||
|
DEFAULT_IMAGE: Final = "default"
|
||
|
DEFAULT_NAME_CURRENT: Final = "Current Version"
|
||
|
DEFAULT_NAME_LATEST: Final = "Latest Version"
|
||
|
DEFAULT_NAME: Final = ""
|
||
|
DEFAULT_SOURCE: Final[HaVersionSource] = HaVersionSource.LOCAL
|
||
|
DEFAULT_CONFIGURATION: Final[dict[str, Any]] = {
|
||
|
CONF_NAME: DEFAULT_NAME,
|
||
|
CONF_CHANNEL: DEFAULT_CHANNEL,
|
||
|
CONF_IMAGE: DEFAULT_IMAGE,
|
||
|
CONF_BOARD: DEFAULT_BOARD,
|
||
|
CONF_VERSION_SOURCE: VERSION_SOURCE_LOCAL,
|
||
|
CONF_SOURCE: DEFAULT_SOURCE,
|
||
|
}
|
||
|
|
||
|
STEP_VERSION_SOURCE: Final = "version_source"
|
||
|
STEP_USER: Final = "user"
|
||
|
|
||
|
HA_VERSION_SOURCES: Final[list[str]] = [source.value for source in HaVersionSource]
|
||
|
|
||
|
BOARD_MAP: Final[dict[str, str]] = {
|
||
|
"OVA": "ova",
|
||
|
"RaspberryPi": "rpi",
|
||
|
"RaspberryPi Zero-W": "rpi0-w",
|
||
|
"RaspberryPi 2": "rpi2",
|
||
|
"RaspberryPi 3": "rpi3",
|
||
|
"RaspberryPi 3 64bit": "rpi3-64",
|
||
|
"RaspberryPi 4": "rpi4",
|
||
|
"RaspberryPi 4 64bit": "rpi4-64",
|
||
|
"ASUS Tinkerboard": "tinker",
|
||
|
"ODROID C2": "odroid-c2",
|
||
|
"ODROID C4": "odroid-c4",
|
||
|
"ODROID N2": "odroid-n2",
|
||
|
"ODROID XU4": "odroid-xu4",
|
||
|
"Generic x86-64": "generic-x86-64",
|
||
|
"Intel NUC": "intel-nuc",
|
||
|
}
|
||
|
|
||
|
VALID_BOARDS: Final[list[str]] = list(BOARD_MAP)
|
||
|
|
||
|
VERSION_SOURCE_MAP: Final[dict[str, HaVersionSource]] = {
|
||
|
VERSION_SOURCE_LOCAL: HaVersionSource.LOCAL,
|
||
|
VERSION_SOURCE_VERSIONS: HaVersionSource.SUPERVISOR,
|
||
|
VERSION_SOURCE_HAIO: HaVersionSource.HAIO,
|
||
|
VERSION_SOURCE_DOCKER_HUB: HaVersionSource.CONTAINER,
|
||
|
VERSION_SOURCE_PYPI: HaVersionSource.PYPI,
|
||
|
}
|
||
|
|
||
|
VERSION_SOURCE_MAP_INVERTED: Final[dict[HaVersionSource, str]] = {
|
||
|
value: key for key, value in VERSION_SOURCE_MAP.items()
|
||
|
}
|
||
|
|
||
|
|
||
|
VALID_SOURCES: Final[list[str]] = HA_VERSION_SOURCES + [
|
||
|
SOURCE_HASSIO, # Kept to not break existing configurations
|
||
|
SOURCE_DOKCER, # Kept to not break existing configurations
|
||
|
]
|
||
|
|
||
|
VALID_IMAGES: Final = [
|
||
|
"default",
|
||
|
"generic-x86-64",
|
||
|
"intel-nuc",
|
||
|
"odroid-c2",
|
||
|
"odroid-n2",
|
||
|
"odroid-xu",
|
||
|
"qemuarm-64",
|
||
|
"qemuarm",
|
||
|
"qemux86-64",
|
||
|
"qemux86",
|
||
|
"raspberrypi",
|
||
|
"raspberrypi2",
|
||
|
"raspberrypi3-64",
|
||
|
"raspberrypi3",
|
||
|
"raspberrypi4-64",
|
||
|
"raspberrypi4",
|
||
|
"tinker",
|
||
|
]
|
||
|
|
||
|
VALID_CONTAINER_IMAGES: Final[list[str]] = [
|
||
|
f"{image}{POSTFIX_CONTAINER_NAME}" if image != DEFAULT_IMAGE else image
|
||
|
for image in VALID_IMAGES
|
||
|
]
|
||
|
VALID_CHANNELS: Final[list[str]] = [
|
||
|
str(channel.value).title() for channel in HaVersionChannel
|
||
|
]
|