mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-14 20:56:30 +00:00
Detect if frontend is not loaded (#3124)
* Detect if frontend is not loaded * update
This commit is contained in:
parent
271e4f0cc4
commit
74530baeb7
@ -105,6 +105,15 @@ class HomeAssistantAPI(CoreSysAttributes):
|
||||
|
||||
raise HomeAssistantAPIError()
|
||||
|
||||
async def get_config(self) -> Dict[str, Any]:
|
||||
"""Return Home Assistant config."""
|
||||
async with self.make_request("get", "api/config") as resp:
|
||||
if resp.status in (200, 201):
|
||||
return await resp.json()
|
||||
else:
|
||||
_LOGGER.debug("Home Assistant API return: %d", resp.status)
|
||||
raise HomeAssistantAPIError()
|
||||
|
||||
async def check_api_state(self) -> bool:
|
||||
"""Return True if Home Assistant up and running."""
|
||||
# Skip check on landingpage
|
||||
@ -124,12 +133,8 @@ class HomeAssistantAPI(CoreSysAttributes):
|
||||
|
||||
# Check if API is up
|
||||
with suppress(HomeAssistantAPIError):
|
||||
async with self.make_request("get", "api/config") as resp:
|
||||
if resp.status in (200, 201):
|
||||
data = await resp.json()
|
||||
if data.get("state", "RUNNING") == "RUNNING":
|
||||
return True
|
||||
else:
|
||||
_LOGGER.debug("Home Assistant API return: %d", resp.status)
|
||||
|
||||
data = await self.get_config()
|
||||
# Older versions of home assistant does not expose the state
|
||||
if data and data.get("state", "RUNNING") == "RUNNING":
|
||||
return True
|
||||
return False
|
||||
|
@ -214,7 +214,20 @@ class HomeAssistantCore(CoreSysAttributes):
|
||||
# Update Home Assistant
|
||||
with suppress(HomeAssistantError):
|
||||
await _update(version)
|
||||
return
|
||||
|
||||
if not self.error_state and rollback:
|
||||
try:
|
||||
data = await self.sys_homeassistant.api.get_config()
|
||||
except HomeAssistantError:
|
||||
# The API stoped responding between the up checks an now
|
||||
self._error_state = True
|
||||
|
||||
# Verify that the frontend is loaded
|
||||
if data and "frontend" not in data.get("components", []):
|
||||
_LOGGER.error("API responds but frontend is not loaded")
|
||||
self._error_state = True
|
||||
else:
|
||||
return
|
||||
|
||||
# Update going wrong, revert it
|
||||
if self.error_state and rollback:
|
||||
|
Loading…
x
Reference in New Issue
Block a user