Bump aiosomecomfort to 0.0.17 (#98978)

* Clean up imports
Add refresh after login in update

* Bump somecomfort 0.0.17
Separate Somecomfort error to unauthorized

* Add tests

* Run Black format
This commit is contained in:
mkmer 2023-08-24 15:13:42 -04:00 committed by GitHub
parent 417fd0838a
commit f2c475cf1b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 43 additions and 17 deletions

View File

@ -6,7 +6,8 @@ import datetime
from typing import Any
from aiohttp import ClientConnectionError
import aiosomecomfort
from aiosomecomfort import SomeComfortError, UnauthorizedError, UnexpectedResponse
from aiosomecomfort.device import Device as SomeComfortDevice
from homeassistant.components.climate import (
ATTR_TARGET_TEMP_HIGH,
@ -106,7 +107,7 @@ class HoneywellUSThermostat(ClimateEntity):
def __init__(
self,
data: HoneywellData,
device: aiosomecomfort.device.Device,
device: SomeComfortDevice,
cool_away_temp: int | None,
heat_away_temp: int | None,
) -> None:
@ -312,7 +313,7 @@ class HoneywellUSThermostat(ClimateEntity):
if mode == "heat":
await self._device.set_setpoint_heat(temperature)
except aiosomecomfort.SomeComfortError as err:
except SomeComfortError as err:
_LOGGER.error("Invalid temperature %.1f: %s", temperature, err)
async def async_set_temperature(self, **kwargs: Any) -> None:
@ -325,7 +326,7 @@ class HoneywellUSThermostat(ClimateEntity):
if temperature := kwargs.get(ATTR_TARGET_TEMP_LOW):
await self._device.set_setpoint_heat(temperature)
except aiosomecomfort.SomeComfortError as err:
except SomeComfortError as err:
_LOGGER.error("Invalid temperature %.1f: %s", temperature, err)
async def async_set_fan_mode(self, fan_mode: str) -> None:
@ -354,7 +355,7 @@ class HoneywellUSThermostat(ClimateEntity):
if mode in HEATING_MODES:
await self._device.set_hold_heat(True, self._heat_away_temp)
except aiosomecomfort.SomeComfortError:
except SomeComfortError:
_LOGGER.error(
"Temperature out of range. Mode: %s, Heat Temperature: %.1f, Cool Temperature: %.1f",
mode,
@ -375,7 +376,7 @@ class HoneywellUSThermostat(ClimateEntity):
if mode in HEATING_MODES:
await self._device.set_hold_heat(True)
except aiosomecomfort.SomeComfortError:
except SomeComfortError:
_LOGGER.error("Couldn't set permanent hold")
else:
_LOGGER.error("Invalid system mode returned: %s", mode)
@ -387,7 +388,7 @@ class HoneywellUSThermostat(ClimateEntity):
# Disabling all hold modes
await self._device.set_hold_cool(False)
await self._device.set_hold_heat(False)
except aiosomecomfort.SomeComfortError:
except SomeComfortError:
_LOGGER.error("Can not stop hold mode")
async def async_set_preset_mode(self, preset_mode: str) -> None:
@ -416,12 +417,14 @@ class HoneywellUSThermostat(ClimateEntity):
try:
await self._device.refresh()
self._attr_available = True
except aiosomecomfort.SomeComfortError:
except UnauthorizedError:
try:
await self._data.client.login()
await self._device.refresh()
self._attr_available = True
except (
aiosomecomfort.SomeComfortError,
SomeComfortError,
ClientConnectionError,
asyncio.TimeoutError,
):
@ -429,3 +432,6 @@ class HoneywellUSThermostat(ClimateEntity):
except (ClientConnectionError, asyncio.TimeoutError):
self._attr_available = False
except UnexpectedResponse:
pass

View File

@ -6,5 +6,5 @@
"documentation": "https://www.home-assistant.io/integrations/honeywell",
"iot_class": "cloud_polling",
"loggers": ["somecomfort"],
"requirements": ["AIOSomecomfort==0.0.16"]
"requirements": ["AIOSomecomfort==0.0.17"]
}

View File

@ -8,7 +8,7 @@ AEMET-OpenData==0.3.0
AIOAladdinConnect==0.1.57
# homeassistant.components.honeywell
AIOSomecomfort==0.0.16
AIOSomecomfort==0.0.17
# homeassistant.components.adax
Adax-local==0.1.5

View File

@ -10,7 +10,7 @@ AEMET-OpenData==0.3.0
AIOAladdinConnect==0.1.57
# homeassistant.components.honeywell
AIOSomecomfort==0.0.16
AIOSomecomfort==0.0.17
# homeassistant.components.adax
Adax-local==0.1.5

View File

@ -1010,8 +1010,8 @@ async def test_async_update_errors(
await init_integration(hass, config_entry)
device.refresh.side_effect = aiosomecomfort.SomeComfortError
client.login.side_effect = aiosomecomfort.SomeComfortError
device.refresh.side_effect = aiosomecomfort.UnauthorizedError
client.login.side_effect = aiosomecomfort.AuthError
entity_id = f"climate.{device.name}"
state = hass.states.get(entity_id)
assert state.state == "off"
@ -1037,6 +1037,28 @@ async def test_async_update_errors(
state = hass.states.get(entity_id)
assert state.state == "off"
device.refresh.side_effect = aiosomecomfort.UnexpectedResponse
client.login.side_effect = None
async_fire_time_changed(
hass,
utcnow() + SCAN_INTERVAL,
)
await hass.async_block_till_done()
state = hass.states.get(entity_id)
assert state.state == "off"
device.refresh.side_effect = [aiosomecomfort.UnauthorizedError, None]
client.login.side_effect = None
async_fire_time_changed(
hass,
utcnow() + SCAN_INTERVAL,
)
await hass.async_block_till_done()
state = hass.states.get(entity_id)
assert state.state == "off"
# "reload integration" test
device.refresh.side_effect = aiosomecomfort.SomeComfortError
client.login.side_effect = aiosomecomfort.AuthError
@ -1046,9 +1068,8 @@ async def test_async_update_errors(
)
await hass.async_block_till_done()
entity_id = f"climate.{device.name}"
state = hass.states.get(entity_id)
assert state.state == "unavailable"
assert state.state == "off"
device.refresh.side_effect = ClientConnectionError
async_fire_time_changed(
@ -1057,7 +1078,6 @@ async def test_async_update_errors(
)
await hass.async_block_till_done()
entity_id = f"climate.{device.name}"
state = hass.states.get(entity_id)
assert state.state == "unavailable"