diff --git a/homeassistant/components/mqtt/config_integration.py b/homeassistant/components/mqtt/config_integration.py index a691197092d..4fb53db1031 100644 --- a/homeassistant/components/mqtt/config_integration.py +++ b/homeassistant/components/mqtt/config_integration.py @@ -19,7 +19,6 @@ from . import ( cover as cover_platform, event as event_platform, lawn_mower as lawn_mower_platform, - lock as lock_platform, number as number_platform, sensor as sensor_platform, update as update_platform, @@ -66,10 +65,7 @@ CONFIG_SCHEMA_BASE = vol.Schema( [lawn_mower_platform.PLATFORM_SCHEMA_MODERN], # type: ignore[has-type] ), Platform.LIGHT.value: vol.All(cv.ensure_list, [dict]), - Platform.LOCK.value: vol.All( - cv.ensure_list, - [lock_platform.PLATFORM_SCHEMA_MODERN], # type: ignore[has-type] - ), + Platform.LOCK.value: vol.All(cv.ensure_list, [dict]), Platform.NUMBER.value: vol.All( cv.ensure_list, [number_platform.PLATFORM_SCHEMA_MODERN], # type: ignore[has-type] diff --git a/homeassistant/components/mqtt/lock.py b/homeassistant/components/mqtt/lock.py index 9a0ce2077f3..f6177d94410 100644 --- a/homeassistant/components/mqtt/lock.py +++ b/homeassistant/components/mqtt/lock.py @@ -2,7 +2,6 @@ from __future__ import annotations from collections.abc import Callable -import functools import re from typing import Any @@ -20,7 +19,7 @@ from homeassistant.const import ( from homeassistant.core import HomeAssistant, callback import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entity_platform import AddEntitiesCallback -from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType, TemplateVarsType +from homeassistant.helpers.typing import ConfigType, TemplateVarsType from . import subscription from .config import MQTT_RW_SCHEMA @@ -37,7 +36,7 @@ from .debug_info import log_messages from .mixins import ( MQTT_ENTITY_COMMON_SCHEMA, MqttEntity, - async_setup_entry_helper, + async_mqtt_entry_helper, write_state_on_attr_change, ) from .models import ( @@ -113,21 +112,15 @@ async def async_setup_entry( async_add_entities: AddEntitiesCallback, ) -> None: """Set up MQTT lock 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, + MqttLock, + lock.DOMAIN, + async_add_entities, + DISCOVERY_SCHEMA, + PLATFORM_SCHEMA_MODERN, ) - await async_setup_entry_helper(hass, lock.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 Lock platform.""" - async_add_entities([MqttLock(hass, config, config_entry, discovery_data)]) class MqttLock(MqttEntity, LockEntity):