Add supervisor install add-on helper (#40138)

This commit is contained in:
Martin Hjelmare 2020-09-21 10:28:24 +02:00 committed by GitHub
parent 37e51aa166
commit a0df6ccb81
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -127,20 +127,27 @@ MAP_SERVICE_API = {
@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.
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.
"""
hassio = hass.data[DOMAIN]
result = await hassio.get_addon_info(addon_id)
result = await hassio.get_addon_info(slug)
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
@bind_hass
def get_info(hass):