mirror of
https://github.com/home-assistant/core.git
synced 2025-08-06 22:25:13 +02:00
Add support for async_setup_entry to switch and climate platform
This commit is contained in:
@@ -246,7 +246,8 @@ def set_swing_mode(hass, swing_mode, entity_id=None):
|
||||
|
||||
async def async_setup(hass, config):
|
||||
"""Set up climate devices."""
|
||||
component = EntityComponent(_LOGGER, DOMAIN, hass, SCAN_INTERVAL)
|
||||
component = hass.data[DOMAIN] = \
|
||||
EntityComponent(_LOGGER, DOMAIN, hass, SCAN_INTERVAL)
|
||||
await component.async_setup(config)
|
||||
|
||||
async def async_away_mode_set_service(service):
|
||||
@@ -456,6 +457,16 @@ async def async_setup(hass, config):
|
||||
return True
|
||||
|
||||
|
||||
async def async_setup_entry(hass, entry):
|
||||
"""Setup a config entry."""
|
||||
return await hass.data[DOMAIN].async_setup_entry(entry)
|
||||
|
||||
|
||||
async def async_unload_entry(hass, entry):
|
||||
"""Unload a config entry."""
|
||||
return await hass.data[DOMAIN].async_unload_entry(entry)
|
||||
|
||||
|
||||
class ClimateDevice(Entity):
|
||||
"""Representation of a climate device."""
|
||||
|
||||
|
@@ -52,8 +52,10 @@ ATTR_OPERATION_LOCK = 'operation_lock'
|
||||
|
||||
COMPONENTS = [
|
||||
'binary_sensor',
|
||||
'climate',
|
||||
'light',
|
||||
'sensor',
|
||||
'switch',
|
||||
]
|
||||
|
||||
|
||||
|
@@ -95,7 +95,7 @@ def toggle(hass, entity_id=None):
|
||||
|
||||
async def async_setup(hass, config):
|
||||
"""Track states and offer events for switches."""
|
||||
component = EntityComponent(
|
||||
component = hass.data[DOMAIN] = EntityComponent(
|
||||
_LOGGER, DOMAIN, hass, SCAN_INTERVAL, GROUP_NAME_ALL_SWITCHES)
|
||||
await component.async_setup(config)
|
||||
|
||||
@@ -132,6 +132,16 @@ async def async_setup(hass, config):
|
||||
return True
|
||||
|
||||
|
||||
async def async_setup_entry(hass, entry):
|
||||
"""Setup a config entry."""
|
||||
return await hass.data[DOMAIN].async_setup_entry(entry)
|
||||
|
||||
|
||||
async def async_unload_entry(hass, entry):
|
||||
"""Unload a config entry."""
|
||||
return await hass.data[DOMAIN].async_unload_entry(entry)
|
||||
|
||||
|
||||
class SwitchDevice(ToggleEntity):
|
||||
"""Representation of a switch."""
|
||||
|
||||
|
Reference in New Issue
Block a user