How to use the pyhaversion.PyPiVersion function in pyhaversion

To help you get started, we’ve selected a few pyhaversion examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github klaasnicolaas / Student-homeassistant-config / custom_components / breaking_changes / __init__.py View on Github external
async def update_data(hass, throttle):
    """Update data."""
    if throttle.throttle:
        return
    throttle.set_last_run()
    if len(hass.data[DOMAIN_DATA]["components"]) == 1:
        return
    from pyhaversion import LocalVersion, PyPiVersion

    session = async_get_clientsession(hass)
    webclient = WebClient(session)
    localversion = LocalVersion(hass.loop, session)
    pypiversion = PyPiVersion(hass.loop, session)

    try:
        await localversion.get_version()
        currentversion = localversion.version.split(".")[1]

        await pypiversion.get_version()
        remoteversion = pypiversion.version.split(".")[1]
    except Exception:  # pylint: disable=broad-except
        _LOGGER.warning("Could not get version data.")
        return

    if currentversion == remoteversion:
        _LOGGER.debug(
            "Current version is %s and remote version is %s skipping update",
            currentversion,
            remoteversion,
github custom-components / breaking_changes / custom_components / breaking_changes / __init__.py View on Github external
async def update_data(hass, throttle):
    """Update data."""
    if throttle.throttle:
        return
    throttle.set_last_run()
    if len(hass.data[DOMAIN_DATA]["components"]) == 1:
        return
    from pyhaversion import LocalVersion, PyPiVersion

    session = async_get_clientsession(hass)
    webclient = WebClient(session)
    localversion = LocalVersion(hass.loop, session)
    pypiversion = PyPiVersion(hass.loop, session)

    try:
        await localversion.get_version()
        currentversion = localversion.version.split(".")[1]

        await pypiversion.get_version()
        remoteversion = pypiversion.version.split(".")[1]
    except Exception:  # pylint: disable=broad-except
        _LOGGER.warning("Could not get version data.")
        return

    if currentversion == remoteversion:
        _LOGGER.debug(
            "Current version is %s and remote version is %s skipping update",
            currentversion,
            remoteversion,
github home-assistant / home-assistant / homeassistant / components / version / sensor.py View on Github external
"""Set up the Version sensor platform."""

    beta = config.get(CONF_BETA)
    image = config.get(CONF_IMAGE)
    name = config.get(CONF_NAME)
    source = config.get(CONF_SOURCE)

    session = async_get_clientsession(hass)

    if beta:
        branch = "beta"
    else:
        branch = "stable"

    if source == "pypi":
        haversion = VersionData(PyPiVersion(hass.loop, session, branch))
    elif source == "hassio":
        haversion = VersionData(HassioVersion(hass.loop, session, branch, image))
    elif source == "docker":
        haversion = VersionData(DockerVersion(hass.loop, session, branch, image))
    elif source == "haio":
        haversion = VersionData(HaIoVersion(hass.loop, session))
    else:
        haversion = VersionData(LocalVersion(hass.loop, session))

    if not name:
        if source == DEFAULT_SOURCE:
            name = DEFAULT_NAME_LOCAL
        else:
            name = DEFAULT_NAME_LATEST

    async_add_entities([VersionSensor(haversion, name)], True)

pyhaversion

Get the latest Home Assistant version from various sources.

MIT
Latest version published 5 months ago

Package Health Score

66 / 100
Full package analysis

Similar packages