mirror of
https://github.com/home-assistant/core.git
synced 2025-08-09 15:45:08 +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):
|
async def async_setup(hass, config):
|
||||||
"""Set up climate devices."""
|
"""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)
|
await component.async_setup(config)
|
||||||
|
|
||||||
async def async_away_mode_set_service(service):
|
async def async_away_mode_set_service(service):
|
||||||
@@ -456,6 +457,16 @@ async def async_setup(hass, config):
|
|||||||
return True
|
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):
|
class ClimateDevice(Entity):
|
||||||
"""Representation of a climate device."""
|
"""Representation of a climate device."""
|
||||||
|
|
||||||
|
@@ -52,8 +52,10 @@ ATTR_OPERATION_LOCK = 'operation_lock'
|
|||||||
|
|
||||||
COMPONENTS = [
|
COMPONENTS = [
|
||||||
'binary_sensor',
|
'binary_sensor',
|
||||||
|
'climate',
|
||||||
'light',
|
'light',
|
||||||
'sensor',
|
'sensor',
|
||||||
|
'switch',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@@ -95,7 +95,7 @@ def toggle(hass, entity_id=None):
|
|||||||
|
|
||||||
async def async_setup(hass, config):
|
async def async_setup(hass, config):
|
||||||
"""Track states and offer events for switches."""
|
"""Track states and offer events for switches."""
|
||||||
component = EntityComponent(
|
component = hass.data[DOMAIN] = EntityComponent(
|
||||||
_LOGGER, DOMAIN, hass, SCAN_INTERVAL, GROUP_NAME_ALL_SWITCHES)
|
_LOGGER, DOMAIN, hass, SCAN_INTERVAL, GROUP_NAME_ALL_SWITCHES)
|
||||||
await component.async_setup(config)
|
await component.async_setup(config)
|
||||||
|
|
||||||
@@ -132,6 +132,16 @@ async def async_setup(hass, config):
|
|||||||
return True
|
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):
|
class SwitchDevice(ToggleEntity):
|
||||||
"""Representation of a switch."""
|
"""Representation of a switch."""
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user