Skip to content

Commit abd9683

Browse files
committed
Fix merge conflicts
2 parents b2e0bab + 8cbeabb commit abd9683

File tree

5 files changed

+27
-4
lines changed

5 files changed

+27
-4
lines changed

hassio/addons/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,10 @@ async def restart(self, addon):
207207
_LOGGER.error("No docker found for addon %s", addon)
208208
return False
209209

210+
if not self.write_addon_options(addon):
211+
_LOGGER.error("Can't write options for addon %s", addon)
212+
return False
213+
210214
return await self.dockers[addon].restart()
211215

212216
async def logs(self, addon):

hassio/const.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Const file for HassIO."""
22
from pathlib import Path
33

4-
HASSIO_VERSION = '0.32'
4+
HASSIO_VERSION = '0.33'
55

66
URL_HASSIO_VERSION = ('https://raw.githubusercontent.com/home-assistant/'
77
'hassio/master/version.json')

hassio/core.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from .tasks import (
2121
hassio_update, homeassistant_watchdog, homeassistant_setup,
2222
api_sessions_cleanup)
23-
from .tools import get_arch_from_image, get_local_ip
23+
from .tools import get_arch_from_image, get_local_ip, fetch_timezone
2424

2525
_LOGGER = logging.getLogger(__name__)
2626

@@ -60,13 +60,17 @@ async def setup(self):
6060
# set api endpoint
6161
self.config.api_endpoint = await get_local_ip(self.loop)
6262

63+
# update timezone
64+
if self.config.timezone == 'UTC':
65+
self.config.timezone = await fetch_timezone(self.websession)
66+
6367
# hostcontrol
6468
await self.host_control.load()
6569

6670
# schedule update info tasks
6771
self.scheduler.register_task(
68-
self.host_control.load, RUN_UPDATE_INFO_TASKS)
6972

73+
self.host_control.load, RUN_UPDATE_INFO_TASKS)
7074
# rest api views
7175
self.api.register_host(self.host_control)
7276
self.api.register_network(self.host_control)

hassio/tools.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""Tools file for HassIO."""
22
import asyncio
3+
from contextlib import suppress
34
import json
45
import logging
56
import re
@@ -14,6 +15,8 @@
1415

1516
_LOGGER = logging.getLogger(__name__)
1617

18+
FREEGEOIP_URL = "https://freegeoip.io/json/"
19+
1720
_RE_VERSION = re.compile(r"VERSION=(.*)")
1821
_IMAGE_ARCH = re.compile(r".*/([a-z0-9]*)-hassio-supervisor")
1922

@@ -105,3 +108,15 @@ def validate_timezone(timezone):
105108
from None
106109

107110
return timezone
111+
112+
113+
async def fetch_timezone(websession):
114+
"""Read timezone from freegeoip."""
115+
data = {}
116+
with suppress(aiohttp.ClientError, asyncio.TimeoutError,
117+
json.JSONDecodeError, KeyError):
118+
with async_timeout.timeout(10, loop=websession.loop):
119+
async with websession.get(FREEGEOIP_URL) as request:
120+
data = await request.json()
121+
122+
return data.get('time_zone', 'UTC')

version.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"hassio": "0.32",
2+
"hassio": "0.33",
33
"homeassistant": "0.45.1",
44
"resinos": "0.8",
55
"resinhup": "0.1",

0 commit comments

Comments
 (0)