From 79cd8ac390b97debd28be454767cb4818558e4e9 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Tue, 30 Nov 2021 17:48:09 +0000 Subject: [PATCH] Allow to clear explicit image name (#3333) The documentation says that passing null to `image` allows to clear the option. Currently `null` is not allowed leading to: Error: expected string or buffer for dictionary value @ data['image']. Got None While at it, also update type annotation to reflect what the API currently allows. --- supervisor/api/homeassistant.py | 2 +- supervisor/homeassistant/module.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/supervisor/api/homeassistant.py b/supervisor/api/homeassistant.py index c2b85c1e5..33d1a804b 100644 --- a/supervisor/api/homeassistant.py +++ b/supervisor/api/homeassistant.py @@ -43,7 +43,7 @@ _LOGGER: logging.Logger = logging.getLogger(__name__) SCHEMA_OPTIONS = vol.Schema( { vol.Optional(ATTR_BOOT): vol.Boolean(), - vol.Optional(ATTR_IMAGE): docker_image, + vol.Optional(ATTR_IMAGE): vol.Maybe(docker_image), vol.Optional(ATTR_PORT): network_port, vol.Optional(ATTR_SSL): vol.Boolean(), vol.Optional(ATTR_WATCHDOG): vol.Boolean(), diff --git a/supervisor/homeassistant/module.py b/supervisor/homeassistant/module.py index d6d4f9a41..3ae85156a 100644 --- a/supervisor/homeassistant/module.py +++ b/supervisor/homeassistant/module.py @@ -156,7 +156,7 @@ class HomeAssistant(FileConfiguration, CoreSysAttributes): return f"ghcr.io/home-assistant/{self.sys_machine}-homeassistant" @image.setter - def image(self, value: str) -> None: + def image(self, value: Optional[str]) -> None: """Set image name of Home Assistant container.""" self._data[ATTR_IMAGE] = value @@ -201,7 +201,7 @@ class HomeAssistant(FileConfiguration, CoreSysAttributes): return self._data.get(ATTR_REFRESH_TOKEN) @refresh_token.setter - def refresh_token(self, value: str): + def refresh_token(self, value: Optional[str]): """Set Home Assistant refresh_token.""" self._data[ATTR_REFRESH_TOKEN] = value