feat: Add config flow for SmartIR integration with multi-step UI wizard
- Implemented a new config flow in `config_flow.py` for SmartIR, allowing users to select platforms, controllers, and devices through a guided interface. - Added support for new device codes in `codes_index.json` for Apton and Andersson manufacturers. - Enhanced fan, light, and media player components to support setup from config entries. - Introduced `strings.json` and `translations/en.json` for improved localization of the configuration steps. - Created a tool `build_index.py` to rebuild the `codes_index.json` from individual device JSON files. - Updated `smartir_capture.py` to handle single-code modes and excluded modes for better device configuration. - Added `iot_class` and `config_flow` attributes in `manifest.json` to support the new configuration flow.
This commit is contained in:
@@ -66,6 +66,31 @@ async def async_setup(hass, config):
|
||||
|
||||
return True
|
||||
|
||||
|
||||
async def async_setup_entry(hass, entry):
|
||||
"""Set up SmartIR from a config entry (UI-configured device)."""
|
||||
platform = entry.data.get('platform')
|
||||
if not platform:
|
||||
return False
|
||||
await hass.config_entries.async_forward_entry_setups(entry, [platform])
|
||||
# Reload the entry whenever options are changed in the UI so the new
|
||||
# controller_data / delay / sensor settings take effect immediately.
|
||||
entry.async_on_unload(entry.add_update_listener(_async_options_updated))
|
||||
return True
|
||||
|
||||
|
||||
async def _async_options_updated(hass, entry):
|
||||
"""Triggered when the options flow saves; reloads the config entry."""
|
||||
await hass.config_entries.async_reload(entry.entry_id)
|
||||
|
||||
|
||||
async def async_unload_entry(hass, entry):
|
||||
"""Unload a SmartIR config entry."""
|
||||
platform = entry.data.get('platform')
|
||||
if not platform:
|
||||
return True
|
||||
return await hass.config_entries.async_unload_platforms(entry, [platform])
|
||||
|
||||
async def _update(hass, branch, do_update=False, notify_if_latest=True):
|
||||
try:
|
||||
async with aiohttp.ClientSession() as session:
|
||||
|
||||
Reference in New Issue
Block a user