mirror of
https://github.com/basnijholt/adaptive-lighting.git
synced 2026-09-11 22:34:04 +02:00
* Check whether this is the first time setup * Keep list * simplify * no UI tracking
This commit is contained in:
parent
e9b7988868
commit
0e23e906da
2 changed files with 7 additions and 7 deletions
|
|
@ -42,13 +42,15 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
async def async_step_import(self, user_input=None):
|
||||
"""Handle configuration by YAML file."""
|
||||
await self.async_set_unique_id(user_input[CONF_NAME])
|
||||
# Keep a list of switches that are configured via YAML
|
||||
data = self.hass.data.setdefault(DOMAIN, {})
|
||||
data.setdefault("__yaml__", set()).add(self.unique_id)
|
||||
|
||||
for entry in self._async_current_entries():
|
||||
if entry.unique_id == self.unique_id:
|
||||
# Keep a list of switches that are configured via YAML
|
||||
data = self.hass.data.setdefault(DOMAIN, {})
|
||||
data.setdefault("__yaml__", []).append(self.unique_id)
|
||||
self.hass.config_entries.async_update_entry(entry, data=user_input)
|
||||
self._abort_if_unique_id_configured()
|
||||
|
||||
return self.async_create_entry(title=user_input[CONF_NAME], data=user_input)
|
||||
|
||||
@staticmethod
|
||||
|
|
|
|||
|
|
@ -410,9 +410,9 @@ async def async_setup_entry( # noqa: PLR0915
|
|||
data,
|
||||
config_entry,
|
||||
)
|
||||
if ( # Skip deleted YAML config entries
|
||||
if ( # Skip deleted YAML config entries or first time YAML config entries
|
||||
config_entry.source == SOURCE_IMPORT
|
||||
and config_entry.unique_id not in data.get("__yaml__", [])
|
||||
and config_entry.unique_id not in data.get("__yaml__", set())
|
||||
):
|
||||
_LOGGER.warning(
|
||||
"Deleting AdaptiveLighting switch '%s' because YAML"
|
||||
|
|
@ -1680,8 +1680,6 @@ class AdaptiveLightingManager:
|
|||
self._service_interceptor_turn_on_handler,
|
||||
),
|
||||
)
|
||||
|
||||
_LOGGER.debug("Proactive adaptation enabled")
|
||||
except RuntimeError:
|
||||
_LOGGER.warning(
|
||||
"Failed to set up service call interceptors, "
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue