Compare commits

...

4 Commits

Author SHA1 Message Date
Pascal Vizeli
e27337da85 Improve local build / allow cache on dev (#2810) 2021-04-15 08:19:58 +02:00
dependabot[bot]
8f22316869 Bump colorlog from 4.8.0 to 5.0.1 (#2808)
Bumps [colorlog](https://github.com/borntyping/python-colorlog) from 4.8.0 to 5.0.1.
- [Release notes](https://github.com/borntyping/python-colorlog/releases)
- [Commits](https://github.com/borntyping/python-colorlog/compare/v4.8.0...v5.0.1)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-04-14 17:01:27 +02:00
Joakim Sørensen
dd10d3e037 Guard against multiple client creations (#2809) 2021-04-14 14:30:49 +02:00
dependabot[bot]
4a53c62af8 Bump home-assistant/builder from 2021.04.0 to 2021.04.1 (#2807)
Bumps [home-assistant/builder](https://github.com/home-assistant/builder) from 2021.04.0 to 2021.04.1.
- [Release notes](https://github.com/home-assistant/builder/releases)
- [Commits](https://github.com/home-assistant/builder/compare/2021.04.0...b77028ab08315dd69807752d2f3e00b0f0f49786)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-04-14 14:30:31 +02:00
6 changed files with 33 additions and 17 deletions

View File

@@ -127,7 +127,7 @@ jobs:
run: echo "BUILD_ARGS=--test" >> $GITHUB_ENV
- name: Build supervisor
uses: home-assistant/builder@2021.04.0
uses: home-assistant/builder@2021.04.1
with:
args: |
$BUILD_ARGS \
@@ -198,7 +198,7 @@ jobs:
uses: actions/checkout@v2
- name: Build the Supervisor
uses: home-assistant/builder@2021.04.0
uses: home-assistant/builder@2021.04.1
with:
args: |
--test \

View File

@@ -5,7 +5,7 @@ attrs==20.3.0
awesomeversion==21.4.0
brotli==1.0.9
cchardet==2.1.7
colorlog==4.8.0
colorlog==5.0.1
cpe==1.2.1
cryptography==3.4.6
debugpy==1.2.1

View File

@@ -9,6 +9,7 @@ from awesomeversion import AwesomeVersion
from ..const import (
ATTR_ARGS,
ATTR_BUILD_FROM,
ATTR_LABELS,
ATTR_SQUASH,
FILE_SUFFIX_CONFIGURATION,
META_ADDON,
@@ -46,9 +47,12 @@ class AddonBuild(FileConfiguration, CoreSysAttributes):
@property
def base_image(self) -> str:
"""Return base image for this add-on."""
return self._data[ATTR_BUILD_FROM].get(
self.sys_arch.default, f"homeassistant/{self.sys_arch.default}-base:latest"
)
if not self._data[ATTR_BUILD_FROM]:
return f"homeassistant/{self.sys_arch.default}-base:latest"
# Evaluate correct base image
arch = self.sys_arch.match(list(self._data[ATTR_BUILD_FROM].keys()))
return self._data[ATTR_BUILD_FROM][arch]
@property
def squash(self) -> bool:
@@ -60,6 +64,11 @@ class AddonBuild(FileConfiguration, CoreSysAttributes):
"""Return additional Docker build arguments."""
return self._data[ATTR_ARGS]
@property
def additional_labels(self) -> Dict[str, str]:
"""Return additional Docker labels."""
return self._data[ATTR_LABELS]
@property
def is_valid(self) -> bool:
"""Return true if the build env is valid."""
@@ -76,7 +85,7 @@ class AddonBuild(FileConfiguration, CoreSysAttributes):
"path": str(self.addon.path_location),
"tag": f"{self.addon.image}:{version!s}",
"pull": True,
"forcerm": True,
"forcerm": not self.sys_dev,
"squash": self.squash,
"labels": {
"io.hass.version": version,
@@ -84,6 +93,7 @@ class AddonBuild(FileConfiguration, CoreSysAttributes):
"io.hass.type": META_ADDON,
"io.hass.name": self._fix_label("name"),
"io.hass.description": self._fix_label("description"),
**self.additional_labels,
},
"buildargs": {
"BUILD_FROM": self.base_image,

View File

@@ -47,6 +47,7 @@ from ..const import (
ATTR_INIT,
ATTR_JOURNALD,
ATTR_KERNEL_MODULES,
ATTR_LABELS,
ATTR_LEGACY,
ATTR_LOCATON,
ATTR_MACHINE,
@@ -317,9 +318,8 @@ SCHEMA_BUILD_CONFIG = vol.Schema(
{vol.In(ARCH_ALL): vol.Match(RE_DOCKER_IMAGE_BUILD)}
),
vol.Optional(ATTR_SQUASH, default=False): vol.Boolean(),
vol.Optional(ATTR_ARGS, default=dict): vol.Schema(
{vol.Coerce(str): vol.Coerce(str)}
),
vol.Optional(ATTR_ARGS, default=dict): vol.Schema({str: str}),
vol.Optional(ATTR_LABELS, default=dict): vol.Schema({str: str}),
},
extra=vol.REMOVE_EXTRA,
)

View File

@@ -102,6 +102,7 @@ ATTR_APPARMOR = "apparmor"
ATTR_APPLICATION = "application"
ATTR_ARCH = "arch"
ATTR_ARGS = "args"
ATTR_LABELS = "labels"
ATTR_AUDIO = "audio"
ATTR_AUDIO_INPUT = "audio_input"
ATTR_AUDIO_OUTPUT = "audio_output"

View File

@@ -86,17 +86,22 @@ class HomeAssistantWebSocket(CoreSysAttributes):
"""Initialize Home Assistant object."""
self.coresys: CoreSys = coresys
self._client: Optional[WSClient] = None
self._lock: asyncio.Lock = asyncio.Lock()
async def _get_ws_client(self) -> WSClient:
"""Return a websocket client."""
await self.sys_homeassistant.api.ensure_access_token()
client = await WSClient.connect_with_auth(
self.sys_websession_ssl,
f"{self.sys_homeassistant.api_url}/api/websocket",
self.sys_homeassistant.api.access_token,
)
async with self._lock:
if self._client is not None:
return self._client
return client
await self.sys_homeassistant.api.ensure_access_token()
client = await WSClient.connect_with_auth(
self.sys_websession_ssl,
f"{self.sys_homeassistant.api_url}/api/websocket",
self.sys_homeassistant.api.access_token,
)
return client
async def async_send_command(self, message: Dict[str, Any]):
"""Send a command with the WS client."""