mirror of
https://github.com/home-assistant/core.git
synced 2025-07-28 15:47:12 +00:00
Avoid mutating entity descriptions in onewire (#105970)
This commit is contained in:
parent
57a6effd70
commit
7a9e303e20
@ -2,8 +2,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import Callable, Mapping
|
from collections.abc import Callable, Mapping
|
||||||
import copy
|
import dataclasses
|
||||||
from dataclasses import dataclass
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
from types import MappingProxyType
|
from types import MappingProxyType
|
||||||
@ -43,7 +42,7 @@ from .onewire_entities import OneWireEntity, OneWireEntityDescription
|
|||||||
from .onewirehub import OneWireHub
|
from .onewirehub import OneWireHub
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclasses.dataclass
|
||||||
class OneWireSensorEntityDescription(OneWireEntityDescription, SensorEntityDescription):
|
class OneWireSensorEntityDescription(OneWireEntityDescription, SensorEntityDescription):
|
||||||
"""Class describing OneWire sensor entities."""
|
"""Class describing OneWire sensor entities."""
|
||||||
|
|
||||||
@ -393,10 +392,12 @@ def get_entities(
|
|||||||
).decode()
|
).decode()
|
||||||
)
|
)
|
||||||
if is_leaf:
|
if is_leaf:
|
||||||
description = copy.deepcopy(description)
|
description = dataclasses.replace(
|
||||||
description.device_class = SensorDeviceClass.HUMIDITY
|
description,
|
||||||
description.native_unit_of_measurement = PERCENTAGE
|
device_class=SensorDeviceClass.HUMIDITY,
|
||||||
description.translation_key = f"wetness_{s_id}"
|
native_unit_of_measurement=PERCENTAGE,
|
||||||
|
translation_key=f"wetness_{s_id}",
|
||||||
|
)
|
||||||
_LOGGER.info(description.translation_key)
|
_LOGGER.info(description.translation_key)
|
||||||
override_key = None
|
override_key = None
|
||||||
if description.override_key:
|
if description.override_key:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user