diff --git a/hassio/api/addons.py b/hassio/api/addons.py index 894b03001..49cdff062 100644 --- a/hassio/api/addons.py +++ b/hassio/api/addons.py @@ -7,6 +7,7 @@ from aiohttp import web import voluptuous as vol from ..addons import AnyAddon +from ..addons.addon import Addon from ..addons.utils import rating_security from ..const import ( ATTR_ADDONS, @@ -129,7 +130,10 @@ class APIAddons(CoreSysAttributes): # Lookup itself if addon_slug == "self": - return request.get(REQUEST_FROM) + addon = request.get(REQUEST_FROM) + if not isinstance(addon, Addon): + raise APIError("Self is not an Addon") + return addon addon = self.sys_addons.get(addon_slug) if not addon: diff --git a/hassio/const.py b/hassio/const.py index 20651c875..f12e00c61 100644 --- a/hassio/const.py +++ b/hassio/const.py @@ -3,7 +3,7 @@ from enum import Enum from ipaddress import ip_network from pathlib import Path -HASSIO_VERSION = "199" +HASSIO_VERSION = "200" URL_HASSIO_ADDONS = "https://github.com/home-assistant/hassio-addons" @@ -11,7 +11,7 @@ URL_HASSIO_VERSION = "https://version.home-assistant.io/{channel}.json" URL_HASSIO_APPARMOR = "https://version.home-assistant.io/apparmor.txt" URL_HASSOS_OTA = ( - "https://github.com/home-assistant/hassos/releases/download/" + "https://github.com/home-assistant/operating-system/releases/download/" "{version}/hassos_{board}-{version}.raucb" ) diff --git a/hassio/core.py b/hassio/core.py index 8f2d7cd7e..beaec91ad 100644 --- a/hassio/core.py +++ b/hassio/core.py @@ -115,7 +115,10 @@ class HassIO(CoreSysAttributes): await self.sys_addons.boot(STARTUP_SERVICES) # run HomeAssistant - if self.sys_homeassistant.boot: + if ( + self.sys_homeassistant.boot + and not await self.sys_homeassistant.is_running() + ): with suppress(HomeAssistantError): await self.sys_homeassistant.start() diff --git a/hassio/misc/hardware.py b/hassio/misc/hardware.py index 269d1ca47..74701b330 100644 --- a/hassio/misc/hardware.py +++ b/hassio/misc/hardware.py @@ -54,10 +54,16 @@ class Hardware: # Exctract all devices for device in self.context.list_devices(): + # Skip devices without mapping + if not device.device_node: + continue + dev_list.append( - Device(device.sys_name), - Path(device.device_node), - [Path(node) for node in device.device_links], + Device( + device.sys_name, + Path(device.device_node), + [Path(node) for node in device.device_links], + ) ) return dev_list diff --git a/requirements.txt b/requirements.txt index 75084b6b1..3a7917b29 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,7 +5,7 @@ cchardet==2.1.5 colorlog==4.1.0 cpe==1.2.1 cryptography==2.8 -docker==4.1.0 +docker==4.2.0 gitpython==3.0.5 packaging==20.1 pytz==2019.3 diff --git a/scripts/test_env.sh b/scripts/test_env.sh index cbfd13aba..3760f3ddb 100755 --- a/scripts/test_env.sh +++ b/scripts/test_env.sh @@ -90,9 +90,6 @@ function setup_test_env() { -e HOMEASSISTANT_REPOSITORY="homeassistant/qemux86-64-homeassistant" \ homeassistant/amd64-hassio-supervisor:latest - if docker rm homeassistant 2> /dev/null; then - echo "Cleanup HomeAssistant instance" - fi } echo "Start Test-Env" @@ -100,6 +97,10 @@ echo "Start Test-Env" start_docker trap "stop_docker" ERR +# Clean homeassistant instance +if docker rm -f homeassistant 2> /dev/null; then + echo "Cleanup HomeAssistant instance" +fi build_supervisor install_cli diff --git a/tests/misc/test_hardware.py b/tests/misc/test_hardware.py new file mode 100644 index 000000000..d969e7152 --- /dev/null +++ b/tests/misc/test_hardware.py @@ -0,0 +1,10 @@ +"""Test hardware utils.""" + +from hassio.misc.hardware import Hardware + + +def test_read_all_devices(): + """Test to read all devices.""" + system = Hardware() + + assert system.devices