diff --git a/homeassistant/components/honeywell/__init__.py b/homeassistant/components/honeywell/__init__.py index c0ebcd9b1cf..93c29446a53 100644 --- a/homeassistant/components/honeywell/__init__.py +++ b/homeassistant/components/honeywell/__init__.py @@ -2,7 +2,7 @@ import asyncio from dataclasses import dataclass -import AIOSomecomfort +import aiosomecomfort from homeassistant.config_entries import ConfigEntry from homeassistant.const import CONF_PASSWORD, CONF_USERNAME, Platform @@ -50,19 +50,19 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b username = config_entry.data[CONF_USERNAME] password = config_entry.data[CONF_PASSWORD] - client = AIOSomecomfort.AIOSomeComfort( + client = aiosomecomfort.AIOSomeComfort( username, password, session=async_get_clientsession(hass) ) try: await client.login() await client.discover() - except AIOSomecomfort.device.AuthError as ex: + except aiosomecomfort.device.AuthError as ex: raise ConfigEntryAuthFailed("Incorrect Password") from ex except ( - AIOSomecomfort.device.ConnectionError, - AIOSomecomfort.device.ConnectionTimeout, + aiosomecomfort.device.ConnectionError, + aiosomecomfort.device.ConnectionTimeout, asyncio.TimeoutError, ) as ex: raise ConfigEntryNotReady( @@ -114,5 +114,5 @@ class HoneywellData: """Shared data for Honeywell.""" entry_id: str - client: AIOSomecomfort.AIOSomeComfort - devices: dict[str, AIOSomecomfort.device.Device] + client: aiosomecomfort.AIOSomeComfort + devices: dict[str, aiosomecomfort.device.Device] diff --git a/homeassistant/components/honeywell/climate.py b/homeassistant/components/honeywell/climate.py index 4fdc1e58f7d..aa7365a936e 100644 --- a/homeassistant/components/honeywell/climate.py +++ b/homeassistant/components/honeywell/climate.py @@ -4,7 +4,7 @@ from __future__ import annotations import datetime from typing import Any -import AIOSomecomfort +import aiosomecomfort from homeassistant.components.climate import ( ATTR_TARGET_TEMP_HIGH, @@ -103,7 +103,7 @@ class HoneywellUSThermostat(ClimateEntity): def __init__( self, data: HoneywellData, - device: AIOSomecomfort.device.Device, + device: aiosomecomfort.device.Device, cool_away_temp: int | None, heat_away_temp: int | None, ) -> None: @@ -304,7 +304,7 @@ class HoneywellUSThermostat(ClimateEntity): if mode == "heat": await self._device.set_setpoint_heat(temperature) - except AIOSomecomfort.SomeComfortError as err: + except aiosomecomfort.SomeComfortError as err: _LOGGER.error("Invalid temperature %.1f: %s", temperature, err) async def async_set_temperature(self, **kwargs: Any) -> None: @@ -317,7 +317,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 aiosomecomfort.SomeComfortError as err: _LOGGER.error("Invalid temperature %.1f: %s", temperature, err) async def async_set_fan_mode(self, fan_mode: str) -> None: @@ -339,7 +339,7 @@ class HoneywellUSThermostat(ClimateEntity): try: # Get current mode mode = self._device.system_mode - except AIOSomecomfort.SomeComfortError: + except aiosomecomfort.SomeComfortError: _LOGGER.error("Can not get system mode") return try: @@ -352,7 +352,7 @@ class HoneywellUSThermostat(ClimateEntity): await self._device.set_hold_heat(True) await self._device.set_setpoint_heat(self._heat_away_temp) - except AIOSomecomfort.SomeComfortError: + except aiosomecomfort.SomeComfortError: _LOGGER.error( "Temperature out of range. Mode: %s, Heat Temperature: %.1f, Cool Temperature: %.1f", mode, @@ -365,7 +365,7 @@ class HoneywellUSThermostat(ClimateEntity): try: # Get current mode mode = self._device.system_mode - except AIOSomecomfort.SomeComfortError: + except aiosomecomfort.SomeComfortError: _LOGGER.error("Can not get system mode") return # Check that we got a valid mode back @@ -377,7 +377,7 @@ class HoneywellUSThermostat(ClimateEntity): if mode in HEATING_MODES: await self._device.set_hold_heat(True) - except AIOSomecomfort.SomeComfortError: + except aiosomecomfort.SomeComfortError: _LOGGER.error("Couldn't set permanent hold") else: _LOGGER.error("Invalid system mode returned: %s", mode) @@ -389,7 +389,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 aiosomecomfort.SomeComfortError: _LOGGER.error("Can not stop hold mode") async def async_set_preset_mode(self, preset_mode: str) -> None: @@ -418,13 +418,13 @@ class HoneywellUSThermostat(ClimateEntity): try: await self._device.refresh() except ( - AIOSomecomfort.SomeComfortError, + aiosomecomfort.SomeComfortError, OSError, ): try: await self._data.client.login() - except AIOSomecomfort.SomeComfortError: + except aiosomecomfort.SomeComfortError: self._attr_available = False await self.hass.async_create_task( self.hass.config_entries.async_reload(self._data.entry_id) diff --git a/homeassistant/components/honeywell/config_flow.py b/homeassistant/components/honeywell/config_flow.py index a5f50cdcca9..8b24fc912f1 100644 --- a/homeassistant/components/honeywell/config_flow.py +++ b/homeassistant/components/honeywell/config_flow.py @@ -5,7 +5,7 @@ import asyncio from collections.abc import Mapping from typing import Any -import AIOSomecomfort +import aiosomecomfort import voluptuous as vol from homeassistant import config_entries @@ -56,12 +56,12 @@ class HoneywellConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): username=data[CONF_USERNAME], password=data[CONF_PASSWORD] ) - except AIOSomecomfort.AuthError: + except aiosomecomfort.AuthError: errors["base"] = "invalid_auth" except ( - AIOSomecomfort.ConnectionError, - AIOSomecomfort.ConnectionTimeout, + aiosomecomfort.ConnectionError, + aiosomecomfort.ConnectionTimeout, asyncio.TimeoutError, ): errors["base"] = "cannot_connect" @@ -89,11 +89,11 @@ class HoneywellConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): if user_input is not None: try: await self.is_valid(**user_input) - except AIOSomecomfort.AuthError: + except aiosomecomfort.AuthError: errors["base"] = "invalid_auth" except ( - AIOSomecomfort.ConnectionError, - AIOSomecomfort.ConnectionTimeout, + aiosomecomfort.ConnectionError, + aiosomecomfort.ConnectionTimeout, asyncio.TimeoutError, ): errors["base"] = "cannot_connect" @@ -114,7 +114,7 @@ class HoneywellConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def is_valid(self, **kwargs) -> bool: """Check if login credentials are valid.""" - client = AIOSomecomfort.AIOSomeComfort( + client = aiosomecomfort.AIOSomeComfort( kwargs[CONF_USERNAME], kwargs[CONF_PASSWORD], session=async_get_clientsession(self.hass), diff --git a/homeassistant/components/honeywell/manifest.json b/homeassistant/components/honeywell/manifest.json index 7eb07711b09..974123825fa 100644 --- a/homeassistant/components/honeywell/manifest.json +++ b/homeassistant/components/honeywell/manifest.json @@ -3,7 +3,7 @@ "name": "Honeywell Total Connect Comfort (US)", "config_flow": true, "documentation": "https://www.home-assistant.io/integrations/honeywell", - "requirements": ["aiosomecomfort==0.0.3"], + "requirements": ["aiosomecomfort==0.0.6"], "codeowners": ["@rdfurman", "@mkmer"], "iot_class": "cloud_polling", "loggers": ["somecomfort"] diff --git a/homeassistant/components/honeywell/sensor.py b/homeassistant/components/honeywell/sensor.py index 6df2bffa494..4d6ea4d9528 100644 --- a/homeassistant/components/honeywell/sensor.py +++ b/homeassistant/components/honeywell/sensor.py @@ -5,7 +5,7 @@ from collections.abc import Callable from dataclasses import dataclass from typing import Any -from AIOSomecomfort.device import Device +from aiosomecomfort.device import Device from homeassistant.components.sensor import ( SensorDeviceClass, diff --git a/requirements_all.txt b/requirements_all.txt index 6335fff09e5..62e6b8be512 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -276,7 +276,7 @@ aioskybell==22.7.0 aioslimproto==2.1.1 # homeassistant.components.honeywell -aiosomecomfort==0.0.3 +aiosomecomfort==0.0.6 # homeassistant.components.steamist aiosteamist==0.3.2 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 3616d8f29a7..2058070829f 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -254,7 +254,7 @@ aioskybell==22.7.0 aioslimproto==2.1.1 # homeassistant.components.honeywell -aiosomecomfort==0.0.3 +aiosomecomfort==0.0.6 # homeassistant.components.steamist aiosteamist==0.3.2 diff --git a/tests/components/honeywell/conftest.py b/tests/components/honeywell/conftest.py index bead64c71d1..95e1758ec22 100644 --- a/tests/components/honeywell/conftest.py +++ b/tests/components/honeywell/conftest.py @@ -2,7 +2,7 @@ from unittest.mock import AsyncMock, create_autospec, patch -import AIOSomecomfort +import aiosomecomfort import pytest from homeassistant.components.honeywell.const import DOMAIN @@ -30,7 +30,7 @@ def config_entry(config_data): @pytest.fixture def device(): """Mock a somecomfort.Device.""" - mock_device = create_autospec(AIOSomecomfort.device.Device, instance=True) + mock_device = create_autospec(aiosomecomfort.device.Device, instance=True) mock_device.deviceid = 1234567 mock_device._data = { "canControlHumidification": False, @@ -48,7 +48,7 @@ def device(): @pytest.fixture def device_with_outdoor_sensor(): """Mock a somecomfort.Device.""" - mock_device = create_autospec(AIOSomecomfort.device.Device, instance=True) + mock_device = create_autospec(aiosomecomfort.device.Device, instance=True) mock_device.deviceid = 1234567 mock_device._data = { "canControlHumidification": False, @@ -67,7 +67,7 @@ def device_with_outdoor_sensor(): @pytest.fixture def another_device(): """Mock a somecomfort.Device.""" - mock_device = create_autospec(AIOSomecomfort.device.Device, instance=True) + mock_device = create_autospec(aiosomecomfort.device.Device, instance=True) mock_device.deviceid = 7654321 mock_device._data = { "canControlHumidification": False, @@ -85,7 +85,7 @@ def another_device(): @pytest.fixture def location(device): """Mock a somecomfort.Location.""" - mock_location = create_autospec(AIOSomecomfort.location.Location, instance=True) + mock_location = create_autospec(aiosomecomfort.location.Location, instance=True) mock_location.locationid.return_value = "location1" mock_location.devices_by_id = {device.deviceid: device} return mock_location @@ -94,13 +94,13 @@ def location(device): @pytest.fixture(autouse=True) def client(location): """Mock a somecomfort.SomeComfort client.""" - client_mock = create_autospec(AIOSomecomfort.AIOSomeComfort, instance=True) + client_mock = create_autospec(aiosomecomfort.AIOSomeComfort, instance=True) client_mock.locations_by_id = {location.locationid: location} client_mock.login = AsyncMock(return_value=True) client_mock.discover = AsyncMock() with patch( - "homeassistant.components.honeywell.AIOSomecomfort.AIOSomeComfort" + "homeassistant.components.honeywell.aiosomecomfort.AIOSomeComfort" ) as sc_class_mock: sc_class_mock.return_value = client_mock yield client_mock diff --git a/tests/components/honeywell/test_config_flow.py b/tests/components/honeywell/test_config_flow.py index 1a1ea42a406..a416f030a05 100644 --- a/tests/components/honeywell/test_config_flow.py +++ b/tests/components/honeywell/test_config_flow.py @@ -2,7 +2,7 @@ import asyncio from unittest.mock import MagicMock, patch -import AIOSomecomfort +import aiosomecomfort import pytest from homeassistant import data_entry_flow @@ -39,7 +39,7 @@ async def test_show_authenticate_form(hass: HomeAssistant) -> None: async def test_connection_error(hass: HomeAssistant, client: MagicMock) -> None: """Test that an error message is shown on connection fail.""" - client.login.side_effect = AIOSomecomfort.device.ConnectionError + client.login.side_effect = aiosomecomfort.device.ConnectionError result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER}, data=FAKE_CONFIG ) @@ -48,7 +48,7 @@ async def test_connection_error(hass: HomeAssistant, client: MagicMock) -> None: async def test_auth_error(hass: HomeAssistant, client: MagicMock) -> None: """Test that an error message is shown on login fail.""" - client.login.side_effect = AIOSomecomfort.device.AuthError + client.login.side_effect = aiosomecomfort.device.AuthError result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER}, data=FAKE_CONFIG @@ -193,7 +193,7 @@ async def test_reauth_flow_auth_error(hass: HomeAssistant, client: MagicMock) -> assert result["type"] == FlowResultType.FORM assert result["errors"] == {} - client.login.side_effect = AIOSomecomfort.device.AuthError + client.login.side_effect = aiosomecomfort.device.AuthError with patch( "homeassistant.components.honeywell.async_setup_entry", return_value=True, @@ -211,8 +211,8 @@ async def test_reauth_flow_auth_error(hass: HomeAssistant, client: MagicMock) -> @pytest.mark.parametrize( "error", [ - AIOSomecomfort.device.ConnectionError, - AIOSomecomfort.device.ConnectionTimeout, + aiosomecomfort.device.ConnectionError, + aiosomecomfort.device.ConnectionTimeout, asyncio.TimeoutError, ], ) diff --git a/tests/components/honeywell/test_init.py b/tests/components/honeywell/test_init.py index 4ecd2a3172d..855d503401e 100644 --- a/tests/components/honeywell/test_init.py +++ b/tests/components/honeywell/test_init.py @@ -2,7 +2,7 @@ from unittest.mock import create_autospec, patch -import AIOSomecomfort +import aiosomecomfort from homeassistant.components.honeywell.const import ( CONF_COOL_AWAY_TEMPERATURE, @@ -46,7 +46,7 @@ async def test_setup_multiple_thermostats_with_same_deviceid( hass: HomeAssistant, caplog, config_entry: MockConfigEntry, device, client ) -> None: """Test Honeywell TCC API returning duplicate device IDs.""" - mock_location2 = create_autospec(AIOSomecomfort.Location, instance=True) + mock_location2 = create_autospec(aiosomecomfort.Location, instance=True) mock_location2.locationid.return_value = "location2" mock_location2.devices_by_id = {device.deviceid: device} client.locations_by_id["location2"] = mock_location2 diff --git a/tests/components/honeywell/test_sensor.py b/tests/components/honeywell/test_sensor.py index 7ed047262bf..c5367764d3d 100644 --- a/tests/components/honeywell/test_sensor.py +++ b/tests/components/honeywell/test_sensor.py @@ -1,6 +1,6 @@ """Test honeywell sensor.""" -from AIOSomecomfort.device import Device -from AIOSomecomfort.location import Location +from aiosomecomfort.device import Device +from aiosomecomfort.location import Location import pytest from homeassistant.core import HomeAssistant