From 104bcc64b7da3195c24ed58f1ec60dff6195ee8d Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Sat, 16 Dec 2023 10:33:50 +0100 Subject: [PATCH] Allow inheriting base component entity descriptions in frozen dataclasses (#105512) Co-authored-by: J. Nick Koston --- homeassistant/components/alarm_control_panel/__init__.py | 4 +--- homeassistant/components/binary_sensor/__init__.py | 4 +--- .../components/bluetooth/passive_update_processor.py | 3 +++ homeassistant/components/button/__init__.py | 4 +--- homeassistant/components/camera/__init__.py | 5 ++--- homeassistant/components/climate/__init__.py | 4 +--- homeassistant/components/cover/__init__.py | 4 +--- homeassistant/components/date/__init__.py | 4 +--- homeassistant/components/datetime/__init__.py | 4 +--- homeassistant/components/event/__init__.py | 3 +-- homeassistant/components/fan/__init__.py | 4 +--- homeassistant/components/humidifier/__init__.py | 4 +--- homeassistant/components/image/__init__.py | 3 +-- homeassistant/components/image_processing/__init__.py | 4 +--- homeassistant/components/lawn_mower/__init__.py | 4 +--- homeassistant/components/light/__init__.py | 3 +-- homeassistant/components/lock/__init__.py | 4 +--- homeassistant/components/media_player/__init__.py | 4 +--- homeassistant/components/number/__init__.py | 3 +-- homeassistant/components/remote/__init__.py | 4 +--- homeassistant/components/select/__init__.py | 4 +--- homeassistant/components/sensor/__init__.py | 3 +-- homeassistant/components/siren/__init__.py | 4 +--- homeassistant/components/switch/__init__.py | 4 +--- homeassistant/components/text/__init__.py | 3 +-- homeassistant/components/time/__init__.py | 4 +--- homeassistant/components/update/__init__.py | 4 +--- homeassistant/components/vacuum/__init__.py | 7 ++----- homeassistant/components/water_heater/__init__.py | 4 +--- homeassistant/components/weather/__init__.py | 4 +--- homeassistant/helpers/entity.py | 3 +-- 31 files changed, 35 insertions(+), 85 deletions(-) diff --git a/homeassistant/components/alarm_control_panel/__init__.py b/homeassistant/components/alarm_control_panel/__init__.py index f3e02465c13a5..c307e96e9f0fc 100644 --- a/homeassistant/components/alarm_control_panel/__init__.py +++ b/homeassistant/components/alarm_control_panel/__init__.py @@ -1,7 +1,6 @@ """Component to interface with an alarm control panel.""" from __future__ import annotations -from dataclasses import dataclass from datetime import timedelta import logging from typing import Any, Final, final @@ -121,8 +120,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: return await component.async_unload_entry(entry) -@dataclass -class AlarmControlPanelEntityDescription(EntityDescription): +class AlarmControlPanelEntityDescription(EntityDescription, frozen_or_thawed=True): """A class that describes alarm control panel entities.""" diff --git a/homeassistant/components/binary_sensor/__init__.py b/homeassistant/components/binary_sensor/__init__.py index a84cbc1875605..a3303c525cb29 100644 --- a/homeassistant/components/binary_sensor/__init__.py +++ b/homeassistant/components/binary_sensor/__init__.py @@ -1,7 +1,6 @@ """Component to interface with binary sensors.""" from __future__ import annotations -from dataclasses import dataclass from datetime import timedelta from enum import StrEnum import logging @@ -176,8 +175,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: return await component.async_unload_entry(entry) -@dataclass -class BinarySensorEntityDescription(EntityDescription): +class BinarySensorEntityDescription(EntityDescription, frozen_or_thawed=True): """A class that describes binary sensor entities.""" device_class: BinarySensorDeviceClass | None = None diff --git a/homeassistant/components/bluetooth/passive_update_processor.py b/homeassistant/components/bluetooth/passive_update_processor.py index eeccf081b55cc..601f78d4c8d19 100644 --- a/homeassistant/components/bluetooth/passive_update_processor.py +++ b/homeassistant/components/bluetooth/passive_update_processor.py @@ -93,7 +93,10 @@ def deserialize_entity_description( descriptions_class: type[EntityDescription], data: dict[str, Any] ) -> EntityDescription: """Deserialize an entity description.""" + # pylint: disable=protected-access result: dict[str, Any] = {} + if hasattr(descriptions_class, "_dataclass"): + descriptions_class = descriptions_class._dataclass for field in cached_fields(descriptions_class): field_name = field.name # It would be nice if field.type returned the actual diff --git a/homeassistant/components/button/__init__.py b/homeassistant/components/button/__init__.py index 901acdcdec198..4ebe1df68a2c5 100644 --- a/homeassistant/components/button/__init__.py +++ b/homeassistant/components/button/__init__.py @@ -1,7 +1,6 @@ """Component to pressing a button as platforms.""" from __future__ import annotations -from dataclasses import dataclass from datetime import datetime, timedelta from enum import StrEnum import logging @@ -73,8 +72,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: return await component.async_unload_entry(entry) -@dataclass -class ButtonEntityDescription(EntityDescription): +class ButtonEntityDescription(EntityDescription, frozen_or_thawed=True): """A class that describes button entities.""" device_class: ButtonDeviceClass | None = None diff --git a/homeassistant/components/camera/__init__.py b/homeassistant/components/camera/__init__.py index bb5a44a530c6f..528c2cef50a77 100644 --- a/homeassistant/components/camera/__init__.py +++ b/homeassistant/components/camera/__init__.py @@ -5,7 +5,7 @@ import collections from collections.abc import Awaitable, Callable, Iterable from contextlib import suppress -from dataclasses import asdict, dataclass +from dataclasses import asdict from datetime import datetime, timedelta from enum import IntFlag from functools import partial @@ -132,8 +132,7 @@ class CameraEntityFeature(IntFlag): } -@dataclass -class CameraEntityDescription(EntityDescription): +class CameraEntityDescription(EntityDescription, frozen_or_thawed=True): """A class that describes camera entities.""" diff --git a/homeassistant/components/climate/__init__.py b/homeassistant/components/climate/__init__.py index a075467a313fc..3e93bf27ffceb 100644 --- a/homeassistant/components/climate/__init__.py +++ b/homeassistant/components/climate/__init__.py @@ -1,7 +1,6 @@ """Provides functionality to interact with climate devices.""" from __future__ import annotations -from dataclasses import dataclass from datetime import timedelta import functools as ft import logging @@ -201,8 +200,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: return await component.async_unload_entry(entry) -@dataclass -class ClimateEntityDescription(EntityDescription): +class ClimateEntityDescription(EntityDescription, frozen_or_thawed=True): """A class that describes climate entities.""" diff --git a/homeassistant/components/cover/__init__.py b/homeassistant/components/cover/__init__.py index 354b972e2b78f..633300af591c1 100644 --- a/homeassistant/components/cover/__init__.py +++ b/homeassistant/components/cover/__init__.py @@ -2,7 +2,6 @@ from __future__ import annotations from collections.abc import Callable -from dataclasses import dataclass from datetime import timedelta from enum import IntFlag, StrEnum import functools as ft @@ -212,8 +211,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: return await component.async_unload_entry(entry) -@dataclass -class CoverEntityDescription(EntityDescription): +class CoverEntityDescription(EntityDescription, frozen_or_thawed=True): """A class that describes cover entities.""" device_class: CoverDeviceClass | None = None diff --git a/homeassistant/components/date/__init__.py b/homeassistant/components/date/__init__.py index 51f3a492c47a4..7426293cfb4a9 100644 --- a/homeassistant/components/date/__init__.py +++ b/homeassistant/components/date/__init__.py @@ -1,7 +1,6 @@ """Component to allow setting date as platforms.""" from __future__ import annotations -from dataclasses import dataclass from datetime import date, timedelta import logging from typing import final @@ -62,8 +61,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: return await component.async_unload_entry(entry) -@dataclass -class DateEntityDescription(EntityDescription): +class DateEntityDescription(EntityDescription, frozen_or_thawed=True): """A class that describes date entities.""" diff --git a/homeassistant/components/datetime/__init__.py b/homeassistant/components/datetime/__init__.py index e25f4535d0c1a..823028ee6a736 100644 --- a/homeassistant/components/datetime/__init__.py +++ b/homeassistant/components/datetime/__init__.py @@ -1,7 +1,6 @@ """Component to allow setting date/time as platforms.""" from __future__ import annotations -from dataclasses import dataclass from datetime import UTC, datetime, timedelta import logging from typing import final @@ -71,8 +70,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: return await component.async_unload_entry(entry) -@dataclass -class DateTimeEntityDescription(EntityDescription): +class DateTimeEntityDescription(EntityDescription, frozen_or_thawed=True): """A class that describes date/time entities.""" diff --git a/homeassistant/components/event/__init__.py b/homeassistant/components/event/__init__.py index d960867097276..40e55472d1276 100644 --- a/homeassistant/components/event/__init__.py +++ b/homeassistant/components/event/__init__.py @@ -71,8 +71,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: return await component.async_unload_entry(entry) -@dataclass -class EventEntityDescription(EntityDescription): +class EventEntityDescription(EntityDescription, frozen_or_thawed=True): """A class that describes event entities.""" device_class: EventDeviceClass | None = None diff --git a/homeassistant/components/fan/__init__.py b/homeassistant/components/fan/__init__.py index 21ffca35962ad..23261c4d94431 100644 --- a/homeassistant/components/fan/__init__.py +++ b/homeassistant/components/fan/__init__.py @@ -1,7 +1,6 @@ """Provides functionality to interact with fans.""" from __future__ import annotations -from dataclasses import dataclass from datetime import timedelta from enum import IntFlag import functools as ft @@ -187,8 +186,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: return await component.async_unload_entry(entry) -@dataclass -class FanEntityDescription(ToggleEntityDescription): +class FanEntityDescription(ToggleEntityDescription, frozen_or_thawed=True): """A class that describes fan entities.""" diff --git a/homeassistant/components/humidifier/__init__.py b/homeassistant/components/humidifier/__init__.py index 47745c53394dc..39150126b7abe 100644 --- a/homeassistant/components/humidifier/__init__.py +++ b/homeassistant/components/humidifier/__init__.py @@ -1,7 +1,6 @@ """Provides functionality to interact with humidifier devices.""" from __future__ import annotations -from dataclasses import dataclass from datetime import timedelta from enum import StrEnum import logging @@ -124,8 +123,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: return await component.async_unload_entry(entry) -@dataclass -class HumidifierEntityDescription(ToggleEntityDescription): +class HumidifierEntityDescription(ToggleEntityDescription, frozen_or_thawed=True): """A class that describes humidifier entities.""" device_class: HumidifierDeviceClass | None = None diff --git a/homeassistant/components/image/__init__.py b/homeassistant/components/image/__init__.py index e5c40affe0fd2..d90295f627911 100644 --- a/homeassistant/components/image/__init__.py +++ b/homeassistant/components/image/__init__.py @@ -44,8 +44,7 @@ GET_IMAGE_TIMEOUT: Final = 10 -@dataclass -class ImageEntityDescription(EntityDescription): +class ImageEntityDescription(EntityDescription, frozen_or_thawed=True): """A class that describes image entities.""" diff --git a/homeassistant/components/image_processing/__init__.py b/homeassistant/components/image_processing/__init__.py index 7640925451ac4..916812e41c93b 100644 --- a/homeassistant/components/image_processing/__init__.py +++ b/homeassistant/components/image_processing/__init__.py @@ -2,7 +2,6 @@ from __future__ import annotations import asyncio -from dataclasses import dataclass from datetime import timedelta from enum import StrEnum import logging @@ -120,8 +119,7 @@ async def async_scan_service(service: ServiceCall) -> None: return True -@dataclass -class ImageProcessingEntityDescription(EntityDescription): +class ImageProcessingEntityDescription(EntityDescription, frozen_or_thawed=True): """A class that describes sensor entities.""" device_class: ImageProcessingDeviceClass | None = None diff --git a/homeassistant/components/lawn_mower/__init__.py b/homeassistant/components/lawn_mower/__init__.py index 5388463316f3c..b25f9ab34af68 100644 --- a/homeassistant/components/lawn_mower/__init__.py +++ b/homeassistant/components/lawn_mower/__init__.py @@ -1,7 +1,6 @@ """The lawn mower integration.""" from __future__ import annotations -from dataclasses import dataclass from datetime import timedelta import logging from typing import final @@ -65,8 +64,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: return await component.async_unload_entry(entry) -@dataclass -class LawnMowerEntityEntityDescription(EntityDescription): +class LawnMowerEntityEntityDescription(EntityDescription, frozen_or_thawed=True): """A class that describes lawn mower entities.""" diff --git a/homeassistant/components/light/__init__.py b/homeassistant/components/light/__init__.py index 3bb3797c284bc..6643884566fc7 100644 --- a/homeassistant/components/light/__init__.py +++ b/homeassistant/components/light/__init__.py @@ -816,8 +816,7 @@ def apply_profile(self, name: str, params: dict[str, Any]) -> None: params.setdefault(ATTR_TRANSITION, profile.transition) -@dataclasses.dataclass -class LightEntityDescription(ToggleEntityDescription): +class LightEntityDescription(ToggleEntityDescription, frozen_or_thawed=True): """A class that describes binary sensor entities.""" diff --git a/homeassistant/components/lock/__init__.py b/homeassistant/components/lock/__init__.py index ca91236a77c5c..b28aa9d0a1b24 100644 --- a/homeassistant/components/lock/__init__.py +++ b/homeassistant/components/lock/__init__.py @@ -1,7 +1,6 @@ """Component to interface with locks that can be controlled remotely.""" from __future__ import annotations -from dataclasses import dataclass from datetime import timedelta from enum import IntFlag import functools as ft @@ -101,8 +100,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: return await component.async_unload_entry(entry) -@dataclass -class LockEntityDescription(EntityDescription): +class LockEntityDescription(EntityDescription, frozen_or_thawed=True): """A class that describes lock entities.""" diff --git a/homeassistant/components/media_player/__init__.py b/homeassistant/components/media_player/__init__.py index 2ca47b97275db..a45127d7b8672 100644 --- a/homeassistant/components/media_player/__init__.py +++ b/homeassistant/components/media_player/__init__.py @@ -5,7 +5,6 @@ import collections from collections.abc import Callable from contextlib import suppress -from dataclasses import dataclass import datetime as dt from enum import StrEnum import functools as ft @@ -449,8 +448,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: return await component.async_unload_entry(entry) -@dataclass -class MediaPlayerEntityDescription(EntityDescription): +class MediaPlayerEntityDescription(EntityDescription, frozen_or_thawed=True): """A class that describes media player entities.""" device_class: MediaPlayerDeviceClass | None = None diff --git a/homeassistant/components/number/__init__.py b/homeassistant/components/number/__init__.py index 201fa8fedb654..631fc5fc96c69 100644 --- a/homeassistant/components/number/__init__.py +++ b/homeassistant/components/number/__init__.py @@ -120,8 +120,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: return await component.async_unload_entry(entry) -@dataclasses.dataclass -class NumberEntityDescription(EntityDescription): +class NumberEntityDescription(EntityDescription, frozen_or_thawed=True): """A class that describes number entities.""" device_class: NumberDeviceClass | None = None diff --git a/homeassistant/components/remote/__init__.py b/homeassistant/components/remote/__init__.py index 17915e1be195d..2901c14c45514 100644 --- a/homeassistant/components/remote/__init__.py +++ b/homeassistant/components/remote/__init__.py @@ -2,7 +2,6 @@ from __future__ import annotations from collections.abc import Iterable -from dataclasses import dataclass from datetime import timedelta from enum import IntFlag import functools as ft @@ -155,8 +154,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: return await component.async_unload_entry(entry) -@dataclass -class RemoteEntityDescription(ToggleEntityDescription): +class RemoteEntityDescription(ToggleEntityDescription, frozen_or_thawed=True): """A class that describes remote entities.""" diff --git a/homeassistant/components/select/__init__.py b/homeassistant/components/select/__init__.py index 4997e088a54b0..9c978555dd5cb 100644 --- a/homeassistant/components/select/__init__.py +++ b/homeassistant/components/select/__init__.py @@ -1,7 +1,6 @@ """Component to allow selecting an option from a list as platforms.""" from __future__ import annotations -from dataclasses import dataclass from datetime import timedelta import logging from typing import Any, final @@ -118,8 +117,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: return await component.async_unload_entry(entry) -@dataclass -class SelectEntityDescription(EntityDescription): +class SelectEntityDescription(EntityDescription, frozen_or_thawed=True): """A class that describes select entities.""" options: list[str] | None = None diff --git a/homeassistant/components/sensor/__init__.py b/homeassistant/components/sensor/__init__.py index 0fa270bb03dd2..9cdcfade9ec13 100644 --- a/homeassistant/components/sensor/__init__.py +++ b/homeassistant/components/sensor/__init__.py @@ -136,8 +136,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: return await component.async_unload_entry(entry) -@dataclass -class SensorEntityDescription(EntityDescription): +class SensorEntityDescription(EntityDescription, frozen_or_thawed=True): """A class that describes sensor entities.""" device_class: SensorDeviceClass | None = None diff --git a/homeassistant/components/siren/__init__.py b/homeassistant/components/siren/__init__.py index ac02201b92862..d7e8843f54b92 100644 --- a/homeassistant/components/siren/__init__.py +++ b/homeassistant/components/siren/__init__.py @@ -1,7 +1,6 @@ """Component to interface with various sirens/chimes.""" from __future__ import annotations -from dataclasses import dataclass from datetime import timedelta import logging from typing import Any, TypedDict, cast, final @@ -149,8 +148,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: return await component.async_unload_entry(entry) -@dataclass -class SirenEntityDescription(ToggleEntityDescription): +class SirenEntityDescription(ToggleEntityDescription, frozen_or_thawed=True): """A class that describes siren entities.""" available_tones: list[int | str] | dict[int, str] | None = None diff --git a/homeassistant/components/switch/__init__.py b/homeassistant/components/switch/__init__.py index bf3c3424142e0..bdbb2b7701bb9 100644 --- a/homeassistant/components/switch/__init__.py +++ b/homeassistant/components/switch/__init__.py @@ -1,7 +1,6 @@ """Component to interface with switches that can be controlled remotely.""" from __future__ import annotations -from dataclasses import dataclass from datetime import timedelta from enum import StrEnum import logging @@ -89,8 +88,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: return await component.async_unload_entry(entry) -@dataclass -class SwitchEntityDescription(ToggleEntityDescription): +class SwitchEntityDescription(ToggleEntityDescription, frozen_or_thawed=True): """A class that describes switch entities.""" device_class: SwitchDeviceClass | None = None diff --git a/homeassistant/components/text/__init__.py b/homeassistant/components/text/__init__.py index acc5f62a0cc57..8e20fdd33afd9 100644 --- a/homeassistant/components/text/__init__.py +++ b/homeassistant/components/text/__init__.py @@ -98,8 +98,7 @@ class TextMode(StrEnum): TEXT = "text" -@dataclass -class TextEntityDescription(EntityDescription): +class TextEntityDescription(EntityDescription, frozen_or_thawed=True): """A class that describes text entities.""" native_min: int = 0 diff --git a/homeassistant/components/time/__init__.py b/homeassistant/components/time/__init__.py index 26d40191fb959..2b5721aaf1bfc 100644 --- a/homeassistant/components/time/__init__.py +++ b/homeassistant/components/time/__init__.py @@ -1,7 +1,6 @@ """Component to allow setting time as platforms.""" from __future__ import annotations -from dataclasses import dataclass from datetime import time, timedelta import logging from typing import final @@ -62,8 +61,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: return await component.async_unload_entry(entry) -@dataclass -class TimeEntityDescription(EntityDescription): +class TimeEntityDescription(EntityDescription, frozen_or_thawed=True): """A class that describes time entities.""" diff --git a/homeassistant/components/update/__init__.py b/homeassistant/components/update/__init__.py index c9496ce8f7bf7..8597647fc18e9 100644 --- a/homeassistant/components/update/__init__.py +++ b/homeassistant/components/update/__init__.py @@ -1,7 +1,6 @@ """Component to allow for providing device or service updates.""" from __future__ import annotations -from dataclasses import dataclass from datetime import timedelta from enum import StrEnum from functools import lru_cache @@ -175,8 +174,7 @@ async def async_clear_skipped(entity: UpdateEntity, service_call: ServiceCall) - await entity.async_clear_skipped() -@dataclass -class UpdateEntityDescription(EntityDescription): +class UpdateEntityDescription(EntityDescription, frozen_or_thawed=True): """A class that describes update entities.""" device_class: UpdateDeviceClass | None = None diff --git a/homeassistant/components/vacuum/__init__.py b/homeassistant/components/vacuum/__init__.py index c0680913df674..5ffb3de2a12b5 100644 --- a/homeassistant/components/vacuum/__init__.py +++ b/homeassistant/components/vacuum/__init__.py @@ -3,7 +3,6 @@ import asyncio from collections.abc import Mapping -from dataclasses import dataclass from datetime import timedelta from enum import IntFlag from functools import partial @@ -367,8 +366,7 @@ async def async_send_command( ) -@dataclass -class VacuumEntityDescription(ToggleEntityDescription): +class VacuumEntityDescription(ToggleEntityDescription, frozen_or_thawed=True): """A class that describes vacuum entities.""" @@ -490,8 +488,7 @@ async def async_start_pause(self, **kwargs: Any) -> None: await self.hass.async_add_executor_job(partial(self.start_pause, **kwargs)) -@dataclass -class StateVacuumEntityDescription(EntityDescription): +class StateVacuumEntityDescription(EntityDescription, frozen_or_thawed=True): """A class that describes vacuum entities.""" diff --git a/homeassistant/components/water_heater/__init__.py b/homeassistant/components/water_heater/__init__.py index 9e796092f6a04..6506be1006550 100644 --- a/homeassistant/components/water_heater/__init__.py +++ b/homeassistant/components/water_heater/__init__.py @@ -2,7 +2,6 @@ from __future__ import annotations from collections.abc import Mapping -from dataclasses import dataclass from datetime import timedelta from enum import IntFlag import functools as ft @@ -156,8 +155,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: return await component.async_unload_entry(entry) -@dataclass -class WaterHeaterEntityEntityDescription(EntityDescription): +class WaterHeaterEntityEntityDescription(EntityDescription, frozen_or_thawed=True): """A class that describes water heater entities.""" diff --git a/homeassistant/components/weather/__init__.py b/homeassistant/components/weather/__init__.py index 3d9eccd9425cf..899181f2b5f66 100644 --- a/homeassistant/components/weather/__init__.py +++ b/homeassistant/components/weather/__init__.py @@ -5,7 +5,6 @@ import asyncio from collections.abc import Callable, Iterable from contextlib import suppress -from dataclasses import dataclass from datetime import timedelta from functools import partial import logging @@ -251,8 +250,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: return await component.async_unload_entry(entry) -@dataclass -class WeatherEntityDescription(EntityDescription): +class WeatherEntityDescription(EntityDescription, frozen_or_thawed=True): """A class that describes weather entities.""" diff --git a/homeassistant/helpers/entity.py b/homeassistant/helpers/entity.py index f19edaf28b926..9f5ff3dad52a8 100644 --- a/homeassistant/helpers/entity.py +++ b/homeassistant/helpers/entity.py @@ -1313,8 +1313,7 @@ def _suggest_report_issue(self) -> str: ) -@dataclasses.dataclass(slots=True) -class ToggleEntityDescription(EntityDescription): +class ToggleEntityDescription(EntityDescription, frozen_or_thawed=True): """A class that describes toggle entities."""