Skip to content

Commit

Permalink
Bump aioswitcher to 5.0.0 (home-assistant#130874)
Browse files Browse the repository at this point in the history
* Bump aioswitcher to 5.0.0

* fix linting
  • Loading branch information
YogevBokobza authored Nov 18, 2024
1 parent e488579 commit 2cf3f2b
Show file tree
Hide file tree
Showing 15 changed files with 46 additions and 47 deletions.
3 changes: 1 addition & 2 deletions homeassistant/components/switcher_kis/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
DeviceState,
SwitcherApi,
SwitcherBaseResponse,
SwitcherType2Api,
ThermostatSwing,
)
from aioswitcher.api.remotes import SwitcherBreezeRemote
Expand Down Expand Up @@ -128,7 +127,7 @@ async def async_press(self) -> None:
error = None

try:
async with SwitcherType2Api(
async with SwitcherApi(
self.coordinator.data.device_type,
self.coordinator.data.ip_address,
self.coordinator.data.device_id,
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/switcher_kis/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from typing import Any, cast

from aioswitcher.api import SwitcherBaseResponse, SwitcherType2Api
from aioswitcher.api import SwitcherApi, SwitcherBaseResponse
from aioswitcher.api.remotes import SwitcherBreezeRemote
from aioswitcher.device import (
DeviceCategory,
Expand Down Expand Up @@ -160,7 +160,7 @@ async def _async_control_breeze_device(self, **kwargs: Any) -> None:
error = None

try:
async with SwitcherType2Api(
async with SwitcherApi(
self.coordinator.data.device_type,
self.coordinator.data.ip_address,
self.coordinator.data.device_id,
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/switcher_kis/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import logging
from typing import Any, cast

from aioswitcher.api import SwitcherBaseResponse, SwitcherType2Api
from aioswitcher.api import SwitcherApi, SwitcherBaseResponse
from aioswitcher.device import DeviceCategory, ShutterDirection, SwitcherShutter

from homeassistant.components.cover import (
Expand Down Expand Up @@ -99,7 +99,7 @@ async def _async_call_api(self, api: str, *args: Any) -> None:
error = None

try:
async with SwitcherType2Api(
async with SwitcherApi(
self.coordinator.data.device_type,
self.coordinator.data.ip_address,
self.coordinator.data.device_id,
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/switcher_kis/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import logging
from typing import Any, cast

from aioswitcher.api import SwitcherBaseResponse, SwitcherType2Api
from aioswitcher.api import SwitcherApi, SwitcherBaseResponse
from aioswitcher.device import DeviceCategory, DeviceState, SwitcherLight

from homeassistant.components.light import ColorMode, LightEntity
Expand Down Expand Up @@ -86,7 +86,7 @@ async def _async_call_api(self, api: str, *args: Any) -> None:
error = None

try:
async with SwitcherType2Api(
async with SwitcherApi(
self.coordinator.data.device_type,
self.coordinator.data.ip_address,
self.coordinator.data.device_id,
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/switcher_kis/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
"iot_class": "local_push",
"loggers": ["aioswitcher"],
"quality_scale": "platinum",
"requirements": ["aioswitcher==4.4.0"],
"requirements": ["aioswitcher==5.0.0"],
"single_config_entry": true
}
4 changes: 2 additions & 2 deletions homeassistant/components/switcher_kis/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import logging
from typing import Any

from aioswitcher.api import Command, SwitcherBaseResponse, SwitcherType1Api
from aioswitcher.api import Command, SwitcherApi, SwitcherBaseResponse
from aioswitcher.device import DeviceCategory, DeviceState
import voluptuous as vol

Expand Down Expand Up @@ -105,7 +105,7 @@ async def _async_call_api(self, api: str, *args: Any) -> None:
error = None

try:
async with SwitcherType1Api(
async with SwitcherApi(
self.coordinator.data.device_type,
self.coordinator.data.ip_address,
self.coordinator.data.device_id,
Expand Down
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ aiosteamist==1.0.0
aiostreammagic==2.8.5

# homeassistant.components.switcher_kis
aioswitcher==4.4.0
aioswitcher==5.0.0

# homeassistant.components.syncthing
aiosyncthing==0.5.1
Expand Down
2 changes: 1 addition & 1 deletion requirements_test_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ aiosteamist==1.0.0
aiostreammagic==2.8.5

# homeassistant.components.switcher_kis
aioswitcher==4.4.0
aioswitcher==5.0.0

# homeassistant.components.syncthing
aiosyncthing==0.5.1
Expand Down
8 changes: 4 additions & 4 deletions tests/components/switcher_kis/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,19 @@ def mock_api():

patchers = [
patch(
"homeassistant.components.switcher_kis.switch.SwitcherType1Api.connect",
"homeassistant.components.switcher_kis.switch.SwitcherApi.connect",
new=api_mock,
),
patch(
"homeassistant.components.switcher_kis.switch.SwitcherType1Api.disconnect",
"homeassistant.components.switcher_kis.switch.SwitcherApi.disconnect",
new=api_mock,
),
patch(
"homeassistant.components.switcher_kis.climate.SwitcherType2Api.connect",
"homeassistant.components.switcher_kis.climate.SwitcherApi.connect",
new=api_mock,
),
patch(
"homeassistant.components.switcher_kis.climate.SwitcherType2Api.disconnect",
"homeassistant.components.switcher_kis.climate.SwitcherApi.disconnect",
new=api_mock,
),
]
Expand Down
8 changes: 4 additions & 4 deletions tests/components/switcher_kis/test_button.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ async def test_assume_button(
assert hass.states.get(SWING_OFF_EID) is None

with patch(
"homeassistant.components.switcher_kis.climate.SwitcherType2Api.control_breeze_device",
"homeassistant.components.switcher_kis.climate.SwitcherApi.control_breeze_device",
) as mock_control_device:
await hass.services.async_call(
BUTTON_DOMAIN,
Expand Down Expand Up @@ -79,7 +79,7 @@ async def test_swing_button(
assert hass.states.get(SWING_OFF_EID) is not None

with patch(
"homeassistant.components.switcher_kis.climate.SwitcherType2Api.control_breeze_device",
"homeassistant.components.switcher_kis.climate.SwitcherApi.control_breeze_device",
) as mock_control_device:
await hass.services.async_call(
BUTTON_DOMAIN,
Expand All @@ -103,7 +103,7 @@ async def test_control_device_fail(

# Test exception during set hvac mode
with patch(
"homeassistant.components.switcher_kis.climate.SwitcherType2Api.control_breeze_device",
"homeassistant.components.switcher_kis.climate.SwitcherApi.control_breeze_device",
side_effect=RuntimeError("fake error"),
) as mock_control_device:
with pytest.raises(HomeAssistantError):
Expand All @@ -130,7 +130,7 @@ async def test_control_device_fail(

# Test error response during turn on
with patch(
"homeassistant.components.switcher_kis.climate.SwitcherType2Api.control_breeze_device",
"homeassistant.components.switcher_kis.climate.SwitcherApi.control_breeze_device",
return_value=SwitcherBaseResponse(None),
) as mock_control_device:
with pytest.raises(HomeAssistantError):
Expand Down
18 changes: 9 additions & 9 deletions tests/components/switcher_kis/test_climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ async def test_climate_hvac_mode(

# Test set hvac mode heat
with patch(
"homeassistant.components.switcher_kis.climate.SwitcherType2Api.control_breeze_device",
"homeassistant.components.switcher_kis.climate.SwitcherApi.control_breeze_device",
) as mock_control_device:
await hass.services.async_call(
CLIMATE_DOMAIN,
Expand All @@ -71,7 +71,7 @@ async def test_climate_hvac_mode(

# Test set hvac mode off
with patch(
"homeassistant.components.switcher_kis.climate.SwitcherType2Api.control_breeze_device",
"homeassistant.components.switcher_kis.climate.SwitcherApi.control_breeze_device",
) as mock_control_device:
await hass.services.async_call(
CLIMATE_DOMAIN,
Expand Down Expand Up @@ -108,7 +108,7 @@ async def test_climate_temperature(

# Test set target temperature
with patch(
"homeassistant.components.switcher_kis.climate.SwitcherType2Api.control_breeze_device",
"homeassistant.components.switcher_kis.climate.SwitcherApi.control_breeze_device",
) as mock_control_device:
await hass.services.async_call(
CLIMATE_DOMAIN,
Expand All @@ -128,7 +128,7 @@ async def test_climate_temperature(

# Test set target temperature - incorrect params
with patch(
"homeassistant.components.switcher_kis.climate.SwitcherType2Api.control_breeze_device",
"homeassistant.components.switcher_kis.climate.SwitcherApi.control_breeze_device",
) as mock_control_device:
with pytest.raises(ServiceValidationError):
await hass.services.async_call(
Expand Down Expand Up @@ -160,7 +160,7 @@ async def test_climate_fan_level(

# Test set fan level to high
with patch(
"homeassistant.components.switcher_kis.climate.SwitcherType2Api.control_breeze_device",
"homeassistant.components.switcher_kis.climate.SwitcherApi.control_breeze_device",
) as mock_control_device:
await hass.services.async_call(
CLIMATE_DOMAIN,
Expand Down Expand Up @@ -195,7 +195,7 @@ async def test_climate_swing(

# Test set swing mode on
with patch(
"homeassistant.components.switcher_kis.climate.SwitcherType2Api.control_breeze_device",
"homeassistant.components.switcher_kis.climate.SwitcherApi.control_breeze_device",
) as mock_control_device:
await hass.services.async_call(
CLIMATE_DOMAIN,
Expand All @@ -218,7 +218,7 @@ async def test_climate_swing(

# Test set swing mode off
with patch(
"homeassistant.components.switcher_kis.climate.SwitcherType2Api.control_breeze_device",
"homeassistant.components.switcher_kis.climate.SwitcherApi.control_breeze_device",
) as mock_control_device:
await hass.services.async_call(
CLIMATE_DOMAIN,
Expand Down Expand Up @@ -249,7 +249,7 @@ async def test_control_device_fail(hass: HomeAssistant, mock_bridge, mock_api) -

# Test exception during set hvac mode
with patch(
"homeassistant.components.switcher_kis.climate.SwitcherType2Api.control_breeze_device",
"homeassistant.components.switcher_kis.climate.SwitcherApi.control_breeze_device",
side_effect=RuntimeError("fake error"),
) as mock_control_device:
with pytest.raises(HomeAssistantError):
Expand All @@ -276,7 +276,7 @@ async def test_control_device_fail(hass: HomeAssistant, mock_bridge, mock_api) -

# Test error response during turn on
with patch(
"homeassistant.components.switcher_kis.climate.SwitcherType2Api.control_breeze_device",
"homeassistant.components.switcher_kis.climate.SwitcherApi.control_breeze_device",
return_value=SwitcherBaseResponse(None),
) as mock_control_device:
with pytest.raises(HomeAssistantError):
Expand Down
12 changes: 6 additions & 6 deletions tests/components/switcher_kis/test_cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ async def test_cover(

# Test set position
with patch(
"homeassistant.components.switcher_kis.cover.SwitcherType2Api.set_position"
"homeassistant.components.switcher_kis.cover.SwitcherApi.set_position"
) as mock_control_device:
await hass.services.async_call(
COVER_DOMAIN,
Expand All @@ -136,7 +136,7 @@ async def test_cover(

# Test open
with patch(
"homeassistant.components.switcher_kis.cover.SwitcherType2Api.set_position"
"homeassistant.components.switcher_kis.cover.SwitcherApi.set_position"
) as mock_control_device:
await hass.services.async_call(
COVER_DOMAIN,
Expand All @@ -156,7 +156,7 @@ async def test_cover(

# Test close
with patch(
"homeassistant.components.switcher_kis.cover.SwitcherType2Api.set_position"
"homeassistant.components.switcher_kis.cover.SwitcherApi.set_position"
) as mock_control_device:
await hass.services.async_call(
COVER_DOMAIN,
Expand All @@ -176,7 +176,7 @@ async def test_cover(

# Test stop
with patch(
"homeassistant.components.switcher_kis.cover.SwitcherType2Api.stop_shutter"
"homeassistant.components.switcher_kis.cover.SwitcherApi.stop_shutter"
) as mock_control_device:
await hass.services.async_call(
COVER_DOMAIN,
Expand Down Expand Up @@ -232,7 +232,7 @@ async def test_cover_control_fail(

# Test exception during set position
with patch(
"homeassistant.components.switcher_kis.cover.SwitcherType2Api.set_position",
"homeassistant.components.switcher_kis.cover.SwitcherApi.set_position",
side_effect=RuntimeError("fake error"),
) as mock_control_device:
with pytest.raises(HomeAssistantError):
Expand All @@ -257,7 +257,7 @@ async def test_cover_control_fail(

# Test error response during set position
with patch(
"homeassistant.components.switcher_kis.cover.SwitcherType2Api.set_position",
"homeassistant.components.switcher_kis.cover.SwitcherApi.set_position",
return_value=SwitcherBaseResponse(None),
) as mock_control_device:
with pytest.raises(HomeAssistantError):
Expand Down
8 changes: 4 additions & 4 deletions tests/components/switcher_kis/test_light.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ async def test_light(

# Test turning on light
with patch(
"homeassistant.components.switcher_kis.light.SwitcherType2Api.set_light",
"homeassistant.components.switcher_kis.light.SwitcherApi.set_light",
) as mock_set_light:
await hass.services.async_call(
LIGHT_DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: entity_id}, blocking=True
Expand All @@ -99,7 +99,7 @@ async def test_light(

# Test turning off light
with patch(
"homeassistant.components.switcher_kis.light.SwitcherType2Api.set_light"
"homeassistant.components.switcher_kis.light.SwitcherApi.set_light"
) as mock_set_light:
await hass.services.async_call(
LIGHT_DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: entity_id}, blocking=True
Expand Down Expand Up @@ -153,7 +153,7 @@ async def test_light_control_fail(

# Test exception during turn on
with patch(
"homeassistant.components.switcher_kis.cover.SwitcherType2Api.set_light",
"homeassistant.components.switcher_kis.cover.SwitcherApi.set_light",
side_effect=RuntimeError("fake error"),
) as mock_control_device:
with pytest.raises(HomeAssistantError):
Expand All @@ -178,7 +178,7 @@ async def test_light_control_fail(

# Test error response during turn on
with patch(
"homeassistant.components.switcher_kis.cover.SwitcherType2Api.set_light",
"homeassistant.components.switcher_kis.cover.SwitcherApi.set_light",
return_value=SwitcherBaseResponse(None),
) as mock_control_device:
with pytest.raises(HomeAssistantError):
Expand Down
6 changes: 3 additions & 3 deletions tests/components/switcher_kis/test_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ async def test_turn_on_with_timer_service(
assert state.state == STATE_OFF

with patch(
"homeassistant.components.switcher_kis.switch.SwitcherType1Api.control_device"
"homeassistant.components.switcher_kis.switch.SwitcherApi.control_device"
) as mock_control_device:
await hass.services.async_call(
DOMAIN,
Expand Down Expand Up @@ -78,7 +78,7 @@ async def test_set_auto_off_service(hass: HomeAssistant, mock_bridge, mock_api)
entity_id = f"{SWITCH_DOMAIN}.{slugify(device.name)}"

with patch(
"homeassistant.components.switcher_kis.switch.SwitcherType1Api.set_auto_shutdown"
"homeassistant.components.switcher_kis.switch.SwitcherApi.set_auto_shutdown"
) as mock_set_auto_shutdown:
await hass.services.async_call(
DOMAIN,
Expand All @@ -105,7 +105,7 @@ async def test_set_auto_off_service_fail(
entity_id = f"{SWITCH_DOMAIN}.{slugify(device.name)}"

with patch(
"homeassistant.components.switcher_kis.switch.SwitcherType1Api.set_auto_shutdown",
"homeassistant.components.switcher_kis.switch.SwitcherApi.set_auto_shutdown",
return_value=None,
) as mock_set_auto_shutdown:
await hass.services.async_call(
Expand Down
Loading

0 comments on commit 2cf3f2b

Please sign in to comment.