From d18f1cc87265b9741c2ba1cae1a4256a58f02377 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20L=C3=B6vdahl?= Date: Tue, 28 Dec 2021 22:23:07 +0200 Subject: [PATCH] Use Platform constants all over the place 2/3 (#62953) --- homeassistant/components/ihc/__init__.py | 8 ++++- homeassistant/components/insteon/const.py | 6 ++-- homeassistant/components/kaiterra/const.py | 3 +- homeassistant/components/linode/__init__.py | 4 +-- homeassistant/components/lupusec/__init__.py | 14 +++++++-- homeassistant/components/lutron/__init__.py | 16 ++++++++-- homeassistant/components/min_max/__init__.py | 4 ++- homeassistant/components/motioneye/camera.py | 3 +- homeassistant/components/mqtt/__init__.py | 29 ++++++++++--------- .../components/nextcloud/__init__.py | 3 +- .../components/nissan_leaf/__init__.py | 4 +-- homeassistant/components/plex/const.py | 4 +-- homeassistant/components/point/__init__.py | 3 +- .../components/proxmoxve/__init__.py | 3 +- 14 files changed, 70 insertions(+), 34 deletions(-) diff --git a/homeassistant/components/ihc/__init__.py b/homeassistant/components/ihc/__init__.py index 3a75a841fde..1e59d06be82 100644 --- a/homeassistant/components/ihc/__init__.py +++ b/homeassistant/components/ihc/__init__.py @@ -17,6 +17,7 @@ from homeassistant.const import ( CONF_URL, CONF_USERNAME, TEMP_CELSIUS, + Platform, ) from homeassistant.core import HomeAssistant from homeassistant.helpers import discovery @@ -55,7 +56,12 @@ DOMAIN = "ihc" IHC_CONTROLLER = "controller" IHC_INFO = "info" -PLATFORMS = ("binary_sensor", "light", "sensor", "switch") +PLATFORMS = ( + Platform.BINARY_SENSOR, + Platform.LIGHT, + Platform.SENSOR, + Platform.SWITCH, +) def validate_name(config): diff --git a/homeassistant/components/insteon/const.py b/homeassistant/components/insteon/const.py index d93d03847a1..bc3eaf6234b 100644 --- a/homeassistant/components/insteon/const.py +++ b/homeassistant/components/insteon/const.py @@ -48,9 +48,9 @@ INSTEON_PLATFORMS = [ ] X10_PLATFORMS = [ - "binary_sensor", - "switch", - "light", + Platform.BINARY_SENSOR, + Platform.SWITCH, + Platform.LIGHT, ] CONF_IP_PORT = "ip_port" diff --git a/homeassistant/components/kaiterra/const.py b/homeassistant/components/kaiterra/const.py index f4cc5638c18..7fdfad36b15 100644 --- a/homeassistant/components/kaiterra/const.py +++ b/homeassistant/components/kaiterra/const.py @@ -8,6 +8,7 @@ from homeassistant.const import ( CONCENTRATION_PARTS_PER_BILLION, CONCENTRATION_PARTS_PER_MILLION, PERCENTAGE, + Platform, ) DOMAIN = "kaiterra" @@ -71,4 +72,4 @@ DEFAULT_AQI_STANDARD = "us" DEFAULT_PREFERRED_UNIT = [] DEFAULT_SCAN_INTERVAL = timedelta(seconds=30) -PLATFORMS = ["sensor", "air_quality"] +PLATFORMS = [Platform.SENSOR, Platform.AIR_QUALITY] diff --git a/homeassistant/components/linode/__init__.py b/homeassistant/components/linode/__init__.py index a18b63d7226..0a72768da7d 100644 --- a/homeassistant/components/linode/__init__.py +++ b/homeassistant/components/linode/__init__.py @@ -5,7 +5,7 @@ import logging import linode import voluptuous as vol -from homeassistant.const import CONF_ACCESS_TOKEN +from homeassistant.const import CONF_ACCESS_TOKEN, Platform import homeassistant.helpers.config_validation as cv from homeassistant.util import Throttle @@ -23,7 +23,7 @@ ATTR_VCPUS = "vcpus" CONF_NODES = "nodes" DATA_LINODE = "data_li" -LINODE_PLATFORMS = ["binary_sensor", "switch"] +LINODE_PLATFORMS = [Platform.BINARY_SENSOR, Platform.SWITCH] DOMAIN = "linode" MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=60) diff --git a/homeassistant/components/lupusec/__init__.py b/homeassistant/components/lupusec/__init__.py index 734c7affe90..54fbf98c9a1 100644 --- a/homeassistant/components/lupusec/__init__.py +++ b/homeassistant/components/lupusec/__init__.py @@ -6,7 +6,13 @@ import lupupy from lupupy.exceptions import LupusecException import voluptuous as vol -from homeassistant.const import CONF_IP_ADDRESS, CONF_NAME, CONF_PASSWORD, CONF_USERNAME +from homeassistant.const import ( + CONF_IP_ADDRESS, + CONF_NAME, + CONF_PASSWORD, + CONF_USERNAME, + Platform, +) from homeassistant.helpers import config_validation as cv, discovery from homeassistant.helpers.entity import Entity @@ -31,7 +37,11 @@ CONFIG_SCHEMA = vol.Schema( extra=vol.ALLOW_EXTRA, ) -LUPUSEC_PLATFORMS = ["alarm_control_panel", "binary_sensor", "switch"] +LUPUSEC_PLATFORMS = [ + Platform.ALARM_CONTROL_PANEL, + Platform.BINARY_SENSOR, + Platform.SWITCH, +] def setup(hass, config): diff --git a/homeassistant/components/lutron/__init__.py b/homeassistant/components/lutron/__init__.py index c0f378d19d7..c785e8ea46f 100644 --- a/homeassistant/components/lutron/__init__.py +++ b/homeassistant/components/lutron/__init__.py @@ -4,7 +4,13 @@ import logging from pylutron import Button, Lutron import voluptuous as vol -from homeassistant.const import ATTR_ID, CONF_HOST, CONF_PASSWORD, CONF_USERNAME +from homeassistant.const import ( + ATTR_ID, + CONF_HOST, + CONF_PASSWORD, + CONF_USERNAME, + Platform, +) from homeassistant.helpers import discovery import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entity import Entity @@ -12,7 +18,13 @@ from homeassistant.util import slugify DOMAIN = "lutron" -PLATFORMS = ["light", "cover", "switch", "scene", "binary_sensor"] +PLATFORMS = [ + Platform.LIGHT, + Platform.COVER, + Platform.SWITCH, + Platform.SCENE, + Platform.BINARY_SENSOR, +] _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/min_max/__init__.py b/homeassistant/components/min_max/__init__.py index 4baf96471aa..84b7c0a2cf5 100644 --- a/homeassistant/components/min_max/__init__.py +++ b/homeassistant/components/min_max/__init__.py @@ -1,4 +1,6 @@ """The min_max component.""" +from homeassistant.const import Platform + DOMAIN = "min_max" -PLATFORMS = ["sensor"] +PLATFORMS = [Platform.SENSOR] diff --git a/homeassistant/components/motioneye/camera.py b/homeassistant/components/motioneye/camera.py index 7d9be209c4e..b9b7f6d42c8 100644 --- a/homeassistant/components/motioneye/camera.py +++ b/homeassistant/components/motioneye/camera.py @@ -38,6 +38,7 @@ from homeassistant.const import ( CONF_USERNAME, HTTP_BASIC_AUTHENTICATION, HTTP_DIGEST_AUTHENTICATION, + Platform, ) from homeassistant.core import HomeAssistant, callback from homeassistant.helpers import config_validation as cv, entity_platform @@ -65,7 +66,7 @@ from .const import ( TYPE_MOTIONEYE_MJPEG_CAMERA, ) -PLATFORMS = ["camera"] +PLATFORMS = [Platform.CAMERA] SCHEMA_TEXT_OVERLAY = vol.In( [ diff --git a/homeassistant/components/mqtt/__init__.py b/homeassistant/components/mqtt/__init__.py index f909fd3745f..84bce798e6d 100644 --- a/homeassistant/components/mqtt/__init__.py +++ b/homeassistant/components/mqtt/__init__.py @@ -32,6 +32,7 @@ from homeassistant.const import ( CONF_VALUE_TEMPLATE, EVENT_HOMEASSISTANT_STARTED, EVENT_HOMEASSISTANT_STOP, + Platform, ) from homeassistant.core import ( CoreState, @@ -127,20 +128,20 @@ DISCOVERY_COOLDOWN = 2 TIMEOUT_ACK = 10 PLATFORMS = [ - "alarm_control_panel", - "binary_sensor", - "camera", - "climate", - "cover", - "fan", - "humidifier", - "light", - "lock", - "number", - "scene", - "sensor", - "switch", - "vacuum", + Platform.ALARM_CONTROL_PANEL, + Platform.BINARY_SENSOR, + Platform.CAMERA, + Platform.CLIMATE, + Platform.COVER, + Platform.FAN, + Platform.HUMIDIFIER, + Platform.LIGHT, + Platform.LOCK, + Platform.NUMBER, + Platform.SCENE, + Platform.SENSOR, + Platform.SWITCH, + Platform.VACUUM, ] diff --git a/homeassistant/components/nextcloud/__init__.py b/homeassistant/components/nextcloud/__init__.py index efa5b2e2f32..6af67505e14 100644 --- a/homeassistant/components/nextcloud/__init__.py +++ b/homeassistant/components/nextcloud/__init__.py @@ -10,6 +10,7 @@ from homeassistant.const import ( CONF_SCAN_INTERVAL, CONF_URL, CONF_USERNAME, + Platform, ) from homeassistant.helpers import config_validation as cv, discovery from homeassistant.helpers.event import track_time_interval @@ -17,7 +18,7 @@ from homeassistant.helpers.event import track_time_interval _LOGGER = logging.getLogger(__name__) DOMAIN = "nextcloud" -PLATFORMS = ("sensor", "binary_sensor") +PLATFORMS = (Platform.SENSOR, Platform.BINARY_SENSOR) SCAN_INTERVAL = timedelta(seconds=60) # Validate user configuration diff --git a/homeassistant/components/nissan_leaf/__init__.py b/homeassistant/components/nissan_leaf/__init__.py index d450eaf7dad..46e1e9bb7a6 100644 --- a/homeassistant/components/nissan_leaf/__init__.py +++ b/homeassistant/components/nissan_leaf/__init__.py @@ -8,7 +8,7 @@ import sys from pycarwings2 import CarwingsError, Session import voluptuous as vol -from homeassistant.const import CONF_PASSWORD, CONF_REGION, CONF_USERNAME +from homeassistant.const import CONF_PASSWORD, CONF_REGION, CONF_USERNAME, Platform from homeassistant.core import callback import homeassistant.helpers.config_validation as cv from homeassistant.helpers.discovery import load_platform @@ -82,7 +82,7 @@ CONFIG_SCHEMA = vol.Schema( extra=vol.ALLOW_EXTRA, ) -PLATFORMS = ["sensor", "switch", "binary_sensor"] +PLATFORMS = [Platform.SENSOR, Platform.SWITCH, Platform.BINARY_SENSOR] SIGNAL_UPDATE_LEAF = "nissan_leaf_update" diff --git a/homeassistant/components/plex/const.py b/homeassistant/components/plex/const.py index e247f7a5db7..ce28357a4b1 100644 --- a/homeassistant/components/plex/const.py +++ b/homeassistant/components/plex/const.py @@ -1,5 +1,5 @@ """Constants for the Plex component.""" -from homeassistant.const import __version__ +from homeassistant.const import Platform, __version__ DOMAIN = "plex" NAME_FORMAT = "Plex ({})" @@ -16,7 +16,7 @@ DEBOUNCE_TIMEOUT = 1 DISPATCHERS = "dispatchers" GDM_DEBOUNCER = "gdm_debouncer" GDM_SCANNER = "gdm_scanner" -PLATFORMS = frozenset(["media_player", "sensor"]) +PLATFORMS = frozenset([Platform.MEDIA_PLAYER, Platform.SENSOR]) PLATFORMS_COMPLETED = "platforms_completed" PLAYER_SOURCE = "player_source" SERVERS = "servers" diff --git a/homeassistant/components/point/__init__.py b/homeassistant/components/point/__init__.py index 5cbab59eabf..9bfd70d4d8d 100644 --- a/homeassistant/components/point/__init__.py +++ b/homeassistant/components/point/__init__.py @@ -13,6 +13,7 @@ from homeassistant.const import ( CONF_CLIENT_SECRET, CONF_TOKEN, CONF_WEBHOOK_ID, + Platform, ) from homeassistant.core import HomeAssistant from homeassistant.exceptions import ConfigEntryNotReady @@ -41,7 +42,7 @@ _LOGGER = logging.getLogger(__name__) DATA_CONFIG_ENTRY_LOCK = "point_config_entry_lock" CONFIG_ENTRY_IS_SETUP = "point_config_entry_is_setup" -PLATFORMS = ["binary_sensor", "sensor"] +PLATFORMS = [Platform.BINARY_SENSOR, Platform.SENSOR] CONFIG_SCHEMA = vol.Schema( { diff --git a/homeassistant/components/proxmoxve/__init__.py b/homeassistant/components/proxmoxve/__init__.py index 089e028afd1..d10e64772ae 100644 --- a/homeassistant/components/proxmoxve/__init__.py +++ b/homeassistant/components/proxmoxve/__init__.py @@ -17,6 +17,7 @@ from homeassistant.const import ( CONF_PORT, CONF_USERNAME, CONF_VERIFY_SSL, + Platform, ) from homeassistant.core import HomeAssistant import homeassistant.helpers.config_validation as cv @@ -26,7 +27,7 @@ from homeassistant.helpers.update_coordinator import ( DataUpdateCoordinator, ) -PLATFORMS = ["binary_sensor"] +PLATFORMS = [Platform.BINARY_SENSOR] DOMAIN = "proxmoxve" PROXMOX_CLIENTS = "proxmox_clients" CONF_REALM = "realm"