Migrate integrations a-d to generic flowhandler (#111861)
This commit is contained in:
parent
ba4120d779
commit
6fe28d3764
111 changed files with 841 additions and 758 deletions
|
@ -12,15 +12,13 @@ from aioelectricitymaps import (
|
|||
)
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.const import (
|
||||
CONF_API_KEY,
|
||||
CONF_COUNTRY_CODE,
|
||||
CONF_LATITUDE,
|
||||
CONF_LONGITUDE,
|
||||
)
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.selector import (
|
||||
|
@ -38,7 +36,7 @@ TYPE_SPECIFY_COORDINATES = "specify_coordinates"
|
|||
TYPE_SPECIFY_COUNTRY = "specify_country_code"
|
||||
|
||||
|
||||
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
class ElectricityMapsConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a config flow for Co2signal."""
|
||||
|
||||
VERSION = 1
|
||||
|
@ -47,7 +45,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle the initial step."""
|
||||
data_schema = vol.Schema(
|
||||
{
|
||||
|
@ -86,7 +84,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
|
||||
async def async_step_coordinates(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Validate coordinates."""
|
||||
data_schema = vol.Schema(
|
||||
{
|
||||
|
@ -109,7 +107,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
|
||||
async def async_step_country(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Validate country."""
|
||||
data_schema = vol.Schema(
|
||||
{
|
||||
|
@ -125,7 +123,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
"country", data_schema, {**self._data, **user_input}
|
||||
)
|
||||
|
||||
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
|
||||
async def async_step_reauth(
|
||||
self, entry_data: Mapping[str, Any]
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle the reauth step."""
|
||||
self._reauth_entry = self.hass.config_entries.async_get_entry(
|
||||
self.context["entry_id"]
|
||||
|
@ -140,7 +140,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
|
||||
async def _validate_and_create(
|
||||
self, step_id: str, data_schema: vol.Schema, data: Mapping[str, Any]
|
||||
) -> FlowResult:
|
||||
) -> ConfigFlowResult:
|
||||
"""Validate data and show form if it is invalid."""
|
||||
errors: dict[str, str] = {}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue