Update FlowHandler with the new return type ConfigFlowResult

This commit is contained in:
pglab-electronics
2024-05-03 21:21:16 +00:00
parent f2356c925c
commit 5f6af01721

View File

@@ -1,16 +1,16 @@
"""Config flow for Tasmota."""
from __future__ import annotations
from typing import Any
from homeassistant import config_entries
from homeassistant.data_entry_flow import FlowResult
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.helpers.service_info.mqtt import MqttServiceInfo, ReceivePayloadType
from .const import CONF_DISCOVERY_PREFIX, DISCOVERY_TOPIC, DOMAIN
class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
class FlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a config flow."""
VERSION = 1
@@ -20,7 +20,9 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
self._prefix = DISCOVERY_TOPIC
self._payload: ReceivePayloadType = ""
async def async_step_mqtt(self, discovery_info: MqttServiceInfo) -> FlowResult:
async def async_step_mqtt(
self, discovery_info: MqttServiceInfo
) -> ConfigFlowResult:
"""Handle a flow initialized by MQTT discovery."""
if self._async_in_progress() or self._async_current_entries():
return self.async_abort(reason="single_instance_allowed")
@@ -44,7 +46,7 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Handle a flow initialized by the user."""
if self._async_current_entries():
return self.async_abort(reason="single_instance_allowed")
@@ -53,7 +55,7 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_confirm(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
) -> ConfigFlowResult:
"""Confirm the setup."""
data = {