mirror of
https://github.com/home-assistant/core.git
synced 2025-11-11 20:10:12 +00:00
* Initial implementation of hardware update model * Fixes * WIP: change the `homeassistant_sky_connect` integration type * More fixes * WIP * Display firmware info in the device page * Make progress more responsive * WIP: Yellow * Abstract the bootloader reset type * Clean up comments * Make the Yellow integration non-hardware * Use the correct radio device for Yellow * Avoid hardcoding strings * Use `FIRMWARE_VERSION` within config flows * Fix up unit tests * Revert integration type changes * Rewrite hardware ownership context manager name, for clarity * Move manifest parsing logic into a new package Pass the correct type to the firmware API library * Create and delete entities instead of mutating the entity description * Move entity replacement into a `async_setup_entry` callback * Change update entity category from "diagnostic" to "config" * Have the client library handle firmware fetching * Switch from dispatcher to `async_on_state_change` * Remove unnecessary type annotation on base update entity * Simplify state recomputation * Remove device registry code, since the devices will not be visible * Further simplify state computation * Give the device-less update entity a more descriptive name * Limit state changes to integer increments when sending firmware update progress * Re-raise `HomeAssistantError` if there is a problem during flashing * Remove unnecessary state write during entity creation * Rename `_maybe_recompute_state` to `_update_attributes` * Bump the flasher to 0.0.30 * Add some tests * Ensure the update entity has a sensible name * Initial ZBT-1 unit tests * Replace `_update_config_entry_after_install` with a more explicit `_firmware_info_callback` override * Write the firmware version to the config entry as well * Test the hardware update platform independently * Add unit tests to the Yellow and ZBT-1 integrations * Load firmware info from the config entry when creating the update entity * Test entity state restoration * Test the reloading of integrations marked as "owning" * Test installation failure cases * Test firmware type change callback failure case * Address review comments
57 lines
1.4 KiB
Python
57 lines
1.4 KiB
Python
"""Constants for the Home Assistant SkyConnect integration."""
|
|
|
|
import dataclasses
|
|
import enum
|
|
from typing import Self
|
|
|
|
DOMAIN = "homeassistant_sky_connect"
|
|
DOCS_WEB_FLASHER_URL = "https://skyconnect.home-assistant.io/firmware-update/"
|
|
|
|
NABU_CASA_FIRMWARE_RELEASES_URL = (
|
|
"https://api.github.com/repos/NabuCasa/silabs-firmware-builder/releases/latest"
|
|
)
|
|
|
|
FIRMWARE = "firmware"
|
|
FIRMWARE_VERSION = "firmware_version"
|
|
SERIAL_NUMBER = "serial_number"
|
|
MANUFACTURER = "manufacturer"
|
|
PRODUCT = "product"
|
|
DESCRIPTION = "description"
|
|
PID = "pid"
|
|
VID = "vid"
|
|
DEVICE = "device"
|
|
|
|
|
|
@dataclasses.dataclass(frozen=True)
|
|
class VariantInfo:
|
|
"""Hardware variant information."""
|
|
|
|
usb_product_name: str
|
|
short_name: str
|
|
full_name: str
|
|
|
|
|
|
class HardwareVariant(VariantInfo, enum.Enum):
|
|
"""Hardware variants."""
|
|
|
|
SKYCONNECT = (
|
|
"SkyConnect v1.0",
|
|
"SkyConnect",
|
|
"Home Assistant SkyConnect",
|
|
)
|
|
|
|
CONNECT_ZBT1 = (
|
|
"Home Assistant Connect ZBT-1",
|
|
"Connect ZBT-1",
|
|
"Home Assistant Connect ZBT-1",
|
|
)
|
|
|
|
@classmethod
|
|
def from_usb_product_name(cls, usb_product_name: str) -> Self:
|
|
"""Get the hardware variant from the USB product name."""
|
|
for variant in cls:
|
|
if variant.value.usb_product_name == usb_product_name:
|
|
return variant
|
|
|
|
raise ValueError(f"Unknown SkyConnect product name: {usb_product_name}")
|