diff --git a/hassio/api/proxy.py b/hassio/api/proxy.py index 9b25ec618..3cbc35cf5 100644 --- a/hassio/api/proxy.py +++ b/hassio/api/proxy.py @@ -4,7 +4,7 @@ import logging import aiohttp from aiohttp import web -from aiohttp.web_exceptions import HTTPBadGateway +from aiohttp.web_exceptions import HTTPBadGateway, HTTPInternalServerError from aiohttp.hdrs import CONTENT_TYPE import async_timeout @@ -100,7 +100,7 @@ class APIProxy(CoreSysAttributes): async def _websocket_client(self): """Initialize a websocket api connection.""" - url = f"{self.homeassistant.api_url}/api/websocket" + url = f"{self._homeassistant.api_url}/api/websocket" try: client = await self._websession_ssl.ws_connect( @@ -133,9 +133,19 @@ class APIProxy(CoreSysAttributes): await server.prepare(request) # handle authentication - await server.send_json({'type': 'auth_required'}) - await server.receive_json() # get internal token - await server.send_json({'type': 'auth_ok'}) + try: + await server.send_json({ + 'type': 'auth_required', + 'ha_version': self._homeassistant.version, + }) + await server.receive_json() # get internal token + await server.send_json({ + 'type': 'auth_ok', + 'ha_version': self._homeassistant.version, + }) + except (RuntimeError, ValueError) as err: + _LOGGER.error("Can't initialize handshake: %s", err) + raise HTTPInternalServerError() from None # init connection to hass client = await self._websocket_client() diff --git a/hassio/const.py b/hassio/const.py index 23ec877aa..cdd9f3d47 100644 --- a/hassio/const.py +++ b/hassio/const.py @@ -2,7 +2,7 @@ from pathlib import Path from ipaddress import ip_network -HASSIO_VERSION = '0.84' +HASSIO_VERSION = '0.85' URL_HASSIO_VERSION = ('https://raw.githubusercontent.com/home-assistant/' 'hassio/{}/version.json') diff --git a/version.json b/version.json index b07176f65..fd5f4699a 100644 --- a/version.json +++ b/version.json @@ -1,5 +1,5 @@ { - "hassio": "0.84", + "hassio": "0.85", "homeassistant": "0.62.0", "resinos": "1.1", "resinhup": "0.3",