Bump pyswitchbee to 1.7.3 (#83748)

This commit is contained in:
Jafar Atili 2022-12-12 17:00:30 +02:00 committed by GitHub
parent b8a5869f76
commit 2d206e7e31
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 30 additions and 25 deletions

View file

@ -2,7 +2,8 @@
from __future__ import annotations
from switchbee.api import CentralUnitAPI, SwitchBeeError
from switchbee.api.central_unit import SwitchBeeError
from switchbee.api.polling import CentralUnitPolling
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME, Platform
@ -29,7 +30,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
user = entry.data[CONF_USERNAME]
password = entry.data[CONF_PASSWORD]
websession = async_get_clientsession(hass, verify_ssl=False)
api = CentralUnitAPI(central_unit, user, password, websession)
api = CentralUnitPolling(central_unit, user, password, websession)
try:
await api.connect()
except SwitchBeeError as exp:

View file

@ -1,6 +1,6 @@
"""Support for SwitchBee scenario button."""
from switchbee.api import SwitchBeeError
from switchbee.api.central_unit import SwitchBeeError
from switchbee.device import ApiStateCommand, DeviceType
from homeassistant.components.button import ButtonEntity

View file

@ -3,7 +3,7 @@ from __future__ import annotations
from typing import Any
from switchbee.api import SwitchBeeDeviceOfflineError, SwitchBeeError
from switchbee.api.central_unit import SwitchBeeDeviceOfflineError, SwitchBeeError
from switchbee.const import (
ApiAttribute,
ThermostatFanSpeed,

View file

@ -4,7 +4,8 @@ from __future__ import annotations
import logging
from typing import Any
from switchbee.api import CentralUnitAPI, SwitchBeeError
from switchbee.api.central_unit import SwitchBeeError
from switchbee.api.polling import CentralUnitPolling
import voluptuous as vol
from homeassistant import config_entries
@ -33,7 +34,7 @@ async def validate_input(hass: HomeAssistant, data: dict[str, Any]) -> str:
"""Validate the user input allows us to connect."""
websession = async_get_clientsession(hass, verify_ssl=False)
api = CentralUnitAPI(
api = CentralUnitPolling(
data[CONF_HOST], data[CONF_USERNAME], data[CONF_PASSWORD], websession
)
try:

View file

@ -6,7 +6,8 @@ from collections.abc import Mapping
from datetime import timedelta
import logging
from switchbee.api import CentralUnitAPI, SwitchBeeError
from switchbee.api.central_unit import SwitchBeeError
from switchbee.api.polling import CentralUnitPolling
from switchbee.device import DeviceType, SwitchBeeBaseDevice
from homeassistant.core import HomeAssistant
@ -24,10 +25,10 @@ class SwitchBeeCoordinator(DataUpdateCoordinator[Mapping[int, SwitchBeeBaseDevic
def __init__(
self,
hass: HomeAssistant,
swb_api: CentralUnitAPI,
swb_api: CentralUnitPolling,
) -> None:
"""Initialize."""
self.api: CentralUnitAPI = swb_api
self.api: CentralUnitPolling = swb_api
self._reconnect_counts: int = 0
self.mac_formatted: str | None = (
None if self.api.mac is None else format_mac(self.api.mac)

View file

@ -4,7 +4,7 @@ from __future__ import annotations
from typing import Any
from switchbee.api import SwitchBeeError, SwitchBeeTokenError
from switchbee.api.central_unit import SwitchBeeError, SwitchBeeTokenError
from switchbee.const import SomfyCommand
from switchbee.device import SwitchBeeShutter, SwitchBeeSomfy

View file

@ -3,7 +3,7 @@ import logging
from typing import Generic, TypeVar, cast
from switchbee import SWITCHBEE_BRAND
from switchbee.api import SwitchBeeDeviceOfflineError, SwitchBeeError
from switchbee.api.central_unit import SwitchBeeDeviceOfflineError, SwitchBeeError
from switchbee.device import DeviceType, SwitchBeeBaseDevice
from homeassistant.helpers.entity import DeviceInfo

View file

@ -4,7 +4,7 @@ from __future__ import annotations
from typing import Any
from switchbee.api import SwitchBeeDeviceOfflineError, SwitchBeeError
from switchbee.api.central_unit import SwitchBeeDeviceOfflineError, SwitchBeeError
from switchbee.device import ApiStateCommand, DeviceType, SwitchBeeDimmer
from homeassistant.components.light import ATTR_BRIGHTNESS, ColorMode, LightEntity

View file

@ -3,7 +3,7 @@
"name": "SwitchBee",
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/switchbee",
"requirements": ["pyswitchbee==1.6.1"],
"requirements": ["pyswitchbee==1.7.3"],
"codeowners": ["@jafar-atili"],
"iot_class": "local_polling"
}

View file

@ -4,7 +4,7 @@ from __future__ import annotations
from typing import Any, TypeVar, Union
from switchbee.api import SwitchBeeDeviceOfflineError, SwitchBeeError
from switchbee.api.central_unit import SwitchBeeDeviceOfflineError, SwitchBeeError
from switchbee.device import (
ApiStateCommand,
SwitchBeeGroupSwitch,

View file

@ -1956,7 +1956,7 @@ pystiebeleltron==0.0.1.dev2
pysuez==0.1.19
# homeassistant.components.switchbee
pyswitchbee==1.6.1
pyswitchbee==1.7.3
# homeassistant.components.syncthru
pysyncthru==0.7.10

View file

@ -1385,7 +1385,7 @@ pyspcwebgw==0.4.0
pysqueezebox==0.6.1
# homeassistant.components.switchbee
pyswitchbee==1.6.1
pyswitchbee==1.7.3
# homeassistant.components.syncthru
pysyncthru==0.7.10

View file

@ -25,15 +25,15 @@ async def test_form(hass):
assert result["errors"] == {}
with patch(
"switchbee.api.CentralUnitAPI.get_configuration",
"switchbee.api.polling.CentralUnitPolling.get_configuration",
return_value=coordinator_data,
), patch(
"homeassistant.components.switchbee.async_setup_entry",
return_value=True,
), patch(
"switchbee.api.CentralUnitAPI.fetch_states", return_value=None
"switchbee.api.polling.CentralUnitPolling.fetch_states", return_value=None
), patch(
"switchbee.api.CentralUnitAPI._login", return_value=None
"switchbee.api.polling.CentralUnitPolling._login", return_value=None
):
result2 = await hass.config_entries.flow.async_configure(
@ -62,7 +62,7 @@ async def test_form_invalid_auth(hass: HomeAssistant) -> None:
)
with patch(
"switchbee.api.CentralUnitAPI._login",
"switchbee.api.polling.CentralUnitPolling._login",
side_effect=SwitchBeeError(MOCK_FAILED_TO_LOGIN_MSG),
):
result2 = await hass.config_entries.flow.async_configure(
@ -86,7 +86,7 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None:
)
with patch(
"switchbee.api.CentralUnitAPI._login",
"switchbee.api.polling.CentralUnitPolling._login",
side_effect=SwitchBeeError(MOCK_INVALID_TOKEN_MGS),
):
result2 = await hass.config_entries.flow.async_configure(
@ -109,7 +109,7 @@ async def test_form_unknown_error(hass):
)
with patch(
"switchbee.api.CentralUnitAPI._login",
"switchbee.api.polling.CentralUnitPolling._login",
side_effect=Exception,
):
form_result = await hass.config_entries.flow.async_configure(
@ -144,14 +144,16 @@ async def test_form_entry_exists(hass):
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
with patch("switchbee.api.CentralUnitAPI._login", return_value=None), patch(
with patch(
"switchbee.api.polling.CentralUnitPolling._login", return_value=None
), patch(
"homeassistant.components.switchbee.async_setup_entry",
return_value=True,
), patch(
"switchbee.api.CentralUnitAPI.get_configuration",
"switchbee.api.polling.CentralUnitPolling.get_configuration",
return_value=coordinator_data,
), patch(
"switchbee.api.CentralUnitAPI.fetch_states", return_value=None
"switchbee.api.polling.CentralUnitPolling.fetch_states", return_value=None
):
form_result = await hass.config_entries.flow.async_configure(
result["flow_id"],