diff --git a/homeassistant/components/tasmota/config_flow.py b/homeassistant/components/tasmota/config_flow.py index e1621f2c126..85959ef0674 100644 --- a/homeassistant/components/tasmota/config_flow.py +++ b/homeassistant/components/tasmota/config_flow.py @@ -1,12 +1,12 @@ """Config flow for Tasmota.""" from __future__ import annotations -from typing import Any, cast +from typing import Any import voluptuous as vol from homeassistant import config_entries -from homeassistant.components.mqtt import ReceiveMessage, valid_subscribe_topic +from homeassistant.components.mqtt import valid_subscribe_topic from homeassistant.data_entry_flow import FlowResult from homeassistant.helpers.typing import DiscoveryInfoType @@ -30,7 +30,7 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN): await self.async_set_unique_id(DOMAIN) # Validate the topic, will throw if it fails - prefix = cast(ReceiveMessage, discovery_info).subscribed_topic + prefix = discovery_info["subscribed_topic"] if prefix.endswith("/#"): prefix = prefix[:-2] try: diff --git a/tests/components/tasmota/test_config_flow.py b/tests/components/tasmota/test_config_flow.py index 767d6b9cfcf..c97ffb9edb8 100644 --- a/tests/components/tasmota/test_config_flow.py +++ b/tests/components/tasmota/test_config_flow.py @@ -1,6 +1,5 @@ """Test config flow.""" from homeassistant import config_entries -from homeassistant.components.mqtt.models import ReceiveMessage from tests.common import MockConfigEntry @@ -19,9 +18,14 @@ async def test_mqtt_abort_if_existing_entry(hass, mqtt_mock): async def test_mqtt_abort_invalid_topic(hass, mqtt_mock): """Check MQTT flow aborts if discovery topic is invalid.""" - discovery_info = ReceiveMessage( - "", "", 0, False, subscribed_topic="custom_prefix/##" - ) + discovery_info = { + "topic": "", + "payload": "", + "qos": 0, + "retain": False, + "subscribed_topic": "custom_prefix/##", + "timestamp": None, + } result = await hass.config_entries.flow.async_init( "tasmota", context={"source": config_entries.SOURCE_MQTT}, data=discovery_info ) @@ -31,9 +35,14 @@ async def test_mqtt_abort_invalid_topic(hass, mqtt_mock): async def test_mqtt_setup(hass, mqtt_mock) -> None: """Test we can finish a config flow through MQTT with custom prefix.""" - discovery_info = ReceiveMessage( - "", "", 0, False, subscribed_topic="custom_prefix/123/#" - ) + discovery_info = { + "topic": "", + "payload": "", + "qos": 0, + "retain": False, + "subscribed_topic": "custom_prefix/123/#", + "timestamp": None, + } result = await hass.config_entries.flow.async_init( "tasmota", context={"source": config_entries.SOURCE_MQTT}, data=discovery_info )