diff --git a/hassio/api/security.py b/hassio/api/security.py index 0db0826fa..59fd70996 100644 --- a/hassio/api/security.py +++ b/hassio/api/security.py @@ -41,7 +41,7 @@ ADDONS_API_BYPASS = re.compile( r"^(?:" r"|/addons/self/(?!security|update)[^/]+" r"|/info" - r"|/hardware/.+" + r"|/hardware/trigger" r"|/services.*" r"|/discovery.*" r"|/auth" diff --git a/hassio/exceptions.py b/hassio/exceptions.py index b03a0c0a3..289433a5f 100644 --- a/hassio/exceptions.py +++ b/hassio/exceptions.py @@ -188,3 +188,10 @@ class JsonFileError(HassioError): class DockerAPIError(HassioError): """Docker API error.""" + + +# Hardware + + +class HardwareNotSupportedError(HassioNotSupportedError): + """Raise if hardware function is not supported.""" diff --git a/hassio/misc/hardware.py b/hassio/misc/hardware.py index ef7bcb850..9ec283c6e 100644 --- a/hassio/misc/hardware.py +++ b/hassio/misc/hardware.py @@ -9,6 +9,7 @@ from typing import Any, Dict, Optional, Set import pyudev from ..const import ATTR_DEVICES, ATTR_NAME, ATTR_TYPE, CHAN_ID, CHAN_TYPE +from ..exceptions import HardwareNotSupportedError _LOGGER: logging.Logger = logging.getLogger(__name__) @@ -155,5 +156,8 @@ class Hardware: proc = await asyncio.create_subprocess_exec("udevadm", "trigger") await proc.wait() - if proc.returncode != 0: - _LOGGER.waring("udevadm device triggering fails!") + if proc.returncode == 0: + return + + _LOGGER.waring("udevadm device triggering fails!") + raise HardwareNotSupportedError()