mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 15:17:35 +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."""
|
"""Support for a ScreenLogic Binary Sensor."""
|
||||||
from copy import copy
|
from copy import copy
|
||||||
from dataclasses import dataclass
|
import dataclasses
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from screenlogicpy.const.common import ON_OFF
|
from screenlogicpy.const.common import ON_OFF
|
||||||
@ -32,14 +32,14 @@ from .util import cleanup_excluded_entity
|
|||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclasses.dataclass
|
||||||
class ScreenLogicBinarySensorDescription(
|
class ScreenLogicBinarySensorDescription(
|
||||||
BinarySensorEntityDescription, ScreenLogicEntityDescription
|
BinarySensorEntityDescription, ScreenLogicEntityDescription
|
||||||
):
|
):
|
||||||
"""A class that describes ScreenLogic binary sensor eneites."""
|
"""A class that describes ScreenLogic binary sensor eneites."""
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclasses.dataclass
|
||||||
class ScreenLogicPushBinarySensorDescription(
|
class ScreenLogicPushBinarySensorDescription(
|
||||||
ScreenLogicBinarySensorDescription, ScreenLogicPushEntityDescription
|
ScreenLogicBinarySensorDescription, ScreenLogicPushEntityDescription
|
||||||
):
|
):
|
||||||
@ -261,5 +261,7 @@ class ScreenLogicPumpBinarySensor(ScreenLogicBinarySensor):
|
|||||||
pump_index: int,
|
pump_index: int,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize of the entity."""
|
"""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)
|
super().__init__(coordinator, entity_description)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
"""Support for a ScreenLogic Sensor."""
|
"""Support for a ScreenLogic Sensor."""
|
||||||
from collections.abc import Callable
|
from collections.abc import Callable
|
||||||
from copy import copy
|
from copy import copy
|
||||||
from dataclasses import dataclass
|
import dataclasses
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from screenlogicpy.const.data import ATTR, DEVICE, GROUP, VALUE
|
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__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclasses.dataclass
|
||||||
class ScreenLogicSensorMixin:
|
class ScreenLogicSensorMixin:
|
||||||
"""Mixin for SecreenLogic sensor entity."""
|
"""Mixin for SecreenLogic sensor entity."""
|
||||||
|
|
||||||
value_mod: Callable[[int | str], int | str] | None = None
|
value_mod: Callable[[int | str], int | str] | None = None
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclasses.dataclass
|
||||||
class ScreenLogicSensorDescription(
|
class ScreenLogicSensorDescription(
|
||||||
ScreenLogicSensorMixin, SensorEntityDescription, ScreenLogicEntityDescription
|
ScreenLogicSensorMixin, SensorEntityDescription, ScreenLogicEntityDescription
|
||||||
):
|
):
|
||||||
"""Describes a ScreenLogic sensor."""
|
"""Describes a ScreenLogic sensor."""
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclasses.dataclass
|
||||||
class ScreenLogicPushSensorDescription(
|
class ScreenLogicPushSensorDescription(
|
||||||
ScreenLogicSensorDescription, ScreenLogicPushEntityDescription
|
ScreenLogicSensorDescription, ScreenLogicPushEntityDescription
|
||||||
):
|
):
|
||||||
@ -336,7 +336,9 @@ class ScreenLogicPumpSensor(ScreenLogicSensor):
|
|||||||
pump_type: int,
|
pump_type: int,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize of the entity."""
|
"""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)
|
super().__init__(coordinator, entity_description)
|
||||||
if entity_description.enabled_lambda:
|
if entity_description.enabled_lambda:
|
||||||
self._attr_entity_registry_enabled_default = (
|
self._attr_entity_registry_enabled_default = (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user