mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 14:17:45 +00:00
Remove platform key and rename schema for mqtt device_automation (#101582)
Refactor mqtt device_automation
This commit is contained in:
parent
f4ac2b7eeb
commit
9407c49819
@ -7,7 +7,6 @@ import voluptuous as vol
|
|||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
import homeassistant.helpers.config_validation as cv
|
|
||||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||||
|
|
||||||
from . import device_trigger
|
from . import device_trigger
|
||||||
@ -19,17 +18,17 @@ AUTOMATION_TYPES = [AUTOMATION_TYPE_TRIGGER]
|
|||||||
AUTOMATION_TYPES_SCHEMA = vol.In(AUTOMATION_TYPES)
|
AUTOMATION_TYPES_SCHEMA = vol.In(AUTOMATION_TYPES)
|
||||||
CONF_AUTOMATION_TYPE = "automation_type"
|
CONF_AUTOMATION_TYPE = "automation_type"
|
||||||
|
|
||||||
PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA.extend(
|
DISCOVERY_SCHEMA = MQTT_BASE_SCHEMA.extend(
|
||||||
{vol.Required(CONF_AUTOMATION_TYPE): AUTOMATION_TYPES_SCHEMA},
|
{vol.Required(CONF_AUTOMATION_TYPE): AUTOMATION_TYPES_SCHEMA},
|
||||||
extra=vol.ALLOW_EXTRA,
|
extra=vol.ALLOW_EXTRA,
|
||||||
).extend(MQTT_BASE_SCHEMA.schema)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> None:
|
async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> None:
|
||||||
"""Set up MQTT device automation dynamically through MQTT discovery."""
|
"""Set up MQTT device automation dynamically through MQTT discovery."""
|
||||||
|
|
||||||
setup = functools.partial(_async_setup_automation, hass, config_entry=config_entry)
|
setup = functools.partial(_async_setup_automation, hass, config_entry=config_entry)
|
||||||
await async_setup_entry_helper(hass, "device_automation", setup, PLATFORM_SCHEMA)
|
await async_setup_entry_helper(hass, "device_automation", setup, DISCOVERY_SCHEMA)
|
||||||
|
|
||||||
|
|
||||||
async def _async_setup_automation(
|
async def _async_setup_automation(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user