mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 16:57:10 +00:00
Bump pyswitchbee to 1.7.3 (#83748)
This commit is contained in:
parent
b8a5869f76
commit
2d206e7e31
@ -2,7 +2,8 @@
|
|||||||
|
|
||||||
from __future__ import annotations
|
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.config_entries import ConfigEntry
|
||||||
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME, Platform
|
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]
|
user = entry.data[CONF_USERNAME]
|
||||||
password = entry.data[CONF_PASSWORD]
|
password = entry.data[CONF_PASSWORD]
|
||||||
websession = async_get_clientsession(hass, verify_ssl=False)
|
websession = async_get_clientsession(hass, verify_ssl=False)
|
||||||
api = CentralUnitAPI(central_unit, user, password, websession)
|
api = CentralUnitPolling(central_unit, user, password, websession)
|
||||||
try:
|
try:
|
||||||
await api.connect()
|
await api.connect()
|
||||||
except SwitchBeeError as exp:
|
except SwitchBeeError as exp:
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
"""Support for SwitchBee scenario button."""
|
"""Support for SwitchBee scenario button."""
|
||||||
|
|
||||||
from switchbee.api import SwitchBeeError
|
from switchbee.api.central_unit import SwitchBeeError
|
||||||
from switchbee.device import ApiStateCommand, DeviceType
|
from switchbee.device import ApiStateCommand, DeviceType
|
||||||
|
|
||||||
from homeassistant.components.button import ButtonEntity
|
from homeassistant.components.button import ButtonEntity
|
||||||
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from switchbee.api import SwitchBeeDeviceOfflineError, SwitchBeeError
|
from switchbee.api.central_unit import SwitchBeeDeviceOfflineError, SwitchBeeError
|
||||||
from switchbee.const import (
|
from switchbee.const import (
|
||||||
ApiAttribute,
|
ApiAttribute,
|
||||||
ThermostatFanSpeed,
|
ThermostatFanSpeed,
|
||||||
|
@ -4,7 +4,8 @@ from __future__ import annotations
|
|||||||
import logging
|
import logging
|
||||||
from typing import Any
|
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
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import config_entries
|
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."""
|
"""Validate the user input allows us to connect."""
|
||||||
|
|
||||||
websession = async_get_clientsession(hass, verify_ssl=False)
|
websession = async_get_clientsession(hass, verify_ssl=False)
|
||||||
api = CentralUnitAPI(
|
api = CentralUnitPolling(
|
||||||
data[CONF_HOST], data[CONF_USERNAME], data[CONF_PASSWORD], websession
|
data[CONF_HOST], data[CONF_USERNAME], data[CONF_PASSWORD], websession
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
|
@ -6,7 +6,8 @@ from collections.abc import Mapping
|
|||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
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 switchbee.device import DeviceType, SwitchBeeBaseDevice
|
||||||
|
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
@ -24,10 +25,10 @@ class SwitchBeeCoordinator(DataUpdateCoordinator[Mapping[int, SwitchBeeBaseDevic
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
swb_api: CentralUnitAPI,
|
swb_api: CentralUnitPolling,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize."""
|
"""Initialize."""
|
||||||
self.api: CentralUnitAPI = swb_api
|
self.api: CentralUnitPolling = swb_api
|
||||||
self._reconnect_counts: int = 0
|
self._reconnect_counts: int = 0
|
||||||
self.mac_formatted: str | None = (
|
self.mac_formatted: str | None = (
|
||||||
None if self.api.mac is None else format_mac(self.api.mac)
|
None if self.api.mac is None else format_mac(self.api.mac)
|
||||||
|
@ -4,7 +4,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from typing import Any
|
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.const import SomfyCommand
|
||||||
from switchbee.device import SwitchBeeShutter, SwitchBeeSomfy
|
from switchbee.device import SwitchBeeShutter, SwitchBeeSomfy
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ import logging
|
|||||||
from typing import Generic, TypeVar, cast
|
from typing import Generic, TypeVar, cast
|
||||||
|
|
||||||
from switchbee import SWITCHBEE_BRAND
|
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 switchbee.device import DeviceType, SwitchBeeBaseDevice
|
||||||
|
|
||||||
from homeassistant.helpers.entity import DeviceInfo
|
from homeassistant.helpers.entity import DeviceInfo
|
||||||
|
@ -4,7 +4,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from typing import Any
|
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 switchbee.device import ApiStateCommand, DeviceType, SwitchBeeDimmer
|
||||||
|
|
||||||
from homeassistant.components.light import ATTR_BRIGHTNESS, ColorMode, LightEntity
|
from homeassistant.components.light import ATTR_BRIGHTNESS, ColorMode, LightEntity
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
"name": "SwitchBee",
|
"name": "SwitchBee",
|
||||||
"config_flow": true,
|
"config_flow": true,
|
||||||
"documentation": "https://www.home-assistant.io/integrations/switchbee",
|
"documentation": "https://www.home-assistant.io/integrations/switchbee",
|
||||||
"requirements": ["pyswitchbee==1.6.1"],
|
"requirements": ["pyswitchbee==1.7.3"],
|
||||||
"codeowners": ["@jafar-atili"],
|
"codeowners": ["@jafar-atili"],
|
||||||
"iot_class": "local_polling"
|
"iot_class": "local_polling"
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from typing import Any, TypeVar, Union
|
from typing import Any, TypeVar, Union
|
||||||
|
|
||||||
from switchbee.api import SwitchBeeDeviceOfflineError, SwitchBeeError
|
from switchbee.api.central_unit import SwitchBeeDeviceOfflineError, SwitchBeeError
|
||||||
from switchbee.device import (
|
from switchbee.device import (
|
||||||
ApiStateCommand,
|
ApiStateCommand,
|
||||||
SwitchBeeGroupSwitch,
|
SwitchBeeGroupSwitch,
|
||||||
|
@ -1956,7 +1956,7 @@ pystiebeleltron==0.0.1.dev2
|
|||||||
pysuez==0.1.19
|
pysuez==0.1.19
|
||||||
|
|
||||||
# homeassistant.components.switchbee
|
# homeassistant.components.switchbee
|
||||||
pyswitchbee==1.6.1
|
pyswitchbee==1.7.3
|
||||||
|
|
||||||
# homeassistant.components.syncthru
|
# homeassistant.components.syncthru
|
||||||
pysyncthru==0.7.10
|
pysyncthru==0.7.10
|
||||||
|
@ -1385,7 +1385,7 @@ pyspcwebgw==0.4.0
|
|||||||
pysqueezebox==0.6.1
|
pysqueezebox==0.6.1
|
||||||
|
|
||||||
# homeassistant.components.switchbee
|
# homeassistant.components.switchbee
|
||||||
pyswitchbee==1.6.1
|
pyswitchbee==1.7.3
|
||||||
|
|
||||||
# homeassistant.components.syncthru
|
# homeassistant.components.syncthru
|
||||||
pysyncthru==0.7.10
|
pysyncthru==0.7.10
|
||||||
|
@ -25,15 +25,15 @@ async def test_form(hass):
|
|||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
"switchbee.api.CentralUnitAPI.get_configuration",
|
"switchbee.api.polling.CentralUnitPolling.get_configuration",
|
||||||
return_value=coordinator_data,
|
return_value=coordinator_data,
|
||||||
), patch(
|
), patch(
|
||||||
"homeassistant.components.switchbee.async_setup_entry",
|
"homeassistant.components.switchbee.async_setup_entry",
|
||||||
return_value=True,
|
return_value=True,
|
||||||
), patch(
|
), patch(
|
||||||
"switchbee.api.CentralUnitAPI.fetch_states", return_value=None
|
"switchbee.api.polling.CentralUnitPolling.fetch_states", return_value=None
|
||||||
), patch(
|
), patch(
|
||||||
"switchbee.api.CentralUnitAPI._login", return_value=None
|
"switchbee.api.polling.CentralUnitPolling._login", return_value=None
|
||||||
):
|
):
|
||||||
|
|
||||||
result2 = await hass.config_entries.flow.async_configure(
|
result2 = await hass.config_entries.flow.async_configure(
|
||||||
@ -62,7 +62,7 @@ async def test_form_invalid_auth(hass: HomeAssistant) -> None:
|
|||||||
)
|
)
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
"switchbee.api.CentralUnitAPI._login",
|
"switchbee.api.polling.CentralUnitPolling._login",
|
||||||
side_effect=SwitchBeeError(MOCK_FAILED_TO_LOGIN_MSG),
|
side_effect=SwitchBeeError(MOCK_FAILED_TO_LOGIN_MSG),
|
||||||
):
|
):
|
||||||
result2 = await hass.config_entries.flow.async_configure(
|
result2 = await hass.config_entries.flow.async_configure(
|
||||||
@ -86,7 +86,7 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None:
|
|||||||
)
|
)
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
"switchbee.api.CentralUnitAPI._login",
|
"switchbee.api.polling.CentralUnitPolling._login",
|
||||||
side_effect=SwitchBeeError(MOCK_INVALID_TOKEN_MGS),
|
side_effect=SwitchBeeError(MOCK_INVALID_TOKEN_MGS),
|
||||||
):
|
):
|
||||||
result2 = await hass.config_entries.flow.async_configure(
|
result2 = await hass.config_entries.flow.async_configure(
|
||||||
@ -109,7 +109,7 @@ async def test_form_unknown_error(hass):
|
|||||||
)
|
)
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
"switchbee.api.CentralUnitAPI._login",
|
"switchbee.api.polling.CentralUnitPolling._login",
|
||||||
side_effect=Exception,
|
side_effect=Exception,
|
||||||
):
|
):
|
||||||
form_result = await hass.config_entries.flow.async_configure(
|
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}
|
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",
|
"homeassistant.components.switchbee.async_setup_entry",
|
||||||
return_value=True,
|
return_value=True,
|
||||||
), patch(
|
), patch(
|
||||||
"switchbee.api.CentralUnitAPI.get_configuration",
|
"switchbee.api.polling.CentralUnitPolling.get_configuration",
|
||||||
return_value=coordinator_data,
|
return_value=coordinator_data,
|
||||||
), patch(
|
), 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(
|
form_result = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user