Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[climate] Add water_heater to evohome #25035

Merged
merged 32 commits into from Jul 12, 2019
Merged
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
e1703a6
initial commit
zxdavb Jul 9, 2019
fb8fb77
refactor for sync
zxdavb Jul 9, 2019
aa301f0
minor tweak
zxdavb Jul 9, 2019
9b9eafe
refactor convert code
zxdavb Jul 9, 2019
3f9a82e
fix regression
zxdavb Jul 9, 2019
9d3192f
remove bad await
zxdavb Jul 9, 2019
4cd3e63
de-lint
zxdavb Jul 9, 2019
06774f9
de-lint 2
zxdavb Jul 9, 2019
e349c14
address edge case - invalid tokens
zxdavb Jul 10, 2019
d5917fb
address edge case - delint
zxdavb Jul 10, 2019
462153c
handle no schedule
zxdavb Jul 10, 2019
95e947e
improve support for RoundThermostat
zxdavb Jul 10, 2019
eb8287f
tweak logging
zxdavb Jul 10, 2019
c77b042
delint
zxdavb Jul 10, 2019
f8916c8
refactor for greatness
zxdavb Jul 10, 2019
040ccd6
use time_zone: for state attributes
zxdavb Jul 11, 2019
9d563db
small tweak
zxdavb Jul 11, 2019
ef02ac3
small tweak 2
zxdavb Jul 11, 2019
ce362bd
have datetime state attributes as UTC
zxdavb Jul 11, 2019
ac76123
have datetime state attributes as UTC - delint
zxdavb Jul 11, 2019
d3502c3
have datetime state attributes as UTC - tweak
zxdavb Jul 11, 2019
612bd73
missed this - remove
zxdavb Jul 11, 2019
a6a7a24
de-lint type hint
zxdavb Jul 11, 2019
74f9006
use parse_datetime instead of datetime.strptime)
zxdavb Jul 11, 2019
0a8cc87
remove debug code
zxdavb Jul 11, 2019
42ea0b5
state atrribute datetimes are UTC now
zxdavb Jul 11, 2019
ec52dbf
revert
zxdavb Jul 11, 2019
0d51731
de-lint (again)
zxdavb Jul 11, 2019
9e40eca
tweak type hints
zxdavb Jul 11, 2019
67b9e8b
de-lint (again, again)
zxdavb Jul 11, 2019
890f8d1
tweak type hints
zxdavb Jul 11, 2019
9d84b2f
Convert datetime closer to sending it out
balloob Jul 12, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 8 additions & 8 deletions homeassistant/components/evohome/__init__.py
Expand Up @@ -7,7 +7,6 @@
import logging
from typing import Awaitable, Any, Dict, Tuple

from dateutil.tz import tzlocal
import requests.exceptions
import voluptuous as vol
import evohomeclient2
Expand All @@ -23,7 +22,7 @@
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.event import (
async_track_point_in_utc_time, track_time_interval)
from homeassistant.util.dt import as_utc, parse_datetime, utcnow
from homeassistant.util.dt import parse_datetime, utcnow, UTC

from .const import DOMAIN, EVO_STRFTIME, STORAGE_VERSION, STORAGE_KEY, GWS, TCS

Expand All @@ -48,13 +47,13 @@


def _local_dt_to_utc(dt_naive: datetime) -> datetime:
zxdavb marked this conversation as resolved.
Show resolved Hide resolved
dt_aware = as_utc(dt_naive.replace(tzinfo=tzlocal()))
dt_aware = utcnow() + (dt_naive - datetime.now())
return dt_aware.replace(microsecond=0, tzinfo=None)


def _utc_to_local_dt(dt_naive: datetime) -> datetime:
dt_aware = as_utc(dt_naive).astimezone(tzlocal())
return dt_aware.replace(microsecond=0, tzinfo=None)
dt_naive = datetime.now() + (dt_naive - utcnow().replace(tzinfo=None))
return dt_naive.replace(microsecond=0)


def _handle_exception(err):
Expand Down Expand Up @@ -157,8 +156,7 @@ def init_client(self) -> bool:
finally:
self.params[CONF_PASSWORD] = 'REDACTED'

asyncio.run_coroutine_threadsafe(
self._save_auth_tokens(), self.hass.loop)
self.hass.add_job(self._save_auth_tokens())

loc_idx = self.params[CONF_LOCATION_IDX]
try:
Expand Down Expand Up @@ -215,10 +213,12 @@ async def _save_auth_tokens(self, *args) -> None:
store = self.hass.helpers.storage.Store(STORAGE_VERSION, STORAGE_KEY)
await store.async_save(self._app_storage)

access_token_expires_utc += self.params[CONF_SCAN_INTERVAL]
zxdavb marked this conversation as resolved.
Show resolved Hide resolved

async_track_point_in_utc_time(
self.hass,
self._save_auth_tokens,
access_token_expires_utc
access_token_expires_utc.replace(tzinfo=UTC)
)

def update(self, *args, **kwargs) -> None:
Expand Down