From bd450ee9ffdb7e7aa765070a1c86118cde6f9e1b Mon Sep 17 00:00:00 2001 From: Rohan Kapoor Date: Mon, 15 Oct 2018 02:18:21 -0700 Subject: [PATCH] Migrate CONF_WEBHOOK_ID to homeassistant.const (#17460) * Migrate CONF_WEBHOOK_ID to homeassistant.const * Switch over all instances of webhook_id to the const * Switch last instance of webhook_id to the const * automation: conf constants for conf * webhook: conf constants for conf --- homeassistant/components/automation/webhook.py | 3 +-- homeassistant/components/ifttt/__init__.py | 6 +++--- homeassistant/const.py | 1 + 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/automation/webhook.py b/homeassistant/components/automation/webhook.py index 2c9c331cdc5..345b0fe3249 100644 --- a/homeassistant/components/automation/webhook.py +++ b/homeassistant/components/automation/webhook.py @@ -11,13 +11,12 @@ from aiohttp import hdrs import voluptuous as vol from homeassistant.core import callback -from homeassistant.const import CONF_PLATFORM +from homeassistant.const import CONF_PLATFORM, CONF_WEBHOOK_ID import homeassistant.helpers.config_validation as cv DEPENDENCIES = ('webhook',) _LOGGER = logging.getLogger(__name__) -CONF_WEBHOOK_ID = 'webhook_id' TRIGGER_SCHEMA = vol.Schema({ vol.Required(CONF_PLATFORM): 'webhook', diff --git a/homeassistant/components/ifttt/__init__.py b/homeassistant/components/ifttt/__init__.py index 60748d6ff13..76f01ad0aca 100644 --- a/homeassistant/components/ifttt/__init__.py +++ b/homeassistant/components/ifttt/__init__.py @@ -14,6 +14,7 @@ import voluptuous as vol import homeassistant.helpers.config_validation as cv from homeassistant import config_entries +from homeassistant.const import CONF_WEBHOOK_ID from homeassistant.util.network import is_local REQUIREMENTS = ['pyfttt==0.3'] @@ -29,7 +30,6 @@ ATTR_VALUE2 = 'value2' ATTR_VALUE3 = 'value3' CONF_KEY = 'key' -CONF_WEBHOOK_ID = 'webhook_id' DOMAIN = 'ifttt' @@ -91,13 +91,13 @@ async def handle_webhook(hass, webhook_id, request): async def async_setup_entry(hass, entry): """Configure based on config entry.""" hass.components.webhook.async_register( - entry.data['webhook_id'], handle_webhook) + entry.data[CONF_WEBHOOK_ID], handle_webhook) return True async def async_unload_entry(hass, entry): """Unload a config entry.""" - hass.components.webhook.async_unregister(entry.data['webhook_id']) + hass.components.webhook.async_unregister(entry.data[CONF_WEBHOOK_ID]) return True diff --git a/homeassistant/const.py b/homeassistant/const.py index 361299181ac..c01a435ca85 100644 --- a/homeassistant/const.py +++ b/homeassistant/const.py @@ -146,6 +146,7 @@ CONF_URL = 'url' CONF_USERNAME = 'username' CONF_VALUE_TEMPLATE = 'value_template' CONF_VERIFY_SSL = 'verify_ssl' +CONF_WEBHOOK_ID = 'webhook_id' CONF_WEEKDAY = 'weekday' CONF_WHITELIST = 'whitelist' CONF_WHITELIST_EXTERNAL_DIRS = 'whitelist_external_dirs'