Bump aioswitcher to 3.4.3 (#118123)
This commit is contained in:
parent
5eeeb8c11f
commit
0ae5275f01
8 changed files with 32 additions and 23 deletions
|
@ -2,11 +2,13 @@
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import Callable
|
from collections.abc import Callable, Coroutine
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
|
from typing import Any, cast
|
||||||
|
|
||||||
from aioswitcher.api import (
|
from aioswitcher.api import (
|
||||||
DeviceState,
|
DeviceState,
|
||||||
|
SwitcherApi,
|
||||||
SwitcherBaseResponse,
|
SwitcherBaseResponse,
|
||||||
SwitcherType2Api,
|
SwitcherType2Api,
|
||||||
ThermostatSwing,
|
ThermostatSwing,
|
||||||
|
@ -34,7 +36,10 @@ from .utils import get_breeze_remote_manager
|
||||||
class SwitcherThermostatButtonEntityDescription(ButtonEntityDescription):
|
class SwitcherThermostatButtonEntityDescription(ButtonEntityDescription):
|
||||||
"""Class to describe a Switcher Thermostat Button entity."""
|
"""Class to describe a Switcher Thermostat Button entity."""
|
||||||
|
|
||||||
press_fn: Callable[[SwitcherType2Api, SwitcherBreezeRemote], SwitcherBaseResponse]
|
press_fn: Callable[
|
||||||
|
[SwitcherApi, SwitcherBreezeRemote],
|
||||||
|
Coroutine[Any, Any, SwitcherBaseResponse],
|
||||||
|
]
|
||||||
supported: Callable[[SwitcherBreezeRemote], bool]
|
supported: Callable[[SwitcherBreezeRemote], bool]
|
||||||
|
|
||||||
|
|
||||||
|
@ -85,9 +90,10 @@ async def async_setup_entry(
|
||||||
|
|
||||||
async def async_add_buttons(coordinator: SwitcherDataUpdateCoordinator) -> None:
|
async def async_add_buttons(coordinator: SwitcherDataUpdateCoordinator) -> None:
|
||||||
"""Get remote and add button from Switcher device."""
|
"""Get remote and add button from Switcher device."""
|
||||||
|
data = cast(SwitcherBreezeRemote, coordinator.data)
|
||||||
if coordinator.data.device_type.category == DeviceCategory.THERMOSTAT:
|
if coordinator.data.device_type.category == DeviceCategory.THERMOSTAT:
|
||||||
remote: SwitcherBreezeRemote = await hass.async_add_executor_job(
|
remote: SwitcherBreezeRemote = await hass.async_add_executor_job(
|
||||||
get_breeze_remote_manager(hass).get_remote, coordinator.data.remote_id
|
get_breeze_remote_manager(hass).get_remote, data.remote_id
|
||||||
)
|
)
|
||||||
async_add_entities(
|
async_add_entities(
|
||||||
SwitcherThermostatButtonEntity(coordinator, description, remote)
|
SwitcherThermostatButtonEntity(coordinator, description, remote)
|
||||||
|
@ -126,7 +132,7 @@ class SwitcherThermostatButtonEntity(
|
||||||
|
|
||||||
async def async_press(self) -> None:
|
async def async_press(self) -> None:
|
||||||
"""Press the button."""
|
"""Press the button."""
|
||||||
response: SwitcherBaseResponse = None
|
response: SwitcherBaseResponse | None = None
|
||||||
error = None
|
error = None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -9,6 +9,7 @@ from aioswitcher.api.remotes import SwitcherBreezeRemote
|
||||||
from aioswitcher.device import (
|
from aioswitcher.device import (
|
||||||
DeviceCategory,
|
DeviceCategory,
|
||||||
DeviceState,
|
DeviceState,
|
||||||
|
SwitcherThermostat,
|
||||||
ThermostatFanLevel,
|
ThermostatFanLevel,
|
||||||
ThermostatMode,
|
ThermostatMode,
|
||||||
ThermostatSwing,
|
ThermostatSwing,
|
||||||
|
@ -68,9 +69,10 @@ async def async_setup_entry(
|
||||||
|
|
||||||
async def async_add_climate(coordinator: SwitcherDataUpdateCoordinator) -> None:
|
async def async_add_climate(coordinator: SwitcherDataUpdateCoordinator) -> None:
|
||||||
"""Get remote and add climate from Switcher device."""
|
"""Get remote and add climate from Switcher device."""
|
||||||
|
data = cast(SwitcherThermostat, coordinator.data)
|
||||||
if coordinator.data.device_type.category == DeviceCategory.THERMOSTAT:
|
if coordinator.data.device_type.category == DeviceCategory.THERMOSTAT:
|
||||||
remote: SwitcherBreezeRemote = await hass.async_add_executor_job(
|
remote: SwitcherBreezeRemote = await hass.async_add_executor_job(
|
||||||
get_breeze_remote_manager(hass).get_remote, coordinator.data.remote_id
|
get_breeze_remote_manager(hass).get_remote, data.remote_id
|
||||||
)
|
)
|
||||||
async_add_entities([SwitcherClimateEntity(coordinator, remote)])
|
async_add_entities([SwitcherClimateEntity(coordinator, remote)])
|
||||||
|
|
||||||
|
@ -133,13 +135,13 @@ class SwitcherClimateEntity(
|
||||||
|
|
||||||
def _update_data(self, force_update: bool = False) -> None:
|
def _update_data(self, force_update: bool = False) -> None:
|
||||||
"""Update data from device."""
|
"""Update data from device."""
|
||||||
data = self.coordinator.data
|
data = cast(SwitcherThermostat, self.coordinator.data)
|
||||||
features = self._remote.modes_features[data.mode]
|
features = self._remote.modes_features[data.mode]
|
||||||
|
|
||||||
if data.target_temperature == 0 and not force_update:
|
if data.target_temperature == 0 and not force_update:
|
||||||
return
|
return
|
||||||
|
|
||||||
self._attr_current_temperature = cast(float, data.temperature)
|
self._attr_current_temperature = data.temperature
|
||||||
self._attr_target_temperature = float(data.target_temperature)
|
self._attr_target_temperature = float(data.target_temperature)
|
||||||
|
|
||||||
self._attr_hvac_mode = HVACMode.OFF
|
self._attr_hvac_mode = HVACMode.OFF
|
||||||
|
@ -162,7 +164,7 @@ class SwitcherClimateEntity(
|
||||||
|
|
||||||
async def _async_control_breeze_device(self, **kwargs: Any) -> None:
|
async def _async_control_breeze_device(self, **kwargs: Any) -> None:
|
||||||
"""Call Switcher Control Breeze API."""
|
"""Call Switcher Control Breeze API."""
|
||||||
response: SwitcherBaseResponse = None
|
response: SwitcherBaseResponse | None = None
|
||||||
error = None
|
error = None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -185,9 +187,8 @@ class SwitcherClimateEntity(
|
||||||
|
|
||||||
async def async_set_temperature(self, **kwargs: Any) -> None:
|
async def async_set_temperature(self, **kwargs: Any) -> None:
|
||||||
"""Set new target temperature."""
|
"""Set new target temperature."""
|
||||||
if not self._remote.modes_features[self.coordinator.data.mode][
|
data = cast(SwitcherThermostat, self.coordinator.data)
|
||||||
"temperature_control"
|
if not self._remote.modes_features[data.mode]["temperature_control"]:
|
||||||
]:
|
|
||||||
raise HomeAssistantError(
|
raise HomeAssistantError(
|
||||||
"Current mode doesn't support setting Target Temperature"
|
"Current mode doesn't support setting Target Temperature"
|
||||||
)
|
)
|
||||||
|
@ -199,7 +200,8 @@ class SwitcherClimateEntity(
|
||||||
|
|
||||||
async def async_set_fan_mode(self, fan_mode: str) -> None:
|
async def async_set_fan_mode(self, fan_mode: str) -> None:
|
||||||
"""Set new target fan mode."""
|
"""Set new target fan mode."""
|
||||||
if not self._remote.modes_features[self.coordinator.data.mode]["fan_levels"]:
|
data = cast(SwitcherThermostat, self.coordinator.data)
|
||||||
|
if not self._remote.modes_features[data.mode]["fan_levels"]:
|
||||||
raise HomeAssistantError("Current mode doesn't support setting Fan Mode")
|
raise HomeAssistantError("Current mode doesn't support setting Fan Mode")
|
||||||
|
|
||||||
await self._async_control_breeze_device(fan_level=HA_TO_DEVICE_FAN[fan_mode])
|
await self._async_control_breeze_device(fan_level=HA_TO_DEVICE_FAN[fan_mode])
|
||||||
|
@ -215,7 +217,8 @@ class SwitcherClimateEntity(
|
||||||
|
|
||||||
async def async_set_swing_mode(self, swing_mode: str) -> None:
|
async def async_set_swing_mode(self, swing_mode: str) -> None:
|
||||||
"""Set new target swing operation."""
|
"""Set new target swing operation."""
|
||||||
if not self._remote.modes_features[self.coordinator.data.mode]["swing"]:
|
data = cast(SwitcherThermostat, self.coordinator.data)
|
||||||
|
if not self._remote.modes_features[data.mode]["swing"]:
|
||||||
raise HomeAssistantError("Current mode doesn't support setting Swing Mode")
|
raise HomeAssistantError("Current mode doesn't support setting Swing Mode")
|
||||||
|
|
||||||
if swing_mode == SWING_VERTICAL:
|
if swing_mode == SWING_VERTICAL:
|
||||||
|
|
|
@ -45,17 +45,17 @@ class SwitcherDataUpdateCoordinator(
|
||||||
@property
|
@property
|
||||||
def model(self) -> str:
|
def model(self) -> str:
|
||||||
"""Switcher device model."""
|
"""Switcher device model."""
|
||||||
return self.data.device_type.value # type: ignore[no-any-return]
|
return self.data.device_type.value
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_id(self) -> str:
|
def device_id(self) -> str:
|
||||||
"""Switcher device id."""
|
"""Switcher device id."""
|
||||||
return self.data.device_id # type: ignore[no-any-return]
|
return self.data.device_id
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def mac_address(self) -> str:
|
def mac_address(self) -> str:
|
||||||
"""Switcher device mac address."""
|
"""Switcher device mac address."""
|
||||||
return self.data.mac_address # type: ignore[no-any-return]
|
return self.data.mac_address
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def async_setup(self) -> None:
|
def async_setup(self) -> None:
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
from typing import Any
|
from typing import Any, cast
|
||||||
|
|
||||||
from aioswitcher.api import SwitcherBaseResponse, SwitcherType2Api
|
from aioswitcher.api import SwitcherBaseResponse, SwitcherType2Api
|
||||||
from aioswitcher.device import DeviceCategory, ShutterDirection, SwitcherShutter
|
from aioswitcher.device import DeviceCategory, ShutterDirection, SwitcherShutter
|
||||||
|
@ -84,7 +84,7 @@ class SwitcherCoverEntity(
|
||||||
|
|
||||||
def _update_data(self) -> None:
|
def _update_data(self) -> None:
|
||||||
"""Update data from device."""
|
"""Update data from device."""
|
||||||
data: SwitcherShutter = self.coordinator.data
|
data = cast(SwitcherShutter, self.coordinator.data)
|
||||||
self._attr_current_cover_position = data.position
|
self._attr_current_cover_position = data.position
|
||||||
self._attr_is_closed = data.position == 0
|
self._attr_is_closed = data.position == 0
|
||||||
self._attr_is_closing = data.direction == ShutterDirection.SHUTTER_DOWN
|
self._attr_is_closing = data.direction == ShutterDirection.SHUTTER_DOWN
|
||||||
|
@ -93,7 +93,7 @@ class SwitcherCoverEntity(
|
||||||
async def _async_call_api(self, api: str, *args: Any) -> None:
|
async def _async_call_api(self, api: str, *args: Any) -> None:
|
||||||
"""Call Switcher API."""
|
"""Call Switcher API."""
|
||||||
_LOGGER.debug("Calling api for %s, api: '%s', args: %s", self.name, api, args)
|
_LOGGER.debug("Calling api for %s, api: '%s', args: %s", self.name, api, args)
|
||||||
response: SwitcherBaseResponse = None
|
response: SwitcherBaseResponse | None = None
|
||||||
error = None
|
error = None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -7,6 +7,6 @@
|
||||||
"iot_class": "local_push",
|
"iot_class": "local_push",
|
||||||
"loggers": ["aioswitcher"],
|
"loggers": ["aioswitcher"],
|
||||||
"quality_scale": "platinum",
|
"quality_scale": "platinum",
|
||||||
"requirements": ["aioswitcher==3.4.1"],
|
"requirements": ["aioswitcher==3.4.3"],
|
||||||
"single_config_entry": true
|
"single_config_entry": true
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,7 +111,7 @@ class SwitcherBaseSwitchEntity(
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
"Calling api for %s, api: '%s', args: %s", self.coordinator.name, api, args
|
"Calling api for %s, api: '%s', args: %s", self.coordinator.name, api, args
|
||||||
)
|
)
|
||||||
response: SwitcherBaseResponse = None
|
response: SwitcherBaseResponse | None = None
|
||||||
error = None
|
error = None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -371,7 +371,7 @@ aiosolaredge==0.2.0
|
||||||
aiosteamist==0.3.2
|
aiosteamist==0.3.2
|
||||||
|
|
||||||
# homeassistant.components.switcher_kis
|
# homeassistant.components.switcher_kis
|
||||||
aioswitcher==3.4.1
|
aioswitcher==3.4.3
|
||||||
|
|
||||||
# homeassistant.components.syncthing
|
# homeassistant.components.syncthing
|
||||||
aiosyncthing==0.5.1
|
aiosyncthing==0.5.1
|
||||||
|
|
|
@ -344,7 +344,7 @@ aiosolaredge==0.2.0
|
||||||
aiosteamist==0.3.2
|
aiosteamist==0.3.2
|
||||||
|
|
||||||
# homeassistant.components.switcher_kis
|
# homeassistant.components.switcher_kis
|
||||||
aioswitcher==3.4.1
|
aioswitcher==3.4.3
|
||||||
|
|
||||||
# homeassistant.components.syncthing
|
# homeassistant.components.syncthing
|
||||||
aiosyncthing==0.5.1
|
aiosyncthing==0.5.1
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue