diff --git a/homeassistant/components/mqtt/config_integration.py b/homeassistant/components/mqtt/config_integration.py index a6ed1dae54d..4a8532682fb 100644 --- a/homeassistant/components/mqtt/config_integration.py +++ b/homeassistant/components/mqtt/config_integration.py @@ -20,7 +20,6 @@ from . import ( number as number_platform, sensor as sensor_platform, update as update_platform, - water_heater as water_heater_platform, ) from .const import ( CONF_BIRTH_MESSAGE, @@ -76,10 +75,7 @@ CONFIG_SCHEMA_BASE = vol.Schema( [update_platform.PLATFORM_SCHEMA_MODERN], # type: ignore[has-type] ), Platform.VACUUM.value: vol.All(cv.ensure_list, [dict]), - Platform.WATER_HEATER.value: vol.All( - cv.ensure_list, - [water_heater_platform.PLATFORM_SCHEMA_MODERN], # type: ignore[has-type] - ), + Platform.WATER_HEATER.value: vol.All(cv.ensure_list, [dict]), } ) diff --git a/homeassistant/components/mqtt/water_heater.py b/homeassistant/components/mqtt/water_heater.py index 9a9326d6d07..99cc35f74a4 100644 --- a/homeassistant/components/mqtt/water_heater.py +++ b/homeassistant/components/mqtt/water_heater.py @@ -1,7 +1,6 @@ """Support for MQTT water heater devices.""" from __future__ import annotations -import functools import logging from typing import Any @@ -38,7 +37,7 @@ from homeassistant.core import HomeAssistant, callback import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.template import Template -from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType +from homeassistant.helpers.typing import ConfigType from homeassistant.util.unit_conversion import TemperatureConverter from .climate import MqttTemperatureControlEntity @@ -67,7 +66,7 @@ from .const import ( from .debug_info import log_messages from .mixins import ( MQTT_ENTITY_COMMON_SCHEMA, - async_setup_entry_helper, + async_mqtt_entry_helper, write_state_on_attr_change, ) from .models import MqttCommandTemplate, MqttValueTemplate, ReceiveMessage @@ -170,21 +169,15 @@ async def async_setup_entry( async_add_entities: AddEntitiesCallback, ) -> None: """Set up MQTT water heater device through YAML and through MQTT discovery.""" - setup = functools.partial( - _async_setup_entity, hass, async_add_entities, config_entry=config_entry + await async_mqtt_entry_helper( + hass, + config_entry, + MqttWaterHeater, + water_heater.DOMAIN, + async_add_entities, + DISCOVERY_SCHEMA, + PLATFORM_SCHEMA_MODERN, ) - await async_setup_entry_helper(hass, water_heater.DOMAIN, setup, DISCOVERY_SCHEMA) - - -async def _async_setup_entity( - hass: HomeAssistant, - async_add_entities: AddEntitiesCallback, - config: ConfigType, - config_entry: ConfigEntry, - discovery_data: DiscoveryInfoType | None = None, -) -> None: - """Set up the MQTT water heater devices.""" - async_add_entities([MqttWaterHeater(hass, config, config_entry, discovery_data)]) class MqttWaterHeater(MqttTemperatureControlEntity, WaterHeaterEntity):