Do not fail MQTT setup if water heaters configured via yaml can't be validated (#102326)
This commit is contained in:
parent
38a0d31edb
commit
c7b1e4186b
2 changed files with 11 additions and 22 deletions
|
@ -20,7 +20,6 @@ from . import (
|
||||||
number as number_platform,
|
number as number_platform,
|
||||||
sensor as sensor_platform,
|
sensor as sensor_platform,
|
||||||
update as update_platform,
|
update as update_platform,
|
||||||
water_heater as water_heater_platform,
|
|
||||||
)
|
)
|
||||||
from .const import (
|
from .const import (
|
||||||
CONF_BIRTH_MESSAGE,
|
CONF_BIRTH_MESSAGE,
|
||||||
|
@ -76,10 +75,7 @@ CONFIG_SCHEMA_BASE = vol.Schema(
|
||||||
[update_platform.PLATFORM_SCHEMA_MODERN], # type: ignore[has-type]
|
[update_platform.PLATFORM_SCHEMA_MODERN], # type: ignore[has-type]
|
||||||
),
|
),
|
||||||
Platform.VACUUM.value: vol.All(cv.ensure_list, [dict]),
|
Platform.VACUUM.value: vol.All(cv.ensure_list, [dict]),
|
||||||
Platform.WATER_HEATER.value: vol.All(
|
Platform.WATER_HEATER.value: vol.All(cv.ensure_list, [dict]),
|
||||||
cv.ensure_list,
|
|
||||||
[water_heater_platform.PLATFORM_SCHEMA_MODERN], # type: ignore[has-type]
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
"""Support for MQTT water heater devices."""
|
"""Support for MQTT water heater devices."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import functools
|
|
||||||
import logging
|
import logging
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
|
@ -38,7 +37,7 @@ from homeassistant.core import HomeAssistant, callback
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.template import Template
|
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 homeassistant.util.unit_conversion import TemperatureConverter
|
||||||
|
|
||||||
from .climate import MqttTemperatureControlEntity
|
from .climate import MqttTemperatureControlEntity
|
||||||
|
@ -67,7 +66,7 @@ from .const import (
|
||||||
from .debug_info import log_messages
|
from .debug_info import log_messages
|
||||||
from .mixins import (
|
from .mixins import (
|
||||||
MQTT_ENTITY_COMMON_SCHEMA,
|
MQTT_ENTITY_COMMON_SCHEMA,
|
||||||
async_setup_entry_helper,
|
async_mqtt_entry_helper,
|
||||||
write_state_on_attr_change,
|
write_state_on_attr_change,
|
||||||
)
|
)
|
||||||
from .models import MqttCommandTemplate, MqttValueTemplate, ReceiveMessage
|
from .models import MqttCommandTemplate, MqttValueTemplate, ReceiveMessage
|
||||||
|
@ -170,21 +169,15 @@ async def async_setup_entry(
|
||||||
async_add_entities: AddEntitiesCallback,
|
async_add_entities: AddEntitiesCallback,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up MQTT water heater device through YAML and through MQTT discovery."""
|
"""Set up MQTT water heater device through YAML and through MQTT discovery."""
|
||||||
setup = functools.partial(
|
await async_mqtt_entry_helper(
|
||||||
_async_setup_entity, hass, async_add_entities, config_entry=config_entry
|
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):
|
class MqttWaterHeater(MqttTemperatureControlEntity, WaterHeaterEntity):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue