Use Platform enum in load_platform [a-l] (#63750)
This commit is contained in:
parent
b78e22e012
commit
c7cb26cbab
22 changed files with 87 additions and 42 deletions
|
@ -17,6 +17,7 @@ from homeassistant.const import (
|
||||||
CONF_SWITCHES,
|
CONF_SWITCHES,
|
||||||
CONF_TIMEOUT,
|
CONF_TIMEOUT,
|
||||||
CONF_USERNAME,
|
CONF_USERNAME,
|
||||||
|
Platform,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.helpers import discovery
|
from homeassistant.helpers import discovery
|
||||||
|
@ -246,14 +247,16 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||||
mjpeg_camera.update({CONF_USERNAME: username, CONF_PASSWORD: password})
|
mjpeg_camera.update({CONF_USERNAME: username, CONF_PASSWORD: password})
|
||||||
|
|
||||||
hass.async_create_task(
|
hass.async_create_task(
|
||||||
discovery.async_load_platform(hass, "camera", "mjpeg", mjpeg_camera, config)
|
discovery.async_load_platform(
|
||||||
|
hass, Platform.CAMERA, "mjpeg", mjpeg_camera, config
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
if sensors:
|
if sensors:
|
||||||
hass.async_create_task(
|
hass.async_create_task(
|
||||||
discovery.async_load_platform(
|
discovery.async_load_platform(
|
||||||
hass,
|
hass,
|
||||||
"sensor",
|
Platform.SENSOR,
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
{CONF_NAME: name, CONF_HOST: host, CONF_SENSORS: sensors},
|
{CONF_NAME: name, CONF_HOST: host, CONF_SENSORS: sensors},
|
||||||
config,
|
config,
|
||||||
|
@ -264,7 +267,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||||
hass.async_create_task(
|
hass.async_create_task(
|
||||||
discovery.async_load_platform(
|
discovery.async_load_platform(
|
||||||
hass,
|
hass,
|
||||||
"switch",
|
Platform.SWITCH,
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
{CONF_NAME: name, CONF_HOST: host, CONF_SWITCHES: switches},
|
{CONF_NAME: name, CONF_HOST: host, CONF_SWITCHES: switches},
|
||||||
config,
|
config,
|
||||||
|
@ -275,7 +278,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||||
hass.async_create_task(
|
hass.async_create_task(
|
||||||
discovery.async_load_platform(
|
discovery.async_load_platform(
|
||||||
hass,
|
hass,
|
||||||
"binary_sensor",
|
Platform.BINARY_SENSOR,
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
{CONF_HOST: host, CONF_NAME: name},
|
{CONF_HOST: host, CONF_NAME: name},
|
||||||
config,
|
config,
|
||||||
|
|
|
@ -13,6 +13,7 @@ from homeassistant.const import (
|
||||||
CONF_NAME,
|
CONF_NAME,
|
||||||
CONF_PROFILE_NAME,
|
CONF_PROFILE_NAME,
|
||||||
CONF_SERVICE,
|
CONF_SERVICE,
|
||||||
|
Platform,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers import config_validation as cv, discovery
|
from homeassistant.helpers import config_validation as cv, discovery
|
||||||
|
@ -149,7 +150,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
# have to use discovery to load platform.
|
# have to use discovery to load platform.
|
||||||
for notify_config in conf[CONF_NOTIFY]:
|
for notify_config in conf[CONF_NOTIFY]:
|
||||||
hass.async_create_task(
|
hass.async_create_task(
|
||||||
discovery.async_load_platform(hass, "notify", DOMAIN, notify_config, config)
|
discovery.async_load_platform(
|
||||||
|
hass, Platform.NOTIFY, DOMAIN, notify_config, config
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
return validation
|
return validation
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
"""The Unify Circuit component."""
|
"""The Unify Circuit component."""
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.const import CONF_NAME, CONF_URL
|
from homeassistant.const import CONF_NAME, CONF_URL, Platform
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers import config_validation as cv, discovery
|
from homeassistant.helpers import config_validation as cv, discovery
|
||||||
from homeassistant.helpers.typing import ConfigType
|
from homeassistant.helpers.typing import ConfigType
|
||||||
|
@ -29,7 +29,9 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||||
|
|
||||||
for webhook_conf in webhooks:
|
for webhook_conf in webhooks:
|
||||||
hass.async_create_task(
|
hass.async_create_task(
|
||||||
discovery.async_load_platform(hass, "notify", DOMAIN, webhook_conf, config)
|
discovery.async_load_platform(
|
||||||
|
hass, Platform.NOTIFY, DOMAIN, webhook_conf, config
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -12,6 +12,7 @@ from homeassistant.const import (
|
||||||
CONF_NAME,
|
CONF_NAME,
|
||||||
CONF_REGION,
|
CONF_REGION,
|
||||||
EVENT_HOMEASSISTANT_STOP,
|
EVENT_HOMEASSISTANT_STOP,
|
||||||
|
Platform,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant, ServiceCall, callback
|
from homeassistant.core import HomeAssistant, ServiceCall, callback
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
|
@ -224,10 +225,14 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||||
loaded = True
|
loaded = True
|
||||||
|
|
||||||
await hass.helpers.discovery.async_load_platform(
|
await hass.helpers.discovery.async_load_platform(
|
||||||
"binary_sensor", DOMAIN, {}, config
|
Platform.BINARY_SENSOR, DOMAIN, {}, config
|
||||||
|
)
|
||||||
|
await hass.helpers.discovery.async_load_platform(
|
||||||
|
Platform.STT, DOMAIN, {}, config
|
||||||
|
)
|
||||||
|
await hass.helpers.discovery.async_load_platform(
|
||||||
|
Platform.TTS, DOMAIN, {}, config
|
||||||
)
|
)
|
||||||
await hass.helpers.discovery.async_load_platform("stt", DOMAIN, {}, config)
|
|
||||||
await hass.helpers.discovery.async_load_platform("tts", DOMAIN, {}, config)
|
|
||||||
|
|
||||||
cloud.iot.register_on_connect(_on_connect)
|
cloud.iot.register_on_connect(_on_connect)
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ from homeassistant.const import (
|
||||||
CONF_PIN,
|
CONF_PIN,
|
||||||
CONF_TOKEN,
|
CONF_TOKEN,
|
||||||
EVENT_HOMEASSISTANT_STOP,
|
EVENT_HOMEASSISTANT_STOP,
|
||||||
|
Platform,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers import discovery
|
from homeassistant.helpers import discovery
|
||||||
|
@ -82,7 +83,7 @@ def setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||||
hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, _shutdown)
|
hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, _shutdown)
|
||||||
|
|
||||||
# Load platforms
|
# Load platforms
|
||||||
discovery.load_platform(hass, "fan", DOMAIN, {}, config)
|
discovery.load_platform(hass, Platform.FAN, DOMAIN, {}, config)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ from homeassistant.const import (
|
||||||
CONF_MONITORED_CONDITIONS,
|
CONF_MONITORED_CONDITIONS,
|
||||||
CONF_NAME,
|
CONF_NAME,
|
||||||
CONF_PORT,
|
CONF_PORT,
|
||||||
|
Platform,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant, ServiceCall
|
from homeassistant.core import HomeAssistant, ServiceCall
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
@ -74,7 +75,7 @@ def setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||||
"client_name": name,
|
"client_name": name,
|
||||||
"sensor_types": SENSOR_TYPES[circuit],
|
"sensor_types": SENSOR_TYPES[circuit],
|
||||||
}
|
}
|
||||||
load_platform(hass, "sensor", DOMAIN, sensor_config, config)
|
load_platform(hass, Platform.SENSOR, DOMAIN, sensor_config, config)
|
||||||
|
|
||||||
hass.services.register(DOMAIN, SERVICE_EBUSD_WRITE, hass.data[DOMAIN].write)
|
hass.services.register(DOMAIN, SERVICE_EBUSD_WRITE, hass.data[DOMAIN].write)
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ from homeassistant.const import (
|
||||||
CONF_SENSORS,
|
CONF_SENSORS,
|
||||||
CONF_SWITCHES,
|
CONF_SWITCHES,
|
||||||
CONF_USERNAME,
|
CONF_USERNAME,
|
||||||
|
Platform,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
@ -102,8 +103,8 @@ def setup(hass: HomeAssistant, hass_config: ConfigType) -> bool:
|
||||||
hass.data[DATA_ECOAL_BOILER] = ecoal_contr
|
hass.data[DATA_ECOAL_BOILER] = ecoal_contr
|
||||||
# Setup switches
|
# Setup switches
|
||||||
switches = conf[CONF_SWITCHES][CONF_MONITORED_CONDITIONS]
|
switches = conf[CONF_SWITCHES][CONF_MONITORED_CONDITIONS]
|
||||||
load_platform(hass, "switch", DOMAIN, switches, hass_config)
|
load_platform(hass, Platform.SWITCH, DOMAIN, switches, hass_config)
|
||||||
# Setup temp sensors
|
# Setup temp sensors
|
||||||
sensors = conf[CONF_SENSORS][CONF_MONITORED_CONDITIONS]
|
sensors = conf[CONF_SENSORS][CONF_MONITORED_CONDITIONS]
|
||||||
load_platform(hass, "sensor", DOMAIN, sensors, hass_config)
|
load_platform(hass, Platform.SENSOR, DOMAIN, sensors, hass_config)
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -6,7 +6,12 @@ import string
|
||||||
from sucks import EcoVacsAPI, VacBot
|
from sucks import EcoVacsAPI, VacBot
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME, EVENT_HOMEASSISTANT_STOP
|
from homeassistant.const import (
|
||||||
|
CONF_PASSWORD,
|
||||||
|
CONF_USERNAME,
|
||||||
|
EVENT_HOMEASSISTANT_STOP,
|
||||||
|
Platform,
|
||||||
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers import discovery
|
from homeassistant.helpers import discovery
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
@ -89,6 +94,6 @@ def setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||||
|
|
||||||
if hass.data[ECOVACS_DEVICES]:
|
if hass.data[ECOVACS_DEVICES]:
|
||||||
_LOGGER.debug("Starting vacuum components")
|
_LOGGER.debug("Starting vacuum components")
|
||||||
discovery.load_platform(hass, "vacuum", DOMAIN, {}, config)
|
discovery.load_platform(hass, Platform.VACUUM, DOMAIN, {}, config)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -12,6 +12,7 @@ from homeassistant.const import (
|
||||||
CONF_PORT,
|
CONF_PORT,
|
||||||
CONF_USERNAME,
|
CONF_USERNAME,
|
||||||
EVENT_HOMEASSISTANT_STOP,
|
EVENT_HOMEASSISTANT_STOP,
|
||||||
|
Platform,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers import discovery
|
from homeassistant.helpers import discovery
|
||||||
|
@ -129,13 +130,13 @@ def setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
discovery.load_platform(
|
discovery.load_platform(
|
||||||
hass, "alarm_control_panel", DOMAIN, discovered=conf, hass_config=config
|
hass, Platform.ALARM_CONTROL_PANEL, DOMAIN, discovered=conf, hass_config=config
|
||||||
)
|
)
|
||||||
|
|
||||||
# Get the sensors from the device and add those
|
# Get the sensors from the device and add those
|
||||||
sensors = device.getsensors()
|
sensors = device.getsensors()
|
||||||
discovery.load_platform(
|
discovery.load_platform(
|
||||||
hass, "binary_sensor", DOMAIN, {ATTR_DISCOVER_DEVICES: sensors}, config
|
hass, Platform.BINARY_SENSOR, DOMAIN, {ATTR_DISCOVER_DEVICES: sensors}, config
|
||||||
)
|
)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -14,6 +14,7 @@ from homeassistant.const import (
|
||||||
CONF_PASSWORD,
|
CONF_PASSWORD,
|
||||||
CONF_SENSORS,
|
CONF_SENSORS,
|
||||||
CONF_USERNAME,
|
CONF_USERNAME,
|
||||||
|
Platform,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant, ServiceCall
|
from homeassistant.core import HomeAssistant, ServiceCall
|
||||||
from homeassistant.helpers import discovery
|
from homeassistant.helpers import discovery
|
||||||
|
@ -154,13 +155,17 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||||
|
|
||||||
hass.async_create_task(
|
hass.async_create_task(
|
||||||
discovery.async_load_platform(
|
discovery.async_load_platform(
|
||||||
hass, "sensor", DOMAIN, {CONF_SENSORS: sensors}, config
|
hass, Platform.SENSOR, DOMAIN, {CONF_SENSORS: sensors}, config
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
hass.async_create_task(
|
hass.async_create_task(
|
||||||
discovery.async_load_platform(
|
discovery.async_load_platform(
|
||||||
hass, "binary_sensor", DOMAIN, {CONF_BINARY_SENSORS: binary_sensors}, config
|
hass,
|
||||||
|
Platform.BINARY_SENSOR,
|
||||||
|
DOMAIN,
|
||||||
|
{CONF_BINARY_SENSORS: binary_sensors},
|
||||||
|
config,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from homeassistant.components import frontend
|
from homeassistant.components import frontend
|
||||||
|
from homeassistant.const import Platform
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers import discovery
|
from homeassistant.helpers import discovery
|
||||||
from homeassistant.helpers.typing import ConfigType
|
from homeassistant.helpers.typing import ConfigType
|
||||||
|
@ -25,7 +26,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||||
frontend.async_register_built_in_panel(hass, DOMAIN, DOMAIN, "mdi:lightning-bolt")
|
frontend.async_register_built_in_panel(hass, DOMAIN, DOMAIN, "mdi:lightning-bolt")
|
||||||
|
|
||||||
hass.async_create_task(
|
hass.async_create_task(
|
||||||
discovery.async_load_platform(hass, "sensor", DOMAIN, {}, config)
|
discovery.async_load_platform(hass, Platform.SENSOR, DOMAIN, {}, config)
|
||||||
)
|
)
|
||||||
hass.data[DOMAIN] = {
|
hass.data[DOMAIN] = {
|
||||||
"cost_sensors": {},
|
"cost_sensors": {},
|
||||||
|
|
|
@ -10,6 +10,7 @@ from homeassistant.const import (
|
||||||
CONF_HOST,
|
CONF_HOST,
|
||||||
CONF_TIMEOUT,
|
CONF_TIMEOUT,
|
||||||
EVENT_HOMEASSISTANT_STOP,
|
EVENT_HOMEASSISTANT_STOP,
|
||||||
|
Platform,
|
||||||
)
|
)
|
||||||
from homeassistant.core import ServiceCall, callback
|
from homeassistant.core import ServiceCall, callback
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
@ -206,7 +207,7 @@ async def async_setup(hass, config):
|
||||||
hass.async_create_task(
|
hass.async_create_task(
|
||||||
async_load_platform(
|
async_load_platform(
|
||||||
hass,
|
hass,
|
||||||
"alarm_control_panel",
|
Platform.ALARM_CONTROL_PANEL,
|
||||||
"envisalink",
|
"envisalink",
|
||||||
{CONF_PARTITIONS: partitions, CONF_CODE: code, CONF_PANIC: panic_type},
|
{CONF_PARTITIONS: partitions, CONF_CODE: code, CONF_PANIC: panic_type},
|
||||||
config,
|
config,
|
||||||
|
@ -215,7 +216,7 @@ async def async_setup(hass, config):
|
||||||
hass.async_create_task(
|
hass.async_create_task(
|
||||||
async_load_platform(
|
async_load_platform(
|
||||||
hass,
|
hass,
|
||||||
"sensor",
|
Platform.SENSOR,
|
||||||
"envisalink",
|
"envisalink",
|
||||||
{CONF_PARTITIONS: partitions, CONF_CODE: code},
|
{CONF_PARTITIONS: partitions, CONF_CODE: code},
|
||||||
config,
|
config,
|
||||||
|
@ -224,7 +225,7 @@ async def async_setup(hass, config):
|
||||||
if zones:
|
if zones:
|
||||||
hass.async_create_task(
|
hass.async_create_task(
|
||||||
async_load_platform(
|
async_load_platform(
|
||||||
hass, "binary_sensor", "envisalink", {CONF_ZONES: zones}, config
|
hass, Platform.BINARY_SENSOR, "envisalink", {CONF_ZONES: zones}, config
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ from homeassistant.const import (
|
||||||
CONF_SCAN_INTERVAL,
|
CONF_SCAN_INTERVAL,
|
||||||
CONF_USERNAME,
|
CONF_USERNAME,
|
||||||
TEMP_CELSIUS,
|
TEMP_CELSIUS,
|
||||||
|
Platform,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant, ServiceCall, callback
|
from homeassistant.core import HomeAssistant, ServiceCall, callback
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
|
@ -247,10 +248,12 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||||
await broker.save_auth_tokens()
|
await broker.save_auth_tokens()
|
||||||
await broker.async_update() # get initial state
|
await broker.async_update() # get initial state
|
||||||
|
|
||||||
hass.async_create_task(async_load_platform(hass, "climate", DOMAIN, {}, config))
|
hass.async_create_task(
|
||||||
|
async_load_platform(hass, Platform.CLIMATE, DOMAIN, {}, config)
|
||||||
|
)
|
||||||
if broker.tcs.hotwater:
|
if broker.tcs.hotwater:
|
||||||
hass.async_create_task(
|
hass.async_create_task(
|
||||||
async_load_platform(hass, "water_heater", DOMAIN, {}, config)
|
async_load_platform(hass, Platform.WATER_HEATER, DOMAIN, {}, config)
|
||||||
)
|
)
|
||||||
|
|
||||||
hass.helpers.event.async_track_time_interval(
|
hass.helpers.event.async_track_time_interval(
|
||||||
|
|
|
@ -8,7 +8,7 @@ from typing import Any
|
||||||
from fastdotcom import fast_com
|
from fastdotcom import fast_com
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.const import CONF_SCAN_INTERVAL
|
from homeassistant.const import CONF_SCAN_INTERVAL, Platform
|
||||||
from homeassistant.core import HomeAssistant, ServiceCall
|
from homeassistant.core import HomeAssistant, ServiceCall
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.discovery import async_load_platform
|
from homeassistant.helpers.discovery import async_load_platform
|
||||||
|
@ -54,7 +54,9 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||||
|
|
||||||
hass.services.async_register(DOMAIN, "speedtest", update)
|
hass.services.async_register(DOMAIN, "speedtest", update)
|
||||||
|
|
||||||
hass.async_create_task(async_load_platform(hass, "sensor", DOMAIN, {}, config))
|
hass.async_create_task(
|
||||||
|
async_load_platform(hass, Platform.SENSOR, DOMAIN, {}, config)
|
||||||
|
)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.humidifier import HumidifierDeviceClass
|
from homeassistant.components.humidifier import HumidifierDeviceClass
|
||||||
from homeassistant.const import CONF_NAME
|
from homeassistant.const import CONF_NAME, Platform
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers import config_validation as cv, discovery
|
from homeassistant.helpers import config_validation as cv, discovery
|
||||||
from homeassistant.helpers.typing import ConfigType
|
from homeassistant.helpers.typing import ConfigType
|
||||||
|
@ -65,7 +65,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||||
for hygrostat_conf in config[DOMAIN]:
|
for hygrostat_conf in config[DOMAIN]:
|
||||||
hass.async_create_task(
|
hass.async_create_task(
|
||||||
discovery.async_load_platform(
|
discovery.async_load_platform(
|
||||||
hass, "humidifier", DOMAIN, hygrostat_conf, config
|
hass, Platform.HUMIDIFIER, DOMAIN, hygrostat_conf, config
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ from homeassistant.const import (
|
||||||
CONF_ENTITIES,
|
CONF_ENTITIES,
|
||||||
CONF_NAME,
|
CONF_NAME,
|
||||||
CONF_OFFSET,
|
CONF_OFFSET,
|
||||||
|
Platform,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant, ServiceCall
|
from homeassistant.core import HomeAssistant, ServiceCall
|
||||||
from homeassistant.helpers import discovery
|
from homeassistant.helpers import discovery
|
||||||
|
@ -283,7 +284,7 @@ def setup_services(
|
||||||
|
|
||||||
discovery.load_platform(
|
discovery.load_platform(
|
||||||
hass,
|
hass,
|
||||||
"calendar",
|
Platform.CALENDAR,
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
hass.data[DATA_INDEX][calendar[CONF_CAL_ID]],
|
hass.data[DATA_INDEX][calendar[CONF_CAL_ID]],
|
||||||
hass_config,
|
hass_config,
|
||||||
|
@ -370,7 +371,7 @@ def do_setup(hass, hass_config, config):
|
||||||
)
|
)
|
||||||
|
|
||||||
for calendar in hass.data[DATA_INDEX].values():
|
for calendar in hass.data[DATA_INDEX].values():
|
||||||
discovery.load_platform(hass, "calendar", DOMAIN, calendar, hass_config)
|
discovery.load_platform(hass, Platform.CALENDAR, DOMAIN, calendar, hass_config)
|
||||||
|
|
||||||
# Look for any new calendars
|
# Look for any new calendars
|
||||||
hass.services.call(DOMAIN, SERVICE_SCAN_CALENDARS, None)
|
hass.services.call(DOMAIN, SERVICE_SCAN_CALENDARS, None)
|
||||||
|
|
|
@ -15,6 +15,7 @@ from homeassistant.const import (
|
||||||
TIME_HOURS,
|
TIME_HOURS,
|
||||||
TIME_MINUTES,
|
TIME_MINUTES,
|
||||||
TIME_SECONDS,
|
TIME_SECONDS,
|
||||||
|
Platform,
|
||||||
)
|
)
|
||||||
from homeassistant.core import Event, HomeAssistant
|
from homeassistant.core import Event, HomeAssistant
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
@ -143,7 +144,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
hass.async_create_task(
|
hass.async_create_task(
|
||||||
async_load_platform(hass, "sensor", DOMAIN, config[DOMAIN], config)
|
async_load_platform(hass, Platform.SENSOR, DOMAIN, config[DOMAIN], config)
|
||||||
)
|
)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -10,6 +10,7 @@ from homeassistant.const import (
|
||||||
CONF_NAME,
|
CONF_NAME,
|
||||||
CONF_PORT,
|
CONF_PORT,
|
||||||
EVENT_HOMEASSISTANT_STOP,
|
EVENT_HOMEASSISTANT_STOP,
|
||||||
|
Platform,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
@ -84,7 +85,7 @@ def setup(hass: HomeAssistant, base_config: ConfigType) -> bool:
|
||||||
hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, cleanup)
|
hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, cleanup)
|
||||||
|
|
||||||
dimmers = config[CONF_DIMMERS]
|
dimmers = config[CONF_DIMMERS]
|
||||||
load_platform(hass, "light", DOMAIN, {CONF_DIMMERS: dimmers}, base_config)
|
load_platform(hass, Platform.LIGHT, DOMAIN, {CONF_DIMMERS: dimmers}, base_config)
|
||||||
|
|
||||||
for key_config in config[CONF_KEYPADS]:
|
for key_config in config[CONF_KEYPADS]:
|
||||||
addr = key_config[CONF_ADDR]
|
addr = key_config[CONF_ADDR]
|
||||||
|
|
|
@ -271,7 +271,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||||
hass.data[DOMAIN] = ios_config
|
hass.data[DOMAIN] = ios_config
|
||||||
|
|
||||||
# No entry support for notify component yet
|
# No entry support for notify component yet
|
||||||
discovery.load_platform(hass, "notify", DOMAIN, {}, config)
|
discovery.load_platform(hass, Platform.NOTIFY, DOMAIN, {}, config)
|
||||||
|
|
||||||
if conf is not None:
|
if conf is not None:
|
||||||
hass.async_create_task(
|
hass.async_create_task(
|
||||||
|
|
|
@ -4,7 +4,7 @@ from __future__ import annotations
|
||||||
from hdate import Location
|
from hdate import Location
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
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.core import HomeAssistant
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.discovery import async_load_platform
|
from homeassistant.helpers.discovery import async_load_platform
|
||||||
|
@ -97,10 +97,12 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||||
"prefix": prefix,
|
"prefix": prefix,
|
||||||
}
|
}
|
||||||
|
|
||||||
hass.async_create_task(async_load_platform(hass, "sensor", DOMAIN, {}, config))
|
hass.async_create_task(
|
||||||
|
async_load_platform(hass, Platform.SENSOR, DOMAIN, {}, config)
|
||||||
|
)
|
||||||
|
|
||||||
hass.async_create_task(
|
hass.async_create_task(
|
||||||
async_load_platform(hass, "binary_sensor", DOMAIN, {}, config)
|
async_load_platform(hass, Platform.BINARY_SENSOR, DOMAIN, {}, config)
|
||||||
)
|
)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -269,7 +269,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
if NotifySchema.PLATFORM in config:
|
if NotifySchema.PLATFORM in config:
|
||||||
hass.async_create_task(
|
hass.async_create_task(
|
||||||
discovery.async_load_platform(
|
discovery.async_load_platform(
|
||||||
hass, "notify", DOMAIN, {}, hass.data[DATA_HASS_CONFIG]
|
hass, Platform.NOTIFY, DOMAIN, {}, hass.data[DATA_HASS_CONFIG]
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,13 @@ import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.climate import DOMAIN as CLIMATE_DOMAIN
|
from homeassistant.components.climate import DOMAIN as CLIMATE_DOMAIN
|
||||||
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
|
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
|
||||||
from homeassistant.const import CONF_HOST, CONF_LIGHTS, CONF_NAME, CONF_SWITCHES
|
from homeassistant.const import (
|
||||||
|
CONF_HOST,
|
||||||
|
CONF_LIGHTS,
|
||||||
|
CONF_NAME,
|
||||||
|
CONF_SWITCHES,
|
||||||
|
Platform,
|
||||||
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.discovery import async_load_platform
|
from homeassistant.helpers.discovery import async_load_platform
|
||||||
|
@ -68,12 +74,12 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||||
|
|
||||||
if lights := config[DOMAIN][CONF_LIGHTS]:
|
if lights := config[DOMAIN][CONF_LIGHTS]:
|
||||||
hass.async_create_task(
|
hass.async_create_task(
|
||||||
async_load_platform(hass, "light", DOMAIN, lights, config)
|
async_load_platform(hass, Platform.LIGHT, DOMAIN, lights, config)
|
||||||
)
|
)
|
||||||
|
|
||||||
if switches := config[DOMAIN][CONF_SWITCHES]:
|
if switches := config[DOMAIN][CONF_SWITCHES]:
|
||||||
hass.async_create_task(
|
hass.async_create_task(
|
||||||
async_load_platform(hass, "switch", DOMAIN, switches, config)
|
async_load_platform(hass, Platform.SWITCH, DOMAIN, switches, config)
|
||||||
)
|
)
|
||||||
|
|
||||||
if trv := config[DOMAIN][CONF_TRV]:
|
if trv := config[DOMAIN][CONF_TRV]:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue