Only set require_restart on config entry reload if its not recoverable (#66994)

This commit is contained in:
J. Nick Koston 2022-02-21 08:27:23 -10:00 committed by GitHub
parent cb877adb6a
commit 9a5eec561a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 5 deletions

View file

@ -88,15 +88,17 @@ class ConfigManagerEntryResourceReloadView(HomeAssistantView):
raise Unauthorized(config_entry_id=entry_id, permission="remove")
hass = request.app["hass"]
entry = hass.config_entries.async_get_entry(entry_id)
if not entry:
return self.json_message("Invalid entry specified", HTTPStatus.NOT_FOUND)
assert isinstance(entry, config_entries.ConfigEntry)
try:
result = await hass.config_entries.async_reload(entry_id)
await hass.config_entries.async_reload(entry_id)
except config_entries.OperationNotAllowed:
return self.json_message("Entry cannot be reloaded", HTTPStatus.FORBIDDEN)
except config_entries.UnknownEntry:
return self.json_message("Invalid entry specified", HTTPStatus.NOT_FOUND)
return self.json({"require_restart": not result})
return self.json({"require_restart": not entry.state.recoverable})
def _prepare_config_flow_result_json(result, prepare_result_json):