home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.58k stars 29.91k forks source link

Evohome fails to start for FocusProWifi, with KeyError: 'status' #102815

Closed Truman78es closed 10 months ago

Truman78es commented 11 months ago

The problem

I am running HA in a Docker container from my Synology DS1819+ and I am trying to add the Evohome integration for Honeywell Total Connect Comfort (Europe), but I am getting an error message when starting the container, preventing the integration from being completed.

After consulting the forum https://community.home-assistant.io/t/official-honeywell-evohome-round-thermostat-integration-eu-only they told me that there is some problem , which I do not have evohome, but FocusProWifiRetail, although these systems are compatible with TCC.

I have also been told that the library is crashing when retrieving high-precision temps from the vendor’s older API because the JSON isn’t as expected. The integration is designed to handle a failure of the older API (everything required is in the newer API), but only in update/refresh and not on setup.

Can anyone help me here?

What version of Home Assistant Core has the issue?

core-2023.10.4

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Container

Integration causing the issue

Honeywell Total Connect Comfort (Europe) / Evohome

Link to integration documentation on our website

https://www.home-assistant.io/integrations/evohome/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

2023-10-24 16:36:08.945 INFO (MainThread) [homeassistant.setup] Setting up evohome
2023-10-24 16:38:32.321 WARNING (MainThread) [homeassistant.setup] Setup of evohome is taking over 10 seconds.
2023-10-24 16:38:34.074 DEBUG (MainThread) [homeassistant.components.evohome] Config = {'locationInfo': {'timeZone': {'timeZoneId': 'RomanceStandardTime', 'displayName': '(UTC+01:00) Brussels, Copenhagen, Madrid, Paris', 'offsetMinutes': 60, 'currentOffsetMinutes': 120, 'supportsDaylightSaving': True}}, 'gateways': [{'temperatureControlSystems': [{'systemId': '632515', 'modelType': 'FocusProWifiRetail', 'zones': [{'zoneId': '632515', 'modelType': 'FocusProWifiRetail', 'setpointCapabilities': {'vacationHoldCapabilities': {'isChangeable': False, 'isCancelable': False}, 'maxHeatSetpoint': 32.0, 'minHeatSetpoint': 4.5, 'maxCoolSetpoint': 37.0, 'minCoolSetpoint': 10.0, 'setpointDeadband': 0.0, 'valueResolution': 0.5, 'canControlHeat': True, 'canControlCool': True, 'allowedSetpointModes': ['PermanentOverride', 'VacationHold'], 'maxDuration': '1.00:00:00', 'timingResolution': '00:15:00'}, 'name': 'DINING ROOM', 'zoneType': 'Thermostat', 'allowedFanModes': [{'fanMode': 'Auto'}, {'fanMode': 'On'}]}], 'allowedSystemModes': [{'systemMode': 'Off', 'canBePermanent': True, 'canBeTemporary': False}, {'systemMode': 'Heat', 'canBePermanent': True, 'canBeTemporary': False}, {'systemMode': 'Cool', 'canBePermanent': True, 'canBeTemporary': False}]}]}]}
2023-10-24 16:38:34.464 ERROR (MainThread) [homeassistant.setup] Error during setup of component evohome
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 288, in _async_setup_component
    result = await task
             ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/evohome/__init__.py", line 265, in async_setup
    await broker.async_update()  # get initial state
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/evohome/__init__.py", line 534, in async_update
    await self._update_v1_api_temps()
  File "/usr/src/homeassistant/homeassistant/components/evohome/__init__.py", line 476, in _update_v1_api_temps
    temps = list(await self.client_v1.temperatures(force_refresh=True))
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/evohomeasync/__init__.py", line 114, in temperatures
    status = device["thermostat"]["changeableValues"]["heatSetpoint"][
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyError: 'status'

Additional information

No response

home-assistant[bot] commented 11 months ago

Hey there @zxdavb, mind taking a look at this issue as it has been labeled with an integration (evohome) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `evohome` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign evohome` Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


evohome documentation evohome source (message by IssueLinks)

zxdavb commented 10 months ago

Here is a cut-and-paste from the HA community forum:

OK, I see you don’t have evohome, but FocusProWifiRetail. These systems are compatible with TCC, but haven’t been extensively tested with this integration (mainly because they are relatively rare).

Looking at the code of the integration (HA) and library (me)…

The library is crashing when retrieving high-precision temps from the vendor’s older API because the JSON isn’t as expected.

The integration is designed to handle a failure of the older API (everything required is in the newer API), but only in update/refresh and not on setup…

So I will ned to submit a patch to HA.

zxdavb commented 10 months ago

The integration will handle failures to obtain the high-precision temperatures during the update cycle (SCAN_INTERVAL), but not during startup.

A fix for this would be relatively straight-forward (see below).

However, the high-precision temps should be opt-in as temps with a precision of 0.01 are inappropriate for a room temp:

I propose a hot-fix for this (slightly rare) use-case, then to implement a (breaking) change to make high-precision temps opt-in, rather than enabled by default at a later date.

This code:

        try:
            temps = list(await self.client_v1.temperatures(force_refresh=True))
        except aiohttp.ClientError as err:

...changes to:

        try:
            temps = list(await self.client_v1.temperatures(force_refresh=True))
        except KeyError:
            self.client_v1 = self.temps = None
        except aiohttp.ClientError as err:

The above shoudl also throw a _LOGGER.warning().

Truman78es commented 10 months ago

Ok, thanks a lot. I understand the difference between 0.5 and 0.01 (0.01 is 50 times greater than 0.5), but I don't understand where and what file I have to modify with that new code

zxdavb commented 10 months ago

@Truman78es I have submitted a PR to fix this issue. All you need to do if wait for it to be merged.

Truman78es commented 10 months ago

Ok, thanks a lot

zxdavb commented 10 months ago

@Truman78es This change will be merged in HA v2023.11.0 - good luck.