feat(update): Firmware-Update aus dem Ordner mit Einmal-URLs und WLAN-Sicherung
This commit is contained in:
@@ -4,14 +4,25 @@ from __future__ import annotations
|
||||
|
||||
from homeassistant.const import CONF_HOST, CONF_TOKEN, Platform
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers import device_registry as dr
|
||||
from homeassistant.helpers import issue_registry as ir
|
||||
from homeassistant.helpers import (
|
||||
config_validation as cv,
|
||||
)
|
||||
from homeassistant.helpers import (
|
||||
device_registry as dr,
|
||||
)
|
||||
from homeassistant.helpers import (
|
||||
issue_registry as ir,
|
||||
)
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
from homeassistant.helpers.device_registry import format_mac
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
|
||||
from .api import NinlightClient
|
||||
from .const import DEFAULT_TOKEN, DOMAIN
|
||||
from .coordinator import NinlightConfigEntry, NinlightCoordinator
|
||||
from .shared import async_get_shared, async_start_catalog, async_stop_catalog
|
||||
|
||||
CONFIG_SCHEMA = cv.config_entry_only_config_schema(DOMAIN)
|
||||
|
||||
PLATFORMS: list[Platform] = [
|
||||
Platform.BUTTON,
|
||||
@@ -20,9 +31,15 @@ PLATFORMS: list[Platform] = [
|
||||
Platform.SELECT,
|
||||
Platform.SENSOR,
|
||||
Platform.SWITCH,
|
||||
Platform.UPDATE,
|
||||
]
|
||||
|
||||
|
||||
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||
async_get_shared(hass)
|
||||
return True
|
||||
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: NinlightConfigEntry) -> bool:
|
||||
client = NinlightClient(
|
||||
async_get_clientsession(hass), entry.data[CONF_HOST], entry.data[CONF_TOKEN]
|
||||
@@ -43,16 +60,25 @@ async def async_setup_entry(hass: HomeAssistant, entry: NinlightConfigEntry) ->
|
||||
registry.async_update_device(device.id, sw_version=info["fw_version"])
|
||||
|
||||
entry.async_on_unload(coordinator.async_add_listener(_sync_firmware_version))
|
||||
await async_start_catalog(hass, async_get_shared(hass))
|
||||
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
|
||||
return True
|
||||
|
||||
|
||||
async def async_unload_entry(hass: HomeAssistant, entry: NinlightConfigEntry) -> bool:
|
||||
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||
unloaded = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||
if unloaded and not [
|
||||
other
|
||||
for other in hass.config_entries.async_loaded_entries(DOMAIN)
|
||||
if other.entry_id != entry.entry_id
|
||||
]:
|
||||
async_stop_catalog(async_get_shared(hass))
|
||||
return unloaded
|
||||
|
||||
|
||||
async def async_remove_entry(hass: HomeAssistant, entry: NinlightConfigEntry) -> None:
|
||||
ir.async_delete_issue(hass, DOMAIN, f"default_token_{entry.entry_id}")
|
||||
ir.async_delete_issue(hass, DOMAIN, f"wifi_guard_{entry.entry_id}")
|
||||
|
||||
|
||||
@callback
|
||||
|
||||
Reference in New Issue
Block a user