mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 05:37:44 +00:00
Avoid mutating entity descriptions in screenlogic (#105983)
This commit is contained in:
parent
ab40ba80a9
commit
0a6f541b27
@ -1,6 +1,6 @@
|
||||
"""Support for a ScreenLogic Binary Sensor."""
|
||||
from copy import copy
|
||||
from dataclasses import dataclass
|
||||
import dataclasses
|
||||
import logging
|
||||
|
||||
from screenlogicpy.const.common import ON_OFF
|
||||
@ -32,14 +32,14 @@ from .util import cleanup_excluded_entity
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@dataclass
|
||||
@dataclasses.dataclass
|
||||
class ScreenLogicBinarySensorDescription(
|
||||
BinarySensorEntityDescription, ScreenLogicEntityDescription
|
||||
):
|
||||
"""A class that describes ScreenLogic binary sensor eneites."""
|
||||
|
||||
|
||||
@dataclass
|
||||
@dataclasses.dataclass
|
||||
class ScreenLogicPushBinarySensorDescription(
|
||||
ScreenLogicBinarySensorDescription, ScreenLogicPushEntityDescription
|
||||
):
|
||||
@ -261,5 +261,7 @@ class ScreenLogicPumpBinarySensor(ScreenLogicBinarySensor):
|
||||
pump_index: int,
|
||||
) -> None:
|
||||
"""Initialize of the entity."""
|
||||
entity_description.data_root = (DEVICE.PUMP, pump_index)
|
||||
entity_description = dataclasses.replace(
|
||||
entity_description, data_root=(DEVICE.PUMP, pump_index)
|
||||
)
|
||||
super().__init__(coordinator, entity_description)
|
||||
|
@ -1,7 +1,7 @@
|
||||
"""Support for a ScreenLogic Sensor."""
|
||||
from collections.abc import Callable
|
||||
from copy import copy
|
||||
from dataclasses import dataclass
|
||||
import dataclasses
|
||||
import logging
|
||||
|
||||
from screenlogicpy.const.data import ATTR, DEVICE, GROUP, VALUE
|
||||
@ -35,21 +35,21 @@ from .util import cleanup_excluded_entity, get_ha_unit
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@dataclass
|
||||
@dataclasses.dataclass
|
||||
class ScreenLogicSensorMixin:
|
||||
"""Mixin for SecreenLogic sensor entity."""
|
||||
|
||||
value_mod: Callable[[int | str], int | str] | None = None
|
||||
|
||||
|
||||
@dataclass
|
||||
@dataclasses.dataclass
|
||||
class ScreenLogicSensorDescription(
|
||||
ScreenLogicSensorMixin, SensorEntityDescription, ScreenLogicEntityDescription
|
||||
):
|
||||
"""Describes a ScreenLogic sensor."""
|
||||
|
||||
|
||||
@dataclass
|
||||
@dataclasses.dataclass
|
||||
class ScreenLogicPushSensorDescription(
|
||||
ScreenLogicSensorDescription, ScreenLogicPushEntityDescription
|
||||
):
|
||||
@ -336,7 +336,9 @@ class ScreenLogicPumpSensor(ScreenLogicSensor):
|
||||
pump_type: int,
|
||||
) -> None:
|
||||
"""Initialize of the entity."""
|
||||
entity_description.data_root = (DEVICE.PUMP, pump_index)
|
||||
entity_description = dataclasses.replace(
|
||||
entity_description, data_root=(DEVICE.PUMP, pump_index)
|
||||
)
|
||||
super().__init__(coordinator, entity_description)
|
||||
if entity_description.enabled_lambda:
|
||||
self._attr_entity_registry_enabled_default = (
|
||||
|
Loading…
x
Reference in New Issue
Block a user