Do not fail MQTT setup if water heaters configured via yaml can't be validated (#102326)

This commit is contained in:
Jan Bouwhuis 2023-10-20 08:15:09 +02:00 committed by GitHub
parent 38a0d31edb
commit c7b1e4186b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 22 deletions

View file

@ -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]),
}
)

View file

@ -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):