Uniformize platform setup (#47101)

* A platform is not a component

* Fix dynalite

* SUPPORTED_PLATFORMS --> PLATFORMS

* In tests

* In tests 2

* Fix SmartThings

* Fix ZHA test

* Fix Z-Wave

* Revert Z-Wave

* Use PLATFORMS const in ambient_station

* Fix ihc comment
This commit is contained in:
Quentame 2021-03-02 21:43:59 +01:00 committed by GitHub
parent ca54de095d
commit 198ecb0945
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
218 changed files with 924 additions and 932 deletions

View File

@ -66,7 +66,7 @@ CAPTURE_IMAGE_SCHEMA = vol.Schema({ATTR_ENTITY_ID: cv.entity_ids})
AUTOMATION_SCHEMA = vol.Schema({ATTR_ENTITY_ID: cv.entity_ids}) AUTOMATION_SCHEMA = vol.Schema({ATTR_ENTITY_ID: cv.entity_ids})
ABODE_PLATFORMS = [ PLATFORMS = [
"alarm_control_panel", "alarm_control_panel",
"binary_sensor", "binary_sensor",
"lock", "lock",
@ -138,7 +138,7 @@ async def async_setup_entry(hass, config_entry):
hass.data[DOMAIN] = AbodeSystem(abode, polling) hass.data[DOMAIN] = AbodeSystem(abode, polling)
for platform in ABODE_PLATFORMS: for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(config_entry, platform) hass.config_entries.async_forward_entry_setup(config_entry, platform)
) )
@ -158,7 +158,7 @@ async def async_unload_entry(hass, config_entry):
tasks = [] tasks = []
for platform in ABODE_PLATFORMS: for platform in PLATFORMS:
tasks.append( tasks.append(
hass.config_entries.async_forward_entry_unload(config_entry, platform) hass.config_entries.async_forward_entry_unload(config_entry, platform)
) )

View File

@ -57,9 +57,9 @@ async def async_setup_entry(hass, config_entry) -> bool:
UNDO_UPDATE_LISTENER: undo_listener, UNDO_UPDATE_LISTENER: undo_listener,
} }
for component in PLATFORMS: for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(config_entry, component) hass.config_entries.async_forward_entry_setup(config_entry, platform)
) )
return True return True
@ -70,8 +70,8 @@ async def async_unload_entry(hass, config_entry):
unload_ok = all( unload_ok = all(
await asyncio.gather( await asyncio.gather(
*[ *[
hass.config_entries.async_forward_entry_unload(config_entry, component) hass.config_entries.async_forward_entry_unload(config_entry, platform)
for component in PLATFORMS for platform in PLATFORMS
] ]
) )
) )

View File

@ -28,9 +28,9 @@ async def async_setup_entry(
hass.data.setdefault(DOMAIN, {}) hass.data.setdefault(DOMAIN, {})
hass.data[DOMAIN][config_entry.entry_id] = hub hass.data[DOMAIN][config_entry.entry_id] = hub
for component in PLATFORMS: for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(config_entry, component) hass.config_entries.async_forward_entry_setup(config_entry, platform)
) )
return True return True
@ -45,8 +45,8 @@ async def async_unload_entry(
unload_ok = all( unload_ok = all(
await asyncio.gather( await asyncio.gather(
*[ *[
hass.config_entries.async_forward_entry_unload(config_entry, component) hass.config_entries.async_forward_entry_unload(config_entry, platform)
for component in PLATFORMS for platform in PLATFORMS
] ]
) )
) )

View File

@ -43,6 +43,8 @@ SERVICE_REFRESH_SCHEMA = vol.Schema(
{vol.Optional(CONF_FORCE, default=False): cv.boolean} {vol.Optional(CONF_FORCE, default=False): cv.boolean}
) )
PLATFORMS = ["sensor", "switch"]
async def async_setup(hass: HomeAssistantType, config: ConfigType) -> bool: async def async_setup(hass: HomeAssistantType, config: ConfigType) -> bool:
"""Set up the AdGuard Home components.""" """Set up the AdGuard Home components."""
@ -69,9 +71,9 @@ async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool
except AdGuardHomeConnectionError as exception: except AdGuardHomeConnectionError as exception:
raise ConfigEntryNotReady from exception raise ConfigEntryNotReady from exception
for component in "sensor", "switch": for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, component) hass.config_entries.async_forward_entry_setup(entry, platform)
) )
async def add_url(call) -> None: async def add_url(call) -> None:
@ -123,8 +125,8 @@ async def async_unload_entry(hass: HomeAssistantType, entry: ConfigType) -> bool
hass.services.async_remove(DOMAIN, SERVICE_DISABLE_URL) hass.services.async_remove(DOMAIN, SERVICE_DISABLE_URL)
hass.services.async_remove(DOMAIN, SERVICE_REFRESH) hass.services.async_remove(DOMAIN, SERVICE_REFRESH)
for component in "sensor", "switch": for platform in PLATFORMS:
await hass.config_entries.async_forward_entry_unload(entry, component) await hass.config_entries.async_forward_entry_unload(entry, platform)
del hass.data[DOMAIN] del hass.data[DOMAIN]

View File

@ -14,7 +14,7 @@ from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, Upda
from .const import ADVANTAGE_AIR_RETRY, DOMAIN from .const import ADVANTAGE_AIR_RETRY, DOMAIN
ADVANTAGE_AIR_SYNC_INTERVAL = 15 ADVANTAGE_AIR_SYNC_INTERVAL = 15
ADVANTAGE_AIR_PLATFORMS = ["climate", "cover", "binary_sensor", "sensor", "switch"] PLATFORMS = ["climate", "cover", "binary_sensor", "sensor", "switch"]
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -67,7 +67,7 @@ async def async_setup_entry(hass, entry):
"async_change": async_change, "async_change": async_change,
} }
for platform in ADVANTAGE_AIR_PLATFORMS: for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, platform) hass.config_entries.async_forward_entry_setup(entry, platform)
) )
@ -80,8 +80,8 @@ async def async_unload_entry(hass, entry):
unload_ok = all( unload_ok = all(
await asyncio.gather( await asyncio.gather(
*[ *[
hass.config_entries.async_forward_entry_unload(entry, component) hass.config_entries.async_forward_entry_unload(entry, platform)
for component in ADVANTAGE_AIR_PLATFORMS for platform in PLATFORMS
] ]
) )
) )

View File

@ -8,7 +8,7 @@ from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE, CONF_NAME from homeassistant.const import CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE, CONF_NAME
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from .const import COMPONENTS, DOMAIN, ENTRY_NAME, ENTRY_WEATHER_COORDINATOR from .const import DOMAIN, ENTRY_NAME, ENTRY_WEATHER_COORDINATOR, PLATFORMS
from .weather_update_coordinator import WeatherUpdateCoordinator from .weather_update_coordinator import WeatherUpdateCoordinator
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -37,9 +37,9 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry):
ENTRY_WEATHER_COORDINATOR: weather_coordinator, ENTRY_WEATHER_COORDINATOR: weather_coordinator,
} }
for component in COMPONENTS: for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(config_entry, component) hass.config_entries.async_forward_entry_setup(config_entry, platform)
) )
return True return True
@ -50,8 +50,8 @@ async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry):
unload_ok = all( unload_ok = all(
await asyncio.gather( await asyncio.gather(
*[ *[
hass.config_entries.async_forward_entry_unload(config_entry, component) hass.config_entries.async_forward_entry_unload(config_entry, platform)
for component in COMPONENTS for platform in PLATFORMS
] ]
) )
) )

View File

@ -34,7 +34,7 @@ from homeassistant.const import (
) )
ATTRIBUTION = "Powered by AEMET OpenData" ATTRIBUTION = "Powered by AEMET OpenData"
COMPONENTS = ["sensor", "weather"] PLATFORMS = ["sensor", "weather"]
DEFAULT_NAME = "AEMET" DEFAULT_NAME = "AEMET"
DOMAIN = "aemet" DOMAIN = "aemet"
ENTRY_NAME = "name" ENTRY_NAME = "name"

View File

@ -79,9 +79,9 @@ async def async_setup_entry(hass, config_entry):
hass.data.setdefault(DOMAIN, {}) hass.data.setdefault(DOMAIN, {})
hass.data[DOMAIN][config_entry.entry_id] = coordinator hass.data[DOMAIN][config_entry.entry_id] = coordinator
for component in PLATFORMS: for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(config_entry, component) hass.config_entries.async_forward_entry_setup(config_entry, platform)
) )
return True return True
@ -92,8 +92,8 @@ async def async_unload_entry(hass, config_entry):
unload_ok = all( unload_ok = all(
await asyncio.gather( await asyncio.gather(
*[ *[
hass.config_entries.async_forward_entry_unload(config_entry, component) hass.config_entries.async_forward_entry_unload(config_entry, platform)
for component in PLATFORMS for platform in PLATFORMS
] ]
) )
) )

View File

@ -68,9 +68,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
hass.data.setdefault(DOMAIN, {}) hass.data.setdefault(DOMAIN, {})
hass.data[DOMAIN][entry.entry_id] = coordinator hass.data[DOMAIN][entry.entry_id] = coordinator
for component in PLATFORMS: for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, component) hass.config_entries.async_forward_entry_setup(entry, platform)
) )
return True return True
@ -81,8 +81,8 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
unload_ok = all( unload_ok = all(
await asyncio.gather( await asyncio.gather(
*[ *[
hass.config_entries.async_forward_entry_unload(entry, component) hass.config_entries.async_forward_entry_unload(entry, platform)
for component in PLATFORMS for platform in PLATFORMS
] ]
) )
) )

View File

@ -268,9 +268,9 @@ async def async_setup_entry(hass, config_entry):
hass.data[DOMAIN][DATA_COORDINATOR][config_entry.entry_id] = coordinator hass.data[DOMAIN][DATA_COORDINATOR][config_entry.entry_id] = coordinator
for component in PLATFORMS: for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(config_entry, component) hass.config_entries.async_forward_entry_setup(config_entry, platform)
) )
return True return True
@ -323,8 +323,8 @@ async def async_unload_entry(hass, config_entry):
unload_ok = all( unload_ok = all(
await asyncio.gather( await asyncio.gather(
*[ *[
hass.config_entries.async_forward_entry_unload(config_entry, component) hass.config_entries.async_forward_entry_unload(config_entry, platform)
for component in PLATFORMS for platform in PLATFORMS
] ]
) )
) )

View File

@ -130,9 +130,9 @@ async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool
await open_connection() await open_connection()
for component in PLATFORMS: for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, component) hass.config_entries.async_forward_entry_setup(entry, platform)
) )
return True return True
@ -144,8 +144,8 @@ async def async_unload_entry(hass: HomeAssistantType, entry: ConfigEntry):
unload_ok = all( unload_ok = all(
await asyncio.gather( await asyncio.gather(
*[ *[
hass.config_entries.async_forward_entry_unload(entry, component) hass.config_entries.async_forward_entry_unload(entry, platform)
for component in PLATFORMS for platform in PLATFORMS
] ]
) )
) )

View File

@ -5,7 +5,11 @@ from aioambient import Client
from aioambient.errors import WebsocketError from aioambient.errors import WebsocketError
import voluptuous as vol import voluptuous as vol
from homeassistant.components.binary_sensor import DEVICE_CLASS_CONNECTIVITY from homeassistant.components.binary_sensor import (
DEVICE_CLASS_CONNECTIVITY,
DOMAIN as BINARY_SENSOR,
)
from homeassistant.components.sensor import DOMAIN as SENSOR
from homeassistant.config_entries import SOURCE_IMPORT from homeassistant.config_entries import SOURCE_IMPORT
from homeassistant.const import ( from homeassistant.const import (
ATTR_LOCATION, ATTR_LOCATION,
@ -39,10 +43,10 @@ from .const import (
DATA_CLIENT, DATA_CLIENT,
DOMAIN, DOMAIN,
LOGGER, LOGGER,
TYPE_BINARY_SENSOR,
TYPE_SENSOR,
) )
PLATFORMS = [BINARY_SENSOR, SENSOR]
DATA_CONFIG = "config" DATA_CONFIG = "config"
DEFAULT_SOCKET_MIN_RETRY = 15 DEFAULT_SOCKET_MIN_RETRY = 15
@ -141,109 +145,109 @@ TYPE_WINDSPDMPH_AVG2M = "windspdmph_avg2m"
TYPE_WINDSPEEDMPH = "windspeedmph" TYPE_WINDSPEEDMPH = "windspeedmph"
TYPE_YEARLYRAININ = "yearlyrainin" TYPE_YEARLYRAININ = "yearlyrainin"
SENSOR_TYPES = { SENSOR_TYPES = {
TYPE_24HOURRAININ: ("24 Hr Rain", "in", TYPE_SENSOR, None), TYPE_24HOURRAININ: ("24 Hr Rain", "in", SENSOR, None),
TYPE_BAROMABSIN: ("Abs Pressure", PRESSURE_INHG, TYPE_SENSOR, "pressure"), TYPE_BAROMABSIN: ("Abs Pressure", PRESSURE_INHG, SENSOR, "pressure"),
TYPE_BAROMRELIN: ("Rel Pressure", PRESSURE_INHG, TYPE_SENSOR, "pressure"), TYPE_BAROMRELIN: ("Rel Pressure", PRESSURE_INHG, SENSOR, "pressure"),
TYPE_BATT10: ("Battery 10", None, TYPE_BINARY_SENSOR, "battery"), TYPE_BATT10: ("Battery 10", None, BINARY_SENSOR, "battery"),
TYPE_BATT1: ("Battery 1", None, TYPE_BINARY_SENSOR, "battery"), TYPE_BATT1: ("Battery 1", None, BINARY_SENSOR, "battery"),
TYPE_BATT2: ("Battery 2", None, TYPE_BINARY_SENSOR, "battery"), TYPE_BATT2: ("Battery 2", None, BINARY_SENSOR, "battery"),
TYPE_BATT3: ("Battery 3", None, TYPE_BINARY_SENSOR, "battery"), TYPE_BATT3: ("Battery 3", None, BINARY_SENSOR, "battery"),
TYPE_BATT4: ("Battery 4", None, TYPE_BINARY_SENSOR, "battery"), TYPE_BATT4: ("Battery 4", None, BINARY_SENSOR, "battery"),
TYPE_BATT5: ("Battery 5", None, TYPE_BINARY_SENSOR, "battery"), TYPE_BATT5: ("Battery 5", None, BINARY_SENSOR, "battery"),
TYPE_BATT6: ("Battery 6", None, TYPE_BINARY_SENSOR, "battery"), TYPE_BATT6: ("Battery 6", None, BINARY_SENSOR, "battery"),
TYPE_BATT7: ("Battery 7", None, TYPE_BINARY_SENSOR, "battery"), TYPE_BATT7: ("Battery 7", None, BINARY_SENSOR, "battery"),
TYPE_BATT8: ("Battery 8", None, TYPE_BINARY_SENSOR, "battery"), TYPE_BATT8: ("Battery 8", None, BINARY_SENSOR, "battery"),
TYPE_BATT9: ("Battery 9", None, TYPE_BINARY_SENSOR, "battery"), TYPE_BATT9: ("Battery 9", None, BINARY_SENSOR, "battery"),
TYPE_BATTOUT: ("Battery", None, TYPE_BINARY_SENSOR, "battery"), TYPE_BATTOUT: ("Battery", None, BINARY_SENSOR, "battery"),
TYPE_CO2: ("co2", CONCENTRATION_PARTS_PER_MILLION, TYPE_SENSOR, None), TYPE_CO2: ("co2", CONCENTRATION_PARTS_PER_MILLION, SENSOR, None),
TYPE_DAILYRAININ: ("Daily Rain", "in", TYPE_SENSOR, None), TYPE_DAILYRAININ: ("Daily Rain", "in", SENSOR, None),
TYPE_DEWPOINT: ("Dew Point", TEMP_FAHRENHEIT, TYPE_SENSOR, "temperature"), TYPE_DEWPOINT: ("Dew Point", TEMP_FAHRENHEIT, SENSOR, "temperature"),
TYPE_EVENTRAININ: ("Event Rain", "in", TYPE_SENSOR, None), TYPE_EVENTRAININ: ("Event Rain", "in", SENSOR, None),
TYPE_FEELSLIKE: ("Feels Like", TEMP_FAHRENHEIT, TYPE_SENSOR, "temperature"), TYPE_FEELSLIKE: ("Feels Like", TEMP_FAHRENHEIT, SENSOR, "temperature"),
TYPE_HOURLYRAININ: ("Hourly Rain Rate", "in/hr", TYPE_SENSOR, None), TYPE_HOURLYRAININ: ("Hourly Rain Rate", "in/hr", SENSOR, None),
TYPE_HUMIDITY10: ("Humidity 10", PERCENTAGE, TYPE_SENSOR, "humidity"), TYPE_HUMIDITY10: ("Humidity 10", PERCENTAGE, SENSOR, "humidity"),
TYPE_HUMIDITY1: ("Humidity 1", PERCENTAGE, TYPE_SENSOR, "humidity"), TYPE_HUMIDITY1: ("Humidity 1", PERCENTAGE, SENSOR, "humidity"),
TYPE_HUMIDITY2: ("Humidity 2", PERCENTAGE, TYPE_SENSOR, "humidity"), TYPE_HUMIDITY2: ("Humidity 2", PERCENTAGE, SENSOR, "humidity"),
TYPE_HUMIDITY3: ("Humidity 3", PERCENTAGE, TYPE_SENSOR, "humidity"), TYPE_HUMIDITY3: ("Humidity 3", PERCENTAGE, SENSOR, "humidity"),
TYPE_HUMIDITY4: ("Humidity 4", PERCENTAGE, TYPE_SENSOR, "humidity"), TYPE_HUMIDITY4: ("Humidity 4", PERCENTAGE, SENSOR, "humidity"),
TYPE_HUMIDITY5: ("Humidity 5", PERCENTAGE, TYPE_SENSOR, "humidity"), TYPE_HUMIDITY5: ("Humidity 5", PERCENTAGE, SENSOR, "humidity"),
TYPE_HUMIDITY6: ("Humidity 6", PERCENTAGE, TYPE_SENSOR, "humidity"), TYPE_HUMIDITY6: ("Humidity 6", PERCENTAGE, SENSOR, "humidity"),
TYPE_HUMIDITY7: ("Humidity 7", PERCENTAGE, TYPE_SENSOR, "humidity"), TYPE_HUMIDITY7: ("Humidity 7", PERCENTAGE, SENSOR, "humidity"),
TYPE_HUMIDITY8: ("Humidity 8", PERCENTAGE, TYPE_SENSOR, "humidity"), TYPE_HUMIDITY8: ("Humidity 8", PERCENTAGE, SENSOR, "humidity"),
TYPE_HUMIDITY9: ("Humidity 9", PERCENTAGE, TYPE_SENSOR, "humidity"), TYPE_HUMIDITY9: ("Humidity 9", PERCENTAGE, SENSOR, "humidity"),
TYPE_HUMIDITY: ("Humidity", PERCENTAGE, TYPE_SENSOR, "humidity"), TYPE_HUMIDITY: ("Humidity", PERCENTAGE, SENSOR, "humidity"),
TYPE_HUMIDITYIN: ("Humidity In", PERCENTAGE, TYPE_SENSOR, "humidity"), TYPE_HUMIDITYIN: ("Humidity In", PERCENTAGE, SENSOR, "humidity"),
TYPE_LASTRAIN: ("Last Rain", None, TYPE_SENSOR, "timestamp"), TYPE_LASTRAIN: ("Last Rain", None, SENSOR, "timestamp"),
TYPE_MAXDAILYGUST: ("Max Gust", SPEED_MILES_PER_HOUR, TYPE_SENSOR, None), TYPE_MAXDAILYGUST: ("Max Gust", SPEED_MILES_PER_HOUR, SENSOR, None),
TYPE_MONTHLYRAININ: ("Monthly Rain", "in", TYPE_SENSOR, None), TYPE_MONTHLYRAININ: ("Monthly Rain", "in", SENSOR, None),
TYPE_RELAY10: ("Relay 10", None, TYPE_BINARY_SENSOR, DEVICE_CLASS_CONNECTIVITY), TYPE_RELAY10: ("Relay 10", None, BINARY_SENSOR, DEVICE_CLASS_CONNECTIVITY),
TYPE_RELAY1: ("Relay 1", None, TYPE_BINARY_SENSOR, DEVICE_CLASS_CONNECTIVITY), TYPE_RELAY1: ("Relay 1", None, BINARY_SENSOR, DEVICE_CLASS_CONNECTIVITY),
TYPE_RELAY2: ("Relay 2", None, TYPE_BINARY_SENSOR, DEVICE_CLASS_CONNECTIVITY), TYPE_RELAY2: ("Relay 2", None, BINARY_SENSOR, DEVICE_CLASS_CONNECTIVITY),
TYPE_RELAY3: ("Relay 3", None, TYPE_BINARY_SENSOR, DEVICE_CLASS_CONNECTIVITY), TYPE_RELAY3: ("Relay 3", None, BINARY_SENSOR, DEVICE_CLASS_CONNECTIVITY),
TYPE_RELAY4: ("Relay 4", None, TYPE_BINARY_SENSOR, DEVICE_CLASS_CONNECTIVITY), TYPE_RELAY4: ("Relay 4", None, BINARY_SENSOR, DEVICE_CLASS_CONNECTIVITY),
TYPE_RELAY5: ("Relay 5", None, TYPE_BINARY_SENSOR, DEVICE_CLASS_CONNECTIVITY), TYPE_RELAY5: ("Relay 5", None, BINARY_SENSOR, DEVICE_CLASS_CONNECTIVITY),
TYPE_RELAY6: ("Relay 6", None, TYPE_BINARY_SENSOR, DEVICE_CLASS_CONNECTIVITY), TYPE_RELAY6: ("Relay 6", None, BINARY_SENSOR, DEVICE_CLASS_CONNECTIVITY),
TYPE_RELAY7: ("Relay 7", None, TYPE_BINARY_SENSOR, DEVICE_CLASS_CONNECTIVITY), TYPE_RELAY7: ("Relay 7", None, BINARY_SENSOR, DEVICE_CLASS_CONNECTIVITY),
TYPE_RELAY8: ("Relay 8", None, TYPE_BINARY_SENSOR, DEVICE_CLASS_CONNECTIVITY), TYPE_RELAY8: ("Relay 8", None, BINARY_SENSOR, DEVICE_CLASS_CONNECTIVITY),
TYPE_RELAY9: ("Relay 9", None, TYPE_BINARY_SENSOR, DEVICE_CLASS_CONNECTIVITY), TYPE_RELAY9: ("Relay 9", None, BINARY_SENSOR, DEVICE_CLASS_CONNECTIVITY),
TYPE_SOILHUM10: ("Soil Humidity 10", PERCENTAGE, TYPE_SENSOR, "humidity"), TYPE_SOILHUM10: ("Soil Humidity 10", PERCENTAGE, SENSOR, "humidity"),
TYPE_SOILHUM1: ("Soil Humidity 1", PERCENTAGE, TYPE_SENSOR, "humidity"), TYPE_SOILHUM1: ("Soil Humidity 1", PERCENTAGE, SENSOR, "humidity"),
TYPE_SOILHUM2: ("Soil Humidity 2", PERCENTAGE, TYPE_SENSOR, "humidity"), TYPE_SOILHUM2: ("Soil Humidity 2", PERCENTAGE, SENSOR, "humidity"),
TYPE_SOILHUM3: ("Soil Humidity 3", PERCENTAGE, TYPE_SENSOR, "humidity"), TYPE_SOILHUM3: ("Soil Humidity 3", PERCENTAGE, SENSOR, "humidity"),
TYPE_SOILHUM4: ("Soil Humidity 4", PERCENTAGE, TYPE_SENSOR, "humidity"), TYPE_SOILHUM4: ("Soil Humidity 4", PERCENTAGE, SENSOR, "humidity"),
TYPE_SOILHUM5: ("Soil Humidity 5", PERCENTAGE, TYPE_SENSOR, "humidity"), TYPE_SOILHUM5: ("Soil Humidity 5", PERCENTAGE, SENSOR, "humidity"),
TYPE_SOILHUM6: ("Soil Humidity 6", PERCENTAGE, TYPE_SENSOR, "humidity"), TYPE_SOILHUM6: ("Soil Humidity 6", PERCENTAGE, SENSOR, "humidity"),
TYPE_SOILHUM7: ("Soil Humidity 7", PERCENTAGE, TYPE_SENSOR, "humidity"), TYPE_SOILHUM7: ("Soil Humidity 7", PERCENTAGE, SENSOR, "humidity"),
TYPE_SOILHUM8: ("Soil Humidity 8", PERCENTAGE, TYPE_SENSOR, "humidity"), TYPE_SOILHUM8: ("Soil Humidity 8", PERCENTAGE, SENSOR, "humidity"),
TYPE_SOILHUM9: ("Soil Humidity 9", PERCENTAGE, TYPE_SENSOR, "humidity"), TYPE_SOILHUM9: ("Soil Humidity 9", PERCENTAGE, SENSOR, "humidity"),
TYPE_SOILTEMP10F: ("Soil Temp 10", TEMP_FAHRENHEIT, TYPE_SENSOR, "temperature"), TYPE_SOILTEMP10F: ("Soil Temp 10", TEMP_FAHRENHEIT, SENSOR, "temperature"),
TYPE_SOILTEMP1F: ("Soil Temp 1", TEMP_FAHRENHEIT, TYPE_SENSOR, "temperature"), TYPE_SOILTEMP1F: ("Soil Temp 1", TEMP_FAHRENHEIT, SENSOR, "temperature"),
TYPE_SOILTEMP2F: ("Soil Temp 2", TEMP_FAHRENHEIT, TYPE_SENSOR, "temperature"), TYPE_SOILTEMP2F: ("Soil Temp 2", TEMP_FAHRENHEIT, SENSOR, "temperature"),
TYPE_SOILTEMP3F: ("Soil Temp 3", TEMP_FAHRENHEIT, TYPE_SENSOR, "temperature"), TYPE_SOILTEMP3F: ("Soil Temp 3", TEMP_FAHRENHEIT, SENSOR, "temperature"),
TYPE_SOILTEMP4F: ("Soil Temp 4", TEMP_FAHRENHEIT, TYPE_SENSOR, "temperature"), TYPE_SOILTEMP4F: ("Soil Temp 4", TEMP_FAHRENHEIT, SENSOR, "temperature"),
TYPE_SOILTEMP5F: ("Soil Temp 5", TEMP_FAHRENHEIT, TYPE_SENSOR, "temperature"), TYPE_SOILTEMP5F: ("Soil Temp 5", TEMP_FAHRENHEIT, SENSOR, "temperature"),
TYPE_SOILTEMP6F: ("Soil Temp 6", TEMP_FAHRENHEIT, TYPE_SENSOR, "temperature"), TYPE_SOILTEMP6F: ("Soil Temp 6", TEMP_FAHRENHEIT, SENSOR, "temperature"),
TYPE_SOILTEMP7F: ("Soil Temp 7", TEMP_FAHRENHEIT, TYPE_SENSOR, "temperature"), TYPE_SOILTEMP7F: ("Soil Temp 7", TEMP_FAHRENHEIT, SENSOR, "temperature"),
TYPE_SOILTEMP8F: ("Soil Temp 8", TEMP_FAHRENHEIT, TYPE_SENSOR, "temperature"), TYPE_SOILTEMP8F: ("Soil Temp 8", TEMP_FAHRENHEIT, SENSOR, "temperature"),
TYPE_SOILTEMP9F: ("Soil Temp 9", TEMP_FAHRENHEIT, TYPE_SENSOR, "temperature"), TYPE_SOILTEMP9F: ("Soil Temp 9", TEMP_FAHRENHEIT, SENSOR, "temperature"),
TYPE_SOLARRADIATION: ( TYPE_SOLARRADIATION: (
"Solar Rad", "Solar Rad",
IRRADIATION_WATTS_PER_SQUARE_METER, IRRADIATION_WATTS_PER_SQUARE_METER,
TYPE_SENSOR, SENSOR,
None, None,
), ),
TYPE_SOLARRADIATION_LX: ("Solar Rad (lx)", LIGHT_LUX, TYPE_SENSOR, "illuminance"), TYPE_SOLARRADIATION_LX: ("Solar Rad (lx)", LIGHT_LUX, SENSOR, "illuminance"),
TYPE_TEMP10F: ("Temp 10", TEMP_FAHRENHEIT, TYPE_SENSOR, "temperature"), TYPE_TEMP10F: ("Temp 10", TEMP_FAHRENHEIT, SENSOR, "temperature"),
TYPE_TEMP1F: ("Temp 1", TEMP_FAHRENHEIT, TYPE_SENSOR, "temperature"), TYPE_TEMP1F: ("Temp 1", TEMP_FAHRENHEIT, SENSOR, "temperature"),
TYPE_TEMP2F: ("Temp 2", TEMP_FAHRENHEIT, TYPE_SENSOR, "temperature"), TYPE_TEMP2F: ("Temp 2", TEMP_FAHRENHEIT, SENSOR, "temperature"),
TYPE_TEMP3F: ("Temp 3", TEMP_FAHRENHEIT, TYPE_SENSOR, "temperature"), TYPE_TEMP3F: ("Temp 3", TEMP_FAHRENHEIT, SENSOR, "temperature"),
TYPE_TEMP4F: ("Temp 4", TEMP_FAHRENHEIT, TYPE_SENSOR, "temperature"), TYPE_TEMP4F: ("Temp 4", TEMP_FAHRENHEIT, SENSOR, "temperature"),
TYPE_TEMP5F: ("Temp 5", TEMP_FAHRENHEIT, TYPE_SENSOR, "temperature"), TYPE_TEMP5F: ("Temp 5", TEMP_FAHRENHEIT, SENSOR, "temperature"),
TYPE_TEMP6F: ("Temp 6", TEMP_FAHRENHEIT, TYPE_SENSOR, "temperature"), TYPE_TEMP6F: ("Temp 6", TEMP_FAHRENHEIT, SENSOR, "temperature"),
TYPE_TEMP7F: ("Temp 7", TEMP_FAHRENHEIT, TYPE_SENSOR, "temperature"), TYPE_TEMP7F: ("Temp 7", TEMP_FAHRENHEIT, SENSOR, "temperature"),
TYPE_TEMP8F: ("Temp 8", TEMP_FAHRENHEIT, TYPE_SENSOR, "temperature"), TYPE_TEMP8F: ("Temp 8", TEMP_FAHRENHEIT, SENSOR, "temperature"),
TYPE_TEMP9F: ("Temp 9", TEMP_FAHRENHEIT, TYPE_SENSOR, "temperature"), TYPE_TEMP9F: ("Temp 9", TEMP_FAHRENHEIT, SENSOR, "temperature"),
TYPE_TEMPF: ("Temp", TEMP_FAHRENHEIT, TYPE_SENSOR, "temperature"), TYPE_TEMPF: ("Temp", TEMP_FAHRENHEIT, SENSOR, "temperature"),
TYPE_TEMPINF: ("Inside Temp", TEMP_FAHRENHEIT, TYPE_SENSOR, "temperature"), TYPE_TEMPINF: ("Inside Temp", TEMP_FAHRENHEIT, SENSOR, "temperature"),
TYPE_TOTALRAININ: ("Lifetime Rain", "in", TYPE_SENSOR, None), TYPE_TOTALRAININ: ("Lifetime Rain", "in", SENSOR, None),
TYPE_UV: ("uv", "Index", TYPE_SENSOR, None), TYPE_UV: ("uv", "Index", SENSOR, None),
TYPE_PM25: ("PM25", CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, TYPE_SENSOR, None), TYPE_PM25: ("PM25", CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, SENSOR, None),
TYPE_PM25_24H: ( TYPE_PM25_24H: (
"PM25 24h Avg", "PM25 24h Avg",
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
TYPE_SENSOR, SENSOR,
None, None,
), ),
TYPE_WEEKLYRAININ: ("Weekly Rain", "in", TYPE_SENSOR, None), TYPE_WEEKLYRAININ: ("Weekly Rain", "in", SENSOR, None),
TYPE_WINDDIR: ("Wind Dir", DEGREE, TYPE_SENSOR, None), TYPE_WINDDIR: ("Wind Dir", DEGREE, SENSOR, None),
TYPE_WINDDIR_AVG10M: ("Wind Dir Avg 10m", DEGREE, TYPE_SENSOR, None), TYPE_WINDDIR_AVG10M: ("Wind Dir Avg 10m", DEGREE, SENSOR, None),
TYPE_WINDDIR_AVG2M: ("Wind Dir Avg 2m", SPEED_MILES_PER_HOUR, TYPE_SENSOR, None), TYPE_WINDDIR_AVG2M: ("Wind Dir Avg 2m", SPEED_MILES_PER_HOUR, SENSOR, None),
TYPE_WINDGUSTDIR: ("Gust Dir", DEGREE, TYPE_SENSOR, None), TYPE_WINDGUSTDIR: ("Gust Dir", DEGREE, SENSOR, None),
TYPE_WINDGUSTMPH: ("Wind Gust", SPEED_MILES_PER_HOUR, TYPE_SENSOR, None), TYPE_WINDGUSTMPH: ("Wind Gust", SPEED_MILES_PER_HOUR, SENSOR, None),
TYPE_WINDSPDMPH_AVG10M: ("Wind Avg 10m", SPEED_MILES_PER_HOUR, TYPE_SENSOR, None), TYPE_WINDSPDMPH_AVG10M: ("Wind Avg 10m", SPEED_MILES_PER_HOUR, SENSOR, None),
TYPE_WINDSPDMPH_AVG2M: ("Wind Avg 2m", SPEED_MILES_PER_HOUR, TYPE_SENSOR, None), TYPE_WINDSPDMPH_AVG2M: ("Wind Avg 2m", SPEED_MILES_PER_HOUR, SENSOR, None),
TYPE_WINDSPEEDMPH: ("Wind Speed", SPEED_MILES_PER_HOUR, TYPE_SENSOR, None), TYPE_WINDSPEEDMPH: ("Wind Speed", SPEED_MILES_PER_HOUR, SENSOR, None),
TYPE_YEARLYRAININ: ("Yearly Rain", "in", TYPE_SENSOR, None), TYPE_YEARLYRAININ: ("Yearly Rain", "in", SENSOR, None),
} }
CONFIG_SCHEMA = vol.Schema( CONFIG_SCHEMA = vol.Schema(
@ -260,7 +264,7 @@ CONFIG_SCHEMA = vol.Schema(
async def async_setup(hass, config): async def async_setup(hass, config):
"""Set up the Ambient PWS component.""" """Set up the Ambient PWS integration."""
hass.data[DOMAIN] = {} hass.data[DOMAIN] = {}
hass.data[DOMAIN][DATA_CLIENT] = {} hass.data[DOMAIN][DATA_CLIENT] = {}
@ -322,8 +326,8 @@ async def async_unload_entry(hass, config_entry):
hass.async_create_task(ambient.ws_disconnect()) hass.async_create_task(ambient.ws_disconnect())
tasks = [ tasks = [
hass.config_entries.async_forward_entry_unload(config_entry, component) hass.config_entries.async_forward_entry_unload(config_entry, platform)
for component in ("binary_sensor", "sensor") for platform in PLATFORMS
] ]
await asyncio.gather(*tasks) await asyncio.gather(*tasks)
@ -431,10 +435,10 @@ class AmbientStation:
# attempt forward setup of the config entry (because it will have # attempt forward setup of the config entry (because it will have
# already been done): # already been done):
if not self._entry_setup_complete: if not self._entry_setup_complete:
for component in ("binary_sensor", "sensor"): for platform in PLATFORMS:
self._hass.async_create_task( self._hass.async_create_task(
self._hass.config_entries.async_forward_entry_setup( self._hass.config_entries.async_forward_entry_setup(
self._config_entry, component self._config_entry, platform
) )
) )
self._entry_setup_complete = True self._entry_setup_complete = True

View File

@ -1,5 +1,8 @@
"""Support for Ambient Weather Station binary sensors.""" """Support for Ambient Weather Station binary sensors."""
from homeassistant.components.binary_sensor import BinarySensorEntity from homeassistant.components.binary_sensor import (
DOMAIN as BINARY_SENSOR,
BinarySensorEntity,
)
from homeassistant.const import ATTR_NAME from homeassistant.const import ATTR_NAME
from homeassistant.core import callback from homeassistant.core import callback
@ -18,13 +21,7 @@ from . import (
TYPE_BATTOUT, TYPE_BATTOUT,
AmbientWeatherEntity, AmbientWeatherEntity,
) )
from .const import ( from .const import ATTR_LAST_DATA, ATTR_MONITORED_CONDITIONS, DATA_CLIENT, DOMAIN
ATTR_LAST_DATA,
ATTR_MONITORED_CONDITIONS,
DATA_CLIENT,
DOMAIN,
TYPE_BINARY_SENSOR,
)
async def async_setup_entry(hass, entry, async_add_entities): async def async_setup_entry(hass, entry, async_add_entities):
@ -35,7 +32,7 @@ async def async_setup_entry(hass, entry, async_add_entities):
for mac_address, station in ambient.stations.items(): for mac_address, station in ambient.stations.items():
for condition in station[ATTR_MONITORED_CONDITIONS]: for condition in station[ATTR_MONITORED_CONDITIONS]:
name, _, kind, device_class = SENSOR_TYPES[condition] name, _, kind, device_class = SENSOR_TYPES[condition]
if kind == TYPE_BINARY_SENSOR: if kind == BINARY_SENSOR:
binary_sensor_list.append( binary_sensor_list.append(
AmbientWeatherBinarySensor( AmbientWeatherBinarySensor(
ambient, ambient,

View File

@ -10,6 +10,3 @@ ATTR_MONITORED_CONDITIONS = "monitored_conditions"
CONF_APP_KEY = "app_key" CONF_APP_KEY = "app_key"
DATA_CLIENT = "data_client" DATA_CLIENT = "data_client"
TYPE_BINARY_SENSOR = "binary_sensor"
TYPE_SENSOR = "sensor"

View File

@ -1,4 +1,5 @@
"""Support for Ambient Weather Station sensors.""" """Support for Ambient Weather Station sensors."""
from homeassistant.components.binary_sensor import DOMAIN as SENSOR
from homeassistant.const import ATTR_NAME from homeassistant.const import ATTR_NAME
from homeassistant.core import callback from homeassistant.core import callback
@ -8,13 +9,7 @@ from . import (
TYPE_SOLARRADIATION_LX, TYPE_SOLARRADIATION_LX,
AmbientWeatherEntity, AmbientWeatherEntity,
) )
from .const import ( from .const import ATTR_LAST_DATA, ATTR_MONITORED_CONDITIONS, DATA_CLIENT, DOMAIN
ATTR_LAST_DATA,
ATTR_MONITORED_CONDITIONS,
DATA_CLIENT,
DOMAIN,
TYPE_SENSOR,
)
async def async_setup_entry(hass, entry, async_add_entities): async def async_setup_entry(hass, entry, async_add_entities):
@ -25,7 +20,7 @@ async def async_setup_entry(hass, entry, async_add_entities):
for mac_address, station in ambient.stations.items(): for mac_address, station in ambient.stations.items():
for condition in station[ATTR_MONITORED_CONDITIONS]: for condition in station[ATTR_MONITORED_CONDITIONS]:
name, unit, kind, device_class = SENSOR_TYPES[condition] name, unit, kind, device_class = SENSOR_TYPES[condition]
if kind == TYPE_SENSOR: if kind == SENSOR:
sensor_list.append( sensor_list.append(
AmbientWeatherSensor( AmbientWeatherSensor(
ambient, ambient,

View File

@ -62,8 +62,8 @@ async def async_setup_entry(hass, entry):
"""Set up platforms and initiate connection.""" """Set up platforms and initiate connection."""
await asyncio.gather( await asyncio.gather(
*[ *[
hass.config_entries.async_forward_entry_setup(entry, component) hass.config_entries.async_forward_entry_setup(entry, platform)
for component in PLATFORMS for platform in PLATFORMS
] ]
) )
await manager.init() await manager.init()

View File

@ -78,8 +78,8 @@ async def async_unload_entry(hass, entry):
unload_ok = all( unload_ok = all(
await asyncio.gather( await asyncio.gather(
*[ *[
hass.config_entries.async_forward_entry_unload(entry, component) hass.config_entries.async_forward_entry_unload(entry, platform)
for component in PLATFORMS for platform in PLATFORMS
] ]
) )
) )

View File

@ -21,7 +21,6 @@ import homeassistant.helpers.config_validation as cv
from .activity import ActivityStream from .activity import ActivityStream
from .const import ( from .const import (
AUGUST_COMPONENTS,
CONF_ACCESS_TOKEN_CACHE_FILE, CONF_ACCESS_TOKEN_CACHE_FILE,
CONF_INSTALL_ID, CONF_INSTALL_ID,
CONF_LOGIN_METHOD, CONF_LOGIN_METHOD,
@ -32,6 +31,7 @@ from .const import (
DOMAIN, DOMAIN,
LOGIN_METHODS, LOGIN_METHODS,
MIN_TIME_BETWEEN_DETAIL_UPDATES, MIN_TIME_BETWEEN_DETAIL_UPDATES,
PLATFORMS,
VERIFICATION_CODE_KEY, VERIFICATION_CODE_KEY,
) )
from .exceptions import CannotConnect, InvalidAuth, RequireValidation from .exceptions import CannotConnect, InvalidAuth, RequireValidation
@ -137,9 +137,9 @@ async def async_setup_august(hass, config_entry, august_gateway):
await hass.data[DOMAIN][entry_id][DATA_AUGUST].async_setup() await hass.data[DOMAIN][entry_id][DATA_AUGUST].async_setup()
for component in AUGUST_COMPONENTS: for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(config_entry, component) hass.config_entries.async_forward_entry_setup(config_entry, platform)
) )
return True return True
@ -209,8 +209,8 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
unload_ok = all( unload_ok = all(
await asyncio.gather( await asyncio.gather(
*[ *[
hass.config_entries.async_forward_entry_unload(entry, component) hass.config_entries.async_forward_entry_unload(entry, platform)
for component in AUGUST_COMPONENTS for platform in PLATFORMS
] ]
) )
) )

View File

@ -43,4 +43,4 @@ ACTIVITY_UPDATE_INTERVAL = timedelta(seconds=10)
LOGIN_METHODS = ["phone", "email"] LOGIN_METHODS = ["phone", "email"]
AUGUST_COMPONENTS = ["camera", "binary_sensor", "lock", "sensor"] PLATFORMS = ["camera", "binary_sensor", "lock", "sensor"]

View File

@ -79,9 +79,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
AURORA_API: api, AURORA_API: api,
} }
for component in PLATFORMS: for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, component) hass.config_entries.async_forward_entry_setup(entry, platform)
) )
return True return True
@ -92,8 +92,8 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
unload_ok = all( unload_ok = all(
await asyncio.gather( await asyncio.gather(
*[ *[
hass.config_entries.async_forward_entry_unload(entry, component) hass.config_entries.async_forward_entry_unload(entry, platform)
for component in PLATFORMS for platform in PLATFORMS
] ]
) )
) )

View File

@ -48,9 +48,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
domain_entry = domain.setdefault(entry.entry_id, {}) domain_entry = domain.setdefault(entry.entry_id, {})
product = domain_entry.setdefault(PRODUCT, product) product = domain_entry.setdefault(PRODUCT, product)
for component in PLATFORMS: for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, component) hass.config_entries.async_forward_entry_setup(entry, platform)
) )
return True return True

View File

@ -86,9 +86,9 @@ async def async_setup_entry(hass, entry):
if not hass.data[DOMAIN][entry.entry_id].available: if not hass.data[DOMAIN][entry.entry_id].available:
raise ConfigEntryNotReady raise ConfigEntryNotReady
for component in PLATFORMS: for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, component) hass.config_entries.async_forward_entry_setup(entry, platform)
) )
def blink_refresh(event_time=None): def blink_refresh(event_time=None):
@ -133,8 +133,8 @@ async def async_unload_entry(hass, entry):
unload_ok = all( unload_ok = all(
await asyncio.gather( await asyncio.gather(
*[ *[
hass.config_entries.async_forward_entry_unload(entry, component) hass.config_entries.async_forward_entry_unload(entry, platform)
for component in PLATFORMS for platform in PLATFORMS
] ]
) )
) )

View File

@ -18,7 +18,7 @@ from homeassistant.util import Throttle
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
BLOOMSKY_TYPE = ["camera", "binary_sensor", "sensor"] PLATFORMS = ["camera", "binary_sensor", "sensor"]
DOMAIN = "bloomsky" DOMAIN = "bloomsky"
@ -32,7 +32,7 @@ CONFIG_SCHEMA = vol.Schema(
def setup(hass, config): def setup(hass, config):
"""Set up the BloomSky component.""" """Set up the BloomSky integration."""
api_key = config[DOMAIN][CONF_API_KEY] api_key = config[DOMAIN][CONF_API_KEY]
try: try:
@ -42,8 +42,8 @@ def setup(hass, config):
hass.data[DOMAIN] = bloomsky hass.data[DOMAIN] = bloomsky
for component in BLOOMSKY_TYPE: for platform in PLATFORMS:
discovery.load_platform(hass, component, DOMAIN, {}, config) discovery.load_platform(hass, platform, DOMAIN, {}, config)
return True return True

View File

@ -59,7 +59,7 @@ DEFAULT_OPTIONS = {
CONF_USE_LOCATION: False, CONF_USE_LOCATION: False,
} }
BMW_PLATFORMS = ["binary_sensor", "device_tracker", "lock", "notify", "sensor"] PLATFORMS = ["binary_sensor", "device_tracker", "lock", "notify", "sensor"]
UPDATE_INTERVAL = 5 # in minutes UPDATE_INTERVAL = 5 # in minutes
SERVICE_UPDATE_STATE = "update_state" SERVICE_UPDATE_STATE = "update_state"
@ -138,13 +138,13 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
await _async_update_all() await _async_update_all()
for platform in BMW_PLATFORMS: for platform in PLATFORMS:
if platform != NOTIFY_DOMAIN: if platform != NOTIFY_DOMAIN:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, platform) hass.config_entries.async_forward_entry_setup(entry, platform)
) )
# set up notify platform, no entry support for notify component yet, # set up notify platform, no entry support for notify platform yet,
# have to use discovery to load platform. # have to use discovery to load platform.
hass.async_create_task( hass.async_create_task(
discovery.async_load_platform( discovery.async_load_platform(
@ -164,9 +164,9 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
unload_ok = all( unload_ok = all(
await asyncio.gather( await asyncio.gather(
*[ *[
hass.config_entries.async_forward_entry_unload(entry, component) hass.config_entries.async_forward_entry_unload(entry, platform)
for component in BMW_PLATFORMS for platform in PLATFORMS
if component != NOTIFY_DOMAIN if platform != NOTIFY_DOMAIN
] ]
) )
) )

View File

@ -65,9 +65,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
_async_remove_old_device_identifiers(config_entry_id, device_registry, hub) _async_remove_old_device_identifiers(config_entry_id, device_registry, hub)
for component in PLATFORMS: for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, component) hass.config_entries.async_forward_entry_setup(entry, platform)
) )
return True return True
@ -78,8 +78,8 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
unload_ok = all( unload_ok = all(
await asyncio.gather( await asyncio.gather(
*[ *[
hass.config_entries.async_forward_entry_unload(entry, component) hass.config_entries.async_forward_entry_unload(entry, platform)
for component in PLATFORMS for platform in PLATFORMS
] ]
) )
) )

View File

@ -28,9 +28,9 @@ async def async_setup_entry(hass, config_entry):
UNDO_UPDATE_LISTENER: undo_listener, UNDO_UPDATE_LISTENER: undo_listener,
} }
for component in PLATFORMS: for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(config_entry, component) hass.config_entries.async_forward_entry_setup(config_entry, platform)
) )
return True return True
@ -41,8 +41,8 @@ async def async_unload_entry(hass, config_entry):
unload_ok = all( unload_ok = all(
await asyncio.gather( await asyncio.gather(
*[ *[
hass.config_entries.async_forward_entry_unload(config_entry, component) hass.config_entries.async_forward_entry_unload(config_entry, platform)
for component in PLATFORMS for platform in PLATFORMS
] ]
) )
) )

View File

@ -46,9 +46,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
hass.data[DOMAIN][DATA_CONFIG_ENTRY][entry.entry_id] = coordinator hass.data[DOMAIN][DATA_CONFIG_ENTRY][entry.entry_id] = coordinator
hass.data[DOMAIN][SNMP] = snmp_engine hass.data[DOMAIN][SNMP] = snmp_engine
for component in PLATFORMS: for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, component) hass.config_entries.async_forward_entry_setup(entry, platform)
) )
return True return True
@ -59,8 +59,8 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
unload_ok = all( unload_ok = all(
await asyncio.gather( await asyncio.gather(
*[ *[
hass.config_entries.async_forward_entry_unload(entry, component) hass.config_entries.async_forward_entry_unload(entry, platform)
for component in PLATFORMS for platform in PLATFORMS
] ]
) )
) )

View File

@ -107,9 +107,9 @@ async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool
DATA_UNDO_UPDATE_LISTENER: undo_listener, DATA_UNDO_UPDATE_LISTENER: undo_listener,
} }
for component in PLATFORMS: for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, component) hass.config_entries.async_forward_entry_setup(entry, platform)
) )
return True return True
@ -120,8 +120,8 @@ async def async_unload_entry(hass: HomeAssistantType, entry: ConfigEntry) -> boo
unload_ok = all( unload_ok = all(
await asyncio.gather( await asyncio.gather(
*[ *[
hass.config_entries.async_forward_entry_unload(entry, component) hass.config_entries.async_forward_entry_unload(entry, platform)
for component in PLATFORMS for platform in PLATFORMS
] ]
) )
) )

View File

@ -117,9 +117,9 @@ async def async_setup_entry(hass: HomeAssistantType, config_entry: ConfigEntry)
hass.data[DOMAIN][config_entry.entry_id] = coordinator hass.data[DOMAIN][config_entry.entry_id] = coordinator
for component in PLATFORMS: for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(config_entry, component) hass.config_entries.async_forward_entry_setup(config_entry, platform)
) )
return True return True
@ -132,8 +132,8 @@ async def async_unload_entry(
unload_ok = all( unload_ok = all(
await asyncio.gather( await asyncio.gather(
*[ *[
hass.config_entries.async_forward_entry_unload(config_entry, component) hass.config_entries.async_forward_entry_unload(config_entry, platform)
for component in PLATFORMS for platform in PLATFORMS
] ]
) )
) )

View File

@ -115,9 +115,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
entry_data[CONF_CONFIG_LISTENER] = entry.add_update_listener(update_listener) entry_data[CONF_CONFIG_LISTENER] = entry.add_update_listener(update_listener)
for component in PLATFORMS: for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, component) hass.config_entries.async_forward_entry_setup(entry, platform)
) )
return True return True
@ -134,8 +134,8 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
unload_ok = all( unload_ok = all(
await asyncio.gather( await asyncio.gather(
*[ *[
hass.config_entries.async_forward_entry_unload(entry, component) hass.config_entries.async_forward_entry_unload(entry, platform)
for component in PLATFORMS for platform in PLATFORMS
] ]
) )
) )

View File

@ -44,9 +44,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
if not entry.unique_id: if not entry.unique_id:
hass.config_entries.async_update_entry(entry, unique_id=entry.data["country"]) hass.config_entries.async_update_entry(entry, unique_id=entry.data["country"])
for component in PLATFORMS: for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, component) hass.config_entries.async_forward_entry_setup(entry, platform)
) )
return True return True
@ -57,8 +57,8 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
unload_ok = all( unload_ok = all(
await asyncio.gather( await asyncio.gather(
*[ *[
hass.config_entries.async_forward_entry_unload(entry, component) hass.config_entries.async_forward_entry_unload(entry, platform)
for component in PLATFORMS for platform in PLATFORMS
] ]
) )
) )

View File

@ -25,7 +25,7 @@ DOMAIN = "daikin"
PARALLEL_UPDATES = 0 PARALLEL_UPDATES = 0
MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=60) MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=60)
COMPONENT_TYPES = ["climate", "sensor", "switch"] PLATFORMS = ["climate", "sensor", "switch"]
CONFIG_SCHEMA = vol.Schema( CONFIG_SCHEMA = vol.Schema(
vol.All( vol.All(
@ -83,9 +83,9 @@ async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry):
if not daikin_api: if not daikin_api:
return False return False
hass.data.setdefault(DOMAIN, {}).update({entry.entry_id: daikin_api}) hass.data.setdefault(DOMAIN, {}).update({entry.entry_id: daikin_api})
for component in COMPONENT_TYPES: for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, component) hass.config_entries.async_forward_entry_setup(entry, platform)
) )
return True return True
@ -94,8 +94,8 @@ async def async_unload_entry(hass, config_entry):
"""Unload a config entry.""" """Unload a config entry."""
await asyncio.wait( await asyncio.wait(
[ [
hass.config_entries.async_forward_entry_unload(config_entry, component) hass.config_entries.async_forward_entry_unload(config_entry, platform)
for component in COMPONENT_TYPES for platform in PLATFORMS
] ]
) )
hass.data[DOMAIN].pop(config_entry.entry_id) hass.data[DOMAIN].pop(config_entry.entry_id)

View File

@ -13,7 +13,7 @@ from homeassistant.util import Throttle
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
DANFOSS_AIR_PLATFORMS = ["sensor", "binary_sensor", "switch"] PLATFORMS = ["sensor", "binary_sensor", "switch"]
DOMAIN = "danfoss_air" DOMAIN = "danfoss_air"
MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=60) MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=60)
@ -29,7 +29,7 @@ def setup(hass, config):
hass.data[DOMAIN] = DanfossAir(conf[CONF_HOST]) hass.data[DOMAIN] = DanfossAir(conf[CONF_HOST])
for platform in DANFOSS_AIR_PLATFORMS: for platform in PLATFORMS:
discovery.load_platform(hass, platform, DOMAIN, {}, config) discovery.load_platform(hass, platform, DOMAIN, {}, config)
return True return True

View File

@ -28,7 +28,7 @@ CONF_ALLOW_DECONZ_GROUPS = "allow_deconz_groups"
CONF_ALLOW_NEW_DEVICES = "allow_new_devices" CONF_ALLOW_NEW_DEVICES = "allow_new_devices"
CONF_MASTER_GATEWAY = "master" CONF_MASTER_GATEWAY = "master"
SUPPORTED_PLATFORMS = [ PLATFORMS = [
BINARY_SENSOR_DOMAIN, BINARY_SENSOR_DOMAIN,
CLIMATE_DOMAIN, CLIMATE_DOMAIN,
COVER_DOMAIN, COVER_DOMAIN,

View File

@ -26,7 +26,7 @@ from .const import (
NEW_LIGHT, NEW_LIGHT,
NEW_SCENE, NEW_SCENE,
NEW_SENSOR, NEW_SENSOR,
SUPPORTED_PLATFORMS, PLATFORMS,
) )
from .deconz_event import async_setup_events, async_unload_events from .deconz_event import async_setup_events, async_unload_events
from .errors import AuthenticationRequired, CannotConnect from .errors import AuthenticationRequired, CannotConnect
@ -184,10 +184,10 @@ class DeconzGateway:
) )
return False return False
for component in SUPPORTED_PLATFORMS: for platform in PLATFORMS:
self.hass.async_create_task( self.hass.async_create_task(
self.hass.config_entries.async_forward_entry_setup( self.hass.config_entries.async_forward_entry_setup(
self.config_entry, component self.config_entry, platform
) )
) )
@ -259,9 +259,9 @@ class DeconzGateway:
self.api.async_connection_status_callback = None self.api.async_connection_status_callback = None
self.api.close() self.api.close()
for component in SUPPORTED_PLATFORMS: for platform in PLATFORMS:
await self.hass.config_entries.async_forward_entry_unload( await self.hass.config_entries.async_forward_entry_unload(
self.config_entry, component self.config_entry, platform
) )
for unsub_dispatcher in self.listeners: for unsub_dispatcher in self.listeners:

View File

@ -50,9 +50,9 @@ async def async_setup(hass, config):
) )
# Set up demo platforms # Set up demo platforms
for component in COMPONENTS_WITH_DEMO_PLATFORM: for platform in COMPONENTS_WITH_DEMO_PLATFORM:
hass.async_create_task( hass.async_create_task(
hass.helpers.discovery.async_load_platform(component, DOMAIN, {}, config) hass.helpers.discovery.async_load_platform(platform, DOMAIN, {}, config)
) )
config.setdefault(ha.DOMAIN, {}) config.setdefault(ha.DOMAIN, {})
@ -146,9 +146,9 @@ async def async_setup(hass, config):
async def async_setup_entry(hass, config_entry): async def async_setup_entry(hass, config_entry):
"""Set the config entry up.""" """Set the config entry up."""
# Set up demo platforms with config entry # Set up demo platforms with config entry
for component in COMPONENTS_WITH_CONFIG_ENTRY_DEMO_PLATFORM: for platform in COMPONENTS_WITH_CONFIG_ENTRY_DEMO_PLATFORM:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(config_entry, component) hass.config_entries.async_forward_entry_setup(config_entry, platform)
) )
return True return True

View File

@ -70,9 +70,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
await hass.data[DOMAIN][entry.entry_id][COORDINATOR].async_refresh() await hass.data[DOMAIN][entry.entry_id][COORDINATOR].async_refresh()
for component in PLATFORMS: for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, component) hass.config_entries.async_forward_entry_setup(entry, platform)
) )
return True return True
@ -83,8 +83,8 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
unload_ok = all( unload_ok = all(
await asyncio.gather( await asyncio.gather(
*[ *[
hass.config_entries.async_forward_entry_unload(entry, component) hass.config_entries.async_forward_entry_unload(entry, platform)
for component in PLATFORMS for platform in PLATFORMS
] ]
) )
) )

View File

@ -45,9 +45,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
hass.data[DOMAIN][entry.entry_id] = dtv hass.data[DOMAIN][entry.entry_id] = dtv
for component in PLATFORMS: for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, component) hass.config_entries.async_forward_entry_setup(entry, platform)
) )
return True return True
@ -58,8 +58,8 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
unload_ok = all( unload_ok = all(
await asyncio.gather( await asyncio.gather(
*[ *[
hass.config_entries.async_forward_entry_unload(entry, component) hass.config_entries.async_forward_entry_unload(entry, platform)
for component in PLATFORMS for platform in PLATFORMS
] ]
) )
) )

View File

@ -168,9 +168,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
UNDO_UPDATE_LISTENER: undo_listener, UNDO_UPDATE_LISTENER: undo_listener,
} }
for component in PLATFORMS: for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, component) hass.config_entries.async_forward_entry_setup(entry, platform)
) )
return True return True
@ -188,8 +188,8 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
unload_ok = all( unload_ok = all(
await asyncio.gather( await asyncio.gather(
*[ *[
hass.config_entries.async_forward_entry_unload(entry, component) hass.config_entries.async_forward_entry_unload(entry, platform)
for component in PLATFORMS for platform in PLATFORMS
] ]
) )
) )

View File

@ -44,8 +44,8 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
unload_ok = all( unload_ok = all(
await asyncio.gather( await asyncio.gather(
*[ *[
hass.config_entries.async_forward_entry_unload(entry, component) hass.config_entries.async_forward_entry_unload(entry, platform)
for component in PLATFORMS for platform in PLATFORMS
] ]
) )
) )

View File

@ -24,9 +24,9 @@ async def async_setup_entry(hass, config_entry):
hass.data.setdefault(DOMAIN, {}) hass.data.setdefault(DOMAIN, {})
hass.data[DOMAIN][config_entry.entry_id] = player hass.data[DOMAIN][config_entry.entry_id] = player
for component in PLATFORMS: for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(config_entry, component) hass.config_entries.async_forward_entry_setup(config_entry, platform)
) )
return True return True
@ -37,8 +37,8 @@ async def async_unload_entry(hass, config_entry):
unload_ok = all( unload_ok = all(
await asyncio.gather( await asyncio.gather(
*[ *[
hass.config_entries.async_forward_entry_unload(config_entry, component) hass.config_entries.async_forward_entry_unload(config_entry, platform)
for component in PLATFORMS for platform in PLATFORMS
] ]
) )
) )

View File

@ -47,8 +47,8 @@ from .const import (
DEFAULT_PORT, DEFAULT_PORT,
DEFAULT_TEMPLATES, DEFAULT_TEMPLATES,
DOMAIN, DOMAIN,
ENTITY_PLATFORMS,
LOGGER, LOGGER,
PLATFORMS,
SERVICE_REQUEST_AREA_PRESET, SERVICE_REQUEST_AREA_PRESET,
SERVICE_REQUEST_CHANNEL_LEVEL, SERVICE_REQUEST_CHANNEL_LEVEL,
) )
@ -267,14 +267,17 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
# need to do it before the listener # need to do it before the listener
hass.data[DOMAIN][entry.entry_id] = bridge hass.data[DOMAIN][entry.entry_id] = bridge
entry.add_update_listener(async_entry_changed) entry.add_update_listener(async_entry_changed)
if not await bridge.async_setup(): if not await bridge.async_setup():
LOGGER.error("Could not set up bridge for entry %s", entry.data) LOGGER.error("Could not set up bridge for entry %s", entry.data)
hass.data[DOMAIN][entry.entry_id] = None hass.data[DOMAIN][entry.entry_id] = None
raise ConfigEntryNotReady raise ConfigEntryNotReady
for platform in ENTITY_PLATFORMS:
for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, platform) hass.config_entries.async_forward_entry_setup(entry, platform)
) )
return True return True
@ -284,7 +287,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
hass.data[DOMAIN].pop(entry.entry_id) hass.data[DOMAIN].pop(entry.entry_id)
tasks = [ tasks = [
hass.config_entries.async_forward_entry_unload(entry, platform) hass.config_entries.async_forward_entry_unload(entry, platform)
for platform in ENTITY_PLATFORMS for platform in PLATFORMS
] ]
results = await asyncio.gather(*tasks) results = await asyncio.gather(*tasks)
return False not in results return False not in results

View File

@ -16,14 +16,7 @@ from homeassistant.const import CONF_HOST
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.dispatcher import async_dispatcher_send from homeassistant.helpers.dispatcher import async_dispatcher_send
from .const import ( from .const import ATTR_AREA, ATTR_HOST, ATTR_PACKET, ATTR_PRESET, LOGGER, PLATFORMS
ATTR_AREA,
ATTR_HOST,
ATTR_PACKET,
ATTR_PRESET,
ENTITY_PLATFORMS,
LOGGER,
)
from .convert_config import convert_config from .convert_config import convert_config
@ -107,7 +100,7 @@ class DynaliteBridge:
def add_devices_when_registered(self, devices: List[DynaliteBaseDevice]) -> None: def add_devices_when_registered(self, devices: List[DynaliteBaseDevice]) -> None:
"""Add the devices to HA if the add devices callback was registered, otherwise queue until it is.""" """Add the devices to HA if the add devices callback was registered, otherwise queue until it is."""
for platform in ENTITY_PLATFORMS: for platform in PLATFORMS:
platform_devices = [ platform_devices = [
device for device in devices if device.category == platform device for device in devices if device.category == platform
] ]

View File

@ -6,7 +6,7 @@ from homeassistant.const import CONF_ROOM
LOGGER = logging.getLogger(__package__) LOGGER = logging.getLogger(__package__)
DOMAIN = "dynalite" DOMAIN = "dynalite"
ENTITY_PLATFORMS = ["light", "switch", "cover"] PLATFORMS = ["light", "switch", "cover"]
CONF_ACTIVE = "active" CONF_ACTIVE = "active"

View File

@ -17,7 +17,7 @@ CONF_RETRY = "retry"
DEFAULT_TIMEOUT = 5 DEFAULT_TIMEOUT = 5
DEFAULT_RETRY = 10 DEFAULT_RETRY = 10
DYSON_DEVICES = "dyson_devices" DYSON_DEVICES = "dyson_devices"
DYSON_PLATFORMS = ["sensor", "fan", "vacuum", "climate", "air_quality"] PLATFORMS = ["sensor", "fan", "vacuum", "climate", "air_quality"]
DOMAIN = "dyson" DOMAIN = "dyson"
@ -105,7 +105,7 @@ def setup(hass, config):
# Start fan/sensors components # Start fan/sensors components
if hass.data[DYSON_DEVICES]: if hass.data[DYSON_DEVICES]:
_LOGGER.debug("Starting sensor/fan components") _LOGGER.debug("Starting sensor/fan components")
for platform in DYSON_PLATFORMS: for platform in PLATFORMS:
discovery.load_platform(hass, platform, DOMAIN, {}, config) discovery.load_platform(hass, platform, DOMAIN, {}, config)
return True return True

View File

@ -10,13 +10,7 @@ from homeassistant.const import CONF_API_KEY
from homeassistant.helpers import config_validation as cv from homeassistant.helpers import config_validation as cv
from homeassistant.util import Throttle from homeassistant.util import Throttle
from .const import ( from .const import _LOGGER, CONF_REFRESH_TOKEN, DATA_ECOBEE_CONFIG, DOMAIN, PLATFORMS
_LOGGER,
CONF_REFRESH_TOKEN,
DATA_ECOBEE_CONFIG,
DOMAIN,
ECOBEE_PLATFORMS,
)
MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=180) MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=180)
@ -32,7 +26,7 @@ async def async_setup(hass, config):
But, an "ecobee:" entry in configuration.yaml will trigger an import flow But, an "ecobee:" entry in configuration.yaml will trigger an import flow
if a config entry doesn't already exist. If ecobee.conf exists, the import if a config entry doesn't already exist. If ecobee.conf exists, the import
flow will attempt to import it and create a config entry, to assist users flow will attempt to import it and create a config entry, to assist users
migrating from the old ecobee component. Otherwise, the user will have to migrating from the old ecobee integration. Otherwise, the user will have to
continue setting up the integration via the config flow. continue setting up the integration via the config flow.
""" """
hass.data[DATA_ECOBEE_CONFIG] = config.get(DOMAIN, {}) hass.data[DATA_ECOBEE_CONFIG] = config.get(DOMAIN, {})
@ -66,9 +60,9 @@ async def async_setup_entry(hass, entry):
hass.data[DOMAIN] = data hass.data[DOMAIN] = data
for component in ECOBEE_PLATFORMS: for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, component) hass.config_entries.async_forward_entry_setup(entry, platform)
) )
return True return True
@ -120,7 +114,7 @@ async def async_unload_entry(hass, config_entry):
hass.data.pop(DOMAIN) hass.data.pop(DOMAIN)
tasks = [] tasks = []
for platform in ECOBEE_PLATFORMS: for platform in PLATFORMS:
tasks.append( tasks.append(
hass.config_entries.async_forward_entry_unload(config_entry, platform) hass.config_entries.async_forward_entry_unload(config_entry, platform)
) )

View File

@ -37,7 +37,7 @@ ECOBEE_MODEL_TO_NAME = {
"vulcanSmart": "ecobee4 Smart", "vulcanSmart": "ecobee4 Smart",
} }
ECOBEE_PLATFORMS = ["binary_sensor", "climate", "sensor", "weather"] PLATFORMS = ["binary_sensor", "climate", "sensor", "weather"]
MANUFACTURER = "ecobee" MANUFACTURER = "ecobee"

View File

@ -60,9 +60,9 @@ async def async_setup_entry(hass, config_entry):
hass.data[DOMAIN][API_CLIENT][config_entry.entry_id] = api hass.data[DOMAIN][API_CLIENT][config_entry.entry_id] = api
hass.data[DOMAIN][EQUIPMENT][config_entry.entry_id] = equipment hass.data[DOMAIN][EQUIPMENT][config_entry.entry_id] = equipment
for component in PLATFORMS: for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(config_entry, component) hass.config_entries.async_forward_entry_setup(config_entry, platform)
) )
api.subscribe() api.subscribe()
@ -92,8 +92,8 @@ async def async_setup_entry(hass, config_entry):
async def async_unload_entry(hass, entry): async def async_unload_entry(hass, entry):
"""Unload a EcoNet config entry.""" """Unload a EcoNet config entry."""
tasks = [ tasks = [
hass.config_entries.async_forward_entry_unload(entry, component) hass.config_entries.async_forward_entry_unload(entry, platform)
for component in PLATFORMS for platform in PLATFORMS
] ]
await asyncio.gather(*tasks) await asyncio.gather(*tasks)

View File

@ -52,7 +52,7 @@ SYNC_TIMEOUT = 120
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
SUPPORTED_DOMAINS = [ PLATFORMS = [
"alarm_control_panel", "alarm_control_panel",
"climate", "climate",
"light", "light",
@ -262,9 +262,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
"keypads": {}, "keypads": {},
} }
for component in SUPPORTED_DOMAINS: for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, component) hass.config_entries.async_forward_entry_setup(entry, platform)
) )
return True return True
@ -289,8 +289,8 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
unload_ok = all( unload_ok = all(
await asyncio.gather( await asyncio.gather(
*[ *[
hass.config_entries.async_forward_entry_unload(entry, component) hass.config_entries.async_forward_entry_unload(entry, platform)
for component in SUPPORTED_DOMAINS for platform in PLATFORMS
] ]
) )
) )

View File

@ -48,9 +48,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
_LOGGER.warning("Cannot connect to projector %s", entry.data[CONF_HOST]) _LOGGER.warning("Cannot connect to projector %s", entry.data[CONF_HOST])
return False return False
hass.data[DOMAIN][entry.entry_id] = projector hass.data[DOMAIN][entry.entry_id] = projector
for component in PLATFORMS: for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, component) hass.config_entries.async_forward_entry_setup(entry, platform)
) )
return True return True
@ -60,8 +60,8 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
unload_ok = all( unload_ok = all(
await asyncio.gather( await asyncio.gather(
*[ *[
hass.config_entries.async_forward_entry_unload(entry, component) hass.config_entries.async_forward_entry_unload(entry, platform)
for component in PLATFORMS for platform in PLATFORMS
] ]
) )
) )

View File

@ -39,9 +39,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
hass.data[DOMAIN][entry.entry_id] = coordinator hass.data[DOMAIN][entry.entry_id] = coordinator
for component in PLATFORMS: for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, component) hass.config_entries.async_forward_entry_setup(entry, platform)
) )
return True return True
@ -52,8 +52,8 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
unload_ok = all( unload_ok = all(
await asyncio.gather( await asyncio.gather(
*[ *[
hass.config_entries.async_forward_entry_unload(entry, component) hass.config_entries.async_forward_entry_unload(entry, platform)
for component in PLATFORMS for platform in PLATFORMS
] ]
) )
) )

View File

@ -37,7 +37,7 @@ CONF_RESET_COLOR = "reset_color"
DOMAIN = "fibaro" DOMAIN = "fibaro"
FIBARO_CONTROLLERS = "fibaro_controllers" FIBARO_CONTROLLERS = "fibaro_controllers"
FIBARO_DEVICES = "fibaro_devices" FIBARO_DEVICES = "fibaro_devices"
FIBARO_COMPONENTS = [ PLATFORMS = [
"binary_sensor", "binary_sensor",
"climate", "climate",
"cover", "cover",
@ -365,21 +365,21 @@ def setup(hass, base_config):
controller.disable_state_handler() controller.disable_state_handler()
hass.data[FIBARO_DEVICES] = {} hass.data[FIBARO_DEVICES] = {}
for component in FIBARO_COMPONENTS: for platform in PLATFORMS:
hass.data[FIBARO_DEVICES][component] = [] hass.data[FIBARO_DEVICES][platform] = []
for gateway in gateways: for gateway in gateways:
controller = FibaroController(gateway) controller = FibaroController(gateway)
if controller.connect(): if controller.connect():
hass.data[FIBARO_CONTROLLERS][controller.hub_serial] = controller hass.data[FIBARO_CONTROLLERS][controller.hub_serial] = controller
for component in FIBARO_COMPONENTS: for platform in PLATFORMS:
hass.data[FIBARO_DEVICES][component].extend( hass.data[FIBARO_DEVICES][platform].extend(
controller.fibaro_devices[component] controller.fibaro_devices[platform]
) )
if hass.data[FIBARO_CONTROLLERS]: if hass.data[FIBARO_CONTROLLERS]:
for component in FIBARO_COMPONENTS: for platform in PLATFORMS:
discovery.load_platform(hass, component, DOMAIN, {}, base_config) discovery.load_platform(hass, platform, DOMAIN, {}, base_config)
for controller in hass.data[FIBARO_CONTROLLERS].values(): for controller in hass.data[FIBARO_CONTROLLERS].values():
controller.enable_state_handler() controller.enable_state_handler()
hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, stop_fibaro) hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, stop_fibaro)

View File

@ -26,7 +26,7 @@ MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=60)
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
SUPPORTED_PLATFORMS = {SENSOR_DOMAIN, BINARYSENSOR_DOMAIN, SWITCH_DOMAIN} PLATFORMS = [SENSOR_DOMAIN, BINARYSENSOR_DOMAIN, SWITCH_DOMAIN]
async def async_setup(hass: HomeAssistant, config: dict) -> bool: async def async_setup(hass: HomeAssistant, config: dict) -> bool:
@ -64,7 +64,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
DATA_COORDINATOR: coordinator, DATA_COORDINATOR: coordinator,
} }
for platform in SUPPORTED_PLATFORMS: for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, platform) hass.config_entries.async_forward_entry_setup(entry, platform)
) )
@ -83,7 +83,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
await asyncio.gather( await asyncio.gather(
*[ *[
hass.config_entries.async_forward_entry_unload(entry, platform) hass.config_entries.async_forward_entry_unload(entry, platform)
for platform in SUPPORTED_PLATFORMS for platform in PLATFORMS
] ]
) )
) )

View File

@ -49,9 +49,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
tasks = [device.async_refresh() for device in devices] tasks = [device.async_refresh() for device in devices]
await asyncio.gather(*tasks) await asyncio.gather(*tasks)
for component in PLATFORMS: for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, component) hass.config_entries.async_forward_entry_setup(entry, platform)
) )
return True return True
@ -62,8 +62,8 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
unload_ok = all( unload_ok = all(
await asyncio.gather( await asyncio.gather(
*[ *[
hass.config_entries.async_forward_entry_unload(entry, component) hass.config_entries.async_forward_entry_unload(entry, platform)
for component in PLATFORMS for platform in PLATFORMS
] ]
) )
) )

View File

@ -79,9 +79,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
FLUME_HTTP_SESSION: http_session, FLUME_HTTP_SESSION: http_session,
} }
for component in PLATFORMS: for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, component) hass.config_entries.async_forward_entry_setup(entry, platform)
) )
return True return True
@ -92,8 +92,8 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
unload_ok = all( unload_ok = all(
await asyncio.gather( await asyncio.gather(
*[ *[
hass.config_entries.async_forward_entry_unload(entry, component) hass.config_entries.async_forward_entry_unload(entry, platform)
for component in PLATFORMS for platform in PLATFORMS
] ]
) )
) )

View File

@ -67,9 +67,9 @@ async def async_setup_entry(hass, config_entry):
await asyncio.gather(*data_init_tasks) await asyncio.gather(*data_init_tasks)
for component in PLATFORMS: for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(config_entry, component) hass.config_entries.async_forward_entry_setup(config_entry, platform)
) )
return True return True
@ -80,8 +80,8 @@ async def async_unload_entry(hass, config_entry):
unload_ok = all( unload_ok = all(
await asyncio.gather( await asyncio.gather(
*[ *[
hass.config_entries.async_forward_entry_unload(config_entry, component) hass.config_entries.async_forward_entry_unload(config_entry, platform)
for component in PLATFORMS for platform in PLATFORMS
] ]
) )
) )

View File

@ -22,9 +22,9 @@ async def async_setup(hass: HomeAssistant, config: dict):
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
"""Set up foscam from a config entry.""" """Set up foscam from a config entry."""
for component in PLATFORMS: for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, component) hass.config_entries.async_forward_entry_setup(entry, platform)
) )
hass.data[DOMAIN][entry.entry_id] = entry.data hass.data[DOMAIN][entry.entry_id] = entry.data
@ -37,8 +37,8 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
unload_ok = all( unload_ok = all(
await asyncio.gather( await asyncio.gather(
*[ *[
hass.config_entries.async_forward_entry_unload(entry, component) hass.config_entries.async_forward_entry_unload(entry, platform)
for component in PLATFORMS for platform in PLATFORMS
] ]
) )
) )

View File

@ -93,9 +93,9 @@ async def async_setup_entry(hass, entry):
hass.data.setdefault(DOMAIN, {CONF_CONNECTIONS: {}, CONF_DEVICES: set()}) hass.data.setdefault(DOMAIN, {CONF_CONNECTIONS: {}, CONF_DEVICES: set()})
hass.data[DOMAIN][CONF_CONNECTIONS][entry.entry_id] = fritz hass.data[DOMAIN][CONF_CONNECTIONS][entry.entry_id] = fritz
for component in PLATFORMS: for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, component) hass.config_entries.async_forward_entry_setup(entry, platform)
) )
def logout_fritzbox(event): def logout_fritzbox(event):
@ -115,8 +115,8 @@ async def async_unload_entry(hass, entry):
unload_ok = all( unload_ok = all(
await asyncio.gather( await asyncio.gather(
*[ *[
hass.config_entries.async_forward_entry_unload(entry, component) hass.config_entries.async_forward_entry_unload(entry, platform)
for component in PLATFORMS for platform in PLATFORMS
] ]
) )
) )

View File

@ -59,9 +59,9 @@ async def async_setup_entry(hass, config_entry):
UNDO_UPDATE_LISTENER: undo_listener, UNDO_UPDATE_LISTENER: undo_listener,
} }
for component in PLATFORMS: for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(config_entry, component) hass.config_entries.async_forward_entry_setup(config_entry, platform)
) )
return True return True
@ -73,8 +73,8 @@ async def async_unload_entry(hass, config_entry):
unload_ok = all( unload_ok = all(
await gather( await gather(
*[ *[
hass.config_entries.async_forward_entry_unload(config_entry, component) hass.config_entries.async_forward_entry_unload(config_entry, platform)
for component in PLATFORMS for platform in PLATFORMS
] ]
) )
) )

View File

@ -57,9 +57,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
garmin_data = GarminConnectData(hass, garmin_client) garmin_data = GarminConnectData(hass, garmin_client)
hass.data[DOMAIN][entry.entry_id] = garmin_data hass.data[DOMAIN][entry.entry_id] = garmin_data
for component in PLATFORMS: for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, component) hass.config_entries.async_forward_entry_setup(entry, platform)
) )
return True return True
@ -70,8 +70,8 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
unload_ok = all( unload_ok = all(
await asyncio.gather( await asyncio.gather(
*[ *[
hass.config_entries.async_forward_entry_unload(entry, component) hass.config_entries.async_forward_entry_unload(entry, platform)
for component in PLATFORMS for platform in PLATFORMS
] ]
) )
) )

View File

@ -76,8 +76,8 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
unload_ok = all( unload_ok = all(
await asyncio.gather( await asyncio.gather(
*[ *[
hass.config_entries.async_forward_entry_unload(entry, component) hass.config_entries.async_forward_entry_unload(entry, platform)
for component in PLATFORMS for platform in PLATFORMS
] ]
) )
) )

View File

@ -104,9 +104,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
].async_add_listener(async_process_paired_sensor_uids) ].async_add_listener(async_process_paired_sensor_uids)
# Set up all of the Guardian entity platforms: # Set up all of the Guardian entity platforms:
for component in PLATFORMS: for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, component) hass.config_entries.async_forward_entry_setup(entry, platform)
) )
return True return True
@ -117,8 +117,8 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
unload_ok = all( unload_ok = all(
await asyncio.gather( await asyncio.gather(
*[ *[
hass.config_entries.async_forward_entry_unload(entry, component) hass.config_entries.async_forward_entry_unload(entry, platform)
for component in PLATFORMS for platform in PLATFORMS
] ]
) )
) )

View File

@ -148,9 +148,9 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
) )
data[config_entry.entry_id] = api data[config_entry.entry_id] = api
for component in PLATFORMS: for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(config_entry, component) hass.config_entries.async_forward_entry_setup(config_entry, platform)
) )
if not hass.services.has_service(DOMAIN, SERVICE_API_CALL): if not hass.services.has_service(DOMAIN, SERVICE_API_CALL):
@ -166,8 +166,8 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
unload_ok = all( unload_ok = all(
await asyncio.gather( await asyncio.gather(
*[ *[
hass.config_entries.async_forward_entry_unload(entry, component) hass.config_entries.async_forward_entry_unload(entry, platform)
for component in PLATFORMS for platform in PLATFORMS
] ]
) )
) )

View File

@ -48,9 +48,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
entry.add_update_listener(_update_listener) entry.add_update_listener(_update_listener)
for component in PLATFORMS: for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, component) hass.config_entries.async_forward_entry_setup(entry, platform)
) )
return True return True
@ -108,8 +108,8 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
unload_ok = all( unload_ok = all(
await asyncio.gather( await asyncio.gather(
*[ *[
hass.config_entries.async_forward_entry_unload(entry, component) hass.config_entries.async_forward_entry_unload(entry, platform)
for component in PLATFORMS for platform in PLATFORMS
] ]
) )
) )

View File

@ -71,9 +71,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
await update_all_devices(hass, entry) await update_all_devices(hass, entry)
for component in PLATFORMS: for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, component) hass.config_entries.async_forward_entry_setup(entry, platform)
) )
return True return True
@ -84,8 +84,8 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
unload_ok = all( unload_ok = all(
await asyncio.gather( await asyncio.gather(
*[ *[
hass.config_entries.async_forward_entry_unload(entry, component) hass.config_entries.async_forward_entry_unload(entry, platform)
for component in PLATFORMS for platform in PLATFORMS
] ]
) )
) )

View File

@ -16,7 +16,7 @@ _LOGGER = logging.getLogger(".")
DOMAIN = "homematicip_cloud" DOMAIN = "homematicip_cloud"
COMPONENTS = [ PLATFORMS = [
ALARM_CONTROL_PANEL_DOMAIN, ALARM_CONTROL_PANEL_DOMAIN,
BINARY_SENSOR_DOMAIN, BINARY_SENSOR_DOMAIN,
CLIMATE_DOMAIN, CLIMATE_DOMAIN,

View File

@ -13,7 +13,7 @@ from homeassistant.exceptions import ConfigEntryNotReady
from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.typing import HomeAssistantType from homeassistant.helpers.typing import HomeAssistantType
from .const import COMPONENTS, HMIPC_AUTHTOKEN, HMIPC_HAPID, HMIPC_NAME, HMIPC_PIN from .const import HMIPC_AUTHTOKEN, HMIPC_HAPID, HMIPC_NAME, HMIPC_PIN, PLATFORMS
from .errors import HmipcConnectionError from .errors import HmipcConnectionError
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -102,10 +102,10 @@ class HomematicipHAP:
"Connected to HomematicIP with HAP %s", self.config_entry.unique_id "Connected to HomematicIP with HAP %s", self.config_entry.unique_id
) )
for component in COMPONENTS: for platform in PLATFORMS:
self.hass.async_create_task( self.hass.async_create_task(
self.hass.config_entries.async_forward_entry_setup( self.hass.config_entries.async_forward_entry_setup(
self.config_entry, component self.config_entry, platform
) )
) )
return True return True
@ -215,9 +215,9 @@ class HomematicipHAP:
self._retry_task.cancel() self._retry_task.cancel()
await self.home.disable_events() await self.home.disable_events()
_LOGGER.info("Closed connection to HomematicIP cloud server") _LOGGER.info("Closed connection to HomematicIP cloud server")
for component in COMPONENTS: for platform in PLATFORMS:
await self.hass.config_entries.async_forward_entry_unload( await self.hass.config_entries.async_forward_entry_unload(
self.config_entry, component self.config_entry, platform
) )
self.hmip_device_by_entity_id = {} self.hmip_device_by_entity_id = {}
return True return True

View File

@ -132,9 +132,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
DEVICE_INFO: device_info, DEVICE_INFO: device_info,
} }
for component in PLATFORMS: for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, component) hass.config_entries.async_forward_entry_setup(entry, platform)
) )
return True return True
@ -180,8 +180,8 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
unload_ok = all( unload_ok = all(
await asyncio.gather( await asyncio.gather(
*[ *[
hass.config_entries.async_forward_entry_unload(entry, component) hass.config_entries.async_forward_entry_unload(entry, platform)
for component in PLATFORMS for platform in PLATFORMS
] ]
) )
) )

View File

@ -32,9 +32,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
hass.data.setdefault(DOMAIN, {}) hass.data.setdefault(DOMAIN, {})
hass.data[DOMAIN][entry.entry_id] = hub hass.data[DOMAIN][entry.entry_id] = hub
for component in PLATFORMS: for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, component) hass.config_entries.async_forward_entry_setup(entry, platform)
) )
return True return True
@ -45,8 +45,8 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
unload_ok = all( unload_ok = all(
await asyncio.gather( await asyncio.gather(
*[ *[
hass.config_entries.async_forward_entry_unload(entry, component) hass.config_entries.async_forward_entry_unload(entry, platform)
for component in PLATFORMS for platform in PLATFORMS
] ]
) )
) )

View File

@ -281,8 +281,8 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
async def setup_then_listen() -> None: async def setup_then_listen() -> None:
await asyncio.gather( await asyncio.gather(
*[ *[
hass.config_entries.async_forward_entry_setup(config_entry, component) hass.config_entries.async_forward_entry_setup(config_entry, platform)
for component in PLATFORMS for platform in PLATFORMS
] ]
) )
assert hyperion_client assert hyperion_client
@ -310,8 +310,8 @@ async def async_unload_entry(
unload_ok = all( unload_ok = all(
await asyncio.gather( await asyncio.gather(
*[ *[
hass.config_entries.async_forward_entry_unload(config_entry, component) hass.config_entries.async_forward_entry_unload(config_entry, platform)
for component in PLATFORMS for platform in PLATFORMS
] ]
) )
) )

View File

@ -55,7 +55,7 @@ DOMAIN = "ihc"
IHC_CONTROLLER = "controller" IHC_CONTROLLER = "controller"
IHC_INFO = "info" IHC_INFO = "info"
IHC_PLATFORMS = ("binary_sensor", "light", "sensor", "switch") PLATFORMS = ("binary_sensor", "light", "sensor", "switch")
def validate_name(config): def validate_name(config):
@ -219,7 +219,7 @@ PULSE_SCHEMA = vol.Schema(
def setup(hass, config): def setup(hass, config):
"""Set up the IHC platform.""" """Set up the IHC integration."""
conf = config.get(DOMAIN) conf = config.get(DOMAIN)
for index, controller_conf in enumerate(conf): for index, controller_conf in enumerate(conf):
if not ihc_setup(hass, config, controller_conf, index): if not ihc_setup(hass, config, controller_conf, index):
@ -229,7 +229,7 @@ def setup(hass, config):
def ihc_setup(hass, config, conf, controller_id): def ihc_setup(hass, config, conf, controller_id):
"""Set up the IHC component.""" """Set up the IHC integration."""
url = conf[CONF_URL] url = conf[CONF_URL]
username = conf[CONF_USERNAME] username = conf[CONF_USERNAME]
password = conf[CONF_PASSWORD] password = conf[CONF_PASSWORD]
@ -256,11 +256,11 @@ def ihc_setup(hass, config, conf, controller_id):
def get_manual_configuration(hass, config, conf, ihc_controller, controller_id): def get_manual_configuration(hass, config, conf, ihc_controller, controller_id):
"""Get manual configuration for IHC devices.""" """Get manual configuration for IHC devices."""
for component in IHC_PLATFORMS: for platform in PLATFORMS:
discovery_info = {} discovery_info = {}
if component in conf: if platform in conf:
component_setup = conf.get(component) platform_setup = conf.get(platform)
for sensor_cfg in component_setup: for sensor_cfg in platform_setup:
name = sensor_cfg[CONF_NAME] name = sensor_cfg[CONF_NAME]
device = { device = {
"ihc_id": sensor_cfg[CONF_ID], "ihc_id": sensor_cfg[CONF_ID],
@ -281,7 +281,7 @@ def get_manual_configuration(hass, config, conf, ihc_controller, controller_id):
} }
discovery_info[name] = device discovery_info[name] = device
if discovery_info: if discovery_info:
discovery.load_platform(hass, component, DOMAIN, discovery_info, config) discovery.load_platform(hass, platform, DOMAIN, discovery_info, config)
def autosetup_ihc_products( def autosetup_ihc_products(
@ -304,21 +304,23 @@ def autosetup_ihc_products(
except vol.Invalid as exception: except vol.Invalid as exception:
_LOGGER.error("Invalid IHC auto setup data: %s", exception) _LOGGER.error("Invalid IHC auto setup data: %s", exception)
return False return False
groups = project.findall(".//group") groups = project.findall(".//group")
for component in IHC_PLATFORMS: for platform in PLATFORMS:
component_setup = auto_setup_conf[component] platform_setup = auto_setup_conf[platform]
discovery_info = get_discovery_info(component_setup, groups, controller_id) discovery_info = get_discovery_info(platform_setup, groups, controller_id)
if discovery_info: if discovery_info:
discovery.load_platform(hass, component, DOMAIN, discovery_info, config) discovery.load_platform(hass, platform, DOMAIN, discovery_info, config)
return True return True
def get_discovery_info(component_setup, groups, controller_id): def get_discovery_info(platform_setup, groups, controller_id):
"""Get discovery info for specified IHC component.""" """Get discovery info for specified IHC platform."""
discovery_data = {} discovery_data = {}
for group in groups: for group in groups:
groupname = group.attrib["name"] groupname = group.attrib["name"]
for product_cfg in component_setup: for product_cfg in platform_setup:
products = group.findall(product_cfg[CONF_XPATH]) products = group.findall(product_cfg[CONF_XPATH])
for product in products: for product in products:
nodes = product.findall(product_cfg[CONF_NODE]) nodes = product.findall(product_cfg[CONF_NODE])

View File

@ -17,7 +17,7 @@ from .const import (
CONF_UNITCODE, CONF_UNITCODE,
CONF_X10, CONF_X10,
DOMAIN, DOMAIN,
INSTEON_COMPONENTS, INSTEON_PLATFORMS,
ON_OFF_EVENTS, ON_OFF_EVENTS,
) )
from .schemas import convert_yaml_to_config_flow from .schemas import convert_yaml_to_config_flow
@ -138,9 +138,9 @@ async def async_setup_entry(hass, entry):
) )
device = devices.add_x10_device(housecode, unitcode, x10_type, steps) device = devices.add_x10_device(housecode, unitcode, x10_type, steps)
for component in INSTEON_COMPONENTS: for platform in INSTEON_PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, component) hass.config_entries.async_forward_entry_setup(entry, platform)
) )
for address in devices: for address in devices:

View File

@ -34,7 +34,7 @@ from pyinsteon.groups import (
DOMAIN = "insteon" DOMAIN = "insteon"
INSTEON_COMPONENTS = [ INSTEON_PLATFORMS = [
"binary_sensor", "binary_sensor",
"climate", "climate",
"cover", "cover",

View File

@ -66,9 +66,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
if not coordinator.last_update_success: if not coordinator.last_update_success:
raise ConfigEntryNotReady raise ConfigEntryNotReady
for component in PLATFORMS: for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, component) hass.config_entries.async_forward_entry_setup(entry, platform)
) )
return True return True
@ -79,8 +79,8 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
unload_ok = all( unload_ok = all(
await asyncio.gather( await asyncio.gather(
*[ *[
hass.config_entries.async_forward_entry_unload(entry, component) hass.config_entries.async_forward_entry_unload(entry, platform)
for component in PLATFORMS for platform in PLATFORMS
] ]
) )
) )

View File

@ -84,9 +84,9 @@ async def async_setup_entry(hass, entry):
await asyncio.gather(*init_data_update_tasks) await asyncio.gather(*init_data_update_tasks)
for component in PLATFORMS: for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, component) hass.config_entries.async_forward_entry_setup(entry, platform)
) )
return True return True
@ -97,8 +97,8 @@ async def async_unload_entry(hass, entry):
unload_ok = all( unload_ok = all(
await asyncio.gather( await asyncio.gather(
*[ *[
hass.config_entries.async_forward_entry_unload(entry, component) hass.config_entries.async_forward_entry_unload(entry, platform)
for component in PLATFORMS for platform in PLATFORMS
] ]
) )
) )

View File

@ -31,7 +31,7 @@ from .const import (
ISY994_PROGRAMS, ISY994_PROGRAMS,
ISY994_VARIABLES, ISY994_VARIABLES,
MANUFACTURER, MANUFACTURER,
SUPPORTED_PLATFORMS, PLATFORMS,
SUPPORTED_PROGRAM_PLATFORMS, SUPPORTED_PROGRAM_PLATFORMS,
UNDO_UPDATE_LISTENER, UNDO_UPDATE_LISTENER,
) )
@ -111,7 +111,7 @@ async def async_setup_entry(
hass_isy_data = hass.data[DOMAIN][entry.entry_id] hass_isy_data = hass.data[DOMAIN][entry.entry_id]
hass_isy_data[ISY994_NODES] = {} hass_isy_data[ISY994_NODES] = {}
for platform in SUPPORTED_PLATFORMS: for platform in PLATFORMS:
hass_isy_data[ISY994_NODES][platform] = [] hass_isy_data[ISY994_NODES][platform] = []
hass_isy_data[ISY994_PROGRAMS] = {} hass_isy_data[ISY994_PROGRAMS] = {}
@ -176,7 +176,7 @@ async def async_setup_entry(
await _async_get_or_create_isy_device_in_registry(hass, entry, isy) await _async_get_or_create_isy_device_in_registry(hass, entry, isy)
# Load platforms for the devices in the ISY controller that we support. # Load platforms for the devices in the ISY controller that we support.
for platform in SUPPORTED_PLATFORMS: for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, platform) hass.config_entries.async_forward_entry_setup(entry, platform)
) )
@ -248,7 +248,7 @@ async def async_unload_entry(
await asyncio.gather( await asyncio.gather(
*[ *[
hass.config_entries.async_forward_entry_unload(entry, platform) hass.config_entries.async_forward_entry_unload(entry, platform)
for platform in SUPPORTED_PLATFORMS for platform in PLATFORMS
] ]
) )
) )

View File

@ -129,7 +129,7 @@ DEFAULT_VAR_SENSOR_STRING = "HA."
KEY_ACTIONS = "actions" KEY_ACTIONS = "actions"
KEY_STATUS = "status" KEY_STATUS = "status"
SUPPORTED_PLATFORMS = [BINARY_SENSOR, SENSOR, LOCK, FAN, COVER, LIGHT, SWITCH, CLIMATE] PLATFORMS = [BINARY_SENSOR, SENSOR, LOCK, FAN, COVER, LIGHT, SWITCH, CLIMATE]
SUPPORTED_PROGRAM_PLATFORMS = [BINARY_SENSOR, LOCK, FAN, COVER, SWITCH] SUPPORTED_PROGRAM_PLATFORMS = [BINARY_SENSOR, LOCK, FAN, COVER, SWITCH]
SUPPORTED_BIN_SENS_CLASSES = ["moisture", "opening", "motion", "climate"] SUPPORTED_BIN_SENS_CLASSES = ["moisture", "opening", "motion", "climate"]

View File

@ -38,12 +38,12 @@ from .const import (
KEY_ACTIONS, KEY_ACTIONS,
KEY_STATUS, KEY_STATUS,
NODE_FILTERS, NODE_FILTERS,
PLATFORMS,
SUBNODE_CLIMATE_COOL, SUBNODE_CLIMATE_COOL,
SUBNODE_CLIMATE_HEAT, SUBNODE_CLIMATE_HEAT,
SUBNODE_EZIO2X4_SENSORS, SUBNODE_EZIO2X4_SENSORS,
SUBNODE_FANLINC_LIGHT, SUBNODE_FANLINC_LIGHT,
SUBNODE_IOLINC_RELAY, SUBNODE_IOLINC_RELAY,
SUPPORTED_PLATFORMS,
SUPPORTED_PROGRAM_PLATFORMS, SUPPORTED_PROGRAM_PLATFORMS,
TYPE_CATEGORY_SENSOR_ACTUATORS, TYPE_CATEGORY_SENSOR_ACTUATORS,
TYPE_EZIO2X4, TYPE_EZIO2X4,
@ -69,7 +69,7 @@ def _check_for_node_def(
node_def_id = node.node_def_id node_def_id = node.node_def_id
platforms = SUPPORTED_PLATFORMS if not single_platform else [single_platform] platforms = PLATFORMS if not single_platform else [single_platform]
for platform in platforms: for platform in platforms:
if node_def_id in NODE_FILTERS[platform][FILTER_NODE_DEF_ID]: if node_def_id in NODE_FILTERS[platform][FILTER_NODE_DEF_ID]:
hass_isy_data[ISY994_NODES][platform].append(node) hass_isy_data[ISY994_NODES][platform].append(node)
@ -94,7 +94,7 @@ def _check_for_insteon_type(
return False return False
device_type = node.type device_type = node.type
platforms = SUPPORTED_PLATFORMS if not single_platform else [single_platform] platforms = PLATFORMS if not single_platform else [single_platform]
for platform in platforms: for platform in platforms:
if any( if any(
device_type.startswith(t) device_type.startswith(t)
@ -159,7 +159,7 @@ def _check_for_zwave_cat(
return False return False
device_type = node.zwave_props.category device_type = node.zwave_props.category
platforms = SUPPORTED_PLATFORMS if not single_platform else [single_platform] platforms = PLATFORMS if not single_platform else [single_platform]
for platform in platforms: for platform in platforms:
if any( if any(
device_type.startswith(t) device_type.startswith(t)
@ -198,7 +198,7 @@ def _check_for_uom_id(
return True return True
return False return False
platforms = SUPPORTED_PLATFORMS if not single_platform else [single_platform] platforms = PLATFORMS if not single_platform else [single_platform]
for platform in platforms: for platform in platforms:
if node_uom in NODE_FILTERS[platform][FILTER_UOM]: if node_uom in NODE_FILTERS[platform][FILTER_UOM]:
hass_isy_data[ISY994_NODES][platform].append(node) hass_isy_data[ISY994_NODES][platform].append(node)
@ -235,7 +235,7 @@ def _check_for_states_in_uom(
return True return True
return False return False
platforms = SUPPORTED_PLATFORMS if not single_platform else [single_platform] platforms = PLATFORMS if not single_platform else [single_platform]
for platform in platforms: for platform in platforms:
if node_uom == set(NODE_FILTERS[platform][FILTER_STATES]): if node_uom == set(NODE_FILTERS[platform][FILTER_STATES]):
hass_isy_data[ISY994_NODES][platform].append(node) hass_isy_data[ISY994_NODES][platform].append(node)

View File

@ -27,7 +27,7 @@ from .const import (
ISY994_NODES, ISY994_NODES,
ISY994_PROGRAMS, ISY994_PROGRAMS,
ISY994_VARIABLES, ISY994_VARIABLES,
SUPPORTED_PLATFORMS, PLATFORMS,
SUPPORTED_PROGRAM_PLATFORMS, SUPPORTED_PROGRAM_PLATFORMS,
) )
@ -279,7 +279,7 @@ def async_setup_services(hass: HomeAssistantType):
hass_isy_data = hass.data[DOMAIN][config_entry_id] hass_isy_data = hass.data[DOMAIN][config_entry_id]
uuid = hass_isy_data[ISY994_ISY].configuration["uuid"] uuid = hass_isy_data[ISY994_ISY].configuration["uuid"]
for platform in SUPPORTED_PLATFORMS: for platform in PLATFORMS:
for node in hass_isy_data[ISY994_NODES][platform]: for node in hass_isy_data[ISY994_NODES][platform]:
if hasattr(node, "address"): if hasattr(node, "address"):
current_unique_ids.append(f"{uuid}_{node.address}") current_unique_ids.append(f"{uuid}_{node.address}")

View File

@ -91,9 +91,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
await coordinator.async_refresh() await coordinator.async_refresh()
for component in PLATFORMS: for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, component) hass.config_entries.async_forward_entry_setup(entry, platform)
) )
return True return True
@ -104,8 +104,8 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
unload_ok = all( unload_ok = all(
await asyncio.gather( await asyncio.gather(
*[ *[
hass.config_entries.async_forward_entry_unload(entry, component) hass.config_entries.async_forward_entry_unload(entry, platform)
for component in PLATFORMS for platform in PLATFORMS
] ]
) )
) )

View File

@ -25,7 +25,7 @@ from .const import (
DEFAULT_PREFERRED_UNIT, DEFAULT_PREFERRED_UNIT,
DEFAULT_SCAN_INTERVAL, DEFAULT_SCAN_INTERVAL,
DOMAIN, DOMAIN,
KAITERRA_COMPONENTS, PLATFORMS,
) )
KAITERRA_DEVICE_SCHEMA = vol.Schema( KAITERRA_DEVICE_SCHEMA = vol.Schema(
@ -54,7 +54,7 @@ CONFIG_SCHEMA = vol.Schema({DOMAIN: KAITERRA_SCHEMA}, extra=vol.ALLOW_EXTRA)
async def async_setup(hass, config): async def async_setup(hass, config):
"""Set up the Kaiterra components.""" """Set up the Kaiterra integration."""
conf = config[DOMAIN] conf = config[DOMAIN]
scan_interval = conf[CONF_SCAN_INTERVAL] scan_interval = conf[CONF_SCAN_INTERVAL]
@ -76,11 +76,11 @@ async def async_setup(hass, config):
device.get(CONF_NAME) or device[CONF_TYPE], device.get(CONF_NAME) or device[CONF_TYPE],
device[CONF_DEVICE_ID], device[CONF_DEVICE_ID],
) )
for component in KAITERRA_COMPONENTS: for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
async_load_platform( async_load_platform(
hass, hass,
component, platform,
DOMAIN, DOMAIN,
{CONF_NAME: device_name, CONF_DEVICE_ID: device_id}, {CONF_NAME: device_name, CONF_DEVICE_ID: device_id},
config, config,

View File

@ -71,4 +71,4 @@ DEFAULT_AQI_STANDARD = "us"
DEFAULT_PREFERRED_UNIT = [] DEFAULT_PREFERRED_UNIT = []
DEFAULT_SCAN_INTERVAL = timedelta(seconds=30) DEFAULT_SCAN_INTERVAL = timedelta(seconds=30)
KAITERRA_COMPONENTS = ["sensor", "air_quality"] PLATFORMS = ["sensor", "air_quality"]

View File

@ -44,9 +44,9 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
UNDO_UPDATE_LISTENER: undo_listener, UNDO_UPDATE_LISTENER: undo_listener,
} }
for component in PLATFORMS: for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(config_entry, component) hass.config_entries.async_forward_entry_setup(config_entry, platform)
) )
return True return True
@ -56,8 +56,8 @@ async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry) ->
"""Unload a config entry.""" """Unload a config entry."""
hass.data[DOMAIN][config_entry.entry_id][UNDO_UPDATE_LISTENER]() hass.data[DOMAIN][config_entry.entry_id][UNDO_UPDATE_LISTENER]()
for component in PLATFORMS: for platform in PLATFORMS:
await hass.config_entries.async_forward_entry_unload(config_entry, component) await hass.config_entries.async_forward_entry_unload(config_entry, platform)
router: KeeneticRouter = hass.data[DOMAIN][config_entry.entry_id][ROUTER] router: KeeneticRouter = hass.data[DOMAIN][config_entry.entry_id][ROUTER]

View File

@ -80,9 +80,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
DATA_COORDINATOR: coordinator, DATA_COORDINATOR: coordinator,
} }
for component in PLATFORMS: for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, component) hass.config_entries.async_forward_entry_setup(entry, platform)
) )
return True return True
@ -93,8 +93,8 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
unload_ok = all( unload_ok = all(
await asyncio.gather( await asyncio.gather(
*[ *[
hass.config_entries.async_forward_entry_unload(entry, component) hass.config_entries.async_forward_entry_unload(entry, platform)
for component in PLATFORMS for platform in PLATFORMS
] ]
) )
) )

View File

@ -72,9 +72,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
DATA_REMOVE_LISTENER: remove_stop_listener, DATA_REMOVE_LISTENER: remove_stop_listener,
} }
for component in PLATFORMS: for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, component) hass.config_entries.async_forward_entry_setup(entry, platform)
) )
return True return True
@ -85,8 +85,8 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
unload_ok = all( unload_ok = all(
await asyncio.gather( await asyncio.gather(
*[ *[
hass.config_entries.async_forward_entry_unload(entry, component) hass.config_entries.async_forward_entry_unload(entry, platform)
for component in PLATFORMS for platform in PLATFORMS
] ]
) )
) )

View File

@ -261,9 +261,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
# async_connect will handle retries until it establishes a connection # async_connect will handle retries until it establishes a connection
await client.async_connect() await client.async_connect()
for component in PLATFORMS: for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, component) hass.config_entries.async_forward_entry_setup(entry, platform)
) )
# config entry specific data to enable unload # config entry specific data to enable unload
@ -278,8 +278,8 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
unload_ok = all( unload_ok = all(
await asyncio.gather( await asyncio.gather(
*[ *[
hass.config_entries.async_forward_entry_unload(entry, component) hass.config_entries.async_forward_entry_unload(entry, platform)
for component in PLATFORMS for platform in PLATFORMS
] ]
) )
) )

View File

@ -16,9 +16,9 @@ async def async_setup(hass: HomeAssistant, config: dict):
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
"""Set up Kuler Sky from a config entry.""" """Set up Kuler Sky from a config entry."""
for component in PLATFORMS: for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, component) hass.config_entries.async_forward_entry_setup(entry, platform)
) )
return True return True
@ -29,8 +29,8 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
unload_ok = all( unload_ok = all(
await asyncio.gather( await asyncio.gather(
*[ *[
hass.config_entries.async_forward_entry_unload(entry, component) hass.config_entries.async_forward_entry_unload(entry, platform)
for component in PLATFORMS for platform in PLATFORMS
] ]
) )
) )

View File

@ -59,9 +59,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
hass.data[DOMAIN] = system hass.data[DOMAIN] = system
for component in PLATFORMS: for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, component) hass.config_entries.async_forward_entry_setup(entry, platform)
) )
return True return True
@ -73,8 +73,8 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
unload_ok = all( unload_ok = all(
await asyncio.gather( await asyncio.gather(
*[ *[
hass.config_entries.async_forward_entry_unload(entry, component) hass.config_entries.async_forward_entry_unload(entry, platform)
for component in PLATFORMS for platform in PLATFORMS
] ]
) )
) )

View File

@ -30,9 +30,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
except LitterRobotException as ex: except LitterRobotException as ex:
raise ConfigEntryNotReady from ex raise ConfigEntryNotReady from ex
for component in PLATFORMS: for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, component) hass.config_entries.async_forward_entry_setup(entry, platform)
) )
return True return True
@ -43,8 +43,8 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
unload_ok = all( unload_ok = all(
await asyncio.gather( await asyncio.gather(
*[ *[
hass.config_entries.async_forward_entry_unload(entry, component) hass.config_entries.async_forward_entry_unload(entry, platform)
for component in PLATFORMS for platform in PLATFORMS
] ]
) )
) )

View File

@ -47,6 +47,8 @@ SERVICE_LIVESTREAM_RECORD = "livestream_record"
ATTR_VALUE = "value" ATTR_VALUE = "value"
ATTR_DURATION = "duration" ATTR_DURATION = "duration"
PLATFORMS = ["camera", "sensor"]
SENSOR_SCHEMA = vol.Schema( SENSOR_SCHEMA = vol.Schema(
{ {
vol.Optional(CONF_MONITORED_CONDITIONS, default=list(LOGI_SENSORS)): vol.All( vol.Optional(CONF_MONITORED_CONDITIONS, default=list(LOGI_SENSORS)): vol.All(
@ -171,9 +173,9 @@ async def async_setup_entry(hass, entry):
hass.data[DATA_LOGI] = logi_circle hass.data[DATA_LOGI] = logi_circle
for component in "camera", "sensor": for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, component) hass.config_entries.async_forward_entry_setup(entry, platform)
) )
async def service_handler(service): async def service_handler(service):
@ -219,8 +221,8 @@ async def async_setup_entry(hass, entry):
async def async_unload_entry(hass, entry): async def async_unload_entry(hass, entry):
"""Unload a config entry.""" """Unload a config entry."""
for component in "camera", "sensor": for platform in PLATFORMS:
await hass.config_entries.async_forward_entry_unload(entry, component) await hass.config_entries.async_forward_entry_unload(entry, platform)
logi_circle = hass.data.pop(DATA_LOGI) logi_circle = hass.data.pop(DATA_LOGI)

View File

@ -12,6 +12,8 @@ from homeassistant.util import slugify
DOMAIN = "lutron" DOMAIN = "lutron"
PLATFORMS = ["light", "cover", "switch", "scene", "binary_sensor"]
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
LUTRON_BUTTONS = "lutron_buttons" LUTRON_BUTTONS = "lutron_buttons"
@ -37,7 +39,7 @@ CONFIG_SCHEMA = vol.Schema(
def setup(hass, base_config): def setup(hass, base_config):
"""Set up the Lutron component.""" """Set up the Lutron integration."""
hass.data[LUTRON_BUTTONS] = [] hass.data[LUTRON_BUTTONS] = []
hass.data[LUTRON_CONTROLLER] = None hass.data[LUTRON_CONTROLLER] = None
hass.data[LUTRON_DEVICES] = { hass.data[LUTRON_DEVICES] = {
@ -92,8 +94,8 @@ def setup(hass, base_config):
(area.name, area.occupancy_group) (area.name, area.occupancy_group)
) )
for component in ("light", "cover", "switch", "scene", "binary_sensor"): for platform in PLATFORMS:
discovery.load_platform(hass, component, DOMAIN, {}, base_config) discovery.load_platform(hass, platform, DOMAIN, {}, base_config)
return True return True

View File

@ -62,7 +62,7 @@ CONFIG_SCHEMA = vol.Schema(
extra=vol.ALLOW_EXTRA, extra=vol.ALLOW_EXTRA,
) )
LUTRON_CASETA_COMPONENTS = ["light", "switch", "cover", "scene", "fan", "binary_sensor"] PLATFORMS = ["light", "switch", "cover", "scene", "fan", "binary_sensor"]
async def async_setup(hass, base_config): async def async_setup(hass, base_config):
@ -125,7 +125,7 @@ async def async_setup_entry(hass, config_entry):
bridge_device = devices[BRIDGE_DEVICE_ID] bridge_device = devices[BRIDGE_DEVICE_ID]
await _async_register_bridge_device(hass, config_entry.entry_id, bridge_device) await _async_register_bridge_device(hass, config_entry.entry_id, bridge_device)
# Store this bridge (keyed by entry_id) so it can be retrieved by the # Store this bridge (keyed by entry_id) so it can be retrieved by the
# components we're setting up. # platforms we're setting up.
hass.data[DOMAIN][config_entry.entry_id] = { hass.data[DOMAIN][config_entry.entry_id] = {
BRIDGE_LEAP: bridge, BRIDGE_LEAP: bridge,
BRIDGE_DEVICE: bridge_device, BRIDGE_DEVICE: bridge_device,
@ -139,9 +139,9 @@ async def async_setup_entry(hass, config_entry):
# pico remotes to control other devices. # pico remotes to control other devices.
await async_setup_lip(hass, config_entry, bridge.lip_devices) await async_setup_lip(hass, config_entry, bridge.lip_devices)
for component in LUTRON_CASETA_COMPONENTS: for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(config_entry, component) hass.config_entries.async_forward_entry_setup(config_entry, platform)
) )
return True return True
@ -289,8 +289,8 @@ async def async_unload_entry(hass, config_entry):
unload_ok = all( unload_ok = all(
await asyncio.gather( await asyncio.gather(
*[ *[
hass.config_entries.async_forward_entry_unload(config_entry, component) hass.config_entries.async_forward_entry_unload(config_entry, platform)
for component in LUTRON_CASETA_COMPONENTS for platform in PLATFORMS
] ]
) )
) )

View File

@ -113,9 +113,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
if not coordinator.last_update_success: if not coordinator.last_update_success:
raise ConfigEntryNotReady raise ConfigEntryNotReady
for component in PLATFORMS: for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, component) hass.config_entries.async_forward_entry_setup(entry, platform)
) )
return True return True
@ -126,8 +126,8 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
unload_ok = all( unload_ok = all(
await asyncio.gather( await asyncio.gather(
*[ *[
hass.config_entries.async_forward_entry_unload(entry, component) hass.config_entries.async_forward_entry_unload(entry, platform)
for component in PLATFORMS for platform in PLATFORMS
] ]
) )
) )

View File

@ -121,9 +121,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
raise ConfigEntryNotReady raise ConfigEntryNotReady
# Setup components # Setup components
for component in PLATFORMS: for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, component) hass.config_entries.async_forward_entry_setup(entry, platform)
) )
return True return True
@ -134,8 +134,8 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
unload_ok = all( unload_ok = all(
await asyncio.gather( await asyncio.gather(
*[ *[
hass.config_entries.async_forward_entry_unload(entry, component) hass.config_entries.async_forward_entry_unload(entry, platform)
for component in PLATFORMS for platform in PLATFORMS
] ]
) )
) )

View File

@ -61,9 +61,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
if metoffice_data.now is None: if metoffice_data.now is None:
raise ConfigEntryNotReady() raise ConfigEntryNotReady()
for component in PLATFORMS: for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, component) hass.config_entries.async_forward_entry_setup(entry, platform)
) )
return True return True
@ -74,8 +74,8 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
unload_ok = all( unload_ok = all(
await asyncio.gather( await asyncio.gather(
*[ *[
hass.config_entries.async_forward_entry_unload(entry, component) hass.config_entries.async_forward_entry_unload(entry, platform)
for component in PLATFORMS for platform in PLATFORMS
] ]
) )
) )

View File

@ -104,8 +104,8 @@ async def async_unload_entry(hass, entry):
unload_ok = all( unload_ok = all(
await asyncio.gather( await asyncio.gather(
*[ *[
hass.config_entries.async_forward_entry_unload(entry, component) hass.config_entries.async_forward_entry_unload(entry, platform)
for component in PLATFORMS for platform in PLATFORMS
] ]
) )
) )

View File

@ -54,9 +54,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
FIRST_RUN: first_run, FIRST_RUN: first_run,
} }
for component in PLATFORMS: for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, component) hass.config_entries.async_forward_entry_setup(entry, platform)
) )
return True return True
@ -67,8 +67,8 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
unload_ok = all( unload_ok = all(
await asyncio.gather( await asyncio.gather(
*[ *[
hass.config_entries.async_forward_entry_unload(entry, component) hass.config_entries.async_forward_entry_unload(entry, platform)
for component in PLATFORMS for platform in PLATFORMS
] ]
) )
) )

View File

@ -18,7 +18,7 @@ from .const import (
KEY_GATEWAY, KEY_GATEWAY,
KEY_MULTICAST_LISTENER, KEY_MULTICAST_LISTENER,
MANUFACTURER, MANUFACTURER,
MOTION_PLATFORMS, PLATFORMS,
) )
from .gateway import ConnectMotionGateway from .gateway import ConnectMotionGateway
@ -107,9 +107,9 @@ async def async_setup_entry(
sw_version=motion_gateway.protocol, sw_version=motion_gateway.protocol,
) )
for component in MOTION_PLATFORMS: for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, component) hass.config_entries.async_forward_entry_setup(entry, platform)
) )
return True return True
@ -122,8 +122,8 @@ async def async_unload_entry(
unload_ok = all( unload_ok = all(
await asyncio.gather( await asyncio.gather(
*[ *[
hass.config_entries.async_forward_entry_unload(config_entry, component) hass.config_entries.async_forward_entry_unload(config_entry, platform)
for component in MOTION_PLATFORMS for platform in PLATFORMS
] ]
) )
) )

View File

@ -3,7 +3,7 @@ DOMAIN = "motion_blinds"
MANUFACTURER = "Motion Blinds, Coulisse B.V." MANUFACTURER = "Motion Blinds, Coulisse B.V."
DEFAULT_GATEWAY_NAME = "Motion Blinds Gateway" DEFAULT_GATEWAY_NAME = "Motion Blinds Gateway"
MOTION_PLATFORMS = ["cover", "sensor"] PLATFORMS = ["cover", "sensor"]
KEY_GATEWAY = "gateway" KEY_GATEWAY = "gateway"
KEY_COORDINATOR = "coordinator" KEY_COORDINATOR = "coordinator"

View File

@ -43,9 +43,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: dict):
hass.data[DOMAIN] = coordinator hass.data[DOMAIN] = coordinator
for component in PLATFORMS: for platform in PLATFORMS:
hass.async_create_task( hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, component) hass.config_entries.async_forward_entry_setup(entry, platform)
) )
return True return True
@ -56,8 +56,8 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
unload_ok = all( unload_ok = all(
await asyncio.gather( await asyncio.gather(
*[ *[
hass.config_entries.async_forward_entry_unload(entry, component) hass.config_entries.async_forward_entry_unload(entry, platform)
for component in PLATFORMS for platform in PLATFORMS
] ]
) )
) )

Some files were not shown because too many files have changed in this diff Show More