diff --git a/homeassistant/components/bluetooth/manifest.json b/homeassistant/components/bluetooth/manifest.json index bf5345e0ba476a..77ed782a5adffe 100644 --- a/homeassistant/components/bluetooth/manifest.json +++ b/homeassistant/components/bluetooth/manifest.json @@ -19,8 +19,8 @@ "bleak-retry-connector==4.4.3", "bluetooth-adapters==2.1.0", "bluetooth-auto-recovery==1.5.3", - "bluetooth-data-tools==1.28.2", - "dbus-fast==2.44.3", - "habluetooth==5.6.4" + "bluetooth-data-tools==1.28.3", + "dbus-fast==2.44.5", + "habluetooth==5.7.0" ] } diff --git a/homeassistant/components/dhcp/manifest.json b/homeassistant/components/dhcp/manifest.json index 32abe0684f71da..7b8405ffc375ab 100644 --- a/homeassistant/components/dhcp/manifest.json +++ b/homeassistant/components/dhcp/manifest.json @@ -17,6 +17,6 @@ "requirements": [ "aiodhcpwatcher==1.2.1", "aiodiscover==2.7.1", - "cached-ipaddress==0.10.0" + "cached-ipaddress==1.0.1" ] } diff --git a/homeassistant/components/esphome/manifest.json b/homeassistant/components/esphome/manifest.json index 5229dfddee265d..b458b39bd16ce8 100644 --- a/homeassistant/components/esphome/manifest.json +++ b/homeassistant/components/esphome/manifest.json @@ -19,7 +19,7 @@ "requirements": [ "aioesphomeapi==41.11.0", "esphome-dashboard-api==1.3.0", - "bleak-esphome==3.3.0" + "bleak-esphome==3.4.0" ], "zeroconf": ["_esphomelib._tcp.local."] } diff --git a/homeassistant/components/homekit/manifest.json b/homeassistant/components/homekit/manifest.json index 137d5b90f848f6..4aaec4a98409ea 100644 --- a/homeassistant/components/homekit/manifest.json +++ b/homeassistant/components/homekit/manifest.json @@ -10,7 +10,7 @@ "loggers": ["pyhap"], "requirements": [ "HAP-python==5.0.0", - "fnv-hash-fast==1.5.0", + "fnv-hash-fast==1.6.0", "PyQRCode==1.2.1", "base36==0.1.1" ], diff --git a/homeassistant/components/ld2410_ble/manifest.json b/homeassistant/components/ld2410_ble/manifest.json index 1efe4e05682244..016377154d2853 100644 --- a/homeassistant/components/ld2410_ble/manifest.json +++ b/homeassistant/components/ld2410_ble/manifest.json @@ -20,5 +20,5 @@ "documentation": "https://www.home-assistant.io/integrations/ld2410_ble", "integration_type": "device", "iot_class": "local_push", - "requirements": ["bluetooth-data-tools==1.28.2", "ld2410-ble==0.1.1"] + "requirements": ["bluetooth-data-tools==1.28.3", "ld2410-ble==0.1.1"] } diff --git a/homeassistant/components/led_ble/manifest.json b/homeassistant/components/led_ble/manifest.json index 3a73c28cdf6d16..7871be1c552b79 100644 --- a/homeassistant/components/led_ble/manifest.json +++ b/homeassistant/components/led_ble/manifest.json @@ -35,5 +35,5 @@ "dependencies": ["bluetooth_adapters"], "documentation": "https://www.home-assistant.io/integrations/led_ble", "iot_class": "local_polling", - "requirements": ["bluetooth-data-tools==1.28.2", "led-ble==1.1.7"] + "requirements": ["bluetooth-data-tools==1.28.3", "led-ble==1.1.7"] } diff --git a/homeassistant/components/mqtt/lock.py b/homeassistant/components/mqtt/lock.py index 00771ce521f6e1..2232abb79340c5 100644 --- a/homeassistant/components/mqtt/lock.py +++ b/homeassistant/components/mqtt/lock.py @@ -188,7 +188,10 @@ def _message_received(self, msg: ReceiveMessage) -> None: return if payload == self._config[CONF_PAYLOAD_RESET]: # Reset the state to `unknown` - self._attr_is_locked = None + self._attr_is_locked = self._attr_is_locking = None + self._attr_is_unlocking = None + self._attr_is_open = self._attr_is_opening = None + self._attr_is_jammed = None elif payload in self._valid_states: self._attr_is_locked = payload == self._config[CONF_STATE_LOCKED] self._attr_is_locking = payload == self._config[CONF_STATE_LOCKING] diff --git a/homeassistant/components/onedrive/backup.py b/homeassistant/components/onedrive/backup.py index 4243a920fe5702..c02fbdfa01d0d7 100644 --- a/homeassistant/components/onedrive/backup.py +++ b/homeassistant/components/onedrive/backup.py @@ -35,7 +35,8 @@ from .coordinator import OneDriveConfigEntry _LOGGER = logging.getLogger(__name__) -UPLOAD_CHUNK_SIZE = 32 * 320 * 1024 # 10.4MB +MAX_CHUNK_SIZE = 60 * 1024 * 1024 # largest chunk possible, must be <= 60 MiB +TARGET_CHUNKS = 20 TIMEOUT = ClientTimeout(connect=10, total=43200) # 12 hours METADATA_VERSION = 2 CACHE_TTL = 300 @@ -161,11 +162,21 @@ async def async_upload_backup( self._folder_id, await open_stream(), ) + + # determine chunk based on target chunks + upload_chunk_size = backup.size / TARGET_CHUNKS + # find the nearest multiple of 320KB + upload_chunk_size = round(upload_chunk_size / (320 * 1024)) * (320 * 1024) + # limit to max chunk size + upload_chunk_size = min(upload_chunk_size, MAX_CHUNK_SIZE) + # ensure minimum chunk size of 320KB + upload_chunk_size = max(upload_chunk_size, 320 * 1024) + try: backup_file = await LargeFileUploadClient.upload( self._token_function, file, - upload_chunk_size=UPLOAD_CHUNK_SIZE, + upload_chunk_size=upload_chunk_size, session=async_get_clientsession(self._hass), ) except HashMismatchError as err: diff --git a/homeassistant/components/private_ble_device/manifest.json b/homeassistant/components/private_ble_device/manifest.json index 439e44faad1864..0d3c16f5b76f5d 100644 --- a/homeassistant/components/private_ble_device/manifest.json +++ b/homeassistant/components/private_ble_device/manifest.json @@ -6,5 +6,5 @@ "dependencies": ["bluetooth_adapters"], "documentation": "https://www.home-assistant.io/integrations/private_ble_device", "iot_class": "local_push", - "requirements": ["bluetooth-data-tools==1.28.2"] + "requirements": ["bluetooth-data-tools==1.28.3"] } diff --git a/homeassistant/components/recorder/manifest.json b/homeassistant/components/recorder/manifest.json index cc6a6979817fef..a1a9ac1bc64091 100644 --- a/homeassistant/components/recorder/manifest.json +++ b/homeassistant/components/recorder/manifest.json @@ -8,7 +8,7 @@ "quality_scale": "internal", "requirements": [ "SQLAlchemy==2.0.41", - "fnv-hash-fast==1.5.0", + "fnv-hash-fast==1.6.0", "psutil-home-assistant==0.0.1" ] } diff --git a/homeassistant/helpers/debounce.py b/homeassistant/helpers/debounce.py index c46c6806d5d029..a562f86f1f9251 100644 --- a/homeassistant/helpers/debounce.py +++ b/homeassistant/helpers/debounce.py @@ -85,11 +85,8 @@ def _async_schedule_or_call_now(self) -> bool: return False - # Locked means a call is in progress. Any call is good, so abort. - if self._execute_lock.locked(): - return False - - if not self.immediate: + # If not immediate or in progress, we schedule a call for later. + if not self.immediate or self._execute_lock.locked(): self._execute_at_end_of_timer = True self._schedule_timer() return False diff --git a/homeassistant/helpers/template/__init__.py b/homeassistant/helpers/template/__init__.py index b37094057f5301..ed1e6151f2a1ce 100644 --- a/homeassistant/helpers/template/__init__.py +++ b/homeassistant/helpers/template/__init__.py @@ -561,15 +561,16 @@ def _render_template() -> None: finally: self.hass.loop.call_soon_threadsafe(finish_event.set) + template_render_thread = ThreadWithException(target=_render_template) try: - template_render_thread = ThreadWithException(target=_render_template) template_render_thread.start() async with asyncio.timeout(timeout): await finish_event.wait() if self._exc_info: raise TemplateError(self._exc_info[1].with_traceback(self._exc_info[2])) except TimeoutError: - template_render_thread.raise_exc(TimeoutError) + if template_render_thread.is_alive(): + template_render_thread.raise_exc(TimeoutError) return True finally: template_render_thread.join() diff --git a/homeassistant/package_constraints.txt b/homeassistant/package_constraints.txt index afb46240776b43..f8af18bf778fba 100644 --- a/homeassistant/package_constraints.txt +++ b/homeassistant/package_constraints.txt @@ -10,7 +10,7 @@ aiohttp==3.12.15 aiohttp_cors==0.8.1 aiousbwatcher==1.1.1 aiozoneinfo==0.2.3 -annotatedyaml==0.4.5 +annotatedyaml==1.0.2 astral==2.2 async-interrupt==1.2.2 async-upnp-client==0.45.0 @@ -24,18 +24,18 @@ bleak-retry-connector==4.4.3 bleak==1.0.1 bluetooth-adapters==2.1.0 bluetooth-auto-recovery==1.5.3 -bluetooth-data-tools==1.28.2 -cached-ipaddress==0.10.0 +bluetooth-data-tools==1.28.3 +cached-ipaddress==1.0.1 certifi>=2021.5.30 ciso8601==2.3.3 cronsim==2.6 cryptography==46.0.2 -dbus-fast==2.44.3 +dbus-fast==2.44.5 file-read-backwards==2.0.0 -fnv-hash-fast==1.5.0 +fnv-hash-fast==1.6.0 go2rtc-client==0.2.1 ha-ffmpeg==3.2.2 -habluetooth==5.6.4 +habluetooth==5.7.0 hass-nabucasa==1.2.0 hassil==3.2.0 home-assistant-bluetooth==1.13.1 diff --git a/pyproject.toml b/pyproject.toml index 14d15e4675f0da..b4e3a8b0a19e81 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,7 +33,7 @@ dependencies = [ "aiohttp-fast-zlib==0.3.0", "aiohttp-asyncmdnsresolver==0.1.1", "aiozoneinfo==0.2.3", - "annotatedyaml==0.4.5", + "annotatedyaml==1.0.2", "astral==2.2", "async-interrupt==1.2.2", "attrs==25.3.0", @@ -44,7 +44,7 @@ dependencies = [ "certifi>=2021.5.30", "ciso8601==2.3.3", "cronsim==2.6", - "fnv-hash-fast==1.5.0", + "fnv-hash-fast==1.6.0", # hass-nabucasa is imported by helpers which don't depend on the cloud # integration "hass-nabucasa==1.2.0", diff --git a/requirements.txt b/requirements.txt index c7e63873f9c983..687436c377d1d7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,7 +10,7 @@ aiohttp_cors==0.8.1 aiohttp-fast-zlib==0.3.0 aiohttp-asyncmdnsresolver==0.1.1 aiozoneinfo==0.2.3 -annotatedyaml==0.4.5 +annotatedyaml==1.0.2 astral==2.2 async-interrupt==1.2.2 attrs==25.3.0 @@ -21,7 +21,7 @@ bcrypt==5.0.0 certifi>=2021.5.30 ciso8601==2.3.3 cronsim==2.6 -fnv-hash-fast==1.5.0 +fnv-hash-fast==1.6.0 hass-nabucasa==1.2.0 httpx==0.28.1 home-assistant-bluetooth==1.13.1 diff --git a/requirements_all.txt b/requirements_all.txt index 46d68538f39cf8..20fe341c4545d6 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -627,7 +627,7 @@ bimmer-connected[china]==0.17.3 bizkaibus==0.1.1 # homeassistant.components.esphome -bleak-esphome==3.3.0 +bleak-esphome==3.4.0 # homeassistant.components.bluetooth bleak-retry-connector==4.4.3 @@ -663,7 +663,7 @@ bluetooth-auto-recovery==1.5.3 # homeassistant.components.ld2410_ble # homeassistant.components.led_ble # homeassistant.components.private_ble_device -bluetooth-data-tools==1.28.2 +bluetooth-data-tools==1.28.3 # homeassistant.components.bond bond-async==0.2.1 @@ -712,7 +712,7 @@ btsmarthub-devicelist==0.2.3 buienradar==1.0.6 # homeassistant.components.dhcp -cached-ipaddress==0.10.0 +cached-ipaddress==1.0.1 # homeassistant.components.caldav caldav==1.6.0 @@ -770,7 +770,7 @@ datadog==0.52.0 datapoint==0.12.1 # homeassistant.components.bluetooth -dbus-fast==2.44.3 +dbus-fast==2.44.5 # homeassistant.components.debugpy debugpy==1.8.16 @@ -972,7 +972,7 @@ flux-led==1.2.0 # homeassistant.components.homekit # homeassistant.components.recorder -fnv-hash-fast==1.5.0 +fnv-hash-fast==1.6.0 # homeassistant.components.foobot foobot_async==1.0.0 @@ -1142,7 +1142,7 @@ ha-silabs-firmware-client==0.2.0 habiticalib==0.4.5 # homeassistant.components.bluetooth -habluetooth==5.6.4 +habluetooth==5.7.0 # homeassistant.components.cloud hass-nabucasa==1.2.0 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 38d599d87f3bc9..71e24f74dbcc95 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -561,7 +561,7 @@ beautifulsoup4==4.13.3 bimmer-connected[china]==0.17.3 # homeassistant.components.esphome -bleak-esphome==3.3.0 +bleak-esphome==3.4.0 # homeassistant.components.bluetooth bleak-retry-connector==4.4.3 @@ -594,7 +594,7 @@ bluetooth-auto-recovery==1.5.3 # homeassistant.components.ld2410_ble # homeassistant.components.led_ble # homeassistant.components.private_ble_device -bluetooth-data-tools==1.28.2 +bluetooth-data-tools==1.28.3 # homeassistant.components.bond bond-async==0.2.1 @@ -630,7 +630,7 @@ bthome-ble==3.14.2 buienradar==1.0.6 # homeassistant.components.dhcp -cached-ipaddress==0.10.0 +cached-ipaddress==1.0.1 # homeassistant.components.caldav caldav==1.6.0 @@ -673,7 +673,7 @@ datadog==0.52.0 datapoint==0.12.1 # homeassistant.components.bluetooth -dbus-fast==2.44.3 +dbus-fast==2.44.5 # homeassistant.components.debugpy debugpy==1.8.16 @@ -848,7 +848,7 @@ flux-led==1.2.0 # homeassistant.components.homekit # homeassistant.components.recorder -fnv-hash-fast==1.5.0 +fnv-hash-fast==1.6.0 # homeassistant.components.foobot foobot_async==1.0.0 @@ -1003,7 +1003,7 @@ ha-silabs-firmware-client==0.2.0 habiticalib==0.4.5 # homeassistant.components.bluetooth -habluetooth==5.6.4 +habluetooth==5.7.0 # homeassistant.components.cloud hass-nabucasa==1.2.0 diff --git a/tests/components/mqtt/test_lock.py b/tests/components/mqtt/test_lock.py index 4aa6ecd03ef4a5..de2d77e69a7a36 100644 --- a/tests/components/mqtt/test_lock.py +++ b/tests/components/mqtt/test_lock.py @@ -75,6 +75,7 @@ "state_opening": "opening", "state_unlocked": "unlocked", "state_unlocking": "unlocking", + "state_jammed": "jammed", } } } @@ -89,6 +90,7 @@ (CONFIG_WITH_STATES, "opening", LockState.OPENING), (CONFIG_WITH_STATES, "unlocked", LockState.UNLOCKED), (CONFIG_WITH_STATES, "unlocking", LockState.UNLOCKING), + (CONFIG_WITH_STATES, "jammed", LockState.JAMMED), ], ) async def test_controlling_state_via_topic( @@ -111,6 +113,12 @@ async def test_controlling_state_via_topic( state = hass.states.get("lock.test") assert state.state == lock_state + async_fire_mqtt_message(hass, "state-topic", "None") + await hass.async_block_till_done() + + state = hass.states.get("lock.test") + assert state.state == STATE_UNKNOWN + @pytest.mark.parametrize( ("hass_config", "payload", "lock_state"), diff --git a/tests/components/shelly/__init__.py b/tests/components/shelly/__init__.py index 30ae74079f04e0..8eaffe5af86649 100644 --- a/tests/components/shelly/__init__.py +++ b/tests/components/shelly/__init__.py @@ -1,10 +1,11 @@ """Tests for the Shelly integration.""" from collections.abc import Mapping, Sequence +from contextlib import contextmanager from copy import deepcopy from datetime import timedelta from typing import Any -from unittest.mock import Mock +from unittest.mock import Mock, patch from aioshelly.const import MODEL_25 from freezegun.api import FrozenDateTimeFactory @@ -12,6 +13,11 @@ from syrupy.assertion import SnapshotAssertion from syrupy.filters import props +from homeassistant.components.shelly import ( + BLOCK_SLEEPING_PLATFORMS, + PLATFORMS, + RPC_SLEEPING_PLATFORMS, +) from homeassistant.components.shelly.const import ( CONF_GEN, CONF_SLEEP_PERIOD, @@ -20,7 +26,7 @@ RPC_SENSORS_POLLING_INTERVAL, ) from homeassistant.config_entries import ConfigEntry -from homeassistant.const import CONF_HOST, CONF_MODEL +from homeassistant.const import CONF_HOST, CONF_MODEL, Platform from homeassistant.core import HomeAssistant from homeassistant.helpers import entity_registry as er from homeassistant.helpers.device_registry import ( @@ -204,3 +210,23 @@ async def force_uptime_value( """Force time to a specific point.""" await hass.config.async_set_time_zone("UTC") freezer.move_to("2025-05-26 16:04:00+00:00") + + +@contextmanager +def patch_platforms(platforms: list[Platform]): + """Only allow given platforms to be loaded.""" + with ( + patch( + "homeassistant.components.shelly.PLATFORMS", + list(set(PLATFORMS) & set(platforms)), + ), + patch( + "homeassistant.components.shelly.BLOCK_SLEEPING_PLATFORMS", + list(set(BLOCK_SLEEPING_PLATFORMS) & set(platforms)), + ), + patch( + "homeassistant.components.shelly.RPC_SLEEPING_PLATFORMS", + list(set(RPC_SLEEPING_PLATFORMS) & set(platforms)), + ), + ): + yield diff --git a/tests/components/shelly/test_binary_sensor.py b/tests/components/shelly/test_binary_sensor.py index db0b05aec955f5..ed764ddf601ae5 100644 --- a/tests/components/shelly/test_binary_sensor.py +++ b/tests/components/shelly/test_binary_sensor.py @@ -10,7 +10,13 @@ from homeassistant.components.binary_sensor import DOMAIN as BINARY_SENSOR_DOMAIN from homeassistant.components.shelly.const import UPDATE_PERIOD_MULTIPLIER -from homeassistant.const import STATE_OFF, STATE_ON, STATE_UNAVAILABLE, STATE_UNKNOWN +from homeassistant.const import ( + STATE_OFF, + STATE_ON, + STATE_UNAVAILABLE, + STATE_UNKNOWN, + Platform, +) from homeassistant.core import HomeAssistant, State from homeassistant.helpers.device_registry import DeviceRegistry from homeassistant.helpers.entity_registry import EntityRegistry @@ -19,6 +25,7 @@ init_integration, mock_rest_update, mutate_rpc_device_status, + patch_platforms, register_device, register_entity, register_sub_device, @@ -30,6 +37,13 @@ SENSOR_BLOCK_ID = 3 +@pytest.fixture(autouse=True) +def fixture_platforms(): + """Limit platforms under test.""" + with patch_platforms([Platform.BINARY_SENSOR]): + yield + + async def test_block_binary_sensor( hass: HomeAssistant, mock_block_device: Mock, diff --git a/tests/components/shelly/test_button.py b/tests/components/shelly/test_button.py index fe220b5b3d7158..f6a3df0bb4860c 100644 --- a/tests/components/shelly/test_button.py +++ b/tests/components/shelly/test_button.py @@ -11,13 +11,20 @@ from homeassistant.components.button import DOMAIN as BUTTON_DOMAIN, SERVICE_PRESS from homeassistant.components.shelly.const import DOMAIN from homeassistant.config_entries import SOURCE_REAUTH, ConfigEntryState -from homeassistant.const import ATTR_ENTITY_ID, STATE_UNKNOWN +from homeassistant.const import ATTR_ENTITY_ID, STATE_UNKNOWN, Platform from homeassistant.core import HomeAssistant from homeassistant.exceptions import HomeAssistantError from homeassistant.helpers.device_registry import DeviceRegistry from homeassistant.helpers.entity_registry import EntityRegistry -from . import init_integration, register_device, register_entity +from . import init_integration, patch_platforms, register_device, register_entity + + +@pytest.fixture(autouse=True) +def fixture_platforms(): + """Limit platforms under test.""" + with patch_platforms([Platform.BUTTON]): + yield async def test_block_button( diff --git a/tests/components/shelly/test_climate.py b/tests/components/shelly/test_climate.py index c19bd916fed812..61946298f79d8d 100644 --- a/tests/components/shelly/test_climate.py +++ b/tests/components/shelly/test_climate.py @@ -35,6 +35,7 @@ ATTR_TEMPERATURE, STATE_ON, STATE_UNAVAILABLE, + Platform, ) from homeassistant.core import HomeAssistant, State from homeassistant.exceptions import HomeAssistantError, ServiceValidationError @@ -43,7 +44,13 @@ from homeassistant.helpers.entity_registry import EntityRegistry from homeassistant.util.unit_system import US_CUSTOMARY_SYSTEM -from . import MOCK_MAC, init_integration, register_device, register_entity +from . import ( + MOCK_MAC, + init_integration, + patch_platforms, + register_device, + register_entity, +) from .conftest import MOCK_STATUS_COAP from tests.common import mock_restore_cache, mock_restore_cache_with_extra_data @@ -55,6 +62,13 @@ ENTITY_ID = f"{CLIMATE_DOMAIN}.test_name" +@pytest.fixture(autouse=True) +def fixture_platforms(): + """Limit platforms under test.""" + with patch_platforms([Platform.CLIMATE, Platform.SWITCH]): + yield + + async def test_climate_hvac_mode( hass: HomeAssistant, mock_block_device: Mock, diff --git a/tests/components/shelly/test_cover.py b/tests/components/shelly/test_cover.py index 7d194b1b005a00..637adaed225086 100644 --- a/tests/components/shelly/test_cover.py +++ b/tests/components/shelly/test_cover.py @@ -23,15 +23,27 @@ CoverState, ) from homeassistant.components.shelly.const import RPC_COVER_UPDATE_TIME_SEC -from homeassistant.const import ATTR_ENTITY_ID +from homeassistant.const import ATTR_ENTITY_ID, Platform from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_registry import EntityRegistry -from . import init_integration, mock_polling_rpc_update, mutate_rpc_device_status +from . import ( + init_integration, + mock_polling_rpc_update, + mutate_rpc_device_status, + patch_platforms, +) ROLLER_BLOCK_ID = 1 +@pytest.fixture(autouse=True) +def fixture_platforms(): + """Limit platforms under test.""" + with patch_platforms([Platform.COVER]): + yield + + async def test_block_device_services( hass: HomeAssistant, mock_block_device: Mock, diff --git a/tests/components/shelly/test_event.py b/tests/components/shelly/test_event.py index 520233eaf60865..c530f30beb9fab 100644 --- a/tests/components/shelly/test_event.py +++ b/tests/components/shelly/test_event.py @@ -14,15 +14,27 @@ DOMAIN as EVENT_DOMAIN, EventDeviceClass, ) -from homeassistant.const import ATTR_DEVICE_CLASS, STATE_UNKNOWN +from homeassistant.const import ATTR_DEVICE_CLASS, STATE_UNKNOWN, Platform from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_registry import EntityRegistry -from . import init_integration, inject_rpc_device_event, register_entity +from . import ( + init_integration, + inject_rpc_device_event, + patch_platforms, + register_entity, +) DEVICE_BLOCK_ID = 4 +@pytest.fixture(autouse=True) +def fixture_platforms(): + """Limit platforms under test.""" + with patch_platforms([Platform.EVENT]): + yield + + async def test_rpc_button( hass: HomeAssistant, mock_rpc_device: Mock, diff --git a/tests/components/shelly/test_light.py b/tests/components/shelly/test_light.py index 959e6a471ba9c1..cf4ffbc2f668c0 100644 --- a/tests/components/shelly/test_light.py +++ b/tests/components/shelly/test_light.py @@ -38,6 +38,7 @@ ATTR_SUPPORTED_FEATURES, STATE_OFF, STATE_ON, + Platform, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.device_registry import DeviceRegistry @@ -47,6 +48,7 @@ get_entity, init_integration, mutate_rpc_device_status, + patch_platforms, register_device, register_entity, ) @@ -57,6 +59,13 @@ SHELLY_PLUS_RGBW_CHANNELS = 4 +@pytest.fixture(autouse=True) +def fixture_platforms(): + """Limit platforms under test.""" + with patch_platforms([Platform.LIGHT]): + yield + + async def test_block_device_rgbw_bulb( hass: HomeAssistant, mock_block_device: Mock, diff --git a/tests/components/shelly/test_number.py b/tests/components/shelly/test_number.py index 9f7e85f8f05e4e..c723082177279b 100644 --- a/tests/components/shelly/test_number.py +++ b/tests/components/shelly/test_number.py @@ -20,19 +20,31 @@ ) from homeassistant.components.shelly.const import DOMAIN from homeassistant.config_entries import SOURCE_REAUTH, ConfigEntryState -from homeassistant.const import ATTR_ENTITY_ID, ATTR_UNIT_OF_MEASUREMENT, STATE_UNKNOWN +from homeassistant.const import ( + ATTR_ENTITY_ID, + ATTR_UNIT_OF_MEASUREMENT, + STATE_UNKNOWN, + Platform, +) from homeassistant.core import HomeAssistant, State from homeassistant.exceptions import HomeAssistantError from homeassistant.helpers.device_registry import DeviceRegistry from homeassistant.helpers.entity_registry import EntityRegistry -from . import init_integration, register_device, register_entity +from . import init_integration, patch_platforms, register_device, register_entity from tests.common import mock_restore_cache_with_extra_data DEVICE_BLOCK_ID = 4 +@pytest.fixture(autouse=True) +def fixture_platforms(): + """Limit platforms under test.""" + with patch_platforms([Platform.NUMBER]): + yield + + async def test_block_number_update( hass: HomeAssistant, mock_block_device: Mock, diff --git a/tests/components/shelly/test_select.py b/tests/components/shelly/test_select.py index 4586da344dbf2b..eefd84d40eb6ad 100644 --- a/tests/components/shelly/test_select.py +++ b/tests/components/shelly/test_select.py @@ -14,13 +14,20 @@ ) from homeassistant.components.shelly.const import DOMAIN from homeassistant.config_entries import SOURCE_REAUTH, ConfigEntryState -from homeassistant.const import ATTR_ENTITY_ID, STATE_UNKNOWN +from homeassistant.const import ATTR_ENTITY_ID, STATE_UNKNOWN, Platform from homeassistant.core import HomeAssistant from homeassistant.exceptions import HomeAssistantError from homeassistant.helpers.device_registry import DeviceRegistry from homeassistant.helpers.entity_registry import EntityRegistry -from . import init_integration, register_device, register_entity +from . import init_integration, patch_platforms, register_device, register_entity + + +@pytest.fixture(autouse=True) +def fixture_platforms(): + """Limit platforms under test.""" + with patch_platforms([Platform.SELECT]): + yield @pytest.mark.parametrize( diff --git a/tests/components/shelly/test_sensor.py b/tests/components/shelly/test_sensor.py index 8bca4ce38ab62c..e6d6812505b9e7 100644 --- a/tests/components/shelly/test_sensor.py +++ b/tests/components/shelly/test_sensor.py @@ -28,6 +28,7 @@ PERCENTAGE, STATE_UNAVAILABLE, STATE_UNKNOWN, + Platform, UnitOfElectricCurrent, UnitOfElectricPotential, UnitOfEnergy, @@ -47,6 +48,7 @@ mock_polling_rpc_update, mock_rest_update, mutate_rpc_device_status, + patch_platforms, register_device, register_entity, ) @@ -58,6 +60,13 @@ DEVICE_BLOCK_ID = 4 +@pytest.fixture(autouse=True) +def fixture_platforms(): + """Limit platforms under test.""" + with patch_platforms([Platform.SENSOR]): + yield + + async def test_block_sensor( hass: HomeAssistant, mock_block_device: Mock, diff --git a/tests/components/shelly/test_switch.py b/tests/components/shelly/test_switch.py index 2cb807236ec4a0..39fc001cbed602 100644 --- a/tests/components/shelly/test_switch.py +++ b/tests/components/shelly/test_switch.py @@ -25,6 +25,7 @@ STATE_OFF, STATE_ON, STATE_UNKNOWN, + Platform, ) from homeassistant.core import HomeAssistant, State from homeassistant.exceptions import HomeAssistantError @@ -34,6 +35,7 @@ from . import ( init_integration, inject_rpc_device_event, + patch_platforms, register_device, register_entity, register_sub_device, @@ -48,6 +50,15 @@ MOTION_BLOCK_ID = 3 +@pytest.fixture(autouse=True) +def fixture_platforms(): + """Limit platforms under test.""" + with patch_platforms( + [Platform.SWITCH, Platform.CLIMATE, Platform.VALVE, Platform.LIGHT] + ): + yield + + async def test_block_device_services( hass: HomeAssistant, mock_block_device: Mock ) -> None: diff --git a/tests/components/shelly/test_text.py b/tests/components/shelly/test_text.py index 3190fabfbea475..59c434213b1eef 100644 --- a/tests/components/shelly/test_text.py +++ b/tests/components/shelly/test_text.py @@ -13,13 +13,20 @@ SERVICE_SET_VALUE, ) from homeassistant.config_entries import SOURCE_REAUTH, ConfigEntryState -from homeassistant.const import ATTR_ENTITY_ID +from homeassistant.const import ATTR_ENTITY_ID, Platform from homeassistant.core import HomeAssistant from homeassistant.exceptions import HomeAssistantError from homeassistant.helpers.device_registry import DeviceRegistry from homeassistant.helpers.entity_registry import EntityRegistry -from . import init_integration, register_device, register_entity +from . import init_integration, patch_platforms, register_device, register_entity + + +@pytest.fixture(autouse=True) +def fixture_platforms(): + """Limit platforms under test.""" + with patch_platforms([Platform.TEXT]): + yield @pytest.mark.parametrize( diff --git a/tests/components/shelly/test_update.py b/tests/components/shelly/test_update.py index 51016f0cdaaaca..8007ecc361534d 100644 --- a/tests/components/shelly/test_update.py +++ b/tests/components/shelly/test_update.py @@ -29,6 +29,7 @@ STATE_OFF, STATE_ON, STATE_UNKNOWN, + Platform, ) from homeassistant.core import HomeAssistant, State from homeassistant.exceptions import HomeAssistantError @@ -39,6 +40,7 @@ init_integration, inject_rpc_device_event, mock_rest_update, + patch_platforms, register_device, register_entity, ) @@ -46,6 +48,13 @@ from tests.common import mock_restore_cache +@pytest.fixture(autouse=True) +def fixture_platforms(): + """Limit platforms under test.""" + with patch_platforms([Platform.UPDATE]): + yield + + @pytest.mark.usefixtures("entity_registry_enabled_by_default") async def test_block_update( hass: HomeAssistant, diff --git a/tests/components/shelly/test_valve.py b/tests/components/shelly/test_valve.py index adb6559ee10fb7..301de83c2d8211 100644 --- a/tests/components/shelly/test_valve.py +++ b/tests/components/shelly/test_valve.py @@ -21,15 +21,23 @@ SERVICE_CLOSE_VALVE, SERVICE_OPEN_VALVE, SERVICE_SET_VALVE_POSITION, + Platform, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_registry import EntityRegistry -from . import init_integration +from . import init_integration, patch_platforms GAS_VALVE_BLOCK_ID = 6 +@pytest.fixture(autouse=True) +def fixture_platforms(): + """Limit platforms under test.""" + with patch_platforms([Platform.VALVE]): + yield + + async def test_block_device_gas_valve( hass: HomeAssistant, entity_registry: EntityRegistry, diff --git a/tests/helpers/test_debounce.py b/tests/helpers/test_debounce.py index b2dd8943e78387..55c03aa630aa92 100644 --- a/tests/helpers/test_debounce.py +++ b/tests/helpers/test_debounce.py @@ -61,12 +61,12 @@ async def test_immediate_works(hass: HomeAssistant) -> None: assert debouncer._job.target == debouncer.function assert debouncer._job == before_job - # Test calling doesn't execute/cooldown if currently executing. + # Test calling enabled timer if currently executing. await debouncer._execute_lock.acquire() await debouncer.async_call() assert len(calls) == 2 - assert debouncer._timer_task is None - assert debouncer._execute_at_end_of_timer is False + assert debouncer._timer_task is not None + assert debouncer._execute_at_end_of_timer is True debouncer._execute_lock.release() assert debouncer._job.target == debouncer.function @@ -118,13 +118,13 @@ async def test_immediate_works_with_schedule_call(hass: HomeAssistant) -> None: assert debouncer._job.target == debouncer.function assert debouncer._job == before_job - # Test calling doesn't execute/cooldown if currently executing. + # Test calling enabled timer if currently executing. await debouncer._execute_lock.acquire() debouncer.async_schedule_call() await hass.async_block_till_done() assert len(calls) == 2 - assert debouncer._timer_task is None - assert debouncer._execute_at_end_of_timer is False + assert debouncer._timer_task is not None + assert debouncer._execute_at_end_of_timer is True debouncer._execute_lock.release() assert debouncer._job.target == debouncer.function @@ -225,12 +225,12 @@ def _append_and_raise() -> None: assert debouncer._job.target == debouncer.function assert debouncer._job == before_job - # Test calling doesn't execute/cooldown if currently executing. + # Test calling enabled timer if currently executing. await debouncer._execute_lock.acquire() await debouncer.async_call() assert len(calls) == 2 - assert debouncer._timer_task is None - assert debouncer._execute_at_end_of_timer is False + assert debouncer._timer_task is not None + assert debouncer._execute_at_end_of_timer is True debouncer._execute_lock.release() assert debouncer._job.target == debouncer.function @@ -288,12 +288,12 @@ async def _append_and_raise() -> None: assert debouncer._job.target == debouncer.function assert debouncer._job == before_job - # Test calling doesn't execute/cooldown if currently executing. + # Test calling enabled timer if currently executing. await debouncer._execute_lock.acquire() await debouncer.async_call() assert len(calls) == 2 - assert debouncer._timer_task is None - assert debouncer._execute_at_end_of_timer is False + assert debouncer._timer_task is not None + assert debouncer._execute_at_end_of_timer is True debouncer._execute_lock.release() assert debouncer._job.target == debouncer.function @@ -339,12 +339,12 @@ async def test_not_immediate_works(hass: HomeAssistant) -> None: # Reset debouncer debouncer.async_cancel() - # Test calling doesn't schedule if currently executing. + # Test calling enabled timer if currently executing. await debouncer._execute_lock.acquire() await debouncer.async_call() assert len(calls) == 1 - assert debouncer._timer_task is None - assert debouncer._execute_at_end_of_timer is False + assert debouncer._timer_task is not None + assert debouncer._execute_at_end_of_timer is True debouncer._execute_lock.release() assert debouncer._job.target == debouncer.function @@ -393,13 +393,13 @@ async def test_not_immediate_works_schedule_call(hass: HomeAssistant) -> None: # Reset debouncer debouncer.async_cancel() - # Test calling doesn't schedule if currently executing. + # Test calling enabled timer if currently executing. await debouncer._execute_lock.acquire() debouncer.async_schedule_call() await hass.async_block_till_done() assert len(calls) == 1 - assert debouncer._timer_task is None - assert debouncer._execute_at_end_of_timer is False + assert debouncer._timer_task is not None + assert debouncer._execute_at_end_of_timer is True debouncer._execute_lock.release() assert debouncer._job.target == debouncer.function @@ -455,13 +455,13 @@ async def test_immediate_works_with_function_swapped(hass: HomeAssistant) -> Non assert debouncer._job.target == debouncer.function assert debouncer._job != before_job - # Test calling doesn't execute/cooldown if currently executing. + # Test calling enabled timer if currently executing. await debouncer._execute_lock.acquire() await debouncer.async_call() assert len(calls) == 2 assert calls == [1, 2] - assert debouncer._timer_task is None - assert debouncer._execute_at_end_of_timer is False + assert debouncer._timer_task is not None + assert debouncer._execute_at_end_of_timer is True debouncer._execute_lock.release() assert debouncer._job.target == debouncer.function