Add supervisor install add-on helper (#40138)
This commit is contained in:
parent
37e51aa166
commit
a0df6ccb81
1 changed files with 13 additions and 6 deletions
|
@ -127,20 +127,27 @@ MAP_SERVICE_API = {
|
||||||
|
|
||||||
|
|
||||||
@bind_hass
|
@bind_hass
|
||||||
async def async_get_addon_info(hass: HomeAssistantType, addon_id: str) -> dict:
|
async def async_get_addon_info(hass: HomeAssistantType, slug: str) -> dict:
|
||||||
"""Return add-on info.
|
"""Return add-on info.
|
||||||
|
|
||||||
The addon_id is a snakecased concatenation of the 'repository' value
|
|
||||||
found in the add-on info and the 'slug' value found in the add-on config.json.
|
|
||||||
In the add-on info the addon_id is called 'slug'.
|
|
||||||
|
|
||||||
The caller of the function should handle HassioAPIError.
|
The caller of the function should handle HassioAPIError.
|
||||||
"""
|
"""
|
||||||
hassio = hass.data[DOMAIN]
|
hassio = hass.data[DOMAIN]
|
||||||
result = await hassio.get_addon_info(addon_id)
|
result = await hassio.get_addon_info(slug)
|
||||||
return result["data"]
|
return result["data"]
|
||||||
|
|
||||||
|
|
||||||
|
@bind_hass
|
||||||
|
async def async_install_addon(hass: HomeAssistantType, slug: str) -> None:
|
||||||
|
"""Install add-on.
|
||||||
|
|
||||||
|
The caller of the function should handle HassioAPIError.
|
||||||
|
"""
|
||||||
|
hassio = hass.data[DOMAIN]
|
||||||
|
command = f"/addons/{slug}/install"
|
||||||
|
await hassio.send_command(command)
|
||||||
|
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
@bind_hass
|
@bind_hass
|
||||||
def get_info(hass):
|
def get_info(hass):
|
||||||
|
|
Loading…
Add table
Reference in a new issue