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