Remove platform key and rename schema for mqtt device_automation (#101582)

Refactor mqtt device_automation
pull/101583/head
Jan Bouwhuis 2023-10-07 20:49:05 +02:00 committed by GitHub
parent f4ac2b7eeb
commit 9407c49819
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 4 deletions

View File

@ -7,7 +7,6 @@ import voluptuous as vol
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
from . import device_trigger
@ -19,17 +18,17 @@ AUTOMATION_TYPES = [AUTOMATION_TYPE_TRIGGER]
AUTOMATION_TYPES_SCHEMA = vol.In(AUTOMATION_TYPES)
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},
extra=vol.ALLOW_EXTRA,
).extend(MQTT_BASE_SCHEMA.schema)
)
async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> None:
"""Set up MQTT device automation dynamically through MQTT discovery."""
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(