Use platform enum (5) [P-R] (#60943)
This commit is contained in:
parent
ed6352a22b
commit
79cd281c48
25 changed files with 80 additions and 42 deletions
|
@ -5,9 +5,8 @@ from typing import TypedDict
|
|||
|
||||
from p1monitor import P1Monitor, Phases, Settings, SmartMeter
|
||||
|
||||
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
|
||||
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.aiohttp_client import async_get_clientsession
|
||||
|
@ -22,7 +21,7 @@ from .const import (
|
|||
SERVICE_SMARTMETER,
|
||||
)
|
||||
|
||||
PLATFORMS = (SENSOR_DOMAIN,)
|
||||
PLATFORMS = [Platform.SENSOR]
|
||||
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
|
|
|
@ -16,6 +16,7 @@ from homeassistant.const import (
|
|||
CONF_HOST,
|
||||
CONF_PASSWORD,
|
||||
CONF_USERNAME,
|
||||
Platform,
|
||||
)
|
||||
from homeassistant.core import CALLBACK_TYPE, Context, HassJob, HomeAssistant, callback
|
||||
from homeassistant.helpers.debounce import Debouncer
|
||||
|
@ -23,7 +24,7 @@ from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
|||
|
||||
from .const import CONF_ALLOW_NOTIFY, DOMAIN
|
||||
|
||||
PLATFORMS = ["media_player", "light", "remote"]
|
||||
PLATFORMS = [Platform.MEDIA_PLAYER, Platform.LIGHT, Platform.REMOTE]
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ from homeassistant.const import (
|
|||
CONF_NAME,
|
||||
CONF_SSL,
|
||||
CONF_VERIFY_SSL,
|
||||
Platform,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.exceptions import ConfigEntryNotReady
|
||||
|
@ -150,11 +151,11 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||
|
||||
|
||||
@callback
|
||||
def _async_platforms(entry: ConfigEntry) -> list[str]:
|
||||
def _async_platforms(entry: ConfigEntry) -> list[Platform]:
|
||||
"""Return platforms to be loaded / unloaded."""
|
||||
platforms = ["binary_sensor", "sensor"]
|
||||
platforms = [Platform.BINARY_SENSOR, Platform.SENSOR]
|
||||
if not entry.data[CONF_STATISTICS_ONLY]:
|
||||
platforms.append("switch")
|
||||
platforms.append(Platform.SWITCH)
|
||||
return platforms
|
||||
|
||||
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
from python_picnic_api import PicnicAPI
|
||||
|
||||
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 .const import CONF_API, CONF_COORDINATOR, CONF_COUNTRY_CODE, DOMAIN
|
||||
from .coordinator import PicnicUpdateCoordinator
|
||||
|
||||
PLATFORMS = ["sensor"]
|
||||
PLATFORMS = [Platform.SENSOR]
|
||||
|
||||
|
||||
def create_picnic_client(entry: ConfigEntry):
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
"""Const for Plaato."""
|
||||
from datetime import timedelta
|
||||
|
||||
from homeassistant.const import Platform
|
||||
|
||||
DOMAIN = "plaato"
|
||||
PLAATO_DEVICE_SENSORS = "sensors"
|
||||
PLAATO_DEVICE_ATTRS = "attrs"
|
||||
|
@ -15,7 +17,7 @@ PLACEHOLDER_DOCS_URL = "docs_url"
|
|||
PLACEHOLDER_DEVICE_TYPE = "device_type"
|
||||
PLACEHOLDER_DEVICE_NAME = "device_name"
|
||||
DOCS_URL = "https://www.home-assistant.io/integrations/plaato/"
|
||||
PLATFORMS = ["sensor", "binary_sensor"]
|
||||
PLATFORMS = [Platform.SENSOR, Platform.BINARY_SENSOR]
|
||||
SENSOR_DATA = "sensor_data"
|
||||
COORDINATOR = "coordinator"
|
||||
DEVICE = "device"
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
"""Constants for Plugwise component."""
|
||||
from homeassistant.const import Platform
|
||||
|
||||
API = "api"
|
||||
ATTR_ILLUMINANCE = "illuminance"
|
||||
|
@ -20,8 +21,13 @@ STRETCH_USERNAME = "stretch"
|
|||
UNDO_UPDATE_LISTENER = "undo_update_listener"
|
||||
UNIT_LUMEN = "lm"
|
||||
|
||||
PLATFORMS_GATEWAY = ["binary_sensor", "climate", "sensor", "switch"]
|
||||
SENSOR_PLATFORMS = ["sensor", "switch"]
|
||||
PLATFORMS_GATEWAY = [
|
||||
Platform.BINARY_SENSOR,
|
||||
Platform.CLIMATE,
|
||||
Platform.SENSOR,
|
||||
Platform.SWITCH,
|
||||
]
|
||||
SENSOR_PLATFORMS = [Platform.SENSOR, Platform.SWITCH]
|
||||
ZEROCONF_MAP = {
|
||||
"smile": "P1",
|
||||
"smile_thermo": "Anna",
|
||||
|
|
|
@ -7,7 +7,7 @@ from poolsense import PoolSense
|
|||
from poolsense.exceptions import PoolSenseError
|
||||
|
||||
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 import aiohttp_client
|
||||
from homeassistant.helpers.entity import EntityDescription
|
||||
|
@ -19,7 +19,7 @@ from homeassistant.helpers.update_coordinator import (
|
|||
|
||||
from .const import ATTRIBUTION, DOMAIN
|
||||
|
||||
PLATFORMS = ["sensor", "binary_sensor"]
|
||||
PLATFORMS = [Platform.SENSOR, Platform.BINARY_SENSOR]
|
||||
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
|
|
@ -11,7 +11,7 @@ from tesla_powerwall import (
|
|||
)
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_IP_ADDRESS, CONF_PASSWORD
|
||||
from homeassistant.const import CONF_IP_ADDRESS, CONF_PASSWORD, Platform
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
|
||||
from homeassistant.helpers import entity_registry
|
||||
|
@ -38,7 +38,7 @@ from .const import (
|
|||
|
||||
CONFIG_SCHEMA = cv.deprecated(DOMAIN)
|
||||
|
||||
PLATFORMS = ["binary_sensor", "sensor"]
|
||||
PLATFORMS = [Platform.BINARY_SENSOR, Platform.SENSOR]
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
@ -5,11 +5,12 @@ from ProgettiHWSW.input import Input
|
|||
from ProgettiHWSW.relay import Relay
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from .const import DOMAIN
|
||||
|
||||
PLATFORMS = ["switch", "binary_sensor"]
|
||||
PLATFORMS = [Platform.SWITCH, Platform.BINARY_SENSOR]
|
||||
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
|
|
|
@ -4,14 +4,14 @@ import logging
|
|||
from pyprosegur.auth import Auth
|
||||
|
||||
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, ConfigEntryNotReady
|
||||
from homeassistant.helpers import aiohttp_client
|
||||
|
||||
from .const import CONF_COUNTRY, DOMAIN
|
||||
|
||||
PLATFORMS = ["alarm_control_panel"]
|
||||
PLATFORMS = [Platform.ALARM_CONTROL_PANEL]
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ from homeassistant.const import (
|
|||
ATTR_LOCKED,
|
||||
CONF_REGION,
|
||||
CONF_TOKEN,
|
||||
Platform,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant, split_entity_id
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
|
@ -45,7 +46,7 @@ PS4_COMMAND_SCHEMA = vol.Schema(
|
|||
}
|
||||
)
|
||||
|
||||
PLATFORMS = ["media_player"]
|
||||
PLATFORMS = [Platform.MEDIA_PLAYER]
|
||||
|
||||
|
||||
class PS4Data:
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
"""Constant values for pvpc_hourly_pricing."""
|
||||
from homeassistant.const import Platform
|
||||
|
||||
DOMAIN = "pvpc_hourly_pricing"
|
||||
PLATFORMS = ["sensor"]
|
||||
PLATFORMS = [Platform.SENSOR]
|
||||
ATTR_POWER = "power"
|
||||
ATTR_POWER_P3 = "power_p3"
|
||||
ATTR_TARIFF = "tariff"
|
||||
|
|
|
@ -6,7 +6,7 @@ from rachiopy import Rachio
|
|||
from requests.exceptions import ConnectTimeout
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_API_KEY
|
||||
from homeassistant.const import CONF_API_KEY, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ConfigEntryNotReady
|
||||
from homeassistant.helpers import config_validation as cv
|
||||
|
@ -20,7 +20,7 @@ from .webhooks import (
|
|||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
PLATFORMS = ["switch", "binary_sensor"]
|
||||
PLATFORMS = [Platform.SWITCH, Platform.BINARY_SENSOR]
|
||||
|
||||
CONFIG_SCHEMA = cv.deprecated(DOMAIN)
|
||||
|
||||
|
|
|
@ -2,12 +2,13 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from . import data
|
||||
from .const import DOMAIN
|
||||
|
||||
PLATFORMS = ("sensor",)
|
||||
PLATFORMS = [Platform.SENSOR]
|
||||
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
|
|
|
@ -18,6 +18,7 @@ from homeassistant.const import (
|
|||
CONF_PASSWORD,
|
||||
CONF_PORT,
|
||||
CONF_SSL,
|
||||
Platform,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant, ServiceCall, callback
|
||||
from homeassistant.exceptions import ConfigEntryNotReady
|
||||
|
@ -56,7 +57,7 @@ DEFAULT_UPDATE_INTERVAL = timedelta(seconds=15)
|
|||
|
||||
CONFIG_SCHEMA = cv.deprecated(DOMAIN)
|
||||
|
||||
PLATFORMS = ["binary_sensor", "sensor", "switch"]
|
||||
PLATFORMS = [Platform.BINARY_SENSOR, Platform.SENSOR, Platform.SWITCH]
|
||||
|
||||
UPDATE_INTERVALS = {
|
||||
DATA_PROVISION_SETTINGS: timedelta(minutes=1),
|
||||
|
|
|
@ -3,16 +3,15 @@ from __future__ import annotations
|
|||
|
||||
from vehicle import RDW, Vehicle
|
||||
|
||||
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.aiohttp_client import async_get_clientsession
|
||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
||||
|
||||
from .const import CONF_LICENSE_PLATE, DOMAIN, LOGGER, SCAN_INTERVAL
|
||||
|
||||
PLATFORMS = (BINARY_SENSOR_DOMAIN, SENSOR_DOMAIN)
|
||||
PLATFORMS = [Platform.BINARY_SENSOR, Platform.SENSOR]
|
||||
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
|
|
|
@ -7,6 +7,7 @@ from aiorecollect.client import Client, PickupEvent
|
|||
from aiorecollect.errors import RecollectError
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import aiohttp_client
|
||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
||||
|
@ -16,7 +17,7 @@ from .const import CONF_PLACE_ID, CONF_SERVICE_ID, DOMAIN, LOGGER
|
|||
DEFAULT_NAME = "recollect_waste"
|
||||
DEFAULT_UPDATE_INTERVAL = timedelta(days=1)
|
||||
|
||||
PLATFORMS = ["sensor"]
|
||||
PLATFORMS = [Platform.SENSOR]
|
||||
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
|
|
|
@ -18,6 +18,7 @@ from homeassistant.const import (
|
|||
CONF_HOST,
|
||||
CONF_PORT,
|
||||
EVENT_HOMEASSISTANT_STOP,
|
||||
Platform,
|
||||
)
|
||||
from homeassistant.core import callback
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
@ -60,7 +61,13 @@ def _bytearray_string(data):
|
|||
|
||||
SERVICE_SEND_SCHEMA = vol.Schema({ATTR_EVENT: _bytearray_string})
|
||||
|
||||
PLATFORMS = ["switch", "sensor", "light", "binary_sensor", "cover"]
|
||||
PLATFORMS = [
|
||||
Platform.SWITCH,
|
||||
Platform.SENSOR,
|
||||
Platform.LIGHT,
|
||||
Platform.BINARY_SENSOR,
|
||||
Platform.COVER,
|
||||
]
|
||||
|
||||
|
||||
async def async_setup_entry(hass, entry: config_entries.ConfigEntry):
|
||||
|
|
|
@ -9,7 +9,7 @@ from aioridwell.client import RidwellAccount, RidwellPickupEvent
|
|||
from aioridwell.errors import InvalidCredentialsError, RidwellError
|
||||
|
||||
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, ConfigEntryNotReady
|
||||
from homeassistant.helpers import aiohttp_client
|
||||
|
@ -19,7 +19,7 @@ from .const import DATA_ACCOUNT, DATA_COORDINATOR, DOMAIN, LOGGER
|
|||
|
||||
DEFAULT_UPDATE_INTERVAL = timedelta(hours=1)
|
||||
|
||||
PLATFORMS: list[str] = ["sensor"]
|
||||
PLATFORMS: list[Platform] = [Platform.SENSOR]
|
||||
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
|
|
|
@ -11,7 +11,7 @@ from oauthlib.oauth2 import AccessDeniedError
|
|||
import requests
|
||||
from ring_doorbell import Auth, Ring
|
||||
|
||||
from homeassistant.const import __version__
|
||||
from homeassistant.const import Platform, __version__
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.event import async_track_time_interval
|
||||
from homeassistant.util.async_ import run_callback_threadsafe
|
||||
|
@ -26,7 +26,13 @@ NOTIFICATION_TITLE = "Ring Setup"
|
|||
DOMAIN = "ring"
|
||||
DEFAULT_ENTITY_NAMESPACE = "ring"
|
||||
|
||||
PLATFORMS = ("binary_sensor", "light", "sensor", "switch", "camera")
|
||||
PLATFORMS = [
|
||||
Platform.BINARY_SENSOR,
|
||||
Platform.LIGHT,
|
||||
Platform.SENSOR,
|
||||
Platform.SWITCH,
|
||||
Platform.CAMERA,
|
||||
]
|
||||
|
||||
|
||||
async def async_setup(hass, config):
|
||||
|
|
|
@ -6,6 +6,7 @@ import aiohttp
|
|||
from pyrituals import Account, Diffuser
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ConfigEntryNotReady
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
|
@ -13,7 +14,13 @@ from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
|||
|
||||
from .const import ACCOUNT_HASH, COORDINATORS, DEVICES, DOMAIN
|
||||
|
||||
PLATFORMS = ["binary_sensor", "number", "select", "sensor", "switch"]
|
||||
PLATFORMS = [
|
||||
Platform.BINARY_SENSOR,
|
||||
Platform.NUMBER,
|
||||
Platform.SELECT,
|
||||
Platform.SENSOR,
|
||||
Platform.SWITCH,
|
||||
]
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
@ -5,10 +5,8 @@ import logging
|
|||
|
||||
from rokuecp import RokuConnectionError, RokuError
|
||||
|
||||
from homeassistant.components.media_player import DOMAIN as MEDIA_PLAYER_DOMAIN
|
||||
from homeassistant.components.remote import DOMAIN as REMOTE_DOMAIN
|
||||
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 config_validation as cv
|
||||
|
||||
|
@ -17,7 +15,7 @@ from .coordinator import RokuDataUpdateCoordinator
|
|||
|
||||
CONFIG_SCHEMA = cv.deprecated(DOMAIN)
|
||||
|
||||
PLATFORMS = [MEDIA_PLAYER_DOMAIN, REMOTE_DOMAIN]
|
||||
PLATFORMS = [Platform.MEDIA_PLAYER, Platform.REMOTE]
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
"""The roomba constants."""
|
||||
from homeassistant.const import Platform
|
||||
|
||||
DOMAIN = "roomba"
|
||||
PLATFORMS = ["sensor", "binary_sensor", "vacuum"]
|
||||
PLATFORMS = [Platform.SENSOR, Platform.BINARY_SENSOR, Platform.VACUUM]
|
||||
CONF_CERT = "certificate"
|
||||
CONF_CONTINUOUS = "continuous"
|
||||
CONF_BLID = "blid"
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
"""The Raspberry Pi Power Supply Checker integration."""
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
PLATFORMS = ["binary_sensor"]
|
||||
PLATFORMS = [Platform.BINARY_SENSOR]
|
||||
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
"""Constants for the Ruckus Unleashed integration."""
|
||||
from homeassistant.const import Platform
|
||||
|
||||
DOMAIN = "ruckus_unleashed"
|
||||
PLATFORMS = ["device_tracker"]
|
||||
PLATFORMS = [Platform.DEVICE_TRACKER]
|
||||
SCAN_INTERVAL = 180
|
||||
|
||||
MANUFACTURER = "Ruckus"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue