mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-15 05:06:30 +00:00
parent
fa9e20385e
commit
e3ae48c8ff
@ -7,7 +7,6 @@ from .coresys import CoreSysAttributes
|
|||||||
from .const import (
|
from .const import (
|
||||||
STARTUP_SYSTEM, STARTUP_SERVICES, STARTUP_APPLICATION, STARTUP_INITIALIZE)
|
STARTUP_SYSTEM, STARTUP_SERVICES, STARTUP_APPLICATION, STARTUP_INITIALIZE)
|
||||||
from .exceptions import HassioError
|
from .exceptions import HassioError
|
||||||
from .utils.dt import fetch_timezone
|
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -21,12 +20,6 @@ class HassIO(CoreSysAttributes):
|
|||||||
|
|
||||||
async def setup(self):
|
async def setup(self):
|
||||||
"""Setup HassIO orchestration."""
|
"""Setup HassIO orchestration."""
|
||||||
# update timezone
|
|
||||||
if self.sys_config.timezone == 'UTC':
|
|
||||||
self.sys_config.timezone = \
|
|
||||||
await fetch_timezone(self.sys_websession)
|
|
||||||
self.sys_loop.call_soon(self.sys_config.save_data)
|
|
||||||
|
|
||||||
# Load Supervisor
|
# Load Supervisor
|
||||||
await self.sys_supervisor.load()
|
await self.sys_supervisor.load()
|
||||||
|
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
"""Tools file for HassIO."""
|
"""Tools file for HassIO."""
|
||||||
import asyncio
|
|
||||||
from datetime import datetime, timedelta, timezone
|
from datetime import datetime, timedelta, timezone
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
|
|
||||||
import aiohttp
|
|
||||||
import pytz
|
import pytz
|
||||||
|
|
||||||
UTC = pytz.utc
|
UTC = pytz.utc
|
||||||
@ -24,22 +22,6 @@ DATETIME_RE = re.compile(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def fetch_timezone(websession):
|
|
||||||
"""Read timezone from freegeoip."""
|
|
||||||
data = {}
|
|
||||||
try:
|
|
||||||
async with websession.get(FREEGEOIP_URL, timeout=10) as request:
|
|
||||||
data = await request.json()
|
|
||||||
|
|
||||||
except (aiohttp.ClientError, asyncio.TimeoutError) as err:
|
|
||||||
_LOGGER.warning("Can't fetch freegeoip data: %s", err)
|
|
||||||
|
|
||||||
except ValueError as err:
|
|
||||||
_LOGGER.warning("Error on parse freegeoip data: %s", err)
|
|
||||||
|
|
||||||
return data.get('time_zone', 'UTC')
|
|
||||||
|
|
||||||
|
|
||||||
# Copyright (c) Django Software Foundation and individual contributors.
|
# Copyright (c) Django Software Foundation and individual contributors.
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
# https://github.com/django/django/blob/master/LICENSE
|
# https://github.com/django/django/blob/master/LICENSE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user