From 587e9618da75730c07cfa7dc6680ab6535965f65 Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Mon, 22 May 2017 23:22:06 +0200 Subject: [PATCH 1/5] Pump version --- hassio/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hassio/const.py b/hassio/const.py index 86cc8b5c0..6ac1e5239 100644 --- a/hassio/const.py +++ b/hassio/const.py @@ -1,7 +1,7 @@ """Const file for HassIO.""" from pathlib import Path -HASSIO_VERSION = '0.32' +HASSIO_VERSION = '0.33' URL_HASSIO_VERSION = ('https://raw.githubusercontent.com/home-assistant/' 'hassio/master/version.json') From f7c79cbd3ac451098b1e9161738ca7fddae1cede Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Mon, 22 May 2017 23:55:47 +0200 Subject: [PATCH 2/5] Update HomeAssistant to 0.45.1 --- version.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.json b/version.json index 3615e0a12..4ddfb763c 100644 --- a/version.json +++ b/version.json @@ -1,6 +1,6 @@ { "hassio": "0.32", - "homeassistant": "0.45", + "homeassistant": "0.45.1", "resinos": "0.8", "resinhup": "0.1", "generic": "0.3" From 544c009b9cd0fa7d540e955567b533d6bc87f155 Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Tue, 23 May 2017 22:52:28 +0200 Subject: [PATCH 3/5] Fix rewrite config to addon on restart (#71) --- hassio/addons/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hassio/addons/__init__.py b/hassio/addons/__init__.py index 7abb80f0b..93d9df0ce 100644 --- a/hassio/addons/__init__.py +++ b/hassio/addons/__init__.py @@ -207,6 +207,10 @@ class AddonManager(AddonsData): _LOGGER.error("No docker found for addon %s", addon) return False + if not self.write_addon_options(addon): + _LOGGER.error("Can't write options for addon %s", addon) + return False + return await self.dockers[addon].restart() async def logs(self, addon): From df7d988d2fcd5c6eaf6b96289281fdf6bbe6048c Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Tue, 23 May 2017 23:17:20 +0200 Subject: [PATCH 4/5] Try to fetch timezone on startup (#70) --- hassio/core.py | 8 ++++++-- hassio/tools.py | 15 +++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/hassio/core.py b/hassio/core.py index d85605418..28cd4b7f6 100644 --- a/hassio/core.py +++ b/hassio/core.py @@ -20,7 +20,7 @@ from .dock.supervisor import DockerSupervisor from .tasks import ( hassio_update, homeassistant_watchdog, homeassistant_setup, api_sessions_cleanup) -from .tools import get_arch_from_image, get_local_ip +from .tools import get_arch_from_image, get_local_ip, fetch_timezone _LOGGER = logging.getLogger(__name__) @@ -60,13 +60,17 @@ class HassIO(object): # set api endpoint self.config.api_endpoint = await get_local_ip(self.loop) + # update timezone + if self.config.timezone == 'UTC': + self.config.timezone = await fetch_timezone(self.websession) + # hostcontrol await self.host_control.load() # schedule update info tasks self.scheduler.register_task( - self.host_control.load, RUN_UPDATE_INFO_TASKS) + self.host_control.load, RUN_UPDATE_INFO_TASKS) # rest api views self.api.register_host(self.host_control) self.api.register_network(self.host_control) diff --git a/hassio/tools.py b/hassio/tools.py index 6eedce39a..01f15fad8 100644 --- a/hassio/tools.py +++ b/hassio/tools.py @@ -1,5 +1,6 @@ """Tools file for HassIO.""" import asyncio +from contextlib import suppress import json import logging import re @@ -14,6 +15,8 @@ from .const import URL_HASSIO_VERSION, URL_HASSIO_VERSION_BETA _LOGGER = logging.getLogger(__name__) +FREEGEOIP_URL = "https://freegeoip.io/json/" + _RE_VERSION = re.compile(r"VERSION=(.*)") _IMAGE_ARCH = re.compile(r".*/([a-z0-9]*)-hassio-supervisor") @@ -105,3 +108,15 @@ def validate_timezone(timezone): from None return timezone + + +async def fetch_timezone(websession): + """Read timezone from freegeoip.""" + data = {} + with suppress(aiohttp.ClientError, asyncio.TimeoutError, + json.JSONDecodeError, KeyError): + with async_timeout.timeout(10, loop=websession.loop): + async with websession.get(FREEGEOIP_URL) as request: + data = await request.json() + + return data.get('time_zone', 'UTC') From 8cbeabbe21b4e8433c13d8ffbe72cd4127881bd7 Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Tue, 23 May 2017 23:58:20 +0200 Subject: [PATCH 5/5] Pump Hass.IO version --- version.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.json b/version.json index 4ddfb763c..20504a2a9 100644 --- a/version.json +++ b/version.json @@ -1,5 +1,5 @@ { - "hassio": "0.32", + "hassio": "0.33", "homeassistant": "0.45.1", "resinos": "0.8", "resinhup": "0.1",