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

Bump evohome-async to 0.4.4 #103084

Merged
merged 29 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
88c5a17
initial commit
zxdavb Oct 29, 2023
277c8d4
use correct attr
zxdavb Oct 29, 2023
7a6f6fb
fix hass-logger-period
zxdavb Oct 29, 2023
dd0337d
initial commit
zxdavb Oct 30, 2023
1322e5e
Merge remote-tracking branch 'upstream/dev' into evo_new_library
zxdavb Oct 30, 2023
e43cc9e
reduce footprint
zxdavb Oct 30, 2023
95f4499
reduce footprint 2
zxdavb Oct 30, 2023
cfcf93c
reduce footprint 3
zxdavb Oct 30, 2023
8a1ceb0
reduce footprint 4
zxdavb Oct 30, 2023
50189f8
reduce footprint 6
zxdavb Oct 30, 2023
f69832f
reduce footprint 7
zxdavb Oct 30, 2023
a159b6d
reduce footprint 8
zxdavb Oct 30, 2023
6a261df
reduce footprint 9
zxdavb Oct 30, 2023
02334cb
Merge remote-tracking branch 'upstream/dev' into evo_new_library
zxdavb Nov 1, 2023
34b88af
bump client to 0.4.1
zxdavb Nov 1, 2023
dbc48a0
Merge branch 'dev' into evo_new_library
zxdavb Nov 1, 2023
5244780
missing commit - changed method name
zxdavb Nov 1, 2023
08be982
bump client to 0.4.3
zxdavb Nov 1, 2023
13af046
Merge branch 'dev' into evo_new_library
zxdavb Nov 1, 2023
41ac8ff
Merge remote-tracking branch 'upstream/dev' into evo_new_library
zxdavb Nov 1, 2023
d17f94e
Merge branch 'evo_new_library' of https://github.com/zxdavb/hass into…
zxdavb Nov 1, 2023
2698eb9
Merge branch 'dev' into evo_new_library
zxdavb Nov 1, 2023
ec99a13
Merge branch 'dev' into evo_new_library
zxdavb Nov 1, 2023
e68c0b7
Merge branch 'dev' into evo_new_library
zxdavb Nov 2, 2023
ff7ae7f
Merge branch 'dev' into evo_new_library
zxdavb Nov 2, 2023
fafb2fd
Merge remote-tracking branch 'upstream/dev' into evo_new_library
zxdavb Nov 5, 2023
b85b8b2
bump client to 0.4.4
zxdavb Nov 5, 2023
8689109
Merge branch 'dev' into evo_new_library
zxdavb Nov 5, 2023
61bbf88
Merge branch 'dev' into evo_new_library
zxdavb Nov 6, 2023
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
82 changes: 49 additions & 33 deletions homeassistant/components/evohome/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import re
from typing import Any

import aiohttp.client_exceptions
import evohomeasync
import evohomeasync2
import voluptuous as vol
Expand Down Expand Up @@ -144,7 +143,7 @@ def _handle_exception(err) -> None:
try:
raise err

except evohomeasync2.AuthenticationError:
except evohomeasync2.AuthenticationFailed:
_LOGGER.error(
(
"Failed to authenticate with the vendor's server. Check your username"
Expand All @@ -155,19 +154,18 @@ def _handle_exception(err) -> None:
err,
)

except aiohttp.ClientConnectionError:
# this appears to be a common occurrence with the vendor's servers
_LOGGER.warning(
(
"Unable to connect with the vendor's server. "
"Check your network and the vendor's service status page. "
"Message is: %s"
),
err,
)
except evohomeasync2.RequestFailed:
if err.status is None:
_LOGGER.warning(
(
"Unable to connect with the vendor's server. "
"Check your network and the vendor's service status page. "
"Message is: %s"
),
err,
)

except aiohttp.ClientResponseError:
if err.status == HTTPStatus.SERVICE_UNAVAILABLE:
elif err.status == HTTPStatus.SERVICE_UNAVAILABLE:
_LOGGER.warning(
"The vendor says their server is currently unavailable. "
"Check the vendor's service status page"
Expand Down Expand Up @@ -219,7 +217,7 @@ async def load_auth_tokens(store) -> tuple[dict, dict | None]:

try:
await client_v2.login()
except (aiohttp.ClientError, evohomeasync2.AuthenticationError) as err:
except evohomeasync2.AuthenticationFailed as err:
_handle_exception(err)
return False
finally:
Expand Down Expand Up @@ -452,7 +450,7 @@ async def call_client_api(self, api_function, update_state=True) -> Any:
"""Call a client API and update the broker state if required."""
try:
result = await api_function
except (aiohttp.ClientError, evohomeasync2.AuthenticationError) as err:
except evohomeasync2.EvohomeError as err:
_handle_exception(err)
return

Expand All @@ -475,15 +473,27 @@ def get_session_id(client_v1) -> str | None:
try:
temps = list(await self.client_v1.temperatures(force_refresh=True))

except aiohttp.ClientError as err:
except evohomeasync.InvalidSchema as exc:
_LOGGER.warning(
(
"Unable to obtain high-precision temperatures. "
"It appears the JSON schema is not as expected, "
"so the high-precision feature will be disabled until next restart."
"Message is: %s"
),
exc,
)
self.temps = self.client_v1 = None

except evohomeasync.EvohomeError as exc:
_LOGGER.warning(
(
"Unable to obtain the latest high-precision temperatures. "
"Check your network and the vendor's service status page. "
"Proceeding with low-precision temperatures. "
"Proceeding without high-precision temperatures for now. "
"Message is: %s"
),
err,
exc,
)
self.temps = None # these are now stale, will fall back to v2 temps

Expand Down Expand Up @@ -513,19 +523,20 @@ def get_session_id(client_v1) -> str | None:
else:
self.temps = {str(i["id"]): i["temp"] for i in temps}

_LOGGER.debug("Temperatures = %s", self.temps)
finally:
if session_id != get_session_id(self.client_v1):
await self.save_auth_tokens()

if session_id != get_session_id(self.client_v1):
await self.save_auth_tokens()
_LOGGER.debug("Temperatures = %s", self.temps)

async def _update_v2_api_state(self, *args, **kwargs) -> None:
"""Get the latest modes, temperatures, setpoints of a Location."""
access_token = self.client.access_token

loc_idx = self.params[CONF_LOCATION_IDX]
try:
status = await self.client.locations[loc_idx].status()
except (aiohttp.ClientError, evohomeasync2.AuthenticationError) as err:
status = await self.client.locations[loc_idx].refresh_status()
except evohomeasync2.EvohomeError as err:
_handle_exception(err)
else:
async_dispatcher_send(self.hass, DOMAIN)
Expand All @@ -542,11 +553,14 @@ async def async_update(self, *args, **kwargs) -> None:
operating mode of the Controller and the current temp of its children (e.g.
Zones, DHW controller).
"""
if self.client_v1:
await self._update_v1_api_temps()

await self._update_v2_api_state()

if self.client_v1:
try:
await self._update_v1_api_temps()
except evohomeasync.EvohomeError:
self.temps = None # these are now stale, will fall back to v2 temps


class EvoDevice(Entity):
"""Base for any evohome device.
Expand Down Expand Up @@ -618,11 +632,13 @@ def __init__(self, evo_broker, evo_device) -> None:
@property
def current_temperature(self) -> float | None:
"""Return the current temperature of a Zone."""
if (
self._evo_broker.temps
and self._evo_broker.temps[self._evo_device.zoneId] != 128
):
return self._evo_broker.temps[self._evo_device.zoneId]
if self._evo_device.TYPE == "domesticHotWater":
dev_id = self._evo_device.dhwId
else:
dev_id = self._evo_device.zoneId

if self._evo_broker.temps and self._evo_broker.temps[dev_id] is not None:
return self._evo_broker.temps[dev_id]

if self._evo_device.temperatureStatus["isAvailable"]:
return self._evo_device.temperatureStatus["temperature"]
Expand Down Expand Up @@ -695,7 +711,7 @@ def _dt_evo_to_aware(dt_naive: dt, utc_offset: timedelta) -> dt:
async def _update_schedule(self) -> None:
"""Get the latest schedule, if any."""
self._schedule = await self._evo_broker.call_client_api(
self._evo_device.schedule(), update_state=False
self._evo_device.get_schedule(), update_state=False
)

_LOGGER.debug("Schedule['%s'] = %s", self.name, self._schedule)
Expand Down
14 changes: 4 additions & 10 deletions homeassistant/components/evohome/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,7 @@ def __init__(self, evo_broker, evo_device) -> None:
async def async_zone_svc_request(self, service: str, data: dict[str, Any]) -> None:
"""Process a service request (setpoint override) for a zone."""
if service == SVC_RESET_ZONE_OVERRIDE:
await self._evo_broker.call_client_api(
self._evo_device.cancel_temp_override()
)
await self._evo_broker.call_client_api(self._evo_device.reset_mode())
return

# otherwise it is SVC_SET_ZONE_OVERRIDE
Expand Down Expand Up @@ -264,18 +262,14 @@ async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
self._evo_device.set_temperature(self.min_temp, until=None)
)
else: # HVACMode.HEAT
await self._evo_broker.call_client_api(
self._evo_device.cancel_temp_override()
)
await self._evo_broker.call_client_api(self._evo_device.reset_mode())

async def async_set_preset_mode(self, preset_mode: str) -> None:
"""Set the preset mode; if None, then revert to following the schedule."""
evo_preset_mode = HA_PRESET_TO_EVO.get(preset_mode, EVO_FOLLOW)

if evo_preset_mode == EVO_FOLLOW:
await self._evo_broker.call_client_api(
self._evo_device.cancel_temp_override()
)
await self._evo_broker.call_client_api(self._evo_device.reset_mode())
return

temperature = self._evo_device.setpointStatus["targetHeatTemperature"]
Expand Down Expand Up @@ -352,7 +346,7 @@ async def _set_tcs_mode(self, mode: str, until: dt | None = None) -> None:
"""Set a Controller to any of its native EVO_* operating modes."""
until = dt_util.as_utc(until) if until else None
await self._evo_broker.call_client_api(
self._evo_tcs.set_status(mode, until=until)
self._evo_tcs.set_mode(mode, until=until)
)

@property
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/evohome/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
"documentation": "https://www.home-assistant.io/integrations/evohome",
"iot_class": "cloud_polling",
"loggers": ["evohomeasync", "evohomeasync2"],
"requirements": ["evohome-async==0.3.15"]
"requirements": ["evohome-async==0.4.4"]
}
19 changes: 10 additions & 9 deletions homeassistant/components/evohome/water_heater.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@ async def async_setup_platform(

_LOGGER.debug(
"Adding: DhwController (%s), id=%s",
broker.tcs.hotwater.zone_type,
broker.tcs.hotwater.zoneId,
broker.tcs.hotwater.TYPE,
broker.tcs.hotwater.dhwId,
)

new_entity = EvoDHW(broker, broker.tcs.hotwater)

async_add_entities([new_entity], update_before_add=True)
Expand Down Expand Up @@ -95,36 +96,36 @@ async def async_set_operation_mode(self, operation_mode: str) -> None:
Except for Auto, the mode is only until the next SetPoint.
"""
if operation_mode == STATE_AUTO:
await self._evo_broker.call_client_api(self._evo_device.set_dhw_auto())
await self._evo_broker.call_client_api(self._evo_device.reset_mode())
else:
await self._update_schedule()
until = dt_util.parse_datetime(self.setpoints.get("next_sp_from", ""))
until = dt_util.as_utc(until) if until else None

if operation_mode == STATE_ON:
await self._evo_broker.call_client_api(
self._evo_device.set_dhw_on(until=until)
self._evo_device.set_on(until=until)
)
else: # STATE_OFF
await self._evo_broker.call_client_api(
self._evo_device.set_dhw_off(until=until)
self._evo_device.set_off(until=until)
)

async def async_turn_away_mode_on(self) -> None:
"""Turn away mode on."""
await self._evo_broker.call_client_api(self._evo_device.set_dhw_off())
await self._evo_broker.call_client_api(self._evo_device.set_off())

async def async_turn_away_mode_off(self) -> None:
"""Turn away mode off."""
await self._evo_broker.call_client_api(self._evo_device.set_dhw_auto())
await self._evo_broker.call_client_api(self._evo_device.reset_mode())

async def async_turn_on(self):
"""Turn on."""
await self._evo_broker.call_client_api(self._evo_device.set_dhw_on())
await self._evo_broker.call_client_api(self._evo_device.set_on())

async def async_turn_off(self):
"""Turn off."""
await self._evo_broker.call_client_api(self._evo_device.set_dhw_off())
await self._evo_broker.call_client_api(self._evo_device.set_off())

async def async_update(self) -> None:
"""Get the latest state data for a DHW controller."""
Expand Down
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ eufylife-ble-client==0.1.8
# evdev==1.6.1

# homeassistant.components.evohome
evohome-async==0.3.15
evohome-async==0.4.4

# homeassistant.components.faa_delays
faadelays==2023.9.1
Expand Down