diff --git a/homeassistant/components/tado/__init__.py b/homeassistant/components/tado/__init__.py index 8bb9b72f1174d..6858f49799a03 100644 --- a/homeassistant/components/tado/__init__.py +++ b/homeassistant/components/tado/__init__.py @@ -9,7 +9,7 @@ from homeassistant.components.climate.const import PRESET_AWAY, PRESET_HOME from homeassistant.config_entries import ConfigEntry -from homeassistant.const import CONF_PASSWORD, CONF_USERNAME +from homeassistant.const import CONF_PASSWORD, CONF_USERNAME, Platform from homeassistant.core import HomeAssistant, callback from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.helpers import config_validation as cv @@ -31,7 +31,12 @@ _LOGGER = logging.getLogger(__name__) -PLATFORMS = ["binary_sensor", "sensor", "climate", "water_heater"] +PLATFORMS = [ + Platform.BINARY_SENSOR, + Platform.CLIMATE, + Platform.SENSOR, + Platform.WATER_HEATER, +] MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=4) SCAN_INTERVAL = timedelta(minutes=5) diff --git a/homeassistant/components/tailscale/__init__.py b/homeassistant/components/tailscale/__init__.py index 72a0ef49fc06e..b23eea7a06c4d 100644 --- a/homeassistant/components/tailscale/__init__.py +++ b/homeassistant/components/tailscale/__init__.py @@ -3,9 +3,8 @@ from tailscale import Device as TailscaleDevice -from homeassistant.components.binary_sensor import DOMAIN as BINARY_SENSOR_DOMAIN -from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN from homeassistant.config_entries import ConfigEntry +from homeassistant.const import Platform from homeassistant.core import HomeAssistant from homeassistant.helpers.device_registry import DeviceEntryType from homeassistant.helpers.entity import DeviceInfo, EntityDescription @@ -17,7 +16,7 @@ from .const import DOMAIN from .coordinator import TailscaleDataUpdateCoordinator -PLATFORMS = (BINARY_SENSOR_DOMAIN, SENSOR_DOMAIN) +PLATFORMS = [Platform.BINARY_SENSOR, Platform.SENSOR] async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: diff --git a/homeassistant/components/tesla_wall_connector/__init__.py b/homeassistant/components/tesla_wall_connector/__init__.py index 78ae232d49345..742b0a34b177d 100644 --- a/homeassistant/components/tesla_wall_connector/__init__.py +++ b/homeassistant/components/tesla_wall_connector/__init__.py @@ -15,7 +15,7 @@ ) from homeassistant.config_entries import ConfigEntry -from homeassistant.const import CONF_HOST, CONF_SCAN_INTERVAL +from homeassistant.const import CONF_HOST, CONF_SCAN_INTERVAL, Platform from homeassistant.core import HomeAssistant from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.helpers.aiohttp_client import async_get_clientsession @@ -34,7 +34,7 @@ WALLCONNECTOR_DEVICE_NAME, ) -PLATFORMS: list[str] = ["binary_sensor", "sensor"] +PLATFORMS: list[Platform] = [Platform.BINARY_SENSOR, Platform.SENSOR] _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/tibber/__init__.py b/homeassistant/components/tibber/__init__.py index da94df55c885a..3b71a40b0932b 100644 --- a/homeassistant/components/tibber/__init__.py +++ b/homeassistant/components/tibber/__init__.py @@ -5,7 +5,12 @@ import aiohttp import tibber -from homeassistant.const import CONF_ACCESS_TOKEN, CONF_NAME, EVENT_HOMEASSISTANT_STOP +from homeassistant.const import ( + CONF_ACCESS_TOKEN, + CONF_NAME, + EVENT_HOMEASSISTANT_STOP, + Platform, +) from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.helpers import discovery from homeassistant.helpers.aiohttp_client import async_get_clientsession @@ -14,9 +19,7 @@ from .const import DATA_HASS_CONFIG, DOMAIN -PLATFORMS = [ - "sensor", -] +PLATFORMS = [Platform.SENSOR] CONFIG_SCHEMA = cv.deprecated(DOMAIN) diff --git a/homeassistant/components/tile/__init__.py b/homeassistant/components/tile/__init__.py index 75bf306a98b82..388ffbff7fd7c 100644 --- a/homeassistant/components/tile/__init__.py +++ b/homeassistant/components/tile/__init__.py @@ -9,7 +9,7 @@ from pytile.tile import Tile from homeassistant.config_entries import ConfigEntry -from homeassistant.const import CONF_PASSWORD, CONF_USERNAME +from homeassistant.const import CONF_PASSWORD, CONF_USERNAME, Platform from homeassistant.core import HomeAssistant, callback from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.helpers import aiohttp_client @@ -19,7 +19,7 @@ from .const import DATA_COORDINATOR, DATA_TILE, DOMAIN, LOGGER -PLATFORMS = ["device_tracker"] +PLATFORMS = [Platform.DEVICE_TRACKER] DEVICE_TYPES = ["PHONE", "TILE"] DEFAULT_INIT_TASK_LIMIT = 2 diff --git a/homeassistant/components/tolo/__init__.py b/homeassistant/components/tolo/__init__.py index 4f41303c8f859..6e95089ccbea2 100644 --- a/homeassistant/components/tolo/__init__.py +++ b/homeassistant/components/tolo/__init__.py @@ -11,7 +11,7 @@ from tololib.message_info import SettingsInfo, StatusInfo from homeassistant.config_entries import ConfigEntry -from homeassistant.const import CONF_HOST +from homeassistant.const import CONF_HOST, Platform from homeassistant.core import HomeAssistant from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.update_coordinator import ( @@ -23,13 +23,13 @@ from .const import DEFAULT_RETRY_COUNT, DEFAULT_RETRY_TIMEOUT, DOMAIN PLATFORMS = [ - "binary_sensor", - "button", - "climate", - "fan", - "light", - "select", - "sensor", + Platform.BINARY_SENSOR, + Platform.BUTTON, + Platform.CLIMATE, + Platform.FAN, + Platform.LIGHT, + Platform.SELECT, + Platform.SENSOR, ] _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/toon/__init__.py b/homeassistant/components/toon/__init__.py index 372eeb47096b6..7d442130130ca 100644 --- a/homeassistant/components/toon/__init__.py +++ b/homeassistant/components/toon/__init__.py @@ -2,16 +2,13 @@ import voluptuous as vol -from homeassistant.components.binary_sensor import DOMAIN as BINARY_SENSOR_DOMAIN -from homeassistant.components.climate import DOMAIN as CLIMATE_DOMAIN -from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN -from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry from homeassistant.const import ( CONF_CLIENT_ID, CONF_CLIENT_SECRET, CONF_SCAN_INTERVAL, EVENT_HOMEASSISTANT_STARTED, + Platform, ) from homeassistant.core import CoreState, HomeAssistant from homeassistant.helpers import config_validation as cv, device_registry as dr @@ -25,12 +22,12 @@ from .coordinator import ToonDataUpdateCoordinator from .oauth2 import register_oauth2_implementations -PLATFORMS = { - BINARY_SENSOR_DOMAIN, - CLIMATE_DOMAIN, - SENSOR_DOMAIN, - SWITCH_DOMAIN, -} +PLATFORMS = [ + Platform.BINARY_SENSOR, + Platform.CLIMATE, + Platform.SENSOR, + Platform.SWITCH, +] # Validation of the user's configuration CONFIG_SCHEMA = vol.Schema( diff --git a/homeassistant/components/totalconnect/__init__.py b/homeassistant/components/totalconnect/__init__.py index dcbc1592814fe..679f7afc3d3cc 100644 --- a/homeassistant/components/totalconnect/__init__.py +++ b/homeassistant/components/totalconnect/__init__.py @@ -7,7 +7,7 @@ from total_connect_client.exceptions import AuthenticationError, TotalConnectError from homeassistant.config_entries import ConfigEntry -from homeassistant.const import CONF_PASSWORD, CONF_USERNAME +from homeassistant.const import CONF_PASSWORD, CONF_USERNAME, Platform from homeassistant.core import HomeAssistant from homeassistant.exceptions import ConfigEntryAuthFailed import homeassistant.helpers.config_validation as cv @@ -15,7 +15,7 @@ from .const import CONF_USERCODES, DOMAIN -PLATFORMS = ["alarm_control_panel", "binary_sensor"] +PLATFORMS = [Platform.ALARM_CONTROL_PANEL, Platform.BINARY_SENSOR] CONFIG_SCHEMA = cv.deprecated(DOMAIN) SCAN_INTERVAL = timedelta(seconds=30) diff --git a/homeassistant/components/tplink/const.py b/homeassistant/components/tplink/const.py index 6d4fcbea75dfa..b1cd323a36a6f 100644 --- a/homeassistant/components/tplink/const.py +++ b/homeassistant/components/tplink/const.py @@ -3,6 +3,8 @@ from typing import Final +from homeassistant.const import Platform + DOMAIN = "tplink" ATTR_CURRENT_A: Final = "current_a" @@ -17,4 +19,4 @@ CONF_SWITCH: Final = "switch" CONF_SENSOR: Final = "sensor" -PLATFORMS: Final = [CONF_LIGHT, CONF_SENSOR, CONF_SWITCH] +PLATFORMS: Final = [Platform.LIGHT, Platform.SENSOR, Platform.SWITCH] diff --git a/homeassistant/components/traccar/__init__.py b/homeassistant/components/traccar/__init__.py index e2605cdfd5458..1d656d75c4789 100644 --- a/homeassistant/components/traccar/__init__.py +++ b/homeassistant/components/traccar/__init__.py @@ -4,8 +4,7 @@ from aiohttp import web import voluptuous as vol -from homeassistant.components.device_tracker import DOMAIN as DEVICE_TRACKER -from homeassistant.const import ATTR_ID, CONF_WEBHOOK_ID +from homeassistant.const import ATTR_ID, CONF_WEBHOOK_ID, Platform from homeassistant.helpers import config_entry_flow import homeassistant.helpers.config_validation as cv from homeassistant.helpers.dispatcher import async_dispatcher_send @@ -22,7 +21,7 @@ DOMAIN, ) -PLATFORMS = [DEVICE_TRACKER] +PLATFORMS = [Platform.DEVICE_TRACKER] TRACKER_UPDATE = f"{DOMAIN}_tracker_update" diff --git a/homeassistant/components/tractive/__init__.py b/homeassistant/components/tractive/__init__.py index 66a2afccb43b4..496ae3a85d0b6 100644 --- a/homeassistant/components/tractive/__init__.py +++ b/homeassistant/components/tractive/__init__.py @@ -15,6 +15,7 @@ CONF_EMAIL, CONF_PASSWORD, EVENT_HOMEASSISTANT_STOP, + Platform, ) from homeassistant.core import Event, HomeAssistant from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady @@ -38,7 +39,12 @@ TRACKER_POSITION_UPDATED, ) -PLATFORMS = ["binary_sensor", "device_tracker", "sensor", "switch"] +PLATFORMS = [ + Platform.BINARY_SENSOR, + Platform.DEVICE_TRACKER, + Platform.SENSOR, + Platform.SWITCH, +] _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/tradfri/const.py b/homeassistant/components/tradfri/const.py index abd3e8aff4a33..b0c3955453cf1 100644 --- a/homeassistant/components/tradfri/const.py +++ b/homeassistant/components/tradfri/const.py @@ -1,6 +1,9 @@ """Consts used by Tradfri.""" from homeassistant.components.light import SUPPORT_BRIGHTNESS, SUPPORT_TRANSITION -from homeassistant.const import CONF_HOST # noqa: F401 pylint: disable=unused-import +from homeassistant.const import ( # noqa: F401 pylint: disable=unused-import + CONF_HOST, + Platform, +) ATTR_AUTO = "Auto" ATTR_DIMMER = "dimmer" @@ -25,5 +28,11 @@ KEY_SECURITY_CODE = "security_code" SUPPORTED_GROUP_FEATURES = SUPPORT_BRIGHTNESS | SUPPORT_TRANSITION SUPPORTED_LIGHT_FEATURES = SUPPORT_TRANSITION -PLATFORMS = ["cover", "fan", "light", "sensor", "switch"] +PLATFORMS = [ + Platform.COVER, + Platform.FAN, + Platform.LIGHT, + Platform.SENSOR, + Platform.SWITCH, +] TIMEOUT_API = 30 diff --git a/homeassistant/components/trafikverket_weatherstation/const.py b/homeassistant/components/trafikverket_weatherstation/const.py index bfda57820849c..3c2cfc4d165c1 100644 --- a/homeassistant/components/trafikverket_weatherstation/const.py +++ b/homeassistant/components/trafikverket_weatherstation/const.py @@ -1,8 +1,9 @@ """Adds constants for Trafikverket Weather integration.""" +from homeassistant.const import Platform DOMAIN = "trafikverket_weatherstation" CONF_STATION = "station" -PLATFORMS = ["sensor"] +PLATFORMS = [Platform.SENSOR] ATTRIBUTION = "Data provided by Trafikverket" ATTR_MEASURE_TIME = "measure_time" ATTR_ACTIVE = "active" diff --git a/homeassistant/components/transmission/__init__.py b/homeassistant/components/transmission/__init__.py index f40f0bd7d826c..f514f751149dd 100644 --- a/homeassistant/components/transmission/__init__.py +++ b/homeassistant/components/transmission/__init__.py @@ -17,6 +17,7 @@ CONF_PORT, CONF_SCAN_INTERVAL, CONF_USERNAME, + Platform, ) from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.helpers import config_validation as cv @@ -95,7 +96,7 @@ extra=vol.ALLOW_EXTRA, ) -PLATFORMS = ["sensor", "switch"] +PLATFORMS = [Platform.SENSOR, Platform.SWITCH] async def async_setup(hass, config): diff --git a/homeassistant/components/tuya/const.py b/homeassistant/components/tuya/const.py index fa69b76695c32..4fc2f37f1065b 100644 --- a/homeassistant/components/tuya/const.py +++ b/homeassistant/components/tuya/const.py @@ -35,6 +35,7 @@ TEMP_FAHRENHEIT, VOLUME_CUBIC_FEET, VOLUME_CUBIC_METERS, + Platform, ) DOMAIN = "tuya" @@ -77,21 +78,21 @@ SMARTLIFE_APP = "smartlife" PLATFORMS = [ - "binary_sensor", - "button", - "camera", - "climate", - "cover", - "fan", - "humidifier", - "light", - "number", - "scene", - "select", - "sensor", - "siren", - "switch", - "vacuum", + Platform.BINARY_SENSOR, + Platform.BUTTON, + Platform.CAMERA, + Platform.CLIMATE, + Platform.COVER, + Platform.FAN, + Platform.HUMIDIFIER, + Platform.LIGHT, + Platform.NUMBER, + Platform.SCENE, + Platform.SELECT, + Platform.SENSOR, + Platform.SIREN, + Platform.SWITCH, + Platform.VACUUM, ] diff --git a/homeassistant/components/twentemilieu/__init__.py b/homeassistant/components/twentemilieu/__init__.py index 60b7d07808b1f..576ab2068a7e4 100644 --- a/homeassistant/components/twentemilieu/__init__.py +++ b/homeassistant/components/twentemilieu/__init__.py @@ -7,7 +7,7 @@ import voluptuous as vol from homeassistant.config_entries import ConfigEntry -from homeassistant.const import CONF_ID +from homeassistant.const import CONF_ID, Platform from homeassistant.core import HomeAssistant from homeassistant.helpers import config_validation as cv from homeassistant.helpers.aiohttp_client import async_get_clientsession @@ -20,7 +20,7 @@ SERVICE_UPDATE = "update" SERVICE_SCHEMA = vol.Schema({vol.Optional(CONF_ID): cv.string}) -PLATFORMS = ["sensor"] +PLATFORMS = [Platform.SENSOR] async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: diff --git a/homeassistant/components/twinkly/__init__.py b/homeassistant/components/twinkly/__init__.py index 3a9a2a8faa2c0..ee52d5473de07 100644 --- a/homeassistant/components/twinkly/__init__.py +++ b/homeassistant/components/twinkly/__init__.py @@ -3,12 +3,13 @@ import twinkly_client from homeassistant.config_entries import ConfigEntry +from homeassistant.const import Platform from homeassistant.core import HomeAssistant from homeassistant.helpers.aiohttp_client import async_get_clientsession from .const import CONF_ENTRY_HOST, CONF_ENTRY_ID, DOMAIN -PLATFORMS = ["light"] +PLATFORMS = [Platform.LIGHT] async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: diff --git a/homeassistant/components/unifi/controller.py b/homeassistant/components/unifi/controller.py index 26463563db286..98eb377dab3bc 100644 --- a/homeassistant/components/unifi/controller.py +++ b/homeassistant/components/unifi/controller.py @@ -26,9 +26,6 @@ from aiounifi.websocket import STATE_DISCONNECTED, STATE_RUNNING import async_timeout -from homeassistant.components.device_tracker import DOMAIN as TRACKER_DOMAIN -from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN -from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN from homeassistant.components.unifi.switch import BLOCK_SWITCH, POE_SWITCH from homeassistant.const import ( CONF_HOST, @@ -36,6 +33,7 @@ CONF_PORT, CONF_USERNAME, CONF_VERIFY_SSL, + Platform, ) from homeassistant.core import callback from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady @@ -75,7 +73,7 @@ RETRY_TIMER = 15 CHECK_HEARTBEAT_INTERVAL = timedelta(seconds=1) -PLATFORMS = [TRACKER_DOMAIN, SENSOR_DOMAIN, SWITCH_DOMAIN] +PLATFORMS = [Platform.DEVICE_TRACKER, Platform.SENSOR, Platform.SWITCH] CLIENT_CONNECTED = ( WIRED_CLIENT_CONNECTED, @@ -337,9 +335,9 @@ async def async_setup(self): for entry in async_entries_for_config_entry( entity_registry, self.config_entry.entry_id ): - if entry.domain == TRACKER_DOMAIN: + if entry.domain == Platform.DEVICE_TRACKER: mac = entry.unique_id.split("-", 1)[0] - elif entry.domain == SWITCH_DOMAIN and ( + elif entry.domain == Platform.SWITCH and ( entry.unique_id.startswith(BLOCK_SWITCH) or entry.unique_id.startswith(POE_SWITCH) ): diff --git a/homeassistant/components/upb/__init__.py b/homeassistant/components/upb/__init__.py index 90d7c35cf64b1..acdf8c045a1a6 100644 --- a/homeassistant/components/upb/__init__.py +++ b/homeassistant/components/upb/__init__.py @@ -2,7 +2,7 @@ import upb_lib -from homeassistant.const import ATTR_COMMAND, CONF_FILE_PATH, CONF_HOST +from homeassistant.const import ATTR_COMMAND, CONF_FILE_PATH, CONF_HOST, Platform from homeassistant.core import callback from homeassistant.helpers.entity import DeviceInfo, Entity @@ -14,7 +14,7 @@ EVENT_UPB_SCENE_CHANGED, ) -PLATFORMS = ["light", "scene"] +PLATFORMS = [Platform.LIGHT, Platform.SCENE] async def async_setup_entry(hass, config_entry): diff --git a/homeassistant/components/upcloud/__init__.py b/homeassistant/components/upcloud/__init__.py index 2ecc6ec7522ae..bbce9cd5304d9 100644 --- a/homeassistant/components/upcloud/__init__.py +++ b/homeassistant/components/upcloud/__init__.py @@ -9,8 +9,6 @@ import requests.exceptions import upcloud_api -from homeassistant.components.binary_sensor import DOMAIN as BINARY_SENSOR_DOMAIN -from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( CONF_PASSWORD, @@ -19,6 +17,7 @@ STATE_OFF, STATE_ON, STATE_PROBLEM, + Platform, ) from homeassistant.core import HomeAssistant from homeassistant.exceptions import ConfigEntryNotReady @@ -48,7 +47,7 @@ DEFAULT_COMPONENT_NAME = "UpCloud {}" -CONFIG_ENTRY_DOMAINS = {BINARY_SENSOR_DOMAIN, SWITCH_DOMAIN} +PLATFORMS = [Platform.BINARY_SENSOR, Platform.SWITCH] SIGNAL_UPDATE_UPCLOUD = "upcloud_update" @@ -157,7 +156,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: hass.data[DATA_UPCLOUD].coordinators[entry.data[CONF_USERNAME]] = coordinator # Forward entry setup - hass.config_entries.async_setup_platforms(entry, CONFIG_ENTRY_DOMAINS) + hass.config_entries.async_setup_platforms(entry, PLATFORMS) return True @@ -165,7 +164,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool: """Unload the config entry.""" unload_ok = await hass.config_entries.async_unload_platforms( - config_entry, CONFIG_ENTRY_DOMAINS + config_entry, PLATFORMS ) hass.data[DATA_UPCLOUD].coordinators.pop(config_entry.data[CONF_USERNAME]) diff --git a/homeassistant/components/upnp/__init__.py b/homeassistant/components/upnp/__init__.py index da0585df9879c..5180932080c67 100644 --- a/homeassistant/components/upnp/__init__.py +++ b/homeassistant/components/upnp/__init__.py @@ -16,6 +16,7 @@ from homeassistant.components.binary_sensor import BinarySensorEntityDescription from homeassistant.components.sensor import SensorEntityDescription from homeassistant.config_entries import ConfigEntry +from homeassistant.const import Platform from homeassistant.core import HomeAssistant from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.helpers import device_registry as dr @@ -43,7 +44,7 @@ NOTIFICATION_ID = "upnp_notification" NOTIFICATION_TITLE = "UPnP/IGD Setup" -PLATFORMS = ["binary_sensor", "sensor"] +PLATFORMS = [Platform.BINARY_SENSOR, Platform.SENSOR] CONFIG_SCHEMA = vol.Schema( vol.All( diff --git a/homeassistant/components/uptimerobot/const.py b/homeassistant/components/uptimerobot/const.py index 1c9bbe3e00b53..7637a61c593db 100644 --- a/homeassistant/components/uptimerobot/const.py +++ b/homeassistant/components/uptimerobot/const.py @@ -5,13 +5,15 @@ from logging import Logger, getLogger from typing import Final +from homeassistant.const import Platform + LOGGER: Logger = getLogger(__package__) # The free plan is limited to 10 requests/minute COORDINATOR_UPDATE_INTERVAL: timedelta = timedelta(seconds=10) DOMAIN: Final = "uptimerobot" -PLATFORMS: Final = ["binary_sensor"] +PLATFORMS: Final = [Platform.BINARY_SENSOR] ATTRIBUTION: Final = "Data provided by UptimeRobot" diff --git a/homeassistant/components/velbus/__init__.py b/homeassistant/components/velbus/__init__.py index 330a4315a25c8..d2aa9531467bf 100644 --- a/homeassistant/components/velbus/__init__.py +++ b/homeassistant/components/velbus/__init__.py @@ -8,7 +8,7 @@ import voluptuous as vol from homeassistant.config_entries import ConfigEntry -from homeassistant.const import CONF_ADDRESS, CONF_PORT +from homeassistant.const import CONF_ADDRESS, CONF_PORT, Platform from homeassistant.core import HomeAssistant, ServiceCall from homeassistant.helpers import device_registry import homeassistant.helpers.config_validation as cv @@ -26,7 +26,14 @@ _LOGGER = logging.getLogger(__name__) -PLATFORMS = ["switch", "sensor", "binary_sensor", "cover", "climate", "light"] +PLATFORMS = [ + Platform.BINARY_SENSOR, + Platform.CLIMATE, + Platform.COVER, + Platform.LIGHT, + Platform.SENSOR, + Platform.SWITCH, +] async def velbus_connect_task( diff --git a/homeassistant/components/venstar/__init__.py b/homeassistant/components/venstar/__init__.py index 2ed6080f84fe8..be082d0ad858a 100644 --- a/homeassistant/components/venstar/__init__.py +++ b/homeassistant/components/venstar/__init__.py @@ -12,6 +12,7 @@ CONF_PIN, CONF_SSL, CONF_USERNAME, + Platform, ) from homeassistant.core import HomeAssistant, callback from homeassistant.helpers import update_coordinator @@ -19,7 +20,7 @@ from .const import _LOGGER, DOMAIN, VENSTAR_TIMEOUT -PLATFORMS = ["binary_sensor", "climate", "sensor"] +PLATFORMS = [Platform.BINARY_SENSOR, Platform.CLIMATE, Platform.SENSOR] async def async_setup_entry(hass, config): diff --git a/homeassistant/components/verisure/__init__.py b/homeassistant/components/verisure/__init__.py index bea82a4785cac..d42a6ad004ba8 100644 --- a/homeassistant/components/verisure/__init__.py +++ b/homeassistant/components/verisure/__init__.py @@ -4,16 +4,8 @@ from contextlib import suppress import os -from homeassistant.components.alarm_control_panel import ( - DOMAIN as ALARM_CONTROL_PANEL_DOMAIN, -) -from homeassistant.components.binary_sensor import DOMAIN as BINARY_SENSOR_DOMAIN -from homeassistant.components.camera import DOMAIN as CAMERA_DOMAIN -from homeassistant.components.lock import DOMAIN as LOCK_DOMAIN -from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN -from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN from homeassistant.config_entries import ConfigEntry -from homeassistant.const import EVENT_HOMEASSISTANT_STOP +from homeassistant.const import EVENT_HOMEASSISTANT_STOP, Platform from homeassistant.core import HomeAssistant from homeassistant.exceptions import ConfigEntryAuthFailed import homeassistant.helpers.config_validation as cv @@ -23,12 +15,12 @@ from .coordinator import VerisureDataUpdateCoordinator PLATFORMS = [ - ALARM_CONTROL_PANEL_DOMAIN, - BINARY_SENSOR_DOMAIN, - CAMERA_DOMAIN, - LOCK_DOMAIN, - SENSOR_DOMAIN, - SWITCH_DOMAIN, + Platform.ALARM_CONTROL_PANEL, + Platform.BINARY_SENSOR, + Platform.CAMERA, + Platform.LOCK, + Platform.SENSOR, + Platform.SWITCH, ] CONFIG_SCHEMA = cv.removed(DOMAIN, raise_if_present=False) diff --git a/homeassistant/components/vicare/const.py b/homeassistant/components/vicare/const.py index db8b782399e10..c5f78f31fc068 100644 --- a/homeassistant/components/vicare/const.py +++ b/homeassistant/components/vicare/const.py @@ -6,11 +6,17 @@ DEVICE_CLASS_GAS, ENERGY_KILO_WATT_HOUR, VOLUME_CUBIC_METERS, + Platform, ) DOMAIN = "vicare" -PLATFORMS = ["climate", "sensor", "binary_sensor", "water_heater"] +PLATFORMS = [ + Platform.CLIMATE, + Platform.SENSOR, + Platform.BINARY_SENSOR, + Platform.WATER_HEATER, +] VICARE_DEVICE_CONFIG = "device_conf" VICARE_API = "api" diff --git a/homeassistant/components/vilfo/__init__.py b/homeassistant/components/vilfo/__init__.py index b2e460c85f259..ac3b8b87f3ff7 100644 --- a/homeassistant/components/vilfo/__init__.py +++ b/homeassistant/components/vilfo/__init__.py @@ -6,14 +6,14 @@ from vilfo.exceptions import VilfoException from homeassistant.config_entries import ConfigEntry -from homeassistant.const import CONF_ACCESS_TOKEN, CONF_HOST +from homeassistant.const import CONF_ACCESS_TOKEN, CONF_HOST, Platform from homeassistant.core import HomeAssistant from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.util import Throttle from .const import ATTR_BOOT_TIME, ATTR_LOAD, DOMAIN, ROUTER_DEFAULT_HOST -PLATFORMS = ["sensor"] +PLATFORMS = [Platform.SENSOR] DEFAULT_SCAN_INTERVAL = timedelta(seconds=30) diff --git a/homeassistant/components/vizio/__init__.py b/homeassistant/components/vizio/__init__.py index aec6f38a1b1f7..e66a8f3a55422 100644 --- a/homeassistant/components/vizio/__init__.py +++ b/homeassistant/components/vizio/__init__.py @@ -11,6 +11,7 @@ from homeassistant.components.media_player import DEVICE_CLASS_TV from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry, ConfigEntryState +from homeassistant.const import Platform from homeassistant.core import HomeAssistant from homeassistant.helpers import config_validation as cv from homeassistant.helpers.aiohttp_client import async_get_clientsession @@ -40,7 +41,7 @@ def validate_apps(config: ConfigType) -> ConfigType: extra=vol.ALLOW_EXTRA, ) -PLATFORMS = ["media_player"] +PLATFORMS = [Platform.MEDIA_PLAYER] async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: diff --git a/homeassistant/components/vlc_telnet/__init__.py b/homeassistant/components/vlc_telnet/__init__.py index 72bbf57ff9448..9fe3b97ab3167 100644 --- a/homeassistant/components/vlc_telnet/__init__.py +++ b/homeassistant/components/vlc_telnet/__init__.py @@ -3,13 +3,13 @@ from aiovlc.exceptions import AuthError, ConnectError from homeassistant.config_entries import ConfigEntry -from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_PORT +from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_PORT, Platform from homeassistant.core import HomeAssistant from homeassistant.exceptions import ConfigEntryAuthFailed from .const import DATA_AVAILABLE, DATA_VLC, DOMAIN, LOGGER -PLATFORMS = ["media_player"] +PLATFORMS = [Platform.MEDIA_PLAYER] async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: diff --git a/homeassistant/components/volumio/__init__.py b/homeassistant/components/volumio/__init__.py index 215cd2e1aff21..8189aeef1f46f 100644 --- a/homeassistant/components/volumio/__init__.py +++ b/homeassistant/components/volumio/__init__.py @@ -3,14 +3,14 @@ from pyvolumio import CannotConnectError, Volumio from homeassistant.config_entries import ConfigEntry -from homeassistant.const import CONF_HOST, CONF_PORT +from homeassistant.const import CONF_HOST, CONF_PORT, Platform from homeassistant.core import HomeAssistant from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.helpers.aiohttp_client import async_get_clientsession from .const import DATA_INFO, DATA_VOLUMIO, DOMAIN -PLATFORMS = ["media_player"] +PLATFORMS = [Platform.MEDIA_PLAYER] async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: diff --git a/homeassistant/components/wallbox/__init__.py b/homeassistant/components/wallbox/__init__.py index c40d3fb37a840..103a293c39fad 100644 --- a/homeassistant/components/wallbox/__init__.py +++ b/homeassistant/components/wallbox/__init__.py @@ -10,7 +10,7 @@ from wallbox import Wallbox from homeassistant.config_entries import ConfigEntry -from homeassistant.const import CONF_PASSWORD, CONF_USERNAME +from homeassistant.const import CONF_PASSWORD, CONF_USERNAME, Platform from homeassistant.core import HomeAssistant from homeassistant.exceptions import ConfigEntryAuthFailed, HomeAssistantError from homeassistant.helpers.update_coordinator import DataUpdateCoordinator @@ -19,7 +19,7 @@ _LOGGER = logging.getLogger(__name__) -PLATFORMS = ["sensor", "number"] +PLATFORMS = [Platform.SENSOR, Platform.NUMBER] UPDATE_INTERVAL = 30 diff --git a/homeassistant/components/watttime/__init__.py b/homeassistant/components/watttime/__init__.py index d33e6fceb2e01..2f07658b923f5 100644 --- a/homeassistant/components/watttime/__init__.py +++ b/homeassistant/components/watttime/__init__.py @@ -13,6 +13,7 @@ CONF_LONGITUDE, CONF_PASSWORD, CONF_USERNAME, + Platform, ) from homeassistant.core import HomeAssistant from homeassistant.exceptions import ConfigEntryAuthFailed @@ -23,7 +24,7 @@ DEFAULT_UPDATE_INTERVAL = timedelta(minutes=5) -PLATFORMS: list[str] = ["sensor"] +PLATFORMS: list[Platform] = [Platform.SENSOR] async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: diff --git a/homeassistant/components/waze_travel_time/__init__.py b/homeassistant/components/waze_travel_time/__init__.py index fa605d19c4924..3b193d6c06bb0 100644 --- a/homeassistant/components/waze_travel_time/__init__.py +++ b/homeassistant/components/waze_travel_time/__init__.py @@ -1,12 +1,13 @@ """The waze_travel_time component.""" from homeassistant.config_entries import ConfigEntry +from homeassistant.const import Platform from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_registry import ( async_entries_for_config_entry, async_get, ) -PLATFORMS = ["sensor"] +PLATFORMS = [Platform.SENSOR] async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: diff --git a/homeassistant/components/whirlpool/__init__.py b/homeassistant/components/whirlpool/__init__.py index c53b9a59ef4e6..659b4602f0d86 100644 --- a/homeassistant/components/whirlpool/__init__.py +++ b/homeassistant/components/whirlpool/__init__.py @@ -5,6 +5,7 @@ from whirlpool.auth import Auth from homeassistant.config_entries import ConfigEntry +from homeassistant.const import Platform from homeassistant.core import HomeAssistant from homeassistant.exceptions import ConfigEntryNotReady @@ -12,7 +13,7 @@ _LOGGER = logging.getLogger(__name__) -PLATFORMS = ["climate"] +PLATFORMS = [Platform.CLIMATE] async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: diff --git a/homeassistant/components/wiffi/__init__.py b/homeassistant/components/wiffi/__init__.py index a7f6b8a7b2279..ab5bda8dd1d96 100644 --- a/homeassistant/components/wiffi/__init__.py +++ b/homeassistant/components/wiffi/__init__.py @@ -6,7 +6,7 @@ from wiffi import WiffiTcpServer from homeassistant.config_entries import ConfigEntry -from homeassistant.const import CONF_PORT, CONF_TIMEOUT +from homeassistant.const import CONF_PORT, CONF_TIMEOUT, Platform from homeassistant.core import HomeAssistant, callback from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.helpers import device_registry @@ -29,7 +29,7 @@ _LOGGER = logging.getLogger(__name__) -PLATFORMS = ["sensor", "binary_sensor"] +PLATFORMS = [Platform.BINARY_SENSOR, Platform.SENSOR] async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: diff --git a/homeassistant/components/wilight/__init__.py b/homeassistant/components/wilight/__init__.py index c77814519a1c5..932ce1538bf4d 100644 --- a/homeassistant/components/wilight/__init__.py +++ b/homeassistant/components/wilight/__init__.py @@ -1,6 +1,7 @@ """The WiLight integration.""" from homeassistant.config_entries import ConfigEntry +from homeassistant.const import Platform from homeassistant.core import HomeAssistant, callback from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.helpers.entity import DeviceInfo, Entity @@ -10,7 +11,7 @@ DOMAIN = "wilight" # List the platforms that you want to support. -PLATFORMS = ["cover", "fan", "light"] +PLATFORMS = [Platform.COVER, Platform.FAN, Platform.LIGHT] async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: diff --git a/homeassistant/components/wolflink/__init__.py b/homeassistant/components/wolflink/__init__.py index e15a5225475d8..19cafa89a1350 100644 --- a/homeassistant/components/wolflink/__init__.py +++ b/homeassistant/components/wolflink/__init__.py @@ -7,7 +7,7 @@ from wolf_smartset.wolf_client import FetchFailed, ParameterReadError, WolfClient from homeassistant.config_entries import ConfigEntry -from homeassistant.const import CONF_PASSWORD, CONF_USERNAME +from homeassistant.const import CONF_PASSWORD, CONF_USERNAME, Platform from homeassistant.core import HomeAssistant from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed @@ -23,7 +23,7 @@ _LOGGER = logging.getLogger(__name__) -PLATFORMS = ["sensor"] +PLATFORMS = [Platform.SENSOR] async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: diff --git a/homeassistant/components/xbox/__init__.py b/homeassistant/components/xbox/__init__.py index 2a09c46598421..0466d0191cf66 100644 --- a/homeassistant/components/xbox/__init__.py +++ b/homeassistant/components/xbox/__init__.py @@ -21,7 +21,7 @@ ) from homeassistant.config_entries import ConfigEntry -from homeassistant.const import CONF_CLIENT_ID, CONF_CLIENT_SECRET +from homeassistant.const import CONF_CLIENT_ID, CONF_CLIENT_SECRET, Platform from homeassistant.core import HomeAssistant from homeassistant.helpers import ( aiohttp_client, @@ -48,7 +48,12 @@ extra=vol.ALLOW_EXTRA, ) -PLATFORMS = ["media_player", "remote", "binary_sensor", "sensor"] +PLATFORMS = [ + Platform.BINARY_SENSOR, + Platform.MEDIA_PLAYER, + Platform.REMOTE, + Platform.SENSOR, +] async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: diff --git a/homeassistant/components/xiaomi_aqara/__init__.py b/homeassistant/components/xiaomi_aqara/__init__.py index 7aff6ece0e1fa..ce3e5d72e0dd3 100644 --- a/homeassistant/components/xiaomi_aqara/__init__.py +++ b/homeassistant/components/xiaomi_aqara/__init__.py @@ -15,6 +15,7 @@ CONF_PORT, CONF_PROTOCOL, EVENT_HOMEASSISTANT_STOP, + Platform, ) from homeassistant.core import callback from homeassistant.helpers import device_registry as dr @@ -36,8 +37,15 @@ _LOGGER = logging.getLogger(__name__) -GATEWAY_PLATFORMS = ["binary_sensor", "sensor", "switch", "light", "cover", "lock"] -GATEWAY_PLATFORMS_NO_KEY = ["binary_sensor", "sensor"] +GATEWAY_PLATFORMS = [ + Platform.BINARY_SENSOR, + Platform.COVER, + Platform.LIGHT, + Platform.LOCK, + Platform.SENSOR, + Platform.SWITCH, +] +GATEWAY_PLATFORMS_NO_KEY = [Platform.BINARY_SENSOR, Platform.SENSOR] ATTR_GW_MAC = "gw_mac" ATTR_RINGTONE_ID = "ringtone_id" diff --git a/homeassistant/components/xiaomi_miio/__init__.py b/homeassistant/components/xiaomi_miio/__init__.py index 62935f5e38b90..009b068a521bf 100644 --- a/homeassistant/components/xiaomi_miio/__init__.py +++ b/homeassistant/components/xiaomi_miio/__init__.py @@ -33,7 +33,7 @@ from miio.gateway.gateway import GatewayException from homeassistant import config_entries, core -from homeassistant.const import CONF_HOST, CONF_TOKEN +from homeassistant.const import CONF_HOST, CONF_TOKEN, Platform from homeassistant.core import callback from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady from homeassistant.helpers import device_registry as dr, entity_registry as er @@ -78,20 +78,32 @@ POLLING_TIMEOUT_SEC = 10 UPDATE_INTERVAL = timedelta(seconds=15) -GATEWAY_PLATFORMS = ["alarm_control_panel", "light", "sensor", "switch"] -SWITCH_PLATFORMS = ["switch"] -FAN_PLATFORMS = ["binary_sensor", "fan", "number", "select", "sensor", "switch"] +GATEWAY_PLATFORMS = [ + Platform.ALARM_CONTROL_PANEL, + Platform.LIGHT, + Platform.SENSOR, + Platform.SWITCH, +] +SWITCH_PLATFORMS = [Platform.SWITCH] +FAN_PLATFORMS = [ + Platform.BINARY_SENSOR, + Platform.FAN, + Platform.NUMBER, + Platform.SELECT, + Platform.SENSOR, + Platform.SWITCH, +] HUMIDIFIER_PLATFORMS = [ - "binary_sensor", - "humidifier", - "number", - "select", - "sensor", - "switch", + Platform.BINARY_SENSOR, + Platform.HUMIDIFIER, + Platform.NUMBER, + Platform.SELECT, + Platform.SENSOR, + Platform.SWITCH, ] -LIGHT_PLATFORMS = ["light"] -VACUUM_PLATFORMS = ["binary_sensor", "sensor", "vacuum"] -AIR_MONITOR_PLATFORMS = ["air_quality", "sensor"] +LIGHT_PLATFORMS = [Platform.LIGHT] +VACUUM_PLATFORMS = [Platform.BINARY_SENSOR, Platform.SENSOR, Platform.VACUUM] +AIR_MONITOR_PLATFORMS = [Platform.AIR_QUALITY, Platform.SENSOR] MODEL_TO_CLASS_MAP = { MODEL_FAN_1C: Fan1C, diff --git a/homeassistant/components/yale_smart_alarm/const.py b/homeassistant/components/yale_smart_alarm/const.py index cbb96579f4f90..6bf61cea610dc 100644 --- a/homeassistant/components/yale_smart_alarm/const.py +++ b/homeassistant/components/yale_smart_alarm/const.py @@ -11,6 +11,7 @@ STATE_ALARM_ARMED_AWAY, STATE_ALARM_ARMED_HOME, STATE_ALARM_DISARMED, + Platform, ) CONF_AREA_ID = "area_id" @@ -30,7 +31,7 @@ ATTR_ONLINE = "online" ATTR_STATUS = "status" -PLATFORMS = ["alarm_control_panel"] +PLATFORMS = [Platform.ALARM_CONTROL_PANEL] STATE_MAP = { YALE_STATE_DISARM: STATE_ALARM_DISARMED, diff --git a/homeassistant/components/yamaha_musiccast/__init__.py b/homeassistant/components/yamaha_musiccast/__init__.py index 194168b2eee3c..142af2d769b59 100644 --- a/homeassistant/components/yamaha_musiccast/__init__.py +++ b/homeassistant/components/yamaha_musiccast/__init__.py @@ -10,7 +10,7 @@ from homeassistant.components import ssdp from homeassistant.config_entries import ConfigEntry -from homeassistant.const import CONF_HOST +from homeassistant.const import CONF_HOST, Platform from homeassistant.core import HomeAssistant from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC, format_mac @@ -30,7 +30,7 @@ ENTITY_CATEGORY_MAPPING, ) -PLATFORMS = ["media_player", "number"] +PLATFORMS = [Platform.MEDIA_PLAYER, Platform.NUMBER] _LOGGER = logging.getLogger(__name__) SCAN_INTERVAL = timedelta(seconds=60) diff --git a/homeassistant/components/yeelight/const.py b/homeassistant/components/yeelight/const.py index 2b494bf9ef282..28b5591dcbf2c 100644 --- a/homeassistant/components/yeelight/const.py +++ b/homeassistant/components/yeelight/const.py @@ -2,6 +2,8 @@ from datetime import timedelta +from homeassistant.const import Platform + DOMAIN = "yeelight" @@ -100,4 +102,4 @@ ] -PLATFORMS = ["binary_sensor", "light"] +PLATFORMS = [Platform.BINARY_SENSOR, Platform.LIGHT] diff --git a/homeassistant/components/youless/__init__.py b/homeassistant/components/youless/__init__.py index 0980e4510287e..3339cdccd36d6 100644 --- a/homeassistant/components/youless/__init__.py +++ b/homeassistant/components/youless/__init__.py @@ -6,14 +6,14 @@ from youless_api import YoulessAPI from homeassistant.config_entries import ConfigEntry -from homeassistant.const import CONF_HOST +from homeassistant.const import CONF_HOST, Platform from homeassistant.core import HomeAssistant from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.helpers.update_coordinator import DataUpdateCoordinator from .const import DOMAIN -PLATFORMS = ["sensor"] +PLATFORMS = [Platform.SENSOR] _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/zerproc/__init__.py b/homeassistant/components/zerproc/__init__.py index ec48fb90345f5..459024ec34ca9 100644 --- a/homeassistant/components/zerproc/__init__.py +++ b/homeassistant/components/zerproc/__init__.py @@ -1,11 +1,12 @@ """Zerproc lights integration.""" from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry +from homeassistant.const import Platform from homeassistant.core import HomeAssistant from .const import DATA_ADDRESSES, DATA_DISCOVERY_SUBSCRIPTION, DOMAIN -PLATFORMS = ["light"] +PLATFORMS = [Platform.LIGHT] async def async_setup(hass, config):