Migrate sun to use single_config_entry (#113370)
This commit is contained in:
parent
c122e32d20
commit
c466008fb4
5 changed files with 14 additions and 14 deletions
|
@ -84,13 +84,17 @@ CONFIG_SCHEMA = cv.empty_config_schema(DOMAIN)
|
|||
|
||||
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||
"""Track the state of the sun."""
|
||||
hass.async_create_task(
|
||||
hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_IMPORT},
|
||||
data=config,
|
||||
if not hass.config_entries.async_entries(DOMAIN):
|
||||
# We avoid creating an import flow if its already
|
||||
# setup since it will have to import the config_flow
|
||||
# module.
|
||||
hass.async_create_task(
|
||||
hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_IMPORT},
|
||||
data=config,
|
||||
)
|
||||
)
|
||||
)
|
||||
return True
|
||||
|
||||
|
||||
|
|
|
@ -18,9 +18,6 @@ class SunConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||
self, user_input: dict[str, Any] | None = None
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle a flow initialized by the user."""
|
||||
if self._async_current_entries():
|
||||
return self.async_abort(reason="single_instance_allowed")
|
||||
|
||||
if user_input is not None:
|
||||
return self.async_create_entry(title=DEFAULT_NAME, data={})
|
||||
|
||||
|
|
|
@ -5,5 +5,6 @@
|
|||
"config_flow": true,
|
||||
"documentation": "https://www.home-assistant.io/integrations/sun",
|
||||
"iot_class": "calculated",
|
||||
"quality_scale": "internal"
|
||||
"quality_scale": "internal",
|
||||
"single_config_entry": true
|
||||
}
|
||||
|
|
|
@ -5,9 +5,6 @@
|
|||
"user": {
|
||||
"description": "[%key:common::config_flow::description::confirm_setup%]"
|
||||
}
|
||||
},
|
||||
"abort": {
|
||||
"single_instance_allowed": "[%key:common::config_flow::abort::single_instance_allowed%]"
|
||||
}
|
||||
},
|
||||
"entity_component": {
|
||||
|
|
|
@ -5743,7 +5743,8 @@
|
|||
"sun": {
|
||||
"integration_type": "hub",
|
||||
"config_flow": true,
|
||||
"iot_class": "calculated"
|
||||
"iot_class": "calculated",
|
||||
"single_config_entry": true
|
||||
},
|
||||
"sunweg": {
|
||||
"name": "Sun WEG",
|
||||
|
|
Loading…
Add table
Reference in a new issue