Bump aioswitcher to 5.0.0 (#130874)

* Bump aioswitcher to 5.0.0

* fix linting
This commit is contained in:
YogevBokobza 2024-11-18 21:42:58 +02:00 committed by GitHub
parent e48857987b
commit 2cf3f2b243
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
15 changed files with 46 additions and 47 deletions

View File

@ -10,7 +10,6 @@ from aioswitcher.api import (
DeviceState, DeviceState,
SwitcherApi, SwitcherApi,
SwitcherBaseResponse, SwitcherBaseResponse,
SwitcherType2Api,
ThermostatSwing, ThermostatSwing,
) )
from aioswitcher.api.remotes import SwitcherBreezeRemote from aioswitcher.api.remotes import SwitcherBreezeRemote
@ -128,7 +127,7 @@ class SwitcherThermostatButtonEntity(SwitcherEntity, ButtonEntity):
error = None error = None
try: try:
async with SwitcherType2Api( async with SwitcherApi(
self.coordinator.data.device_type, self.coordinator.data.device_type,
self.coordinator.data.ip_address, self.coordinator.data.ip_address,
self.coordinator.data.device_id, self.coordinator.data.device_id,

View File

@ -4,7 +4,7 @@ from __future__ import annotations
from typing import Any, cast 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.api.remotes import SwitcherBreezeRemote
from aioswitcher.device import ( from aioswitcher.device import (
DeviceCategory, DeviceCategory,
@ -160,7 +160,7 @@ class SwitcherClimateEntity(SwitcherEntity, ClimateEntity):
error = None error = None
try: try:
async with SwitcherType2Api( async with SwitcherApi(
self.coordinator.data.device_type, self.coordinator.data.device_type,
self.coordinator.data.ip_address, self.coordinator.data.ip_address,
self.coordinator.data.device_id, self.coordinator.data.device_id,

View File

@ -5,7 +5,7 @@ from __future__ import annotations
import logging import logging
from typing import Any, cast 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 aioswitcher.device import DeviceCategory, ShutterDirection, SwitcherShutter
from homeassistant.components.cover import ( from homeassistant.components.cover import (
@ -99,7 +99,7 @@ class SwitcherBaseCoverEntity(SwitcherEntity, CoverEntity):
error = None error = None
try: try:
async with SwitcherType2Api( async with SwitcherApi(
self.coordinator.data.device_type, self.coordinator.data.device_type,
self.coordinator.data.ip_address, self.coordinator.data.ip_address,
self.coordinator.data.device_id, self.coordinator.data.device_id,

View File

@ -5,7 +5,7 @@ from __future__ import annotations
import logging import logging
from typing import Any, cast 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 aioswitcher.device import DeviceCategory, DeviceState, SwitcherLight
from homeassistant.components.light import ColorMode, LightEntity from homeassistant.components.light import ColorMode, LightEntity
@ -86,7 +86,7 @@ class SwitcherBaseLightEntity(SwitcherEntity, LightEntity):
error = None error = None
try: try:
async with SwitcherType2Api( async with SwitcherApi(
self.coordinator.data.device_type, self.coordinator.data.device_type,
self.coordinator.data.ip_address, self.coordinator.data.ip_address,
self.coordinator.data.device_id, self.coordinator.data.device_id,

View File

@ -7,6 +7,6 @@
"iot_class": "local_push", "iot_class": "local_push",
"loggers": ["aioswitcher"], "loggers": ["aioswitcher"],
"quality_scale": "platinum", "quality_scale": "platinum",
"requirements": ["aioswitcher==4.4.0"], "requirements": ["aioswitcher==5.0.0"],
"single_config_entry": true "single_config_entry": true
} }

View File

@ -6,7 +6,7 @@ from datetime import timedelta
import logging import logging
from typing import Any from typing import Any
from aioswitcher.api import Command, SwitcherBaseResponse, SwitcherType1Api from aioswitcher.api import Command, SwitcherApi, SwitcherBaseResponse
from aioswitcher.device import DeviceCategory, DeviceState from aioswitcher.device import DeviceCategory, DeviceState
import voluptuous as vol import voluptuous as vol
@ -105,7 +105,7 @@ class SwitcherBaseSwitchEntity(SwitcherEntity, SwitchEntity):
error = None error = None
try: try:
async with SwitcherType1Api( async with SwitcherApi(
self.coordinator.data.device_type, self.coordinator.data.device_type,
self.coordinator.data.ip_address, self.coordinator.data.ip_address,
self.coordinator.data.device_id, self.coordinator.data.device_id,

View File

@ -387,7 +387,7 @@ aiosteamist==1.0.0
aiostreammagic==2.8.5 aiostreammagic==2.8.5
# homeassistant.components.switcher_kis # homeassistant.components.switcher_kis
aioswitcher==4.4.0 aioswitcher==5.0.0
# homeassistant.components.syncthing # homeassistant.components.syncthing
aiosyncthing==0.5.1 aiosyncthing==0.5.1

View File

@ -369,7 +369,7 @@ aiosteamist==1.0.0
aiostreammagic==2.8.5 aiostreammagic==2.8.5
# homeassistant.components.switcher_kis # homeassistant.components.switcher_kis
aioswitcher==4.4.0 aioswitcher==5.0.0
# homeassistant.components.syncthing # homeassistant.components.syncthing
aiosyncthing==0.5.1 aiosyncthing==0.5.1

View File

@ -60,19 +60,19 @@ def mock_api():
patchers = [ patchers = [
patch( patch(
"homeassistant.components.switcher_kis.switch.SwitcherType1Api.connect", "homeassistant.components.switcher_kis.switch.SwitcherApi.connect",
new=api_mock, new=api_mock,
), ),
patch( patch(
"homeassistant.components.switcher_kis.switch.SwitcherType1Api.disconnect", "homeassistant.components.switcher_kis.switch.SwitcherApi.disconnect",
new=api_mock, new=api_mock,
), ),
patch( patch(
"homeassistant.components.switcher_kis.climate.SwitcherType2Api.connect", "homeassistant.components.switcher_kis.climate.SwitcherApi.connect",
new=api_mock, new=api_mock,
), ),
patch( patch(
"homeassistant.components.switcher_kis.climate.SwitcherType2Api.disconnect", "homeassistant.components.switcher_kis.climate.SwitcherApi.disconnect",
new=api_mock, new=api_mock,
), ),
] ]

View File

@ -42,7 +42,7 @@ async def test_assume_button(
assert hass.states.get(SWING_OFF_EID) is None assert hass.states.get(SWING_OFF_EID) is None
with patch( with patch(
"homeassistant.components.switcher_kis.climate.SwitcherType2Api.control_breeze_device", "homeassistant.components.switcher_kis.climate.SwitcherApi.control_breeze_device",
) as mock_control_device: ) as mock_control_device:
await hass.services.async_call( await hass.services.async_call(
BUTTON_DOMAIN, BUTTON_DOMAIN,
@ -79,7 +79,7 @@ async def test_swing_button(
assert hass.states.get(SWING_OFF_EID) is not None assert hass.states.get(SWING_OFF_EID) is not None
with patch( with patch(
"homeassistant.components.switcher_kis.climate.SwitcherType2Api.control_breeze_device", "homeassistant.components.switcher_kis.climate.SwitcherApi.control_breeze_device",
) as mock_control_device: ) as mock_control_device:
await hass.services.async_call( await hass.services.async_call(
BUTTON_DOMAIN, BUTTON_DOMAIN,
@ -103,7 +103,7 @@ async def test_control_device_fail(
# Test exception during set hvac mode # Test exception during set hvac mode
with patch( 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"), side_effect=RuntimeError("fake error"),
) as mock_control_device: ) as mock_control_device:
with pytest.raises(HomeAssistantError): with pytest.raises(HomeAssistantError):
@ -130,7 +130,7 @@ async def test_control_device_fail(
# Test error response during turn on # Test error response during turn on
with patch( with patch(
"homeassistant.components.switcher_kis.climate.SwitcherType2Api.control_breeze_device", "homeassistant.components.switcher_kis.climate.SwitcherApi.control_breeze_device",
return_value=SwitcherBaseResponse(None), return_value=SwitcherBaseResponse(None),
) as mock_control_device: ) as mock_control_device:
with pytest.raises(HomeAssistantError): with pytest.raises(HomeAssistantError):

View File

@ -49,7 +49,7 @@ async def test_climate_hvac_mode(
# Test set hvac mode heat # Test set hvac mode heat
with patch( with patch(
"homeassistant.components.switcher_kis.climate.SwitcherType2Api.control_breeze_device", "homeassistant.components.switcher_kis.climate.SwitcherApi.control_breeze_device",
) as mock_control_device: ) as mock_control_device:
await hass.services.async_call( await hass.services.async_call(
CLIMATE_DOMAIN, CLIMATE_DOMAIN,
@ -71,7 +71,7 @@ async def test_climate_hvac_mode(
# Test set hvac mode off # Test set hvac mode off
with patch( with patch(
"homeassistant.components.switcher_kis.climate.SwitcherType2Api.control_breeze_device", "homeassistant.components.switcher_kis.climate.SwitcherApi.control_breeze_device",
) as mock_control_device: ) as mock_control_device:
await hass.services.async_call( await hass.services.async_call(
CLIMATE_DOMAIN, CLIMATE_DOMAIN,
@ -108,7 +108,7 @@ async def test_climate_temperature(
# Test set target temperature # Test set target temperature
with patch( with patch(
"homeassistant.components.switcher_kis.climate.SwitcherType2Api.control_breeze_device", "homeassistant.components.switcher_kis.climate.SwitcherApi.control_breeze_device",
) as mock_control_device: ) as mock_control_device:
await hass.services.async_call( await hass.services.async_call(
CLIMATE_DOMAIN, CLIMATE_DOMAIN,
@ -128,7 +128,7 @@ async def test_climate_temperature(
# Test set target temperature - incorrect params # Test set target temperature - incorrect params
with patch( with patch(
"homeassistant.components.switcher_kis.climate.SwitcherType2Api.control_breeze_device", "homeassistant.components.switcher_kis.climate.SwitcherApi.control_breeze_device",
) as mock_control_device: ) as mock_control_device:
with pytest.raises(ServiceValidationError): with pytest.raises(ServiceValidationError):
await hass.services.async_call( await hass.services.async_call(
@ -160,7 +160,7 @@ async def test_climate_fan_level(
# Test set fan level to high # Test set fan level to high
with patch( with patch(
"homeassistant.components.switcher_kis.climate.SwitcherType2Api.control_breeze_device", "homeassistant.components.switcher_kis.climate.SwitcherApi.control_breeze_device",
) as mock_control_device: ) as mock_control_device:
await hass.services.async_call( await hass.services.async_call(
CLIMATE_DOMAIN, CLIMATE_DOMAIN,
@ -195,7 +195,7 @@ async def test_climate_swing(
# Test set swing mode on # Test set swing mode on
with patch( with patch(
"homeassistant.components.switcher_kis.climate.SwitcherType2Api.control_breeze_device", "homeassistant.components.switcher_kis.climate.SwitcherApi.control_breeze_device",
) as mock_control_device: ) as mock_control_device:
await hass.services.async_call( await hass.services.async_call(
CLIMATE_DOMAIN, CLIMATE_DOMAIN,
@ -218,7 +218,7 @@ async def test_climate_swing(
# Test set swing mode off # Test set swing mode off
with patch( with patch(
"homeassistant.components.switcher_kis.climate.SwitcherType2Api.control_breeze_device", "homeassistant.components.switcher_kis.climate.SwitcherApi.control_breeze_device",
) as mock_control_device: ) as mock_control_device:
await hass.services.async_call( await hass.services.async_call(
CLIMATE_DOMAIN, CLIMATE_DOMAIN,
@ -249,7 +249,7 @@ async def test_control_device_fail(hass: HomeAssistant, mock_bridge, mock_api) -
# Test exception during set hvac mode # Test exception during set hvac mode
with patch( 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"), side_effect=RuntimeError("fake error"),
) as mock_control_device: ) as mock_control_device:
with pytest.raises(HomeAssistantError): with pytest.raises(HomeAssistantError):
@ -276,7 +276,7 @@ async def test_control_device_fail(hass: HomeAssistant, mock_bridge, mock_api) -
# Test error response during turn on # Test error response during turn on
with patch( with patch(
"homeassistant.components.switcher_kis.climate.SwitcherType2Api.control_breeze_device", "homeassistant.components.switcher_kis.climate.SwitcherApi.control_breeze_device",
return_value=SwitcherBaseResponse(None), return_value=SwitcherBaseResponse(None),
) as mock_control_device: ) as mock_control_device:
with pytest.raises(HomeAssistantError): with pytest.raises(HomeAssistantError):

View File

@ -115,7 +115,7 @@ async def test_cover(
# Test set position # Test set position
with patch( with patch(
"homeassistant.components.switcher_kis.cover.SwitcherType2Api.set_position" "homeassistant.components.switcher_kis.cover.SwitcherApi.set_position"
) as mock_control_device: ) as mock_control_device:
await hass.services.async_call( await hass.services.async_call(
COVER_DOMAIN, COVER_DOMAIN,
@ -136,7 +136,7 @@ async def test_cover(
# Test open # Test open
with patch( with patch(
"homeassistant.components.switcher_kis.cover.SwitcherType2Api.set_position" "homeassistant.components.switcher_kis.cover.SwitcherApi.set_position"
) as mock_control_device: ) as mock_control_device:
await hass.services.async_call( await hass.services.async_call(
COVER_DOMAIN, COVER_DOMAIN,
@ -156,7 +156,7 @@ async def test_cover(
# Test close # Test close
with patch( with patch(
"homeassistant.components.switcher_kis.cover.SwitcherType2Api.set_position" "homeassistant.components.switcher_kis.cover.SwitcherApi.set_position"
) as mock_control_device: ) as mock_control_device:
await hass.services.async_call( await hass.services.async_call(
COVER_DOMAIN, COVER_DOMAIN,
@ -176,7 +176,7 @@ async def test_cover(
# Test stop # Test stop
with patch( with patch(
"homeassistant.components.switcher_kis.cover.SwitcherType2Api.stop_shutter" "homeassistant.components.switcher_kis.cover.SwitcherApi.stop_shutter"
) as mock_control_device: ) as mock_control_device:
await hass.services.async_call( await hass.services.async_call(
COVER_DOMAIN, COVER_DOMAIN,
@ -232,7 +232,7 @@ async def test_cover_control_fail(
# Test exception during set position # Test exception during set position
with patch( with patch(
"homeassistant.components.switcher_kis.cover.SwitcherType2Api.set_position", "homeassistant.components.switcher_kis.cover.SwitcherApi.set_position",
side_effect=RuntimeError("fake error"), side_effect=RuntimeError("fake error"),
) as mock_control_device: ) as mock_control_device:
with pytest.raises(HomeAssistantError): with pytest.raises(HomeAssistantError):
@ -257,7 +257,7 @@ async def test_cover_control_fail(
# Test error response during set position # Test error response during set position
with patch( with patch(
"homeassistant.components.switcher_kis.cover.SwitcherType2Api.set_position", "homeassistant.components.switcher_kis.cover.SwitcherApi.set_position",
return_value=SwitcherBaseResponse(None), return_value=SwitcherBaseResponse(None),
) as mock_control_device: ) as mock_control_device:
with pytest.raises(HomeAssistantError): with pytest.raises(HomeAssistantError):

View File

@ -86,7 +86,7 @@ async def test_light(
# Test turning on light # Test turning on light
with patch( with patch(
"homeassistant.components.switcher_kis.light.SwitcherType2Api.set_light", "homeassistant.components.switcher_kis.light.SwitcherApi.set_light",
) as mock_set_light: ) as mock_set_light:
await hass.services.async_call( await hass.services.async_call(
LIGHT_DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: entity_id}, blocking=True LIGHT_DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: entity_id}, blocking=True
@ -99,7 +99,7 @@ async def test_light(
# Test turning off light # Test turning off light
with patch( with patch(
"homeassistant.components.switcher_kis.light.SwitcherType2Api.set_light" "homeassistant.components.switcher_kis.light.SwitcherApi.set_light"
) as mock_set_light: ) as mock_set_light:
await hass.services.async_call( await hass.services.async_call(
LIGHT_DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: entity_id}, blocking=True LIGHT_DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: entity_id}, blocking=True
@ -153,7 +153,7 @@ async def test_light_control_fail(
# Test exception during turn on # Test exception during turn on
with patch( with patch(
"homeassistant.components.switcher_kis.cover.SwitcherType2Api.set_light", "homeassistant.components.switcher_kis.cover.SwitcherApi.set_light",
side_effect=RuntimeError("fake error"), side_effect=RuntimeError("fake error"),
) as mock_control_device: ) as mock_control_device:
with pytest.raises(HomeAssistantError): with pytest.raises(HomeAssistantError):
@ -178,7 +178,7 @@ async def test_light_control_fail(
# Test error response during turn on # Test error response during turn on
with patch( with patch(
"homeassistant.components.switcher_kis.cover.SwitcherType2Api.set_light", "homeassistant.components.switcher_kis.cover.SwitcherApi.set_light",
return_value=SwitcherBaseResponse(None), return_value=SwitcherBaseResponse(None),
) as mock_control_device: ) as mock_control_device:
with pytest.raises(HomeAssistantError): with pytest.raises(HomeAssistantError):

View File

@ -48,7 +48,7 @@ async def test_turn_on_with_timer_service(
assert state.state == STATE_OFF assert state.state == STATE_OFF
with patch( with patch(
"homeassistant.components.switcher_kis.switch.SwitcherType1Api.control_device" "homeassistant.components.switcher_kis.switch.SwitcherApi.control_device"
) as mock_control_device: ) as mock_control_device:
await hass.services.async_call( await hass.services.async_call(
DOMAIN, DOMAIN,
@ -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)}" entity_id = f"{SWITCH_DOMAIN}.{slugify(device.name)}"
with patch( 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: ) as mock_set_auto_shutdown:
await hass.services.async_call( await hass.services.async_call(
DOMAIN, DOMAIN,
@ -105,7 +105,7 @@ async def test_set_auto_off_service_fail(
entity_id = f"{SWITCH_DOMAIN}.{slugify(device.name)}" entity_id = f"{SWITCH_DOMAIN}.{slugify(device.name)}"
with patch( with patch(
"homeassistant.components.switcher_kis.switch.SwitcherType1Api.set_auto_shutdown", "homeassistant.components.switcher_kis.switch.SwitcherApi.set_auto_shutdown",
return_value=None, return_value=None,
) as mock_set_auto_shutdown: ) as mock_set_auto_shutdown:
await hass.services.async_call( await hass.services.async_call(

View File

@ -47,7 +47,7 @@ async def test_switch(
# Test turning on # Test turning on
with patch( with patch(
"homeassistant.components.switcher_kis.switch.SwitcherType1Api.control_device", "homeassistant.components.switcher_kis.switch.SwitcherApi.control_device",
) as mock_control_device: ) as mock_control_device:
await hass.services.async_call( await hass.services.async_call(
SWITCH_DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: entity_id}, blocking=True SWITCH_DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: entity_id}, blocking=True
@ -60,7 +60,7 @@ async def test_switch(
# Test turning off # Test turning off
with patch( with patch(
"homeassistant.components.switcher_kis.switch.SwitcherType1Api.control_device" "homeassistant.components.switcher_kis.switch.SwitcherApi.control_device"
) as mock_control_device: ) as mock_control_device:
await hass.services.async_call( await hass.services.async_call(
SWITCH_DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: entity_id}, blocking=True SWITCH_DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: entity_id}, blocking=True
@ -97,7 +97,7 @@ async def test_switch_control_fail(
# Test exception during turn on # Test exception during turn on
with patch( with patch(
"homeassistant.components.switcher_kis.switch.SwitcherType1Api.control_device", "homeassistant.components.switcher_kis.switch.SwitcherApi.control_device",
side_effect=RuntimeError("fake error"), side_effect=RuntimeError("fake error"),
) as mock_control_device: ) as mock_control_device:
await hass.services.async_call( await hass.services.async_call(
@ -121,7 +121,7 @@ async def test_switch_control_fail(
# Test error response during turn on # Test error response during turn on
with patch( with patch(
"homeassistant.components.switcher_kis.switch.SwitcherType1Api.control_device", "homeassistant.components.switcher_kis.switch.SwitcherApi.control_device",
return_value=SwitcherBaseResponse(None), return_value=SwitcherBaseResponse(None),
) as mock_control_device: ) as mock_control_device:
await hass.services.async_call( await hass.services.async_call(