Update board file list to reflect currently available boards (#72085)

* Update board file list to reflect currently available boards

* Warn if board does not exist and migrate Intel NUC to Generic x86-64

* Remove integration in case a old board is referenced

* Don't remove the config entry automatically/fix logging message

* Address pylint issue
This commit is contained in:
Stefan Agner 2022-05-23 14:28:56 +02:00 committed by GitHub
parent 071f6d7099
commit 6ec755a79d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 4 deletions

View file

@ -1,6 +1,8 @@
"""The Version integration.""" """The Version integration."""
from __future__ import annotations from __future__ import annotations
import logging
from pyhaversion import HaVersion from pyhaversion import HaVersion
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
@ -18,16 +20,29 @@ from .const import (
) )
from .coordinator import VersionDataUpdateCoordinator from .coordinator import VersionDataUpdateCoordinator
_LOGGER = logging.getLogger(__name__)
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up the version integration from a config entry.""" """Set up the version integration from a config entry."""
board = entry.data[CONF_BOARD]
if board not in BOARD_MAP:
_LOGGER.error(
'Board "%s" is (no longer) valid. Please remove the integration "%s"',
board,
entry.title,
)
return False
coordinator = VersionDataUpdateCoordinator( coordinator = VersionDataUpdateCoordinator(
hass=hass, hass=hass,
api=HaVersion( api=HaVersion(
session=async_get_clientsession(hass), session=async_get_clientsession(hass),
source=entry.data[CONF_SOURCE], source=entry.data[CONF_SOURCE],
image=entry.data[CONF_IMAGE], image=entry.data[CONF_IMAGE],
board=BOARD_MAP[entry.data[CONF_BOARD]], board=BOARD_MAP[board],
channel=entry.data[CONF_CHANNEL].lower(), channel=entry.data[CONF_CHANNEL].lower(),
), ),
) )

View file

@ -61,8 +61,6 @@ HA_VERSION_SOURCES: Final[list[str]] = [source.value for source in HaVersionSour
BOARD_MAP: Final[dict[str, str]] = { BOARD_MAP: Final[dict[str, str]] = {
"OVA": "ova", "OVA": "ova",
"RaspberryPi": "rpi",
"RaspberryPi Zero-W": "rpi0-w",
"RaspberryPi 2": "rpi2", "RaspberryPi 2": "rpi2",
"RaspberryPi 3": "rpi3", "RaspberryPi 3": "rpi3",
"RaspberryPi 3 64bit": "rpi3-64", "RaspberryPi 3 64bit": "rpi3-64",
@ -73,8 +71,10 @@ BOARD_MAP: Final[dict[str, str]] = {
"ODROID C4": "odroid-c4", "ODROID C4": "odroid-c4",
"ODROID N2": "odroid-n2", "ODROID N2": "odroid-n2",
"ODROID XU4": "odroid-xu4", "ODROID XU4": "odroid-xu4",
"Generic AArch64": "generic-aarch64",
"Generic x86-64": "generic-x86-64", "Generic x86-64": "generic-x86-64",
"Intel NUC": "intel-nuc", "Home Assistant Yellow": "yellow",
"Khadas VIM3": "khadas-vim3",
} }
VALID_BOARDS: Final[list[str]] = list(BOARD_MAP) VALID_BOARDS: Final[list[str]] = list(BOARD_MAP)