How to use pyhaversion - 10 common examples

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 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,
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,
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
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)
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)
github klaasnicolaas / Smarthome-homeassistant-config / custom_components / sensor / versions.py View on Github external
def update(self):
        """Update sensor value."""
        import pyhaversion
        if self._installation == 'venv' or self._installation == 'hassbian':
            source = 'pip'
        else:
            source = self._installation
        if self._branch == 'rc':
            branch = 'beta'
        else:
            branch = self._branch
        data = pyhaversion.get_version_number(source, branch, self._image)
        self._state = data['homeassistant']
        self._attributes = data
github home-assistant / home-assistant / homeassistant / components / version / sensor.py View on Github external
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)
github home-assistant / home-assistant / homeassistant / components / version / sensor.py View on Github external
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)
github home-assistant / home-assistant / homeassistant / components / version / sensor.py View on Github external
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 3 months ago

Package Health Score

64 / 100
Full package analysis

Similar packages