Improve deCONZ platforms (#40986)

* Use platform domain imports with the list of supported platforms

* Remove legacy async_setup_platform from platforms
This commit is contained in:
Robert Svensson 2020-10-01 19:06:20 +02:00 committed by GitHub
parent 40ea30da96
commit c2ed743237
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 17 additions and 36 deletions

View File

@ -33,10 +33,6 @@ DEVICE_CLASS = {
} }
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Old way of setting up deCONZ platforms."""
async def async_setup_entry(hass, config_entry, async_add_entities): async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up the deCONZ binary sensor.""" """Set up the deCONZ binary sensor."""
gateway = get_gateway_from_config_entry(hass, config_entry) gateway = get_gateway_from_config_entry(hass, config_entry)

View File

@ -19,10 +19,6 @@ from .gateway import get_gateway_from_config_entry
SUPPORT_HVAC = [HVAC_MODE_AUTO, HVAC_MODE_HEAT, HVAC_MODE_OFF] SUPPORT_HVAC = [HVAC_MODE_AUTO, HVAC_MODE_HEAT, HVAC_MODE_OFF]
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Old way of setting up deCONZ platforms."""
async def async_setup_entry(hass, config_entry, async_add_entities): async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up the deCONZ climate devices. """Set up the deCONZ climate devices.

View File

@ -1,6 +1,15 @@
"""Constants for the deCONZ component.""" """Constants for the deCONZ component."""
import logging import logging
from homeassistant.components.binary_sensor import DOMAIN as BINARY_SENSOR_DOMAIN
from homeassistant.components.climate import DOMAIN as CLIMATE_DOMAIN
from homeassistant.components.cover import DOMAIN as COVER_DOMAIN
from homeassistant.components.light import DOMAIN as LIGHT_DOMAIN
from homeassistant.components.lock import DOMAIN as LOCK_DOMAIN
from homeassistant.components.scene import DOMAIN as SCENE_DOMAIN
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN
LOGGER = logging.getLogger(__package__) LOGGER = logging.getLogger(__package__)
DOMAIN = "deconz" DOMAIN = "deconz"
@ -19,14 +28,14 @@ CONF_ALLOW_NEW_DEVICES = "allow_new_devices"
CONF_MASTER_GATEWAY = "master" CONF_MASTER_GATEWAY = "master"
SUPPORTED_PLATFORMS = [ SUPPORTED_PLATFORMS = [
"binary_sensor", BINARY_SENSOR_DOMAIN,
"climate", CLIMATE_DOMAIN,
"cover", COVER_DOMAIN,
"light", LIGHT_DOMAIN,
"lock", LOCK_DOMAIN,
"scene", SCENE_DOMAIN,
"sensor", SENSOR_DOMAIN,
"switch", SWITCH_DOMAIN,
] ]
NEW_GROUP = "groups" NEW_GROUP = "groups"

View File

@ -17,10 +17,6 @@ from .deconz_device import DeconzDevice
from .gateway import get_gateway_from_config_entry from .gateway import get_gateway_from_config_entry
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Old way of setting up deCONZ platforms."""
async def async_setup_entry(hass, config_entry, async_add_entities): async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up covers for deCONZ component. """Set up covers for deCONZ component.

View File

@ -35,10 +35,6 @@ from .deconz_device import DeconzDevice
from .gateway import get_gateway_from_config_entry from .gateway import get_gateway_from_config_entry
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Old way of setting up deCONZ platforms."""
async def async_setup_entry(hass, config_entry, async_add_entities): async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up the deCONZ lights and groups from a config entry.""" """Set up the deCONZ lights and groups from a config entry."""
gateway = get_gateway_from_config_entry(hass, config_entry) gateway = get_gateway_from_config_entry(hass, config_entry)

View File

@ -9,10 +9,6 @@ from .const import NEW_SCENE
from .gateway import get_gateway_from_config_entry from .gateway import get_gateway_from_config_entry
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Old way of setting up deCONZ platforms."""
async def async_setup_entry(hass, config_entry, async_add_entities): async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up scenes for deCONZ component.""" """Set up scenes for deCONZ component."""
gateway = get_gateway_from_config_entry(hass, config_entry) gateway = get_gateway_from_config_entry(hass, config_entry)

View File

@ -68,10 +68,6 @@ UNIT_OF_MEASUREMENT = {
} }
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Old way of setting up deCONZ platforms."""
async def async_setup_entry(hass, config_entry, async_add_entities): async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up the deCONZ sensors.""" """Set up the deCONZ sensors."""
gateway = get_gateway_from_config_entry(hass, config_entry) gateway = get_gateway_from_config_entry(hass, config_entry)

View File

@ -8,10 +8,6 @@ from .deconz_device import DeconzDevice
from .gateway import get_gateway_from_config_entry from .gateway import get_gateway_from_config_entry
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Old way of setting up deCONZ platforms."""
async def async_setup_entry(hass, config_entry, async_add_entities): async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up switches for deCONZ component. """Set up switches for deCONZ component.