From bc3bf2ffe32ec937836fc42d5ef64963c48ad836 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20L=C3=B6vdahl?= Date: Tue, 28 Dec 2021 22:13:20 +0200 Subject: [PATCH] Use Platform constants all over the place 1/3 (#62952) --- .../components/aseko_pool_live/__init__.py | 4 ++-- homeassistant/components/bloomsky/__init__.py | 4 ++-- homeassistant/components/command_line/const.py | 9 ++++++++- .../components/danfoss_air/__init__.py | 4 ++-- .../components/digital_ocean/__init__.py | 4 ++-- homeassistant/components/eafm/__init__.py | 4 +++- homeassistant/components/elv/__init__.py | 4 ++-- homeassistant/components/enocean/const.py | 9 ++++++++- homeassistant/components/fibaro/__init__.py | 17 +++++++++-------- homeassistant/components/filesize/__init__.py | 4 +++- homeassistant/components/filter/__init__.py | 4 +++- homeassistant/components/generic/__init__.py | 4 +++- .../components/generic_thermostat/__init__.py | 4 +++- homeassistant/components/group/__init__.py | 9 ++++++++- .../components/history_stats/__init__.py | 4 +++- 15 files changed, 61 insertions(+), 27 deletions(-) diff --git a/homeassistant/components/aseko_pool_live/__init__.py b/homeassistant/components/aseko_pool_live/__init__.py index 7c7e8cc009f..b8f95f6f74b 100644 --- a/homeassistant/components/aseko_pool_live/__init__.py +++ b/homeassistant/components/aseko_pool_live/__init__.py @@ -8,7 +8,7 @@ from typing import Dict from aioaseko import APIUnavailable, MobileAccount, Unit, Variable from homeassistant.config_entries import ConfigEntry -from homeassistant.const import CONF_ACCESS_TOKEN +from homeassistant.const import CONF_ACCESS_TOKEN, Platform from homeassistant.core import HomeAssistant from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.helpers.aiohttp_client import async_get_clientsession @@ -18,7 +18,7 @@ from .const import DOMAIN _LOGGER = logging.getLogger(__name__) -PLATFORMS: list[str] = ["sensor"] +PLATFORMS: list[str] = [Platform.SENSOR] async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: diff --git a/homeassistant/components/bloomsky/__init__.py b/homeassistant/components/bloomsky/__init__.py index e04f4731918..3c049fe2176 100644 --- a/homeassistant/components/bloomsky/__init__.py +++ b/homeassistant/components/bloomsky/__init__.py @@ -7,14 +7,14 @@ from aiohttp.hdrs import AUTHORIZATION import requests 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 from homeassistant.util import Throttle _LOGGER = logging.getLogger(__name__) -PLATFORMS = ["camera", "binary_sensor", "sensor"] +PLATFORMS = [Platform.CAMERA, Platform.BINARY_SENSOR, Platform.SENSOR] DOMAIN = "bloomsky" diff --git a/homeassistant/components/command_line/const.py b/homeassistant/components/command_line/const.py index 2ac6aab29a5..4394f388910 100644 --- a/homeassistant/components/command_line/const.py +++ b/homeassistant/components/command_line/const.py @@ -1,6 +1,13 @@ """Allows to configure custom shell commands to turn a value for a sensor.""" +from homeassistant.const import Platform + CONF_COMMAND_TIMEOUT = "command_timeout" DEFAULT_TIMEOUT = 15 DOMAIN = "command_line" -PLATFORMS = ["binary_sensor", "cover", "sensor", "switch"] +PLATFORMS = [ + Platform.BINARY_SENSOR, + Platform.COVER, + Platform.SENSOR, + Platform.SWITCH, +] diff --git a/homeassistant/components/danfoss_air/__init__.py b/homeassistant/components/danfoss_air/__init__.py index 18780c10310..e98545fe1b2 100644 --- a/homeassistant/components/danfoss_air/__init__.py +++ b/homeassistant/components/danfoss_air/__init__.py @@ -6,14 +6,14 @@ from pydanfossair.commands import ReadCommand from pydanfossair.danfossclient import DanfossClient import voluptuous as vol -from homeassistant.const import CONF_HOST +from homeassistant.const import CONF_HOST, Platform from homeassistant.helpers import discovery import homeassistant.helpers.config_validation as cv from homeassistant.util import Throttle _LOGGER = logging.getLogger(__name__) -PLATFORMS = ["sensor", "binary_sensor", "switch"] +PLATFORMS = [Platform.SENSOR, Platform.BINARY_SENSOR, Platform.SWITCH] DOMAIN = "danfoss_air" MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=60) diff --git a/homeassistant/components/digital_ocean/__init__.py b/homeassistant/components/digital_ocean/__init__.py index 9ae61ed9b84..194841da662 100644 --- a/homeassistant/components/digital_ocean/__init__.py +++ b/homeassistant/components/digital_ocean/__init__.py @@ -5,7 +5,7 @@ import logging import digitalocean 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 @@ -26,7 +26,7 @@ ATTRIBUTION = "Data provided by Digital Ocean" CONF_DROPLETS = "droplets" DATA_DIGITAL_OCEAN = "data_do" -DIGITAL_OCEAN_PLATFORMS = ["switch", "binary_sensor"] +DIGITAL_OCEAN_PLATFORMS = [Platform.SWITCH, Platform.BINARY_SENSOR] DOMAIN = "digital_ocean" MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=60) diff --git a/homeassistant/components/eafm/__init__.py b/homeassistant/components/eafm/__init__.py index 7d2853266ff..513db3a7bed 100644 --- a/homeassistant/components/eafm/__init__.py +++ b/homeassistant/components/eafm/__init__.py @@ -1,8 +1,10 @@ """UK Environment Agency Flood Monitoring Integration.""" +from homeassistant.const import Platform + from .const import DOMAIN -PLATFORMS = ["sensor"] +PLATFORMS = [Platform.SENSOR] async def async_setup_entry(hass, entry): diff --git a/homeassistant/components/elv/__init__.py b/homeassistant/components/elv/__init__.py index a3153eee1e4..a9076fc1d2f 100644 --- a/homeassistant/components/elv/__init__.py +++ b/homeassistant/components/elv/__init__.py @@ -1,7 +1,7 @@ """The Elv integration.""" import voluptuous as vol -from homeassistant.const import CONF_DEVICE +from homeassistant.const import CONF_DEVICE, Platform from homeassistant.helpers import discovery import homeassistant.helpers.config_validation as cv @@ -9,7 +9,7 @@ DOMAIN = "elv" DEFAULT_DEVICE = "/dev/ttyUSB0" -ELV_PLATFORMS = ["switch"] +ELV_PLATFORMS = [Platform.SWITCH] CONFIG_SCHEMA = vol.Schema( { diff --git a/homeassistant/components/enocean/const.py b/homeassistant/components/enocean/const.py index a020a745137..08e9b5ba11d 100644 --- a/homeassistant/components/enocean/const.py +++ b/homeassistant/components/enocean/const.py @@ -1,6 +1,8 @@ """Constants for the ENOcean integration.""" import logging +from homeassistant.const import Platform + DOMAIN = "enocean" DATA_ENOCEAN = "enocean" ENOCEAN_DONGLE = "dongle" @@ -12,4 +14,9 @@ SIGNAL_SEND_MESSAGE = "enocean.send_message" LOGGER = logging.getLogger(__package__) -PLATFORMS = ["light", "binary_sensor", "sensor", "switch"] +PLATFORMS = [ + Platform.LIGHT, + Platform.BINARY_SENSOR, + Platform.SENSOR, + Platform.SWITCH, +] diff --git a/homeassistant/components/fibaro/__init__.py b/homeassistant/components/fibaro/__init__.py index cff4e153d98..7e638b1224c 100644 --- a/homeassistant/components/fibaro/__init__.py +++ b/homeassistant/components/fibaro/__init__.py @@ -18,6 +18,7 @@ from homeassistant.const import ( CONF_USERNAME, CONF_WHITE_VALUE, EVENT_HOMEASSISTANT_STOP, + Platform, ) from homeassistant.helpers import discovery import homeassistant.helpers.config_validation as cv @@ -39,14 +40,14 @@ DOMAIN = "fibaro" FIBARO_CONTROLLERS = "fibaro_controllers" FIBARO_DEVICES = "fibaro_devices" PLATFORMS = [ - "binary_sensor", - "climate", - "cover", - "light", - "scene", - "sensor", - "lock", - "switch", + Platform.BINARY_SENSOR, + Platform.CLIMATE, + Platform.COVER, + Platform.LIGHT, + Platform.SCENE, + Platform.SENSOR, + Platform.LOCK, + Platform.SWITCH, ] FIBARO_TYPEMAP = { diff --git a/homeassistant/components/filesize/__init__.py b/homeassistant/components/filesize/__init__.py index d209a845b15..9e2ab2477a9 100644 --- a/homeassistant/components/filesize/__init__.py +++ b/homeassistant/components/filesize/__init__.py @@ -1,4 +1,6 @@ """The filesize component.""" +from homeassistant.const import Platform + DOMAIN = "filesize" -PLATFORMS = ["sensor"] +PLATFORMS = [Platform.SENSOR] diff --git a/homeassistant/components/filter/__init__.py b/homeassistant/components/filter/__init__.py index 35e374771c2..7f3f6cbfffc 100644 --- a/homeassistant/components/filter/__init__.py +++ b/homeassistant/components/filter/__init__.py @@ -1,4 +1,6 @@ """The filter component.""" +from homeassistant.const import Platform + DOMAIN = "filter" -PLATFORMS = ["sensor"] +PLATFORMS = [Platform.SENSOR] diff --git a/homeassistant/components/generic/__init__.py b/homeassistant/components/generic/__init__.py index feb51d0177d..3ca526f2029 100644 --- a/homeassistant/components/generic/__init__.py +++ b/homeassistant/components/generic/__init__.py @@ -1,4 +1,6 @@ """The generic component.""" +from homeassistant.const import Platform + DOMAIN = "generic" -PLATFORMS = ["camera"] +PLATFORMS = [Platform.CAMERA] diff --git a/homeassistant/components/generic_thermostat/__init__.py b/homeassistant/components/generic_thermostat/__init__.py index 69acb5bb1a5..75f69bbe88c 100644 --- a/homeassistant/components/generic_thermostat/__init__.py +++ b/homeassistant/components/generic_thermostat/__init__.py @@ -1,4 +1,6 @@ """The generic_thermostat component.""" +from homeassistant.const import Platform + DOMAIN = "generic_thermostat" -PLATFORMS = ["climate"] +PLATFORMS = [Platform.CLIMATE] diff --git a/homeassistant/components/group/__init__.py b/homeassistant/components/group/__init__.py index a609009fe80..0d53239bb5e 100644 --- a/homeassistant/components/group/__init__.py +++ b/homeassistant/components/group/__init__.py @@ -25,6 +25,7 @@ from homeassistant.const import ( SERVICE_RELOAD, STATE_OFF, STATE_ON, + Platform, ) from homeassistant.core import ( CoreState, @@ -62,7 +63,13 @@ ATTR_ALL = "all" SERVICE_SET = "set" SERVICE_REMOVE = "remove" -PLATFORMS = ["light", "cover", "notify", "fan", "binary_sensor"] +PLATFORMS = [ + Platform.LIGHT, + Platform.COVER, + Platform.NOTIFY, + Platform.FAN, + Platform.BINARY_SENSOR, +] REG_KEY = f"{DOMAIN}_registry" diff --git a/homeassistant/components/history_stats/__init__.py b/homeassistant/components/history_stats/__init__.py index dcdca70b71c..1eb2ab972bb 100644 --- a/homeassistant/components/history_stats/__init__.py +++ b/homeassistant/components/history_stats/__init__.py @@ -1,4 +1,6 @@ """The history_stats component.""" +from homeassistant.const import Platform + DOMAIN = "history_stats" -PLATFORMS = ["sensor"] +PLATFORMS = [Platform.SENSOR]