Use typed BMWConfigEntry (#133272)

This commit is contained in:
Richard Kroegel 2024-12-15 14:41:35 +01:00 committed by GitHub
parent b13a54f605
commit b4b6067e8e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 6 additions and 7 deletions

View File

@ -6,7 +6,6 @@ import logging
import voluptuous as vol import voluptuous as vol
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_DEVICE_ID, CONF_ENTITY_ID, CONF_NAME, Platform from homeassistant.const import CONF_DEVICE_ID, CONF_ENTITY_ID, CONF_NAME, Platform
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import ( from homeassistant.helpers import (
@ -50,7 +49,7 @@ SERVICE_UPDATE_STATE = "update_state"
@callback @callback
def _async_migrate_options_from_data_if_missing( def _async_migrate_options_from_data_if_missing(
hass: HomeAssistant, entry: ConfigEntry hass: HomeAssistant, entry: BMWConfigEntry
) -> None: ) -> None:
data = dict(entry.data) data = dict(entry.data)
options = dict(entry.options) options = dict(entry.options)
@ -116,7 +115,7 @@ async def _async_migrate_entries(
return True return True
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: async def async_setup_entry(hass: HomeAssistant, entry: BMWConfigEntry) -> bool:
"""Set up BMW Connected Drive from a config entry.""" """Set up BMW Connected Drive from a config entry."""
_async_migrate_options_from_data_if_missing(hass, entry) _async_migrate_options_from_data_if_missing(hass, entry)
@ -164,7 +163,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
return True return True
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: async def async_unload_entry(hass: HomeAssistant, entry: BMWConfigEntry) -> bool:
"""Unload a config entry.""" """Unload a config entry."""
return await hass.config_entries.async_unload_platforms( return await hass.config_entries.async_unload_platforms(

View File

@ -18,7 +18,6 @@ import voluptuous as vol
from homeassistant.config_entries import ( from homeassistant.config_entries import (
SOURCE_REAUTH, SOURCE_REAUTH,
SOURCE_RECONFIGURE, SOURCE_RECONFIGURE,
ConfigEntry,
ConfigFlow, ConfigFlow,
ConfigFlowResult, ConfigFlowResult,
OptionsFlow, OptionsFlow,
@ -39,6 +38,7 @@ from .const import (
CONF_READ_ONLY, CONF_READ_ONLY,
CONF_REFRESH_TOKEN, CONF_REFRESH_TOKEN,
) )
from .coordinator import BMWConfigEntry
DATA_SCHEMA = vol.Schema( DATA_SCHEMA = vol.Schema(
{ {
@ -224,7 +224,7 @@ class BMWConfigFlow(ConfigFlow, domain=DOMAIN):
@staticmethod @staticmethod
@callback @callback
def async_get_options_flow( def async_get_options_flow(
config_entry: ConfigEntry, config_entry: BMWConfigEntry,
) -> BMWOptionsFlow: ) -> BMWOptionsFlow:
"""Return a MyBMW option flow.""" """Return a MyBMW option flow."""
return BMWOptionsFlow() return BMWOptionsFlow()

View File

@ -42,7 +42,7 @@ class BMWDataUpdateCoordinator(DataUpdateCoordinator[None]):
account: MyBMWAccount account: MyBMWAccount
config_entry: BMWConfigEntry config_entry: BMWConfigEntry
def __init__(self, hass: HomeAssistant, *, config_entry: ConfigEntry) -> None: def __init__(self, hass: HomeAssistant, *, config_entry: BMWConfigEntry) -> None:
"""Initialize account-wide BMW data updater.""" """Initialize account-wide BMW data updater."""
self.account = MyBMWAccount( self.account = MyBMWAccount(
config_entry.data[CONF_USERNAME], config_entry.data[CONF_USERNAME],