Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use platform enum (2) [E-G] #60933

Merged
merged 2 commits into from Dec 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion homeassistant/components/ecobee/const.py
Expand Up @@ -14,6 +14,7 @@
ATTR_CONDITION_SUNNY,
ATTR_CONDITION_WINDY,
)
from homeassistant.const import Platform

_LOGGER = logging.getLogger(__package__)

Expand All @@ -37,7 +38,13 @@
"vulcanSmart": "ecobee4 Smart",
}

PLATFORMS = ["binary_sensor", "climate", "humidifier", "sensor", "weather"]
PLATFORMS = [
Platform.BINARY_SENSOR,
Platform.CLIMATE,
Platform.HUMIDIFIER,
Platform.SENSOR,
Platform.WEATHER,
]

MANUFACTURER = "ecobee"

Expand Down
9 changes: 7 additions & 2 deletions homeassistant/components/econet/__init__.py
Expand Up @@ -12,7 +12,7 @@
PyeconetError,
)

from homeassistant.const import CONF_EMAIL, CONF_PASSWORD, TEMP_FAHRENHEIT
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD, TEMP_FAHRENHEIT, Platform
from homeassistant.core import callback
from homeassistant.exceptions import ConfigEntryNotReady
from homeassistant.helpers.dispatcher import dispatcher_send
Expand All @@ -23,7 +23,12 @@

_LOGGER = logging.getLogger(__name__)

PLATFORMS = ["climate", "binary_sensor", "sensor", "water_heater"]
PLATFORMS = [
Platform.CLIMATE,
Platform.BINARY_SENSOR,
Platform.SENSOR,
Platform.WATER_HEATER,
]
PUSH_UPDATE = "econet.push_update"

INTERVAL = timedelta(minutes=60)
Expand Down
5 changes: 2 additions & 3 deletions homeassistant/components/efergy/__init__.py
Expand Up @@ -3,9 +3,8 @@

from pyefergy import Efergy, exceptions

from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ATTR_ATTRIBUTION, CONF_API_KEY
from homeassistant.const import ATTR_ATTRIBUTION, CONF_API_KEY, Platform
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
from homeassistant.helpers import device_registry as dr
Expand All @@ -14,7 +13,7 @@

from .const import ATTRIBUTION, DATA_KEY_API, DEFAULT_NAME, DOMAIN

PLATFORMS = [SENSOR_DOMAIN]
PLATFORMS = [Platform.SENSOR]


async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
Expand Down
6 changes: 2 additions & 4 deletions homeassistant/components/elgato/__init__.py
Expand Up @@ -3,17 +3,15 @@

from elgato import Elgato, ElgatoConnectionError

from homeassistant.components.button import DOMAIN as BUTTON_DOMAIN
from homeassistant.components.light import DOMAIN as LIGHT_DOMAIN
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 DOMAIN

PLATFORMS = [BUTTON_DOMAIN, LIGHT_DOMAIN]
PLATFORMS = [Platform.BUTTON, Platform.LIGHT]


async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
Expand Down
13 changes: 7 additions & 6 deletions homeassistant/components/elkm1/__init__.py
Expand Up @@ -22,6 +22,7 @@
CONF_USERNAME,
TEMP_CELSIUS,
TEMP_FAHRENHEIT,
Platform,
)
from homeassistant.core import HomeAssistant, callback
from homeassistant.exceptions import ConfigEntryNotReady, HomeAssistantError
Expand Down Expand Up @@ -57,12 +58,12 @@
_LOGGER = logging.getLogger(__name__)

PLATFORMS = [
"alarm_control_panel",
"climate",
"light",
"scene",
"sensor",
"switch",
Platform.ALARM_CONTROL_PANEL,
Platform.CLIMATE,
Platform.LIGHT,
Platform.SCENE,
Platform.SENSOR,
Platform.SWITCH,
]

SPEAK_SERVICE_SCHEMA = vol.Schema(
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/emonitor/__init__.py
Expand Up @@ -5,7 +5,7 @@
from aioemonitor import Emonitor

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 import aiohttp_client
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
Expand All @@ -16,7 +16,7 @@

DEFAULT_UPDATE_RATE = 60

PLATFORMS = ["sensor"]
PLATFORMS = [Platform.SENSOR]


async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
Expand Down
9 changes: 7 additions & 2 deletions homeassistant/components/enphase_envoy/const.py
Expand Up @@ -6,11 +6,16 @@
STATE_CLASS_TOTAL_INCREASING,
SensorEntityDescription,
)
from homeassistant.const import DEVICE_CLASS_ENERGY, ENERGY_WATT_HOUR, POWER_WATT
from homeassistant.const import (
DEVICE_CLASS_ENERGY,
ENERGY_WATT_HOUR,
POWER_WATT,
Platform,
)

DOMAIN = "enphase_envoy"

PLATFORMS = ["sensor"]
PLATFORMS = [Platform.SENSOR]


COORDINATOR = "coordinator"
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/environment_canada/__init__.py
Expand Up @@ -6,15 +6,15 @@
from env_canada import ECRadar, ECWeather, ec_exc

from homeassistant.config_entries import SOURCE_IMPORT
from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE
from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE, Platform
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed

from .const import CONF_LANGUAGE, CONF_STATION, DOMAIN

DEFAULT_RADAR_UPDATE_INTERVAL = timedelta(minutes=5)
DEFAULT_WEATHER_UPDATE_INTERVAL = timedelta(minutes=5)

PLATFORMS = ["camera", "sensor", "weather"]
PLATFORMS = [Platform.CAMERA, Platform.SENSOR, Platform.WEATHER]

_LOGGER = logging.getLogger(__name__)

Expand Down
5 changes: 2 additions & 3 deletions homeassistant/components/epson/__init__.py
Expand Up @@ -7,16 +7,15 @@
STATE_UNAVAILABLE as EPSON_STATE_UNAVAILABLE,
)

from homeassistant.components.media_player import DOMAIN as MEDIA_PLAYER_PLATFORM
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 .const import DOMAIN, HTTP
from .exceptions import CannotConnect, PoweredOff

PLATFORMS = [MEDIA_PLAYER_PLATFORM]
PLATFORMS = [Platform.MEDIA_PLAYER]

_LOGGER = logging.getLogger(__name__)

Expand Down
3 changes: 2 additions & 1 deletion homeassistant/components/evil_genius_labs/__init__.py
Expand Up @@ -9,6 +9,7 @@
import pyevilgenius

from homeassistant.config_entries import ConfigEntry
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers import (
aiohttp_client,
Expand All @@ -19,7 +20,7 @@

from .const import DOMAIN

PLATFORMS = ["light"]
PLATFORMS = [Platform.LIGHT]

UPDATE_INTERVAL = 10

Expand Down
9 changes: 5 additions & 4 deletions homeassistant/components/ezviz/__init__.py
Expand Up @@ -11,6 +11,7 @@
CONF_TYPE,
CONF_URL,
CONF_USERNAME,
Platform,
)
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryNotReady
Expand All @@ -30,10 +31,10 @@
_LOGGER = logging.getLogger(__name__)

PLATFORMS = [
"binary_sensor",
"camera",
"sensor",
"switch",
Platform.BINARY_SENSOR,
Platform.CAMERA,
Platform.SENSOR,
Platform.SWITCH,
]


Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/faa_delays/__init__.py
Expand Up @@ -7,7 +7,7 @@
from faadelays import Airport

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 aiohttp_client
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
Expand All @@ -16,7 +16,7 @@

_LOGGER = logging.getLogger(__name__)

PLATFORMS = ["binary_sensor"]
PLATFORMS = [Platform.BINARY_SENSOR]


async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
Expand Down
7 changes: 2 additions & 5 deletions homeassistant/components/fireservicerota/__init__.py
Expand Up @@ -10,11 +10,8 @@
InvalidTokenError,
)

from homeassistant.components.binary_sensor import DOMAIN as BINARYSENSOR_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 CONF_TOKEN, CONF_URL, CONF_USERNAME
from homeassistant.const import CONF_TOKEN, CONF_URL, CONF_USERNAME, Platform
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryAuthFailed
from homeassistant.helpers.dispatcher import dispatcher_send
Expand All @@ -26,7 +23,7 @@

_LOGGER = logging.getLogger(__name__)

PLATFORMS = [SENSOR_DOMAIN, BINARYSENSOR_DOMAIN, SWITCH_DOMAIN]
PLATFORMS = [Platform.SENSOR, Platform.BINARY_SENSOR, Platform.SWITCH]


async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
Expand Down
9 changes: 8 additions & 1 deletion homeassistant/components/fjaraskupan/__init__.py
Expand Up @@ -12,6 +12,7 @@
from fjaraskupan import UUID_SERVICE, Device, State, device_filter

from homeassistant.config_entries import ConfigEntry
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.dispatcher import (
async_dispatcher_connect,
Expand All @@ -23,7 +24,13 @@

from .const import DISPATCH_DETECTION, DOMAIN

PLATFORMS = ["binary_sensor", "fan", "light", "number", "sensor"]
PLATFORMS = [
Platform.BINARY_SENSOR,
Platform.FAN,
Platform.LIGHT,
Platform.NUMBER,
Platform.SENSOR,
]

_LOGGER = logging.getLogger(__name__)

Expand Down
3 changes: 2 additions & 1 deletion homeassistant/components/flick_electric/__init__.py
Expand Up @@ -13,6 +13,7 @@
CONF_CLIENT_SECRET,
CONF_PASSWORD,
CONF_USERNAME,
Platform,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers import aiohttp_client
Expand All @@ -21,7 +22,7 @@

CONF_ID_TOKEN = "id_token"

PLATFORMS = ["sensor"]
PLATFORMS = [Platform.SENSOR]


async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/flipr/__init__.py
Expand Up @@ -5,7 +5,7 @@
from flipr_api import FliprAPIRestClient

from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ATTR_ATTRIBUTION, CONF_EMAIL, CONF_PASSWORD
from homeassistant.const import ATTR_ATTRIBUTION, CONF_EMAIL, CONF_PASSWORD, Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import DeviceInfo, EntityDescription
from homeassistant.helpers.update_coordinator import (
Expand All @@ -20,7 +20,7 @@
SCAN_INTERVAL = timedelta(minutes=60)


PLATFORMS = ["binary_sensor", "sensor"]
PLATFORMS = [Platform.BINARY_SENSOR, Platform.SENSOR]


async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/flo/__init__.py
Expand Up @@ -6,7 +6,7 @@
from aioflo.errors import RequestError

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.aiohttp_client import async_get_clientsession
Expand All @@ -16,7 +16,7 @@

_LOGGER = logging.getLogger(__name__)

PLATFORMS = ["binary_sensor", "sensor", "switch"]
PLATFORMS = [Platform.BINARY_SENSOR, Platform.SENSOR, Platform.SWITCH]


async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
Expand Down
3 changes: 2 additions & 1 deletion homeassistant/components/flume/const.py
Expand Up @@ -2,10 +2,11 @@
from __future__ import annotations

from homeassistant.components.sensor import SensorEntityDescription
from homeassistant.const import Platform

DOMAIN = "flume"

PLATFORMS = ["sensor"]
PLATFORMS = [Platform.SENSOR]

DEFAULT_NAME = "Flume Sensor"

Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/flunearyou/__init__.py
Expand Up @@ -10,7 +10,7 @@
from pyflunearyou.errors import FluNearYouError

from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE
from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE, Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers import aiohttp_client, config_validation as cv
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
Expand All @@ -21,7 +21,7 @@

CONFIG_SCHEMA = cv.deprecated(DOMAIN)

PLATFORMS = ["sensor"]
PLATFORMS = [Platform.SENSOR]


async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
Expand Down
11 changes: 8 additions & 3 deletions homeassistant/components/flux_led/__init__.py
Expand Up @@ -14,7 +14,12 @@

from homeassistant import config_entries
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_HOST, CONF_NAME, EVENT_HOMEASSISTANT_STARTED
from homeassistant.const import (
CONF_HOST,
CONF_NAME,
EVENT_HOMEASSISTANT_STARTED,
Platform,
)
from homeassistant.core import HomeAssistant, callback
from homeassistant.exceptions import ConfigEntryNotReady
from homeassistant.helpers import device_registry as dr
Expand All @@ -37,8 +42,8 @@
_LOGGER = logging.getLogger(__name__)

PLATFORMS_BY_TYPE: Final = {
DeviceType.Bulb: ["light", "number"],
DeviceType.Switch: ["switch"],
DeviceType.Bulb: [Platform.LIGHT, Platform.NUMBER],
DeviceType.Switch: [Platform.SWITCH],
}
DISCOVERY_INTERVAL: Final = timedelta(minutes=15)
REQUEST_REFRESH_DELAY: Final = 1.5
Expand Down