From 53f4a3d8bcadfee2b6528961cc01a7a9769d6518 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20L=C3=B6vdahl?= Date: Tue, 28 Dec 2021 22:24:27 +0200 Subject: [PATCH] Use Platform constants all over the place 3/3 (#62954) --- homeassistant/components/rest/__init__.py | 9 ++++++- homeassistant/components/rpi_gpio/__init__.py | 12 +++++++-- homeassistant/components/smtp/__init__.py | 4 ++- .../components/statistics/__init__.py | 4 ++- .../components/streamlabswater/__init__.py | 4 +-- homeassistant/components/telegram/__init__.py | 4 ++- homeassistant/components/template/const.py | 26 ++++++++++--------- homeassistant/components/trend/__init__.py | 4 ++- homeassistant/components/velux/__init__.py | 9 +++++-- homeassistant/components/vesync/__init__.py | 2 +- homeassistant/components/vultr/__init__.py | 4 +-- homeassistant/components/xs1/__init__.py | 3 ++- 12 files changed, 58 insertions(+), 27 deletions(-) diff --git a/homeassistant/components/rest/__init__.py b/homeassistant/components/rest/__init__.py index fc07d5c9b67..f8e6941572a 100644 --- a/homeassistant/components/rest/__init__.py +++ b/homeassistant/components/rest/__init__.py @@ -23,6 +23,7 @@ from homeassistant.const import ( CONF_VERIFY_SSL, HTTP_DIGEST_AUTHENTICATION, SERVICE_RELOAD, + Platform, ) from homeassistant.core import HomeAssistant, ServiceCall, callback from homeassistant.helpers import discovery, template @@ -40,7 +41,13 @@ from .schema import CONFIG_SCHEMA # noqa: F401 _LOGGER = logging.getLogger(__name__) -PLATFORMS = ["binary_sensor", "notify", "sensor", "switch"] +PLATFORMS = [ + Platform.BINARY_SENSOR, + Platform.NOTIFY, + Platform.SENSOR, + Platform.SWITCH, +] + COORDINATOR_AWARE_PLATFORMS = [SENSOR_DOMAIN, BINARY_SENSOR_DOMAIN] diff --git a/homeassistant/components/rpi_gpio/__init__.py b/homeassistant/components/rpi_gpio/__init__.py index 75aa5bccdb6..b8f8bed05a6 100644 --- a/homeassistant/components/rpi_gpio/__init__.py +++ b/homeassistant/components/rpi_gpio/__init__.py @@ -1,10 +1,18 @@ """Support for controlling GPIO pins of a Raspberry Pi.""" from RPi import GPIO # pylint: disable=import-error -from homeassistant.const import EVENT_HOMEASSISTANT_START, EVENT_HOMEASSISTANT_STOP +from homeassistant.const import ( + EVENT_HOMEASSISTANT_START, + EVENT_HOMEASSISTANT_STOP, + Platform, +) DOMAIN = "rpi_gpio" -PLATFORMS = ["binary_sensor", "cover", "switch"] +PLATFORMS = [ + Platform.BINARY_SENSOR, + Platform.COVER, + Platform.SWITCH, +] def setup(hass, config): diff --git a/homeassistant/components/smtp/__init__.py b/homeassistant/components/smtp/__init__.py index 7461dd2b6c3..abf54efdd9d 100644 --- a/homeassistant/components/smtp/__init__.py +++ b/homeassistant/components/smtp/__init__.py @@ -1,4 +1,6 @@ """The smtp component.""" +from homeassistant.const import Platform + DOMAIN = "smtp" -PLATFORMS = ["notify"] +PLATFORMS = [Platform.NOTIFY] diff --git a/homeassistant/components/statistics/__init__.py b/homeassistant/components/statistics/__init__.py index ce5f959d731..a6419c2fb4d 100644 --- a/homeassistant/components/statistics/__init__.py +++ b/homeassistant/components/statistics/__init__.py @@ -1,4 +1,6 @@ """The statistics component.""" +from homeassistant.const import Platform + DOMAIN = "statistics" -PLATFORMS = ["sensor"] +PLATFORMS = [Platform.SENSOR] diff --git a/homeassistant/components/streamlabswater/__init__.py b/homeassistant/components/streamlabswater/__init__.py index 0a49e128c2f..a802cb39252 100644 --- a/homeassistant/components/streamlabswater/__init__.py +++ b/homeassistant/components/streamlabswater/__init__.py @@ -4,7 +4,7 @@ import logging from streamlabswater import streamlabswater import voluptuous as vol -from homeassistant.const import CONF_API_KEY +from homeassistant.const import CONF_API_KEY, Platform from homeassistant.helpers import discovery import homeassistant.helpers.config_validation as cv @@ -17,7 +17,7 @@ SERVICE_SET_AWAY_MODE = "set_away_mode" AWAY_MODE_AWAY = "away" AWAY_MODE_HOME = "home" -PLATFORMS = ["sensor", "binary_sensor"] +PLATFORMS = [Platform.SENSOR, Platform.BINARY_SENSOR] CONF_LOCATION_ID = "location_id" diff --git a/homeassistant/components/telegram/__init__.py b/homeassistant/components/telegram/__init__.py index 43a639cb2c3..fe0b8d98530 100644 --- a/homeassistant/components/telegram/__init__.py +++ b/homeassistant/components/telegram/__init__.py @@ -1,4 +1,6 @@ """The telegram component.""" +from homeassistant.const import Platform + DOMAIN = "telegram" -PLATFORMS = ["notify"] +PLATFORMS = [Platform.NOTIFY] diff --git a/homeassistant/components/template/const.py b/homeassistant/components/template/const.py index 9dfbe4a11d9..1b36628a677 100644 --- a/homeassistant/components/template/const.py +++ b/homeassistant/components/template/const.py @@ -1,5 +1,7 @@ """Constants for the Template Platform Components.""" +from homeassistant.const import Platform + CONF_AVAILABILITY_TEMPLATE = "availability_template" CONF_ATTRIBUTE_TEMPLATES = "attribute_templates" CONF_TRIGGER = "trigger" @@ -9,18 +11,18 @@ DOMAIN = "template" PLATFORM_STORAGE_KEY = "template_platforms" PLATFORMS = [ - "alarm_control_panel", - "binary_sensor", - "cover", - "fan", - "light", - "lock", - "number", - "select", - "sensor", - "switch", - "vacuum", - "weather", + Platform.ALARM_CONTROL_PANEL, + Platform.BINARY_SENSOR, + Platform.COVER, + Platform.FAN, + Platform.LIGHT, + Platform.LOCK, + Platform.NUMBER, + Platform.SELECT, + Platform.SENSOR, + Platform.SWITCH, + Platform.VACUUM, + Platform.WEATHER, ] CONF_AVAILABILITY = "availability" diff --git a/homeassistant/components/trend/__init__.py b/homeassistant/components/trend/__init__.py index 12ce7fdfe49..a56bb00d97b 100644 --- a/homeassistant/components/trend/__init__.py +++ b/homeassistant/components/trend/__init__.py @@ -1,4 +1,6 @@ """A sensor that monitors trends in other components.""" +from homeassistant.const import Platform + DOMAIN = "trend" -PLATFORMS = ["binary_sensor"] +PLATFORMS = [Platform.BINARY_SENSOR] diff --git a/homeassistant/components/velux/__init__.py b/homeassistant/components/velux/__init__.py index e763a7003d5..630414c1020 100644 --- a/homeassistant/components/velux/__init__.py +++ b/homeassistant/components/velux/__init__.py @@ -4,7 +4,12 @@ import logging from pyvlx import PyVLX, PyVLXException import voluptuous as vol -from homeassistant.const import CONF_HOST, CONF_PASSWORD, EVENT_HOMEASSISTANT_STOP +from homeassistant.const import ( + CONF_HOST, + CONF_PASSWORD, + EVENT_HOMEASSISTANT_STOP, + Platform, +) from homeassistant.core import ServiceCall, callback from homeassistant.helpers import discovery import homeassistant.helpers.config_validation as cv @@ -12,7 +17,7 @@ from homeassistant.helpers.entity import Entity DOMAIN = "velux" DATA_VELUX = "data_velux" -PLATFORMS = ["cover", "light", "scene"] +PLATFORMS = [Platform.COVER, Platform.LIGHT, Platform.SCENE] _LOGGER = logging.getLogger(__name__) CONFIG_SCHEMA = vol.Schema( diff --git a/homeassistant/components/vesync/__init__.py b/homeassistant/components/vesync/__init__.py index 41de93da092..459c52df421 100644 --- a/homeassistant/components/vesync/__init__.py +++ b/homeassistant/components/vesync/__init__.py @@ -20,7 +20,7 @@ from .const import ( VS_SWITCHES, ) -PLATFORMS = ["switch", "fan", "light"] +PLATFORMS = [Platform.SWITCH, Platform.FAN, Platform.LIGHT] _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/vultr/__init__.py b/homeassistant/components/vultr/__init__.py index 9b26c4a75b3..4ee261cda81 100644 --- a/homeassistant/components/vultr/__init__.py +++ b/homeassistant/components/vultr/__init__.py @@ -5,7 +5,7 @@ import logging import voluptuous as vol from vultr import Vultr as VultrAPI -from homeassistant.const import CONF_API_KEY +from homeassistant.const import CONF_API_KEY, Platform import homeassistant.helpers.config_validation as cv from homeassistant.util import Throttle @@ -35,7 +35,7 @@ DOMAIN = "vultr" NOTIFICATION_ID = "vultr_notification" NOTIFICATION_TITLE = "Vultr Setup" -VULTR_PLATFORMS = ["binary_sensor", "sensor", "switch"] +VULTR_PLATFORMS = [Platform.BINARY_SENSOR, Platform.SENSOR, Platform.SWITCH] MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=60) diff --git a/homeassistant/components/xs1/__init__.py b/homeassistant/components/xs1/__init__.py index 1d65b2bcfd1..a0c3fa3a36a 100644 --- a/homeassistant/components/xs1/__init__.py +++ b/homeassistant/components/xs1/__init__.py @@ -11,6 +11,7 @@ from homeassistant.const import ( CONF_PORT, CONF_SSL, CONF_USERNAME, + Platform, ) from homeassistant.helpers import discovery import homeassistant.helpers.config_validation as cv @@ -38,7 +39,7 @@ CONFIG_SCHEMA = vol.Schema( extra=vol.ALLOW_EXTRA, ) -PLATFORMS = ["climate", "sensor", "switch"] +PLATFORMS = [Platform.CLIMATE, Platform.SENSOR, Platform.SWITCH] # Lock used to limit the amount of concurrent update requests # as the XS1 Gateway can only handle a very