mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-15 13:16:29 +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()
|
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:
|
async def check_api_state(self) -> bool:
|
||||||
"""Return True if Home Assistant up and running."""
|
"""Return True if Home Assistant up and running."""
|
||||||
# Skip check on landingpage
|
# Skip check on landingpage
|
||||||
@ -124,12 +133,8 @@ class HomeAssistantAPI(CoreSysAttributes):
|
|||||||
|
|
||||||
# Check if API is up
|
# Check if API is up
|
||||||
with suppress(HomeAssistantAPIError):
|
with suppress(HomeAssistantAPIError):
|
||||||
async with self.make_request("get", "api/config") as resp:
|
data = await self.get_config()
|
||||||
if resp.status in (200, 201):
|
# Older versions of home assistant does not expose the state
|
||||||
data = await resp.json()
|
if data and data.get("state", "RUNNING") == "RUNNING":
|
||||||
if data.get("state", "RUNNING") == "RUNNING":
|
return True
|
||||||
return True
|
|
||||||
else:
|
|
||||||
_LOGGER.debug("Home Assistant API return: %d", resp.status)
|
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
@ -214,7 +214,20 @@ class HomeAssistantCore(CoreSysAttributes):
|
|||||||
# Update Home Assistant
|
# Update Home Assistant
|
||||||
with suppress(HomeAssistantError):
|
with suppress(HomeAssistantError):
|
||||||
await _update(version)
|
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
|
# Update going wrong, revert it
|
||||||
if self.error_state and rollback:
|
if self.error_state and rollback:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user