Use platform enum (1) [A-D] (#60908)
* Use platform enum (1) [A-D] * Fix imports * Fix tests * Use Platform even in tests
This commit is contained in:
parent
ef458b237c
commit
f57d42a9e8
65 changed files with 272 additions and 183 deletions
|
@ -16,6 +16,7 @@ from homeassistant.const import (
|
|||
CONF_PASSWORD,
|
||||
CONF_USERNAME,
|
||||
EVENT_HOMEASSISTANT_STOP,
|
||||
Platform,
|
||||
)
|
||||
from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
|
||||
from homeassistant.helpers import config_validation as cv
|
||||
|
@ -53,14 +54,14 @@ CAPTURE_IMAGE_SCHEMA = vol.Schema({ATTR_ENTITY_ID: cv.entity_ids})
|
|||
AUTOMATION_SCHEMA = vol.Schema({ATTR_ENTITY_ID: cv.entity_ids})
|
||||
|
||||
PLATFORMS = [
|
||||
"alarm_control_panel",
|
||||
"binary_sensor",
|
||||
"lock",
|
||||
"switch",
|
||||
"cover",
|
||||
"camera",
|
||||
"light",
|
||||
"sensor",
|
||||
Platform.ALARM_CONTROL_PANEL,
|
||||
Platform.BINARY_SENSOR,
|
||||
Platform.LOCK,
|
||||
Platform.SWITCH,
|
||||
Platform.COVER,
|
||||
Platform.CAMERA,
|
||||
Platform.LIGHT,
|
||||
Platform.SENSOR,
|
||||
]
|
||||
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ from aiohttp.client_exceptions import ClientConnectorError
|
|||
from async_timeout import timeout
|
||||
|
||||
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.helpers.aiohttp_client import async_get_clientsession
|
||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
||||
|
@ -20,7 +20,7 @@ from .const import ATTR_FORECAST, CONF_FORECAST, DOMAIN
|
|||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
PLATFORMS = ["sensor", "weather"]
|
||||
PLATFORMS = [Platform.SENSOR, Platform.WEATHER]
|
||||
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
"""The Rollease Acmeda Automate integration."""
|
||||
|
||||
from homeassistant import config_entries, core
|
||||
from homeassistant.const import Platform
|
||||
|
||||
from .const import DOMAIN
|
||||
from .hub import PulseHub
|
||||
|
||||
CONF_HUBS = "hubs"
|
||||
|
||||
PLATFORMS = ["cover", "sensor"]
|
||||
PLATFORMS = [Platform.COVER, Platform.SENSOR]
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
|
|
|
@ -2,9 +2,10 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
PLATFORMS = ["climate"]
|
||||
PLATFORMS = [Platform.CLIMATE]
|
||||
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
|
|
|
@ -16,6 +16,7 @@ from homeassistant.const import (
|
|||
CONF_URL,
|
||||
CONF_USERNAME,
|
||||
CONF_VERIFY_SSL,
|
||||
Platform,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ConfigEntryNotReady
|
||||
|
@ -46,7 +47,7 @@ SERVICE_REFRESH_SCHEMA = vol.Schema(
|
|||
{vol.Optional(CONF_FORCE, default=False): cv.boolean}
|
||||
)
|
||||
|
||||
PLATFORMS = ["sensor", "switch"]
|
||||
PLATFORMS = [Platform.SENSOR, Platform.SWITCH]
|
||||
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
|
|
|
@ -5,14 +5,21 @@ import logging
|
|||
|
||||
from advantage_air import ApiError, advantage_air
|
||||
|
||||
from homeassistant.const import CONF_IP_ADDRESS, CONF_PORT
|
||||
from homeassistant.const import CONF_IP_ADDRESS, CONF_PORT, Platform
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
||||
|
||||
from .const import ADVANTAGE_AIR_RETRY, DOMAIN
|
||||
|
||||
ADVANTAGE_AIR_SYNC_INTERVAL = 15
|
||||
PLATFORMS = ["binary_sensor", "climate", "cover", "select", "sensor", "switch"]
|
||||
PLATFORMS = [
|
||||
Platform.BINARY_SENSOR,
|
||||
Platform.CLIMATE,
|
||||
Platform.COVER,
|
||||
Platform.SELECT,
|
||||
Platform.SENSOR,
|
||||
Platform.SWITCH,
|
||||
]
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
@ -33,11 +33,12 @@ from homeassistant.const import (
|
|||
PRESSURE_HPA,
|
||||
SPEED_KILOMETERS_PER_HOUR,
|
||||
TEMP_CELSIUS,
|
||||
Platform,
|
||||
)
|
||||
|
||||
ATTRIBUTION = "Powered by AEMET OpenData"
|
||||
CONF_STATION_UPDATES = "station_updates"
|
||||
PLATFORMS = ["sensor", "weather"]
|
||||
PLATFORMS = [Platform.SENSOR, Platform.WEATHER]
|
||||
DEFAULT_NAME = "AEMET"
|
||||
DOMAIN = "aemet"
|
||||
ENTRY_NAME = "name"
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
from agent import AgentError
|
||||
from agent.a import Agent
|
||||
|
||||
from homeassistant.const import Platform
|
||||
from homeassistant.exceptions import ConfigEntryNotReady
|
||||
from homeassistant.helpers import device_registry as dr
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
|
@ -12,7 +13,7 @@ from .const import CONNECTION, DOMAIN as AGENT_DOMAIN, SERVER_URL
|
|||
ATTRIBUTION = "ispyconnect.com"
|
||||
DEFAULT_BRAND = "Agent DVR by ispyconnect.com"
|
||||
|
||||
FORWARDS = ["alarm_control_panel", "camera"]
|
||||
PLATFORMS = [Platform.ALARM_CONTROL_PANEL, Platform.CAMERA]
|
||||
|
||||
|
||||
async def async_setup_entry(hass, config_entry):
|
||||
|
@ -46,14 +47,16 @@ async def async_setup_entry(hass, config_entry):
|
|||
sw_version=agent_client.version,
|
||||
)
|
||||
|
||||
hass.config_entries.async_setup_platforms(config_entry, FORWARDS)
|
||||
hass.config_entries.async_setup_platforms(config_entry, PLATFORMS)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
async def async_unload_entry(hass, config_entry):
|
||||
"""Unload a config entry."""
|
||||
unload_ok = await hass.config_entries.async_unload_platforms(config_entry, FORWARDS)
|
||||
unload_ok = await hass.config_entries.async_unload_platforms(
|
||||
config_entry, PLATFORMS
|
||||
)
|
||||
|
||||
await hass.data[AGENT_DOMAIN][config_entry.entry_id][CONNECTION].close()
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ import async_timeout
|
|||
|
||||
from homeassistant.components.air_quality import DOMAIN as AIR_QUALITY_PLATFORM
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE
|
||||
from homeassistant.const import CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
|
@ -33,7 +33,7 @@ from .const import (
|
|||
NO_AIRLY_SENSORS,
|
||||
)
|
||||
|
||||
PLATFORMS = ["sensor"]
|
||||
PLATFORMS = [Platform.SENSOR]
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
@ -8,7 +8,13 @@ from pyairnow.conv import aqi_to_concentration
|
|||
from pyairnow.errors import AirNowError
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE, CONF_RADIUS
|
||||
from homeassistant.const import (
|
||||
CONF_API_KEY,
|
||||
CONF_LATITUDE,
|
||||
CONF_LONGITUDE,
|
||||
CONF_RADIUS,
|
||||
Platform,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
||||
|
@ -33,7 +39,7 @@ from .const import (
|
|||
)
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
PLATFORMS = ["sensor"]
|
||||
PLATFORMS = [Platform.SENSOR]
|
||||
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
|
|
|
@ -7,6 +7,7 @@ import logging
|
|||
from airthings import Airthings, AirthingsError
|
||||
|
||||
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, UpdateFailed
|
||||
|
@ -15,7 +16,7 @@ from .const import CONF_ID, CONF_SECRET, DOMAIN
|
|||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
PLATFORMS: list[str] = ["sensor"]
|
||||
PLATFORMS: list[Platform] = [Platform.SENSOR]
|
||||
SCAN_INTERVAL = timedelta(minutes=6)
|
||||
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ from airtouch4pyapi.airtouch import AirTouchStatus
|
|||
|
||||
from homeassistant.components.climate import SCAN_INTERVAL
|
||||
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, UpdateFailed
|
||||
|
@ -15,7 +15,7 @@ from .const import DOMAIN
|
|||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
PLATFORMS = ["climate"]
|
||||
PLATFORMS = [Platform.CLIMATE]
|
||||
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
|
|
|
@ -23,6 +23,7 @@ from homeassistant.const import (
|
|||
CONF_PASSWORD,
|
||||
CONF_SHOW_ON_MAP,
|
||||
CONF_STATE,
|
||||
Platform,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.exceptions import ConfigEntryAuthFailed
|
||||
|
@ -51,7 +52,7 @@ from .const import (
|
|||
LOGGER,
|
||||
)
|
||||
|
||||
PLATFORMS = ["sensor"]
|
||||
PLATFORMS = [Platform.SENSOR]
|
||||
|
||||
DEFAULT_ATTRIBUTION = "Data provided by AirVisual"
|
||||
DEFAULT_NODE_PRO_UPDATE_INTERVAL = timedelta(minutes=1)
|
||||
|
|
|
@ -12,6 +12,7 @@ from homeassistant.const import (
|
|||
CONF_PORT,
|
||||
CONF_PROTOCOL,
|
||||
EVENT_HOMEASSISTANT_STOP,
|
||||
Platform,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.util import dt as dt_util
|
||||
|
@ -35,7 +36,11 @@ from .const import (
|
|||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
PLATFORMS = ["alarm_control_panel", "sensor", "binary_sensor"]
|
||||
PLATFORMS = [
|
||||
Platform.ALARM_CONTROL_PANEL,
|
||||
Platform.SENSOR,
|
||||
Platform.BINARY_SENSOR,
|
||||
]
|
||||
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
|
|
|
@ -3,16 +3,15 @@ from __future__ import annotations
|
|||
|
||||
from ambee import AirQuality, Ambee, AmbeeAuthenticationError, Pollen
|
||||
|
||||
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE
|
||||
from homeassistant.const import CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ConfigEntryAuthFailed
|
||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
||||
|
||||
from .const import DOMAIN, LOGGER, SCAN_INTERVAL, SERVICE_AIR_QUALITY, SERVICE_POLLEN
|
||||
|
||||
PLATFORMS = (SENSOR_DOMAIN,)
|
||||
PLATFORMS = [Platform.SENSOR]
|
||||
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
"""Amber Electric Constants."""
|
||||
import logging
|
||||
|
||||
from homeassistant.const import Platform
|
||||
|
||||
DOMAIN = "amberelectric"
|
||||
CONF_API_TOKEN = "api_token"
|
||||
CONF_SITE_NAME = "site_name"
|
||||
|
@ -10,4 +12,4 @@ CONF_SITE_NMI = "site_nmi"
|
|||
ATTRIBUTION = "Data provided by Amber Electric"
|
||||
|
||||
LOGGER = logging.getLogger(__package__)
|
||||
PLATFORMS = ["sensor", "binary_sensor"]
|
||||
PLATFORMS = [Platform.SENSOR, Platform.BINARY_SENSOR]
|
||||
|
|
|
@ -13,6 +13,7 @@ from homeassistant.const import (
|
|||
ATTR_NAME,
|
||||
CONF_API_KEY,
|
||||
EVENT_HOMEASSISTANT_STOP,
|
||||
Platform,
|
||||
)
|
||||
from homeassistant.core import Event, HomeAssistant, callback
|
||||
from homeassistant.exceptions import ConfigEntryNotReady
|
||||
|
@ -34,7 +35,7 @@ from .const import (
|
|||
TYPE_SOLARRADIATION_LX,
|
||||
)
|
||||
|
||||
PLATFORMS = ["binary_sensor", "sensor"]
|
||||
PLATFORMS = [Platform.BINARY_SENSOR, Platform.SENSOR]
|
||||
|
||||
DATA_CONFIG = "config"
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ from arcam.fmj.client import Client
|
|||
import async_timeout
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_HOST, CONF_PORT, EVENT_HOMEASSISTANT_STOP
|
||||
from homeassistant.const import CONF_HOST, CONF_PORT, EVENT_HOMEASSISTANT_STOP, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
|
@ -27,7 +27,7 @@ _LOGGER = logging.getLogger(__name__)
|
|||
|
||||
CONFIG_SCHEMA = cv.deprecated(DOMAIN)
|
||||
|
||||
PLATFORMS = ["media_player"]
|
||||
PLATFORMS = [Platform.MEDIA_PLAYER]
|
||||
|
||||
|
||||
async def _await_cancel(task):
|
||||
|
|
|
@ -12,6 +12,7 @@ from homeassistant.const import (
|
|||
CONF_SENSORS,
|
||||
CONF_USERNAME,
|
||||
EVENT_HOMEASSISTANT_STOP,
|
||||
Platform,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import config_validation as cv
|
||||
|
@ -33,7 +34,7 @@ from .const import (
|
|||
)
|
||||
from .router import AsusWrtRouter
|
||||
|
||||
PLATFORMS = ["device_tracker", "sensor"]
|
||||
PLATFORMS = [Platform.DEVICE_TRACKER, Platform.SENSOR]
|
||||
|
||||
CONF_PUB_KEY = "pub_key"
|
||||
SECRET_GROUP = "Password or SSH Key"
|
||||
|
|
|
@ -5,10 +5,8 @@ import logging
|
|||
import async_timeout
|
||||
from pyatag import AtagException, AtagOne
|
||||
|
||||
from homeassistant.components.climate import DOMAIN as CLIMATE
|
||||
from homeassistant.components.sensor import DOMAIN as SENSOR
|
||||
from homeassistant.components.water_heater import DOMAIN as WATER_HEATER
|
||||
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.entity import DeviceInfo
|
||||
|
@ -21,7 +19,7 @@ from homeassistant.helpers.update_coordinator import (
|
|||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
DOMAIN = "atag"
|
||||
PLATFORMS = [CLIMATE, WATER_HEATER, SENSOR]
|
||||
PLATFORMS = [Platform.CLIMATE, Platform.WATER_HEATER, Platform.SENSOR]
|
||||
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
|
|
|
@ -12,9 +12,9 @@ from homeassistant.components.climate.const import (
|
|||
SUPPORT_PRESET_MODE,
|
||||
SUPPORT_TARGET_TEMPERATURE,
|
||||
)
|
||||
from homeassistant.const import ATTR_TEMPERATURE
|
||||
from homeassistant.const import ATTR_TEMPERATURE, Platform
|
||||
|
||||
from . import CLIMATE, DOMAIN, AtagEntity
|
||||
from . import DOMAIN, AtagEntity
|
||||
|
||||
PRESET_MAP = {
|
||||
"Manual": "manual",
|
||||
|
@ -31,7 +31,7 @@ HVAC_MODES = [HVAC_MODE_AUTO, HVAC_MODE_HEAT]
|
|||
async def async_setup_entry(hass, entry, async_add_entities):
|
||||
"""Load a config entry."""
|
||||
coordinator = hass.data[DOMAIN][entry.entry_id]
|
||||
async_add_entities([AtagThermostat(coordinator, CLIMATE)])
|
||||
async_add_entities([AtagThermostat(coordinator, Platform.CLIMATE)])
|
||||
|
||||
|
||||
class AtagThermostat(AtagEntity, ClimateEntity):
|
||||
|
|
|
@ -5,9 +5,9 @@ from homeassistant.components.water_heater import (
|
|||
STATE_PERFORMANCE,
|
||||
WaterHeaterEntity,
|
||||
)
|
||||
from homeassistant.const import STATE_OFF, TEMP_CELSIUS
|
||||
from homeassistant.const import STATE_OFF, TEMP_CELSIUS, Platform
|
||||
|
||||
from . import DOMAIN, WATER_HEATER, AtagEntity
|
||||
from . import DOMAIN, AtagEntity
|
||||
|
||||
SUPPORT_FLAGS_HEATER = 0
|
||||
OPERATION_LIST = [STATE_OFF, STATE_ECO, STATE_PERFORMANCE]
|
||||
|
@ -16,7 +16,7 @@ OPERATION_LIST = [STATE_OFF, STATE_ECO, STATE_PERFORMANCE]
|
|||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
"""Initialize DHW device from config entry."""
|
||||
coordinator = hass.data[DOMAIN][config_entry.entry_id]
|
||||
async_add_entities([AtagWaterHeater(coordinator, WATER_HEATER)])
|
||||
async_add_entities([AtagWaterHeater(coordinator, Platform.WATER_HEATER)])
|
||||
|
||||
|
||||
class AtagWaterHeater(AtagEntity, WaterHeaterEntity):
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
from datetime import timedelta
|
||||
|
||||
from homeassistant.const import Platform
|
||||
|
||||
DEFAULT_TIMEOUT = 10
|
||||
|
||||
CONF_ACCESS_TOKEN_CACHE_FILE = "access_token_cache_file"
|
||||
|
@ -43,4 +45,9 @@ ACTIVITY_UPDATE_INTERVAL = timedelta(seconds=10)
|
|||
|
||||
LOGIN_METHODS = ["phone", "email"]
|
||||
|
||||
PLATFORMS = ["camera", "binary_sensor", "lock", "sensor"]
|
||||
PLATFORMS = [
|
||||
Platform.CAMERA,
|
||||
Platform.BINARY_SENSOR,
|
||||
Platform.LOCK,
|
||||
Platform.SENSOR,
|
||||
]
|
||||
|
|
|
@ -7,7 +7,7 @@ from aiohttp import ClientError
|
|||
from auroranoaa import AuroraForecast
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE, CONF_NAME
|
||||
from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE, CONF_NAME, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import aiohttp_client
|
||||
from homeassistant.helpers.device_registry import DeviceEntryType
|
||||
|
@ -30,7 +30,7 @@ from .const import (
|
|||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
PLATFORMS = ["binary_sensor", "sensor"]
|
||||
PLATFORMS = [Platform.BINARY_SENSOR, Platform.SENSOR]
|
||||
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
|
|
|
@ -13,14 +13,14 @@ import logging
|
|||
from aurorapy.client import AuroraError, AuroraSerialClient
|
||||
|
||||
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
|
||||
from homeassistant.exceptions import ConfigEntryNotReady
|
||||
|
||||
from .config_flow import validate_and_connect
|
||||
from .const import ATTR_SERIAL_NUMBER, DOMAIN
|
||||
|
||||
PLATFORMS = ["sensor"]
|
||||
PLATFORMS = [Platform.SENSOR]
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
@ -8,14 +8,14 @@ from async_timeout import timeout
|
|||
from python_awair import Awair
|
||||
from python_awair.exceptions import AuthError
|
||||
|
||||
from homeassistant.const import CONF_ACCESS_TOKEN
|
||||
from homeassistant.const import CONF_ACCESS_TOKEN, Platform
|
||||
from homeassistant.exceptions import ConfigEntryAuthFailed
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
||||
|
||||
from .const import API_TIMEOUT, DOMAIN, LOGGER, UPDATE_INTERVAL, AwairResult
|
||||
|
||||
PLATFORMS = ["sensor"]
|
||||
PLATFORMS = [Platform.SENSOR]
|
||||
|
||||
|
||||
async def async_setup_entry(hass, config_entry) -> bool:
|
||||
|
|
|
@ -12,6 +12,7 @@ from aioazuredevops.core import DevOpsProject
|
|||
import aiohttp
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ConfigEntryAuthFailed
|
||||
from homeassistant.helpers.device_registry import DeviceEntryType
|
||||
|
@ -26,7 +27,7 @@ from .const import CONF_ORG, CONF_PAT, CONF_PROJECT, DOMAIN
|
|||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
PLATFORMS = ["sensor"]
|
||||
PLATFORMS = [Platform.SENSOR]
|
||||
|
||||
BUILDS_QUERY: Final = "?queryOrder=queueTimeDescending&maxBuildsPerDefinition=1"
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ from homeassistant.components.climate.const import (
|
|||
HVAC_MODE_OFF,
|
||||
)
|
||||
from homeassistant.components.fan import SPEED_HIGH, SPEED_LOW, SPEED_OFF
|
||||
from homeassistant.const import Platform
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@ -21,7 +22,7 @@ CLIMATE_SUPPORTED_MODES = [HVAC_MODE_AUTO, HVAC_MODE_HEAT, HVAC_MODE_OFF]
|
|||
CONF_SYNC_TIME = "sync_time"
|
||||
DEFAULT_SYNC_TIME = False
|
||||
FAN_SUPPORTED_SPEEDS = [SPEED_OFF, SPEED_LOW, SPEED_HIGH]
|
||||
PLATFORMS = ["binary_sensor", "climate"]
|
||||
PLATFORMS = [Platform.BINARY_SENSOR, Platform.CLIMATE]
|
||||
|
||||
AUX = "Aux"
|
||||
CIRC_PUMP = "Circ Pump"
|
||||
|
|
|
@ -6,7 +6,7 @@ from blebox_uniapi.products import Products
|
|||
from blebox_uniapi.session import ApiHost
|
||||
|
||||
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, callback
|
||||
from homeassistant.exceptions import ConfigEntryNotReady
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
|
@ -16,7 +16,14 @@ from .const import DEFAULT_SETUP_TIMEOUT, DOMAIN, PRODUCT
|
|||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
PLATFORMS = ["cover", "sensor", "switch", "air_quality", "light", "climate"]
|
||||
PLATFORMS = [
|
||||
Platform.COVER,
|
||||
Platform.SENSOR,
|
||||
Platform.SWITCH,
|
||||
Platform.AIR_QUALITY,
|
||||
Platform.LIGHT,
|
||||
Platform.CLIMATE,
|
||||
]
|
||||
|
||||
PARALLEL_UPDATES = 0
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
"""Constants for Blink."""
|
||||
from homeassistant.const import Platform
|
||||
|
||||
DOMAIN = "blink"
|
||||
DEVICE_ID = "Home Assistant"
|
||||
|
||||
|
@ -23,4 +25,9 @@ SERVICE_TRIGGER = "trigger_camera"
|
|||
SERVICE_SAVE_VIDEO = "save_video"
|
||||
SERVICE_SEND_PIN = "send_pin"
|
||||
|
||||
PLATFORMS = ("alarm_control_panel", "binary_sensor", "camera", "sensor")
|
||||
PLATFORMS = [
|
||||
Platform.ALARM_CONTROL_PANEL,
|
||||
Platform.BINARY_SENSOR,
|
||||
Platform.CAMERA,
|
||||
Platform.SENSOR,
|
||||
]
|
||||
|
|
|
@ -18,6 +18,7 @@ from homeassistant.const import (
|
|||
CONF_PASSWORD,
|
||||
CONF_REGION,
|
||||
CONF_USERNAME,
|
||||
Platform,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant, ServiceCall, callback
|
||||
from homeassistant.exceptions import ConfigEntryNotReady
|
||||
|
@ -67,7 +68,13 @@ DEFAULT_OPTIONS = {
|
|||
CONF_USE_LOCATION: False,
|
||||
}
|
||||
|
||||
PLATFORMS = ["binary_sensor", "device_tracker", "lock", "notify", "sensor"]
|
||||
PLATFORMS = [
|
||||
Platform.BINARY_SENSOR,
|
||||
Platform.DEVICE_TRACKER,
|
||||
Platform.LOCK,
|
||||
Platform.NOTIFY,
|
||||
Platform.SENSOR,
|
||||
]
|
||||
UPDATE_INTERVAL = 5 # in minutes
|
||||
|
||||
SERVICE_UPDATE_STATE = "update_state"
|
||||
|
@ -150,7 +157,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||
await _async_update_all()
|
||||
|
||||
hass.config_entries.async_setup_platforms(
|
||||
entry, [platform for platform in PLATFORMS if platform != NOTIFY_DOMAIN]
|
||||
entry, [platform for platform in PLATFORMS if platform != Platform.NOTIFY]
|
||||
)
|
||||
|
||||
# set up notify platform, no entry support for notify platform yet,
|
||||
|
@ -171,7 +178,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
"""Unload a config entry."""
|
||||
unload_ok = await hass.config_entries.async_unload_platforms(
|
||||
entry, [platform for platform in PLATFORMS if platform != NOTIFY_DOMAIN]
|
||||
entry, [platform for platform in PLATFORMS if platform != Platform.NOTIFY]
|
||||
)
|
||||
|
||||
# Only remove services if it is the last account and not read only
|
||||
|
|
|
@ -8,7 +8,12 @@ from aiohttp import ClientError, ClientResponseError, ClientTimeout
|
|||
from bond_api import Bond, BPUPSubscriptions, start_bpup
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_ACCESS_TOKEN, CONF_HOST, EVENT_HOMEASSISTANT_STOP
|
||||
from homeassistant.const import (
|
||||
CONF_ACCESS_TOKEN,
|
||||
CONF_HOST,
|
||||
EVENT_HOMEASSISTANT_STOP,
|
||||
Platform,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.exceptions import ConfigEntryNotReady
|
||||
from homeassistant.helpers import device_registry as dr
|
||||
|
@ -18,7 +23,12 @@ from homeassistant.helpers.entity import SLOW_UPDATE_WARNING
|
|||
from .const import BPUP_SUBS, BRIDGE_MAKE, DOMAIN, HUB
|
||||
from .utils import BondHub
|
||||
|
||||
PLATFORMS = ["cover", "fan", "light", "switch"]
|
||||
PLATFORMS = [
|
||||
Platform.COVER,
|
||||
Platform.FAN,
|
||||
Platform.LIGHT,
|
||||
Platform.SWITCH,
|
||||
]
|
||||
_API_TIMEOUT = SLOW_UPDATE_WARNING - 1
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
|
|
@ -6,7 +6,7 @@ from boschshcpy.exceptions import SHCAuthenticationError, SHCConnectionError
|
|||
|
||||
from homeassistant.components.zeroconf import async_get_instance
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_HOST, EVENT_HOMEASSISTANT_STOP
|
||||
from homeassistant.const import CONF_HOST, EVENT_HOMEASSISTANT_STOP, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
|
||||
from homeassistant.helpers import device_registry as dr
|
||||
|
@ -19,7 +19,7 @@ from .const import (
|
|||
DOMAIN,
|
||||
)
|
||||
|
||||
PLATFORMS = ["binary_sensor", "cover", "sensor"]
|
||||
PLATFORMS = [Platform.BINARY_SENSOR, Platform.COVER, Platform.SENSOR]
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
@ -10,10 +10,8 @@ from typing import Final
|
|||
from bravia_tv import BraviaRC
|
||||
from bravia_tv.braviarc import NoIPControl
|
||||
|
||||
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, CONF_MAC, CONF_PIN
|
||||
from homeassistant.const import CONF_HOST, CONF_MAC, CONF_PIN, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.debounce import Debouncer
|
||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
||||
|
@ -22,7 +20,7 @@ from .const import CLIENTID_PREFIX, CONF_IGNORED_SOURCES, DOMAIN, NICKNAME
|
|||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
PLATFORMS: Final[list[str]] = [MEDIA_PLAYER_DOMAIN, REMOTE_DOMAIN]
|
||||
PLATFORMS: Final[list[Platform]] = [Platform.MEDIA_PLAYER, Platform.REMOTE]
|
||||
SCAN_INTERVAL: Final = timedelta(seconds=10)
|
||||
|
||||
|
||||
|
|
|
@ -1,14 +1,11 @@
|
|||
"""Constants."""
|
||||
from homeassistant.components.light import DOMAIN as LIGHT_DOMAIN
|
||||
from homeassistant.components.remote import DOMAIN as REMOTE_DOMAIN
|
||||
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
|
||||
from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN
|
||||
from homeassistant.const import Platform
|
||||
|
||||
DOMAIN = "broadlink"
|
||||
|
||||
DOMAINS_AND_TYPES = {
|
||||
REMOTE_DOMAIN: {"RM4MINI", "RM4PRO", "RMMINI", "RMMINIB", "RMPRO"},
|
||||
SENSOR_DOMAIN: {
|
||||
Platform.REMOTE: {"RM4MINI", "RM4PRO", "RMMINI", "RMMINIB", "RMPRO"},
|
||||
Platform.SENSOR: {
|
||||
"A1",
|
||||
"RM4MINI",
|
||||
"RM4PRO",
|
||||
|
@ -18,7 +15,7 @@ DOMAINS_AND_TYPES = {
|
|||
"SP4",
|
||||
"SP4B",
|
||||
},
|
||||
SWITCH_DOMAIN: {
|
||||
Platform.SWITCH: {
|
||||
"BG1",
|
||||
"MP1",
|
||||
"RM4MINI",
|
||||
|
@ -34,7 +31,7 @@ DOMAINS_AND_TYPES = {
|
|||
"SP4",
|
||||
"SP4B",
|
||||
},
|
||||
LIGHT_DOMAIN: {"LB1"},
|
||||
Platform.LIGHT: {"LB1"},
|
||||
}
|
||||
DEVICE_TYPES = set.union(*DOMAINS_AND_TYPES.values())
|
||||
|
||||
|
|
|
@ -22,11 +22,12 @@ from homeassistant.const import (
|
|||
CONF_TIMEOUT,
|
||||
CONF_TYPE,
|
||||
STATE_ON,
|
||||
Platform,
|
||||
)
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.restore_state import RestoreEntity
|
||||
|
||||
from .const import DOMAIN, SWITCH_DOMAIN
|
||||
from .const import DOMAIN
|
||||
from .entity import BroadlinkEntity
|
||||
from .helpers import data_packet, import_device, mac_address
|
||||
|
||||
|
@ -90,7 +91,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
|
|||
)
|
||||
|
||||
if switches:
|
||||
platform_data = hass.data[DOMAIN].platforms.setdefault(SWITCH_DOMAIN, {})
|
||||
platform_data = hass.data[DOMAIN].platforms.setdefault(Platform.SWITCH, {})
|
||||
platform_data.setdefault(mac_addr, []).extend(switches)
|
||||
|
||||
else:
|
||||
|
@ -110,7 +111,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
|||
switches = []
|
||||
|
||||
if device.api.type in {"RM4MINI", "RM4PRO", "RMMINI", "RMMINIB", "RMPRO"}:
|
||||
platform_data = hass.data[DOMAIN].platforms.get(SWITCH_DOMAIN, {})
|
||||
platform_data = hass.data[DOMAIN].platforms.get(Platform.SWITCH, {})
|
||||
user_defined_switches = platform_data.get(device.api.mac, {})
|
||||
switches.extend(
|
||||
BroadlinkRMSwitch(device, config) for config in user_defined_switches
|
||||
|
|
|
@ -8,14 +8,14 @@ from brother import Brother, DictToObj, SnmpError, UnsupportedModel
|
|||
import pysnmp.hlapi.asyncio as SnmpEngine
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_HOST, CONF_TYPE
|
||||
from homeassistant.const import CONF_HOST, CONF_TYPE, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
||||
|
||||
from .const import DATA_CONFIG_ENTRY, DOMAIN, SNMP
|
||||
from .utils import get_snmp_engine
|
||||
|
||||
PLATFORMS = ["sensor"]
|
||||
PLATFORMS = [Platform.SENSOR]
|
||||
|
||||
SCAN_INTERVAL = timedelta(seconds=30)
|
||||
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
"""Constants for Brunt."""
|
||||
from datetime import timedelta
|
||||
|
||||
from homeassistant.const import Platform
|
||||
|
||||
DOMAIN = "brunt"
|
||||
ATTR_REQUEST_POSITION = "request_position"
|
||||
NOTIFICATION_ID = "brunt_notification"
|
||||
NOTIFICATION_TITLE = "Brunt Cover Setup"
|
||||
ATTRIBUTION = "Based on an unofficial Brunt SDK."
|
||||
PLATFORMS = ["cover"]
|
||||
PLATFORMS = [Platform.COVER]
|
||||
DATA_BAPI = "bapi"
|
||||
DATA_COOR = "coordinator"
|
||||
|
||||
|
|
|
@ -3,9 +3,14 @@ from datetime import timedelta
|
|||
|
||||
from bsblan import BSBLan, BSBLanConnectionError
|
||||
|
||||
from homeassistant.components.climate import DOMAIN as CLIMATE_DOMAIN
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_PORT, CONF_USERNAME
|
||||
from homeassistant.const import (
|
||||
CONF_HOST,
|
||||
CONF_PASSWORD,
|
||||
CONF_PORT,
|
||||
CONF_USERNAME,
|
||||
Platform,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ConfigEntryNotReady
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
|
@ -14,7 +19,7 @@ from .const import CONF_PASSKEY, DATA_BSBLAN_CLIENT, DOMAIN
|
|||
|
||||
SCAN_INTERVAL = timedelta(seconds=30)
|
||||
|
||||
PLATFORMS = [CLIMATE_DOMAIN]
|
||||
PLATFORMS = [Platform.CLIMATE]
|
||||
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
|
|
|
@ -2,11 +2,12 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from .const import DOMAIN
|
||||
|
||||
PLATFORMS = ["camera", "sensor", "weather"]
|
||||
PLATFORMS = [Platform.CAMERA, Platform.SENSOR, Platform.WEATHER]
|
||||
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
|
|
|
@ -11,7 +11,7 @@ import voluptuous as vol
|
|||
|
||||
from homeassistant.components.camera.const import DOMAIN as CAMERA_DOMAIN
|
||||
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
|
||||
from homeassistant.const import CONF_PASSWORD, CONF_TIMEOUT, CONF_USERNAME
|
||||
from homeassistant.const import CONF_PASSWORD, CONF_TIMEOUT, CONF_USERNAME, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ConfigEntryNotReady
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
@ -49,7 +49,11 @@ CONFIG_SCHEMA: Final = vol.Schema(
|
|||
extra=vol.ALLOW_EXTRA,
|
||||
)
|
||||
|
||||
PLATFORMS: Final[list[str]] = ["alarm_control_panel", "camera", "sensor"]
|
||||
PLATFORMS: Final[list[Platform]] = [
|
||||
Platform.ALARM_CONTROL_PANEL,
|
||||
Platform.CAMERA,
|
||||
Platform.SENSOR,
|
||||
]
|
||||
|
||||
|
||||
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||
|
|
|
@ -6,7 +6,12 @@ import logging
|
|||
from typing import Optional
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_HOST, CONF_PORT, EVENT_HOMEASSISTANT_STARTED
|
||||
from homeassistant.const import (
|
||||
CONF_HOST,
|
||||
CONF_PORT,
|
||||
EVENT_HOMEASSISTANT_STARTED,
|
||||
Platform,
|
||||
)
|
||||
from homeassistant.core import CoreState, HomeAssistant
|
||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
||||
|
||||
|
@ -18,7 +23,7 @@ _LOGGER = logging.getLogger(__name__)
|
|||
|
||||
SCAN_INTERVAL = timedelta(hours=12)
|
||||
|
||||
PLATFORMS = ["sensor"]
|
||||
PLATFORMS = [Platform.SENSOR]
|
||||
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
|
|
|
@ -15,8 +15,6 @@ from pyclimacell.exceptions import (
|
|||
UnknownException,
|
||||
)
|
||||
|
||||
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
|
||||
from homeassistant.components.weather import DOMAIN as WEATHER_DOMAIN
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
CONF_API_KEY,
|
||||
|
@ -24,6 +22,7 @@ from homeassistant.const import (
|
|||
CONF_LATITUDE,
|
||||
CONF_LONGITUDE,
|
||||
CONF_NAME,
|
||||
Platform,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
|
@ -76,7 +75,7 @@ from .const import (
|
|||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
PLATFORMS = [SENSOR_DOMAIN, WEATHER_DOMAIN]
|
||||
PLATFORMS = [Platform.SENSOR, Platform.WEATHER]
|
||||
|
||||
|
||||
def _set_update_interval(hass: HomeAssistant, current_entry: ConfigEntry) -> timedelta:
|
||||
|
|
|
@ -8,7 +8,7 @@ from typing import TypedDict, cast
|
|||
import CO2Signal
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE
|
||||
from homeassistant.const import CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ConfigEntryAuthFailed, HomeAssistantError
|
||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
||||
|
@ -16,7 +16,7 @@ from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, Upda
|
|||
from .const import CONF_COUNTRY_CODE, DOMAIN
|
||||
from .util import get_extra_name
|
||||
|
||||
PLATFORMS = ["sensor"]
|
||||
PLATFORMS = [Platform.SENSOR]
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ from coinbase.wallet.error import AuthenticationError
|
|||
import voluptuous as vol
|
||||
|
||||
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
|
||||
from homeassistant.const import CONF_API_KEY, CONF_API_TOKEN
|
||||
from homeassistant.const import CONF_API_KEY, CONF_API_TOKEN, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
@ -28,7 +28,7 @@ from .const import (
|
|||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
PLATFORMS = ["sensor"]
|
||||
PLATFORMS = [Platform.SENSOR]
|
||||
MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=1)
|
||||
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ from homeassistant.const import (
|
|||
CONF_SCAN_INTERVAL,
|
||||
CONF_TOKEN,
|
||||
CONF_USERNAME,
|
||||
Platform,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ConfigEntryNotReady
|
||||
|
@ -41,7 +42,7 @@ from .const import (
|
|||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
PLATFORMS = ["light"]
|
||||
PLATFORMS = [Platform.LIGHT]
|
||||
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
|
|
|
@ -4,7 +4,7 @@ import logging
|
|||
from pycoolmasternet_async import CoolMasterNet
|
||||
|
||||
from homeassistant.components.climate import SCAN_INTERVAL
|
||||
from homeassistant.const import CONF_HOST, CONF_PORT
|
||||
from homeassistant.const import CONF_HOST, CONF_PORT, Platform
|
||||
from homeassistant.exceptions import ConfigEntryNotReady
|
||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
||||
|
||||
|
@ -12,7 +12,7 @@ from .const import DATA_COORDINATOR, DATA_INFO, DOMAIN
|
|||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
PLATFORMS = ["climate"]
|
||||
PLATFORMS = [Platform.CLIMATE]
|
||||
|
||||
|
||||
async def async_setup_entry(hass, entry):
|
||||
|
|
|
@ -6,13 +6,14 @@ import async_timeout
|
|||
import coronavirus
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import Platform
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers import aiohttp_client, entity_registry, update_coordinator
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
|
||||
from .const import DOMAIN
|
||||
|
||||
PLATFORMS = ["sensor"]
|
||||
PLATFORMS = [Platform.SENSOR]
|
||||
|
||||
|
||||
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||
|
|
|
@ -3,9 +3,11 @@ from __future__ import annotations
|
|||
|
||||
from typing import Final
|
||||
|
||||
from homeassistant.const import Platform
|
||||
|
||||
# Platforms
|
||||
DOMAIN: Final = "crownstone"
|
||||
PLATFORMS: Final[list[str]] = ["light"]
|
||||
PLATFORMS: Final[list[Platform]] = [Platform.LIGHT]
|
||||
|
||||
# Listeners
|
||||
SSE_LISTENERS: Final = "sse_listeners"
|
||||
|
|
|
@ -8,7 +8,7 @@ from async_timeout import timeout
|
|||
from pydaikin.daikin_base import Appliance
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_API_KEY, CONF_HOST, CONF_PASSWORD
|
||||
from homeassistant.const import CONF_API_KEY, CONF_HOST, CONF_PASSWORD, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ConfigEntryNotReady
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
@ -23,7 +23,7 @@ _LOGGER = logging.getLogger(__name__)
|
|||
PARALLEL_UPDATES = 0
|
||||
MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=60)
|
||||
|
||||
PLATFORMS = ["climate", "sensor", "switch"]
|
||||
PLATFORMS = [Platform.CLIMATE, Platform.SENSOR, Platform.SWITCH]
|
||||
|
||||
CONFIG_SCHEMA = cv.deprecated(DOMAIN)
|
||||
|
||||
|
|
|
@ -1,20 +1,7 @@
|
|||
"""Constants for the deCONZ component."""
|
||||
import logging
|
||||
|
||||
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.climate import DOMAIN as CLIMATE_DOMAIN
|
||||
from homeassistant.components.cover import DOMAIN as COVER_DOMAIN
|
||||
from homeassistant.components.fan import DOMAIN as FAN_DOMAIN
|
||||
from homeassistant.components.light import DOMAIN as LIGHT_DOMAIN
|
||||
from homeassistant.components.lock import DOMAIN as LOCK_DOMAIN
|
||||
from homeassistant.components.number import DOMAIN as NUMBER_DOMAIN
|
||||
from homeassistant.components.scene import DOMAIN as SCENE_DOMAIN
|
||||
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
|
||||
from homeassistant.components.siren import DOMAIN as SIREN_DOMAIN
|
||||
from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN
|
||||
from homeassistant.const import Platform
|
||||
|
||||
LOGGER = logging.getLogger(__package__)
|
||||
|
||||
|
@ -34,18 +21,18 @@ CONF_ALLOW_NEW_DEVICES = "allow_new_devices"
|
|||
CONF_MASTER_GATEWAY = "master"
|
||||
|
||||
PLATFORMS = [
|
||||
ALARM_CONTROL_PANEL_DOMAIN,
|
||||
BINARY_SENSOR_DOMAIN,
|
||||
CLIMATE_DOMAIN,
|
||||
COVER_DOMAIN,
|
||||
FAN_DOMAIN,
|
||||
LIGHT_DOMAIN,
|
||||
LOCK_DOMAIN,
|
||||
NUMBER_DOMAIN,
|
||||
SCENE_DOMAIN,
|
||||
SENSOR_DOMAIN,
|
||||
SIREN_DOMAIN,
|
||||
SWITCH_DOMAIN,
|
||||
Platform.ALARM_CONTROL_PANEL,
|
||||
Platform.BINARY_SENSOR,
|
||||
Platform.CLIMATE,
|
||||
Platform.COVER,
|
||||
Platform.FAN,
|
||||
Platform.LIGHT,
|
||||
Platform.LOCK,
|
||||
Platform.NUMBER,
|
||||
Platform.SCENE,
|
||||
Platform.SENSOR,
|
||||
Platform.SIREN,
|
||||
Platform.SWITCH,
|
||||
]
|
||||
|
||||
ATTR_DARK = "dark"
|
||||
|
|
|
@ -4,7 +4,7 @@ import logging
|
|||
from denonavr.exceptions import AvrNetworkError, AvrTimoutError
|
||||
|
||||
from homeassistant import config_entries, core
|
||||
from homeassistant.const import CONF_HOST
|
||||
from homeassistant.const import CONF_HOST, Platform
|
||||
from homeassistant.exceptions import ConfigEntryNotReady
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
from homeassistant.helpers.httpx_client import get_async_client
|
||||
|
@ -23,7 +23,7 @@ from .receiver import ConnectDenonAVR
|
|||
|
||||
CONF_RECEIVER = "receiver"
|
||||
UNDO_UPDATE_LISTENER = "undo_update_listener"
|
||||
PLATFORMS = ["media_player"]
|
||||
PLATFORMS = [Platform.MEDIA_PLAYER]
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
@ -1,9 +1,18 @@
|
|||
"""Constants for the devolo_home_control integration."""
|
||||
import re
|
||||
|
||||
from homeassistant.const import Platform
|
||||
|
||||
DOMAIN = "devolo_home_control"
|
||||
DEFAULT_MYDEVOLO = "https://www.mydevolo.com"
|
||||
PLATFORMS = ["binary_sensor", "climate", "cover", "light", "sensor", "switch"]
|
||||
PLATFORMS = [
|
||||
Platform.BINARY_SENSOR,
|
||||
Platform.CLIMATE,
|
||||
Platform.COVER,
|
||||
Platform.LIGHT,
|
||||
Platform.SENSOR,
|
||||
Platform.SWITCH,
|
||||
]
|
||||
CONF_MYDEVOLO = "mydevolo_url"
|
||||
GATEWAY_SERIAL_PATTERN = re.compile(r"\d{16}")
|
||||
SUPPORTED_MODEL_TYPES = ["2600", "2601"]
|
||||
|
|
|
@ -2,8 +2,10 @@
|
|||
|
||||
from datetime import timedelta
|
||||
|
||||
from homeassistant.const import Platform
|
||||
|
||||
DOMAIN = "devolo_home_network"
|
||||
PLATFORMS = ["sensor"]
|
||||
PLATFORMS = [Platform.SENSOR]
|
||||
|
||||
PRODUCT = "product"
|
||||
SERIAL_NUMBER = "serial_number"
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
"""Constants for the Dexcom integration."""
|
||||
from homeassistant.const import Platform
|
||||
|
||||
DOMAIN = "dexcom"
|
||||
PLATFORMS = ["sensor"]
|
||||
|
||||
PLATFORMS = [Platform.SENSOR]
|
||||
GLUCOSE_VALUE_ICON = "mdi:diabetes"
|
||||
|
||||
GLUCOSE_TREND_ICON = [
|
||||
|
|
|
@ -6,7 +6,7 @@ from datetime import timedelta
|
|||
from directv import DIRECTV, DIRECTVError
|
||||
|
||||
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 import config_validation as cv
|
||||
|
@ -16,7 +16,7 @@ from .const import DOMAIN
|
|||
|
||||
CONFIG_SCHEMA = cv.deprecated(DOMAIN)
|
||||
|
||||
PLATFORMS = ["media_player", "remote"]
|
||||
PLATFORMS = [Platform.MEDIA_PLAYER, Platform.REMOTE]
|
||||
SCAN_INTERVAL = timedelta(seconds=30)
|
||||
|
||||
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components.media_player.const import DOMAIN as MEDIA_PLAYER_DOMAIN
|
||||
from homeassistant.const import Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from .const import LOGGER
|
||||
|
||||
PLATFORMS = [MEDIA_PLAYER_DOMAIN]
|
||||
PLATFORMS = [Platform.MEDIA_PLAYER]
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
"""The DoorBird integration constants."""
|
||||
|
||||
from homeassistant.const import Platform
|
||||
|
||||
DOMAIN = "doorbird"
|
||||
PLATFORMS = ["switch", "camera"]
|
||||
PLATFORMS = [Platform.SWITCH, Platform.CAMERA]
|
||||
DOOR_STATION = "door_station"
|
||||
DOOR_STATION_INFO = "door_station_info"
|
||||
DOOR_STATION_EVENT_ENTITY_IDS = "door_station_event_entity_ids"
|
||||
|
|
|
@ -6,6 +6,7 @@ import logging
|
|||
from dsmr_parser import obis_references
|
||||
|
||||
from homeassistant.components.sensor import SensorDeviceClass, SensorStateClass
|
||||
from homeassistant.const import Platform
|
||||
|
||||
from .models import DSMRSensorEntityDescription
|
||||
|
||||
|
@ -13,8 +14,7 @@ DOMAIN = "dsmr"
|
|||
|
||||
LOGGER = logging.getLogger(__package__)
|
||||
|
||||
PLATFORMS = ["sensor"]
|
||||
|
||||
PLATFORMS = [Platform.SENSOR]
|
||||
CONF_DSMR_VERSION = "dsmr_version"
|
||||
CONF_RECONNECT_INTERVAL = "reconnect_interval"
|
||||
CONF_PRECISION = "precision"
|
||||
|
|
|
@ -6,12 +6,12 @@ from typing import Final
|
|||
from pdunehd import DuneHDPlayer
|
||||
|
||||
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 .const import DOMAIN
|
||||
|
||||
PLATFORMS: Final[list[str]] = ["media_player"]
|
||||
PLATFORMS: Final[list[Platform]] = [Platform.MEDIA_PLAYER]
|
||||
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
"""Constants for the Dynalite component."""
|
||||
import logging
|
||||
|
||||
from homeassistant.const import CONF_ROOM
|
||||
from homeassistant.const import CONF_ROOM, Platform
|
||||
|
||||
LOGGER = logging.getLogger(__package__)
|
||||
DOMAIN = "dynalite"
|
||||
|
||||
PLATFORMS = ["light", "switch", "cover"]
|
||||
PLATFORMS = [Platform.LIGHT, Platform.SWITCH, Platform.COVER]
|
||||
|
||||
|
||||
CONF_ACTIVE = "active"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""Tests for the Atag climate platform."""
|
||||
from unittest.mock import PropertyMock, patch
|
||||
|
||||
from homeassistant.components.atag.climate import CLIMATE, DOMAIN, PRESET_MAP
|
||||
from homeassistant.components.atag.climate import DOMAIN, PRESET_MAP
|
||||
from homeassistant.components.climate import (
|
||||
ATTR_HVAC_ACTION,
|
||||
ATTR_HVAC_MODE,
|
||||
|
@ -13,7 +13,12 @@ from homeassistant.components.climate import (
|
|||
)
|
||||
from homeassistant.components.climate.const import CURRENT_HVAC_IDLE, PRESET_AWAY
|
||||
from homeassistant.components.homeassistant import DOMAIN as HA_DOMAIN
|
||||
from homeassistant.const import ATTR_ENTITY_ID, ATTR_TEMPERATURE, STATE_UNKNOWN
|
||||
from homeassistant.const import (
|
||||
ATTR_ENTITY_ID,
|
||||
ATTR_TEMPERATURE,
|
||||
STATE_UNKNOWN,
|
||||
Platform,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
@ -21,7 +26,7 @@ from homeassistant.setup import async_setup_component
|
|||
from tests.components.atag import UID, init_integration
|
||||
from tests.test_util.aiohttp import AiohttpClientMocker
|
||||
|
||||
CLIMATE_ID = f"{CLIMATE}.{DOMAIN}"
|
||||
CLIMATE_ID = f"{Platform.CLIMATE}.{DOMAIN}"
|
||||
|
||||
|
||||
async def test_climate(
|
||||
|
@ -33,7 +38,7 @@ async def test_climate(
|
|||
|
||||
assert entity_registry.async_is_registered(CLIMATE_ID)
|
||||
entity = entity_registry.async_get(CLIMATE_ID)
|
||||
assert entity.unique_id == f"{UID}-{CLIMATE}"
|
||||
assert entity.unique_id == f"{UID}-{Platform.CLIMATE}"
|
||||
assert hass.states.get(CLIMATE_ID).attributes[ATTR_HVAC_ACTION] == CURRENT_HVAC_IDLE
|
||||
|
||||
|
||||
|
@ -44,7 +49,7 @@ async def test_setting_climate(
|
|||
await init_integration(hass, aioclient_mock)
|
||||
with patch("pyatag.entities.Climate.set_temp") as mock_set_temp:
|
||||
await hass.services.async_call(
|
||||
CLIMATE,
|
||||
Platform.CLIMATE,
|
||||
SERVICE_SET_TEMPERATURE,
|
||||
{ATTR_ENTITY_ID: CLIMATE_ID, ATTR_TEMPERATURE: 15},
|
||||
blocking=True,
|
||||
|
@ -54,7 +59,7 @@ async def test_setting_climate(
|
|||
|
||||
with patch("pyatag.entities.Climate.set_preset_mode") as mock_set_preset:
|
||||
await hass.services.async_call(
|
||||
CLIMATE,
|
||||
Platform.CLIMATE,
|
||||
SERVICE_SET_PRESET_MODE,
|
||||
{ATTR_ENTITY_ID: CLIMATE_ID, ATTR_PRESET_MODE: PRESET_AWAY},
|
||||
blocking=True,
|
||||
|
@ -64,7 +69,7 @@ async def test_setting_climate(
|
|||
|
||||
with patch("pyatag.entities.Climate.set_hvac_mode") as mock_set_hvac:
|
||||
await hass.services.async_call(
|
||||
CLIMATE,
|
||||
Platform.CLIMATE,
|
||||
SERVICE_SET_HVAC_MODE,
|
||||
{ATTR_ENTITY_ID: CLIMATE_ID, ATTR_HVAC_MODE: HVAC_MODE_HEAT},
|
||||
blocking=True,
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
"""Tests for the Atag water heater platform."""
|
||||
from unittest.mock import patch
|
||||
|
||||
from homeassistant.components.atag import DOMAIN, WATER_HEATER
|
||||
from homeassistant.components.atag import DOMAIN
|
||||
from homeassistant.components.water_heater import SERVICE_SET_TEMPERATURE
|
||||
from homeassistant.const import ATTR_ENTITY_ID, ATTR_TEMPERATURE
|
||||
from homeassistant.const import ATTR_ENTITY_ID, ATTR_TEMPERATURE, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
|
||||
from tests.components.atag import UID, init_integration
|
||||
from tests.test_util.aiohttp import AiohttpClientMocker
|
||||
|
||||
WATER_HEATER_ID = f"{WATER_HEATER}.{DOMAIN}"
|
||||
WATER_HEATER_ID = f"{Platform.WATER_HEATER}.{DOMAIN}"
|
||||
|
||||
|
||||
async def test_water_heater(
|
||||
|
@ -23,7 +23,7 @@ async def test_water_heater(
|
|||
|
||||
assert registry.async_is_registered(WATER_HEATER_ID)
|
||||
entry = registry.async_get(WATER_HEATER_ID)
|
||||
assert entry.unique_id == f"{UID}-{WATER_HEATER}"
|
||||
assert entry.unique_id == f"{UID}-{Platform.WATER_HEATER}"
|
||||
|
||||
|
||||
async def test_setting_target_temperature(
|
||||
|
@ -33,7 +33,7 @@ async def test_setting_target_temperature(
|
|||
await init_integration(hass, aioclient_mock)
|
||||
with patch("pyatag.entities.DHW.set_temp") as mock_set_temp:
|
||||
await hass.services.async_call(
|
||||
WATER_HEATER,
|
||||
Platform.WATER_HEATER,
|
||||
SERVICE_SET_TEMPERATURE,
|
||||
{ATTR_ENTITY_ID: WATER_HEATER_ID, ATTR_TEMPERATURE: 50},
|
||||
blocking=True,
|
||||
|
|
|
@ -2,13 +2,13 @@
|
|||
from base64 import b64decode
|
||||
from unittest.mock import call
|
||||
|
||||
from homeassistant.components.broadlink.const import DOMAIN, REMOTE_DOMAIN
|
||||
from homeassistant.components.broadlink.const import DOMAIN
|
||||
from homeassistant.components.remote import (
|
||||
SERVICE_SEND_COMMAND,
|
||||
SERVICE_TURN_OFF,
|
||||
SERVICE_TURN_ON,
|
||||
)
|
||||
from homeassistant.const import STATE_OFF, STATE_ON
|
||||
from homeassistant.const import STATE_OFF, STATE_ON, Platform
|
||||
from homeassistant.helpers.entity_registry import async_entries_for_device
|
||||
|
||||
from . import get_device
|
||||
|
@ -34,7 +34,7 @@ async def test_remote_setup_works(hass):
|
|||
{(DOMAIN, mock_setup.entry.unique_id)}
|
||||
)
|
||||
entries = async_entries_for_device(entity_registry, device_entry.id)
|
||||
remotes = {entry for entry in entries if entry.domain == REMOTE_DOMAIN}
|
||||
remotes = {entry for entry in entries if entry.domain == Platform.REMOTE}
|
||||
assert len(remotes) == 1
|
||||
|
||||
remote = remotes.pop()
|
||||
|
@ -54,12 +54,12 @@ async def test_remote_send_command(hass):
|
|||
{(DOMAIN, mock_setup.entry.unique_id)}
|
||||
)
|
||||
entries = async_entries_for_device(entity_registry, device_entry.id)
|
||||
remotes = {entry for entry in entries if entry.domain == REMOTE_DOMAIN}
|
||||
remotes = {entry for entry in entries if entry.domain == Platform.REMOTE}
|
||||
assert len(remotes) == 1
|
||||
|
||||
remote = remotes.pop()
|
||||
await hass.services.async_call(
|
||||
REMOTE_DOMAIN,
|
||||
Platform.REMOTE,
|
||||
SERVICE_SEND_COMMAND,
|
||||
{"entity_id": remote.entity_id, "command": "b64:" + IR_PACKET},
|
||||
blocking=True,
|
||||
|
@ -81,12 +81,12 @@ async def test_remote_turn_off_turn_on(hass):
|
|||
{(DOMAIN, mock_setup.entry.unique_id)}
|
||||
)
|
||||
entries = async_entries_for_device(entity_registry, device_entry.id)
|
||||
remotes = {entry for entry in entries if entry.domain == REMOTE_DOMAIN}
|
||||
remotes = {entry for entry in entries if entry.domain == Platform.REMOTE}
|
||||
assert len(remotes) == 1
|
||||
|
||||
remote = remotes.pop()
|
||||
await hass.services.async_call(
|
||||
REMOTE_DOMAIN,
|
||||
Platform.REMOTE,
|
||||
SERVICE_TURN_OFF,
|
||||
{"entity_id": remote.entity_id},
|
||||
blocking=True,
|
||||
|
@ -94,7 +94,7 @@ async def test_remote_turn_off_turn_on(hass):
|
|||
assert hass.states.get(remote.entity_id).state == STATE_OFF
|
||||
|
||||
await hass.services.async_call(
|
||||
REMOTE_DOMAIN,
|
||||
Platform.REMOTE,
|
||||
SERVICE_SEND_COMMAND,
|
||||
{"entity_id": remote.entity_id, "command": "b64:" + IR_PACKET},
|
||||
blocking=True,
|
||||
|
@ -102,7 +102,7 @@ async def test_remote_turn_off_turn_on(hass):
|
|||
assert mock_setup.api.send_data.call_count == 0
|
||||
|
||||
await hass.services.async_call(
|
||||
REMOTE_DOMAIN,
|
||||
Platform.REMOTE,
|
||||
SERVICE_TURN_ON,
|
||||
{"entity_id": remote.entity_id},
|
||||
blocking=True,
|
||||
|
@ -110,7 +110,7 @@ async def test_remote_turn_off_turn_on(hass):
|
|||
assert hass.states.get(remote.entity_id).state == STATE_ON
|
||||
|
||||
await hass.services.async_call(
|
||||
REMOTE_DOMAIN,
|
||||
Platform.REMOTE,
|
||||
SERVICE_SEND_COMMAND,
|
||||
{"entity_id": remote.entity_id, "command": "b64:" + IR_PACKET},
|
||||
blocking=True,
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
"""Tests for Broadlink sensors."""
|
||||
from datetime import timedelta
|
||||
|
||||
from homeassistant.components.broadlink.const import DOMAIN, SENSOR_DOMAIN
|
||||
from homeassistant.components.broadlink.const import DOMAIN
|
||||
from homeassistant.components.broadlink.updater import BroadlinkSP4UpdateManager
|
||||
from homeassistant.const import Platform
|
||||
from homeassistant.helpers.entity_registry import async_entries_for_device
|
||||
from homeassistant.util import dt
|
||||
|
||||
|
@ -33,7 +34,7 @@ async def test_a1_sensor_setup(hass):
|
|||
{(DOMAIN, mock_setup.entry.unique_id)}
|
||||
)
|
||||
entries = async_entries_for_device(entity_registry, device_entry.id)
|
||||
sensors = [entry for entry in entries if entry.domain == SENSOR_DOMAIN]
|
||||
sensors = [entry for entry in entries if entry.domain == Platform.SENSOR]
|
||||
assert len(sensors) == 5
|
||||
|
||||
sensors_and_states = {
|
||||
|
@ -70,7 +71,7 @@ async def test_a1_sensor_update(hass):
|
|||
{(DOMAIN, mock_setup.entry.unique_id)}
|
||||
)
|
||||
entries = async_entries_for_device(entity_registry, device_entry.id)
|
||||
sensors = [entry for entry in entries if entry.domain == SENSOR_DOMAIN]
|
||||
sensors = [entry for entry in entries if entry.domain == Platform.SENSOR]
|
||||
assert len(sensors) == 5
|
||||
|
||||
mock_setup.api.check_sensors_raw.return_value = {
|
||||
|
@ -114,7 +115,7 @@ async def test_rm_pro_sensor_setup(hass):
|
|||
{(DOMAIN, mock_setup.entry.unique_id)}
|
||||
)
|
||||
entries = async_entries_for_device(entity_registry, device_entry.id)
|
||||
sensors = [entry for entry in entries if entry.domain == SENSOR_DOMAIN]
|
||||
sensors = [entry for entry in entries if entry.domain == Platform.SENSOR]
|
||||
assert len(sensors) == 1
|
||||
|
||||
sensors_and_states = {
|
||||
|
@ -139,7 +140,7 @@ async def test_rm_pro_sensor_update(hass):
|
|||
{(DOMAIN, mock_setup.entry.unique_id)}
|
||||
)
|
||||
entries = async_entries_for_device(entity_registry, device_entry.id)
|
||||
sensors = [entry for entry in entries if entry.domain == SENSOR_DOMAIN]
|
||||
sensors = [entry for entry in entries if entry.domain == Platform.SENSOR]
|
||||
assert len(sensors) == 1
|
||||
|
||||
mock_setup.api.check_sensors.return_value = {"temperature": 25.8}
|
||||
|
@ -173,7 +174,7 @@ async def test_rm_pro_filter_crazy_temperature(hass):
|
|||
{(DOMAIN, mock_setup.entry.unique_id)}
|
||||
)
|
||||
entries = async_entries_for_device(entity_registry, device_entry.id)
|
||||
sensors = [entry for entry in entries if entry.domain == SENSOR_DOMAIN]
|
||||
sensors = [entry for entry in entries if entry.domain == Platform.SENSOR]
|
||||
assert len(sensors) == 1
|
||||
|
||||
mock_setup.api.check_sensors.return_value = {"temperature": -7}
|
||||
|
@ -205,7 +206,7 @@ async def test_rm_mini3_no_sensor(hass):
|
|||
{(DOMAIN, mock_setup.entry.unique_id)}
|
||||
)
|
||||
entries = async_entries_for_device(entity_registry, device_entry.id)
|
||||
sensors = [entry for entry in entries if entry.domain == SENSOR_DOMAIN]
|
||||
sensors = [entry for entry in entries if entry.domain == Platform.SENSOR]
|
||||
assert len(sensors) == 0
|
||||
|
||||
|
||||
|
@ -225,7 +226,7 @@ async def test_rm4_pro_hts2_sensor_setup(hass):
|
|||
{(DOMAIN, mock_setup.entry.unique_id)}
|
||||
)
|
||||
entries = async_entries_for_device(entity_registry, device_entry.id)
|
||||
sensors = [entry for entry in entries if entry.domain == SENSOR_DOMAIN]
|
||||
sensors = [entry for entry in entries if entry.domain == Platform.SENSOR]
|
||||
assert len(sensors) == 2
|
||||
|
||||
sensors_and_states = {
|
||||
|
@ -253,7 +254,7 @@ async def test_rm4_pro_hts2_sensor_update(hass):
|
|||
{(DOMAIN, mock_setup.entry.unique_id)}
|
||||
)
|
||||
entries = async_entries_for_device(entity_registry, device_entry.id)
|
||||
sensors = [entry for entry in entries if entry.domain == SENSOR_DOMAIN]
|
||||
sensors = [entry for entry in entries if entry.domain == Platform.SENSOR]
|
||||
assert len(sensors) == 2
|
||||
|
||||
mock_setup.api.check_sensors.return_value = {"temperature": 16.8, "humidity": 34.0}
|
||||
|
@ -288,7 +289,7 @@ async def test_rm4_pro_no_sensor(hass):
|
|||
{(DOMAIN, mock_setup.entry.unique_id)}
|
||||
)
|
||||
entries = async_entries_for_device(entity_registry, device_entry.id)
|
||||
sensors = {entry for entry in entries if entry.domain == SENSOR_DOMAIN}
|
||||
sensors = {entry for entry in entries if entry.domain == Platform.SENSOR}
|
||||
assert len(sensors) == 0
|
||||
|
||||
|
||||
|
@ -318,7 +319,7 @@ async def test_scb1e_sensor_setup(hass):
|
|||
{(DOMAIN, mock_setup.entry.unique_id)}
|
||||
)
|
||||
entries = async_entries_for_device(entity_registry, device_entry.id)
|
||||
sensors = [entry for entry in entries if entry.domain == SENSOR_DOMAIN]
|
||||
sensors = [entry for entry in entries if entry.domain == Platform.SENSOR]
|
||||
assert len(sensors) == 5
|
||||
|
||||
sensors_and_states = {
|
||||
|
@ -363,7 +364,7 @@ async def test_scb1e_sensor_update(hass):
|
|||
{(DOMAIN, mock_setup.entry.unique_id)}
|
||||
)
|
||||
entries = async_entries_for_device(entity_registry, device_entry.id)
|
||||
sensors = [entry for entry in entries if entry.domain == SENSOR_DOMAIN]
|
||||
sensors = [entry for entry in entries if entry.domain == Platform.SENSOR]
|
||||
assert len(sensors) == 5
|
||||
|
||||
mock_setup.api.get_state.return_value = {
|
||||
|
|
Loading…
Add table
Reference in a new issue