mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Bump tololib to 1.1.0 (#113268)
* upgrade tololib dependency to v1.0.0 * use latest available patch version * fixed tolo tests * fixed test cases
This commit is contained in:
parent
1fd447f65b
commit
6a1913b372
@ -6,9 +6,7 @@ from datetime import timedelta
|
||||
import logging
|
||||
from typing import NamedTuple
|
||||
|
||||
from tololib import ToloClient
|
||||
from tololib.errors import ResponseTimedOutError
|
||||
from tololib.message_info import SettingsInfo, StatusInfo
|
||||
from tololib import ToloClient, ToloSettings, ToloStatus
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_HOST, Platform
|
||||
@ -59,8 +57,8 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
class ToloSaunaData(NamedTuple):
|
||||
"""Compound class for reflecting full state (status and info) of a TOLO Sauna."""
|
||||
|
||||
status: StatusInfo
|
||||
settings: SettingsInfo
|
||||
status: ToloStatus
|
||||
settings: ToloSettings
|
||||
|
||||
|
||||
class ToloSaunaUpdateCoordinator(DataUpdateCoordinator[ToloSaunaData]): # pylint: disable=hass-enforce-coordinator-module
|
||||
@ -68,7 +66,11 @@ class ToloSaunaUpdateCoordinator(DataUpdateCoordinator[ToloSaunaData]): # pylin
|
||||
|
||||
def __init__(self, hass: HomeAssistant, entry: ConfigEntry) -> None:
|
||||
"""Initialize ToloSaunaUpdateCoordinator."""
|
||||
self.client = ToloClient(entry.data[CONF_HOST])
|
||||
self.client = ToloClient(
|
||||
address=entry.data[CONF_HOST],
|
||||
retry_timeout=DEFAULT_RETRY_TIMEOUT,
|
||||
retry_count=DEFAULT_RETRY_COUNT,
|
||||
)
|
||||
super().__init__(
|
||||
hass=hass,
|
||||
logger=_LOGGER,
|
||||
@ -81,13 +83,9 @@ class ToloSaunaUpdateCoordinator(DataUpdateCoordinator[ToloSaunaData]): # pylin
|
||||
|
||||
def _get_tolo_sauna_data(self) -> ToloSaunaData:
|
||||
try:
|
||||
status = self.client.get_status_info(
|
||||
resend_timeout=DEFAULT_RETRY_TIMEOUT, retries=DEFAULT_RETRY_COUNT
|
||||
)
|
||||
settings = self.client.get_settings_info(
|
||||
resend_timeout=DEFAULT_RETRY_TIMEOUT, retries=DEFAULT_RETRY_COUNT
|
||||
)
|
||||
except ResponseTimedOutError as error:
|
||||
status = self.client.get_status()
|
||||
settings = self.client.get_settings()
|
||||
except TimeoutError as error:
|
||||
raise UpdateFailed("communication timeout") from error
|
||||
return ToloSaunaData(status, settings)
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
"""TOLO Sauna Button controls."""
|
||||
|
||||
from tololib.const import LampMode
|
||||
from tololib import LampMode
|
||||
|
||||
from homeassistant.components.button import ButtonEntity
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
|
@ -4,7 +4,13 @@ from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from tololib.const import Calefaction
|
||||
from tololib import (
|
||||
TARGET_HUMIDITY_MAX,
|
||||
TARGET_HUMIDITY_MIN,
|
||||
TARGET_TEMPERATURE_MAX,
|
||||
TARGET_TEMPERATURE_MIN,
|
||||
Calefaction,
|
||||
)
|
||||
|
||||
from homeassistant.components.climate import (
|
||||
FAN_OFF,
|
||||
@ -20,13 +26,7 @@ from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from . import ToloSaunaCoordinatorEntity, ToloSaunaUpdateCoordinator
|
||||
from .const import (
|
||||
DEFAULT_MAX_HUMIDITY,
|
||||
DEFAULT_MAX_TEMP,
|
||||
DEFAULT_MIN_HUMIDITY,
|
||||
DEFAULT_MIN_TEMP,
|
||||
DOMAIN,
|
||||
)
|
||||
from .const import DOMAIN
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
@ -44,10 +44,10 @@ class SaunaClimate(ToloSaunaCoordinatorEntity, ClimateEntity):
|
||||
|
||||
_attr_fan_modes = [FAN_ON, FAN_OFF]
|
||||
_attr_hvac_modes = [HVACMode.OFF, HVACMode.HEAT, HVACMode.DRY]
|
||||
_attr_max_humidity = DEFAULT_MAX_HUMIDITY
|
||||
_attr_max_temp = DEFAULT_MAX_TEMP
|
||||
_attr_min_humidity = DEFAULT_MIN_HUMIDITY
|
||||
_attr_min_temp = DEFAULT_MIN_TEMP
|
||||
_attr_max_humidity = TARGET_HUMIDITY_MAX
|
||||
_attr_max_temp = TARGET_TEMPERATURE_MAX
|
||||
_attr_min_humidity = TARGET_HUMIDITY_MIN
|
||||
_attr_min_temp = TARGET_TEMPERATURE_MIN
|
||||
_attr_name = None
|
||||
_attr_precision = PRECISION_WHOLE
|
||||
_attr_supported_features = (
|
||||
|
@ -5,8 +5,7 @@ from __future__ import annotations
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
from tololib import ToloClient
|
||||
from tololib.errors import ResponseTimedOutError
|
||||
from tololib import ToloClient, ToloCommunicationError
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components import dhcp
|
||||
@ -14,7 +13,7 @@ from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.const import CONF_HOST
|
||||
from homeassistant.helpers.device_registry import format_mac
|
||||
|
||||
from .const import DEFAULT_NAME, DEFAULT_RETRY_COUNT, DEFAULT_RETRY_TIMEOUT, DOMAIN
|
||||
from .const import DEFAULT_NAME, DOMAIN
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@ -30,10 +29,8 @@ class ToloSaunaConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
def _check_device_availability(host: str) -> bool:
|
||||
client = ToloClient(host)
|
||||
try:
|
||||
result = client.get_status_info(
|
||||
resend_timeout=DEFAULT_RETRY_TIMEOUT, retries=DEFAULT_RETRY_COUNT
|
||||
)
|
||||
except ResponseTimedOutError:
|
||||
result = client.get_status()
|
||||
except ToloCommunicationError:
|
||||
return False
|
||||
return result is not None
|
||||
|
||||
|
@ -5,13 +5,3 @@ DEFAULT_NAME = "TOLO Sauna"
|
||||
|
||||
DEFAULT_RETRY_TIMEOUT = 1
|
||||
DEFAULT_RETRY_COUNT = 3
|
||||
|
||||
DEFAULT_MAX_TEMP = 60
|
||||
DEFAULT_MIN_TEMP = 20
|
||||
|
||||
DEFAULT_MAX_HUMIDITY = 99
|
||||
DEFAULT_MIN_HUMIDITY = 60
|
||||
|
||||
POWER_TIMER_MAX = 60
|
||||
SALT_BATH_TIMER_MAX = 60
|
||||
FAN_TIMER_MAX = 60
|
||||
|
@ -11,5 +11,5 @@
|
||||
"documentation": "https://www.home-assistant.io/integrations/tolo",
|
||||
"iot_class": "local_polling",
|
||||
"loggers": ["tololib"],
|
||||
"requirements": ["tololib==0.1.0b4"]
|
||||
"requirements": ["tololib==1.1.0"]
|
||||
}
|
||||
|
@ -6,8 +6,13 @@ from collections.abc import Callable
|
||||
from dataclasses import dataclass
|
||||
from typing import Any
|
||||
|
||||
from tololib import ToloClient
|
||||
from tololib.message_info import SettingsInfo
|
||||
from tololib import (
|
||||
FAN_TIMER_MAX,
|
||||
POWER_TIMER_MAX,
|
||||
SALT_BATH_TIMER_MAX,
|
||||
ToloClient,
|
||||
ToloSettings,
|
||||
)
|
||||
|
||||
from homeassistant.components.number import NumberEntity, NumberEntityDescription
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
@ -16,14 +21,14 @@ from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from . import ToloSaunaCoordinatorEntity, ToloSaunaUpdateCoordinator
|
||||
from .const import DOMAIN, FAN_TIMER_MAX, POWER_TIMER_MAX, SALT_BATH_TIMER_MAX
|
||||
from .const import DOMAIN
|
||||
|
||||
|
||||
@dataclass(frozen=True, kw_only=True)
|
||||
class ToloNumberEntityDescription(NumberEntityDescription):
|
||||
"""Class describing TOLO Number entities."""
|
||||
|
||||
getter: Callable[[SettingsInfo], int | None]
|
||||
getter: Callable[[ToloSettings], int | None]
|
||||
setter: Callable[[ToloClient, int | None], Any]
|
||||
|
||||
entity_category = EntityCategory.CONFIG
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from tololib.const import LampMode
|
||||
from tololib import LampMode
|
||||
|
||||
from homeassistant.components.select import SelectEntity
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
|
@ -5,7 +5,7 @@ from __future__ import annotations
|
||||
from collections.abc import Callable
|
||||
from dataclasses import dataclass
|
||||
|
||||
from tololib.message_info import SettingsInfo, StatusInfo
|
||||
from tololib import ToloSettings, ToloStatus
|
||||
|
||||
from homeassistant.components.sensor import (
|
||||
SensorDeviceClass,
|
||||
@ -31,8 +31,8 @@ from .const import DOMAIN
|
||||
class ToloSensorEntityDescription(SensorEntityDescription):
|
||||
"""Class describing TOLO Sensor entities."""
|
||||
|
||||
getter: Callable[[StatusInfo], int | None]
|
||||
availability_checker: Callable[[SettingsInfo, StatusInfo], bool] | None
|
||||
getter: Callable[[ToloStatus], int | None]
|
||||
availability_checker: Callable[[ToloSettings, ToloStatus], bool] | None
|
||||
|
||||
state_class = SensorStateClass.MEASUREMENT
|
||||
|
||||
|
@ -2716,7 +2716,7 @@ tmb==0.0.4
|
||||
todoist-api-python==2.1.2
|
||||
|
||||
# homeassistant.components.tolo
|
||||
tololib==0.1.0b4
|
||||
tololib==1.1.0
|
||||
|
||||
# homeassistant.components.toon
|
||||
toonapi==0.3.0
|
||||
|
@ -2075,7 +2075,7 @@ tilt-ble==0.2.3
|
||||
todoist-api-python==2.1.2
|
||||
|
||||
# homeassistant.components.tolo
|
||||
tololib==0.1.0b4
|
||||
tololib==1.1.0
|
||||
|
||||
# homeassistant.components.toon
|
||||
toonapi==0.3.0
|
||||
|
@ -3,7 +3,7 @@
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
import pytest
|
||||
from tololib.errors import ResponseTimedOutError
|
||||
from tololib import ToloCommunicationError
|
||||
|
||||
from homeassistant.components import dhcp
|
||||
from homeassistant.components.tolo.const import DOMAIN
|
||||
@ -38,7 +38,7 @@ def coordinator_toloclient() -> Mock:
|
||||
|
||||
async def test_user_with_timed_out_host(hass: HomeAssistant, toloclient: Mock) -> None:
|
||||
"""Test a user initiated config flow with provided host which times out."""
|
||||
toloclient().get_status_info.side_effect = ResponseTimedOutError()
|
||||
toloclient().get_status.side_effect = ToloCommunicationError
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
@ -62,7 +62,7 @@ async def test_user_walkthrough(
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
|
||||
toloclient().get_status_info.side_effect = lambda *args, **kwargs: None
|
||||
toloclient().get_status.side_effect = lambda *args, **kwargs: None
|
||||
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
@ -73,7 +73,7 @@ async def test_user_walkthrough(
|
||||
assert result2["step_id"] == "user"
|
||||
assert result2["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
toloclient().get_status_info.side_effect = lambda *args, **kwargs: object()
|
||||
toloclient().get_status.side_effect = lambda *args, **kwargs: object()
|
||||
|
||||
result3 = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
@ -89,7 +89,7 @@ async def test_dhcp(
|
||||
hass: HomeAssistant, toloclient: Mock, coordinator_toloclient: Mock
|
||||
) -> None:
|
||||
"""Test starting a flow from discovery."""
|
||||
toloclient().get_status_info.side_effect = lambda *args, **kwargs: object()
|
||||
toloclient().get_status.side_effect = lambda *args, **kwargs: object()
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": SOURCE_DHCP}, data=MOCK_DHCP_DATA
|
||||
@ -110,7 +110,7 @@ async def test_dhcp(
|
||||
|
||||
async def test_dhcp_invalid_device(hass: HomeAssistant, toloclient: Mock) -> None:
|
||||
"""Test starting a flow from discovery."""
|
||||
toloclient().get_status_info.side_effect = lambda *args, **kwargs: None
|
||||
toloclient().get_status.side_effect = lambda *args, **kwargs: None
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": SOURCE_DHCP}, data=MOCK_DHCP_DATA
|
||||
|
Loading…
x
Reference in New Issue
Block a user