diff --git a/hassio/const.py b/hassio/const.py index a5c5ab073a2..c30893bdbb4 100644 --- a/hassio/const.py +++ b/hassio/const.py @@ -1,7 +1,7 @@ """Const file for HassIO.""" from pathlib import Path -HASSIO_VERSION = '0.51' +HASSIO_VERSION = '0.52' URL_HASSIO_VERSION = ('https://raw.githubusercontent.com/home-assistant/' 'hassio/{}/version.json') diff --git a/hassio/core.py b/hassio/core.py index b2cebed7ce2..059b99a5533 100644 --- a/hassio/core.py +++ b/hassio/core.py @@ -138,15 +138,15 @@ async def start(self): await self.api.start() _LOGGER.info("Start hassio api on %s", self.config.api_endpoint) - # start addon mark as system - await self.addons.auto_boot(STARTUP_SYSTEM) - try: # HomeAssistant is already running / supervisor have only reboot if await self.homeassistant.is_running(): _LOGGER.info("HassIO reboot detected") return + # start addon mark as system + await self.addons.auto_boot(STARTUP_SYSTEM) + # start addon mark as services await self.addons.auto_boot(STARTUP_SERVICES) diff --git a/hassio/dock/addon.py b/hassio/dock/addon.py index e5e3df2b076..b9e56829fd1 100644 --- a/hassio/dock/addon.py +++ b/hassio/dock/addon.py @@ -13,6 +13,8 @@ _LOGGER = logging.getLogger(__name__) +AUDIO_DEVICE = "/dev/snd:/dev/snd:rwm" + class DockerAddon(DockerBase): """Docker hassio wrapper for HomeAssistant.""" @@ -28,6 +30,11 @@ def name(self): """Return name of docker container.""" return "addon_{}".format(self.addon.slug) + @property + def hostname(self): + """Return slug/id of addon.""" + return self.addon.slug.replace('_', '-') + @property def environment(self): """Return environment for docker add-on.""" @@ -43,6 +50,20 @@ def environment(self): 'TZ': self.config.timezone, } + @property + def devices(self): + """Return needed devices.""" + devices = self.addon.devices or [] + + # use audio devices + if self.addon.with_audio and AUDIO_DEVICE not in devices: + devices.append(AUDIO_DEVICE) + + # Return None if no devices is present + if devices: + return devices + return None + @property def tmpfs(self): """Return tmpfs for docker add-on.""" @@ -122,12 +143,12 @@ def _run(self): self.dock.containers.run( self.image, name=self.name, - hostname=self.addon.slug, + hostname=self.hostname, detach=True, network_mode=self.addon.network_mode, ports=self.addon.ports, extra_hosts=self.mapping, - devices=self.addon.devices, + devices=self.devices, cap_add=self.addon.privileged, environment=self.environment, volumes=self.volumes, diff --git a/version.json b/version.json index 2e661ed1f87..1cef5eff566 100644 --- a/version.json +++ b/version.json @@ -1,5 +1,5 @@ { - "hassio": "0.51", + "hassio": "0.52", "homeassistant": "0.50.2", "resinos": "1.0", "resinhup": "0.3",