Do not fail MQTT setup if lights configured via yaml can't be validated (#101649)
* Add light * Deduplicate code * Follow up comment
This commit is contained in:
parent
90687e9794
commit
d149bffb07
9 changed files with 107 additions and 166 deletions
|
@ -32,7 +32,6 @@ from homeassistant.components.light import (
|
|||
filter_supported_color_modes,
|
||||
valid_supported_color_modes,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
CONF_BRIGHTNESS,
|
||||
CONF_COLOR_TEMP,
|
||||
|
@ -44,12 +43,11 @@ from homeassistant.const import (
|
|||
CONF_XY,
|
||||
STATE_ON,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.core import callback
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.json import json_dumps
|
||||
from homeassistant.helpers.restore_state import RestoreEntity
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
import homeassistant.util.color as color_util
|
||||
from homeassistant.util.json import json_loads_object
|
||||
|
||||
|
@ -166,17 +164,6 @@ PLATFORM_SCHEMA_MODERN_JSON = vol.All(
|
|||
)
|
||||
|
||||
|
||||
async def async_setup_entity_json(
|
||||
hass: HomeAssistant,
|
||||
config: ConfigType,
|
||||
async_add_entities: AddEntitiesCallback,
|
||||
config_entry: ConfigEntry,
|
||||
discovery_data: DiscoveryInfoType | None,
|
||||
) -> None:
|
||||
"""Set up a MQTT JSON Light."""
|
||||
async_add_entities([MqttLightJson(hass, config, config_entry, discovery_data)])
|
||||
|
||||
|
||||
class MqttLightJson(MqttEntity, LightEntity, RestoreEntity):
|
||||
"""Representation of a MQTT JSON light."""
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue