Add supervisor get addon info helper (#36260)

This commit is contained in:
Martin Hjelmare 2020-06-02 20:11:23 +02:00 committed by GitHub
parent 08566f84cd
commit db8d4053d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -17,6 +17,7 @@ from homeassistant.const import (
from homeassistant.core import DOMAIN as HASS_DOMAIN, callback
from homeassistant.exceptions import HomeAssistantError
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.typing import HomeAssistantType
from homeassistant.loader import bind_hass
from homeassistant.util.dt import utcnow
@ -124,6 +125,21 @@ MAP_SERVICE_API = {
}
@bind_hass
async def async_get_addon_info(hass: HomeAssistantType, addon_id: 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)
return result["data"]
@callback
@bind_hass
def get_homeassistant_version(hass):