Izone component (#24550)
* iZone component * Rename constants to const. * Changes as per code review. * Stop listening if discovery times out. * Unload properly * Changes as per code review * Climate 1.0 * Use dispatcher instead of listener * Free air settings * Test case for config flow. * Changes as per code review * Fix error on shutdown * Changes as per code review * Lint fix * Black formatting * Black on test * Fix test * Lint fix * Formatting * Updated requirements * Remaining patches * Per code r/v
This commit is contained in:
1 parent
c8fb7ce98b
commit
b68b8430a4
16 files changed
+894
No files matched your search
@@ -0,0 +1,67 @@
|
||||
"""
|
||||
Platform for the iZone AC.
|
||||
|
||||
For more details about this component, please refer to the documentation
|
||||
https://home-assistant.io/components/izone/
|
||||
"""
|
||||
import logging
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.const import CONF_EXCLUDE
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.typing import ConfigType, HomeAssistantType
|
||||
|
||||
from .const import IZONE, DATA_CONFIG
|
||||
from .discovery import async_start_discovery_service, async_stop_discovery_service
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
CONFIG_SCHEMA = vol.Schema(
|
||||
{
|
||||
IZONE: vol.Schema(
|
||||
{
|
||||
vol.Optional(CONF_EXCLUDE, default=[]): vol.All(
|
||||
cv.ensure_list, [cv.string]
|
||||
)
|
||||
}
|
||||
)
|
||||
},
|
||||
extra=vol.ALLOW_EXTRA,
|
||||
)
|
||||
|
||||
|
||||
async def async_setup(hass: HomeAssistantType, config: ConfigType):
|
||||
"""Register the iZone component config."""
|
||||
conf = config.get(IZONE)
|
||||
if not conf:
|
||||
return True
|
||||
|
||||
hass.data[DATA_CONFIG] = conf
|
||||
|
||||
# Explicitly added in the config file, create a config entry.
|
||||
hass.async_create_task(
|
||||
hass.config_entries.flow.async_init(
|
||||
IZONE, context={"source": config_entries.SOURCE_IMPORT}
|
||||
)
|
||||
)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
async def async_setup_entry(hass, entry):
|
||||
"""Set up from a config entry."""
|
||||
await async_start_discovery_service(hass)
|
||||
|
||||
hass.async_create_task(
|
||||
hass.config_entries.async_forward_entry_setup(entry, "climate")
|
||||
)
|
||||
return True
|
||||
|
||||
|
||||
async def async_unload_entry(hass, entry):
|
||||
"""Unload the config entry and stop discovery process."""
|
||||
await async_stop_discovery_service(hass)
|
||||
await hass.config_entries.async_forward_entry_unload(entry, "climate")
|
||||
return True
|
||||
Reference in new issue
Block a user