Skip to content

Commit

Permalink
Use platform enum (7) [T-Z] (home-assistant#60948)
Browse files Browse the repository at this point in the history
Co-authored-by: Joakim Sørensen <[email protected]>
Co-authored-by: Franck Nijhof <[email protected]>
  • Loading branch information
3 people authored Dec 4, 2021
1 parent 73c880b commit b79b35a
Show file tree
Hide file tree
Showing 45 changed files with 199 additions and 135 deletions.
9 changes: 7 additions & 2 deletions homeassistant/components/tado/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
5 changes: 2 additions & 3 deletions homeassistant/components/tailscale/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/tesla_wall_connector/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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__)

Expand Down
11 changes: 7 additions & 4 deletions homeassistant/components/tibber/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -14,9 +19,7 @@

from .const import DATA_HASS_CONFIG, DOMAIN

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

CONFIG_SCHEMA = cv.deprecated(DOMAIN)

Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/tile/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
16 changes: 8 additions & 8 deletions homeassistant/components/tolo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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__)
Expand Down
17 changes: 7 additions & 10 deletions homeassistant/components/toon/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/totalconnect/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
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
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed

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)
Expand Down
4 changes: 3 additions & 1 deletion homeassistant/components/tplink/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

from typing import Final

from homeassistant.const import Platform

DOMAIN = "tplink"

ATTR_CURRENT_A: Final = "current_a"
Expand All @@ -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]
5 changes: 2 additions & 3 deletions homeassistant/components/traccar/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -22,7 +21,7 @@
DOMAIN,
)

PLATFORMS = [DEVICE_TRACKER]
PLATFORMS = [Platform.DEVICE_TRACKER]


TRACKER_UPDATE = f"{DOMAIN}_tracker_update"
Expand Down
8 changes: 7 additions & 1 deletion homeassistant/components/tractive/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
CONF_EMAIL,
CONF_PASSWORD,
EVENT_HOMEASSISTANT_STOP,
Platform,
)
from homeassistant.core import Event, HomeAssistant
from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
Expand All @@ -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__)
Expand Down
13 changes: 11 additions & 2 deletions homeassistant/components/tradfri/const.py
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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
Original file line number Diff line number Diff line change
@@ -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"
3 changes: 2 additions & 1 deletion homeassistant/components/transmission/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -95,7 +96,7 @@
extra=vol.ALLOW_EXTRA,
)

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


async def async_setup(hass, config):
Expand Down
31 changes: 16 additions & 15 deletions homeassistant/components/tuya/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
TEMP_FAHRENHEIT,
VOLUME_CUBIC_FEET,
VOLUME_CUBIC_METERS,
Platform,
)

DOMAIN = "tuya"
Expand Down Expand Up @@ -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,
]


Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/twentemilieu/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion homeassistant/components/twinkly/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading

0 comments on commit b79b35a

Please sign in to comment.