mirror of
https://github.com/home-assistant/core.git
synced 2025-07-08 13:57:10 +00:00
Add supervisor install add-on helper (#40138)
This commit is contained in:
parent
37e51aa166
commit
a0df6ccb81
@ -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…
x
Reference in New Issue
Block a user