mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 08:47:10 +00:00
Do not fail MQTT setup if lawn mowers configured via yaml can't be validated (#102314)
This commit is contained in:
parent
e6d9f89991
commit
dcdd4b470c
@ -18,7 +18,6 @@ from . import (
|
||||
button as button_platform,
|
||||
cover as cover_platform,
|
||||
event as event_platform,
|
||||
lawn_mower as lawn_mower_platform,
|
||||
number as number_platform,
|
||||
sensor as sensor_platform,
|
||||
update as update_platform,
|
||||
@ -60,10 +59,7 @@ CONFIG_SCHEMA_BASE = vol.Schema(
|
||||
Platform.FAN.value: vol.All(cv.ensure_list, [dict]),
|
||||
Platform.HUMIDIFIER.value: vol.All(cv.ensure_list, [dict]),
|
||||
Platform.IMAGE.value: vol.All(cv.ensure_list, [dict]),
|
||||
Platform.LAWN_MOWER.value: vol.All(
|
||||
cv.ensure_list,
|
||||
[lawn_mower_platform.PLATFORM_SCHEMA_MODERN], # type: ignore[has-type]
|
||||
),
|
||||
Platform.LAWN_MOWER.value: vol.All(cv.ensure_list, [dict]),
|
||||
Platform.LIGHT.value: vol.All(cv.ensure_list, [dict]),
|
||||
Platform.LOCK.value: vol.All(cv.ensure_list, [dict]),
|
||||
Platform.NUMBER.value: vol.All(
|
||||
|
@ -3,7 +3,6 @@ from __future__ import annotations
|
||||
|
||||
from collections.abc import Callable
|
||||
import contextlib
|
||||
import functools
|
||||
import logging
|
||||
|
||||
import voluptuous as vol
|
||||
@ -20,7 +19,7 @@ from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers import config_validation as cv
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.restore_state import RestoreEntity
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
|
||||
from . import subscription
|
||||
from .config import MQTT_BASE_SCHEMA
|
||||
@ -35,7 +34,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 (
|
||||
@ -92,21 +91,15 @@ async def async_setup_entry(
|
||||
async_add_entities: AddEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up MQTT lawn mower 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,
|
||||
MqttLawnMower,
|
||||
lawn_mower.DOMAIN,
|
||||
async_add_entities,
|
||||
DISCOVERY_SCHEMA,
|
||||
PLATFORM_SCHEMA_MODERN,
|
||||
)
|
||||
await async_setup_entry_helper(hass, lawn_mower.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 lawn mower."""
|
||||
async_add_entities([MqttLawnMower(hass, config, config_entry, discovery_data)])
|
||||
|
||||
|
||||
class MqttLawnMower(MqttEntity, LawnMowerEntity, RestoreEntity):
|
||||
|
Loading…
x
Reference in New Issue
Block a user