Detach name from unique id in incomfort (#118862)
* Detach name from unique id in incomfort
* Add entity descriptions to incomfort
* Revert "Add entity descriptions to incomfort"
This reverts commit 2b6ccd4c3b
.
pull/118837/head
parent
9a510cfe32
commit
7a7a9c610a
|
@ -16,7 +16,7 @@ from homeassistant.const import UnitOfPressure, UnitOfTemperature
|
|||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.device_registry import DeviceInfo
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.util import slugify
|
||||
from homeassistant.helpers.typing import StateType
|
||||
|
||||
from . import InComfortConfigEntry
|
||||
from .const import DOMAIN
|
||||
|
@ -28,10 +28,11 @@ INCOMFORT_PRESSURE = "CV Pressure"
|
|||
INCOMFORT_TAP_TEMP = "Tap Temp"
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@dataclass(frozen=True, kw_only=True)
|
||||
class IncomfortSensorEntityDescription(SensorEntityDescription):
|
||||
"""Describes Incomfort sensor entity."""
|
||||
|
||||
value_key: str
|
||||
extra_key: str | None = None
|
||||
# IncomfortSensor does not support UNDEFINED or None,
|
||||
# restrict the type to str
|
||||
|
@ -40,17 +41,19 @@ class IncomfortSensorEntityDescription(SensorEntityDescription):
|
|||
|
||||
SENSOR_TYPES: tuple[IncomfortSensorEntityDescription, ...] = (
|
||||
IncomfortSensorEntityDescription(
|
||||
key="pressure",
|
||||
key="cv_pressure",
|
||||
name=INCOMFORT_PRESSURE,
|
||||
device_class=SensorDeviceClass.PRESSURE,
|
||||
native_unit_of_measurement=UnitOfPressure.BAR,
|
||||
value_key="pressure",
|
||||
),
|
||||
IncomfortSensorEntityDescription(
|
||||
key="heater_temp",
|
||||
key="cv_temp",
|
||||
name=INCOMFORT_HEATER_TEMP,
|
||||
device_class=SensorDeviceClass.TEMPERATURE,
|
||||
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||
extra_key="is_pumping",
|
||||
value_key="heater_temp",
|
||||
),
|
||||
IncomfortSensorEntityDescription(
|
||||
key="tap_temp",
|
||||
|
@ -58,6 +61,7 @@ SENSOR_TYPES: tuple[IncomfortSensorEntityDescription, ...] = (
|
|||
device_class=SensorDeviceClass.TEMPERATURE,
|
||||
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||
extra_key="is_tapping",
|
||||
value_key="tap_temp",
|
||||
),
|
||||
)
|
||||
|
||||
|
@ -94,7 +98,7 @@ class IncomfortSensor(IncomfortEntity, SensorEntity):
|
|||
|
||||
self._heater = heater
|
||||
|
||||
self._attr_unique_id = f"{heater.serial_no}_{slugify(description.name)}"
|
||||
self._attr_unique_id = f"{heater.serial_no}_{description.key}"
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={(DOMAIN, heater.serial_no)},
|
||||
manufacturer="Intergas",
|
||||
|
@ -102,9 +106,9 @@ class IncomfortSensor(IncomfortEntity, SensorEntity):
|
|||
)
|
||||
|
||||
@property
|
||||
def native_value(self) -> str | None:
|
||||
def native_value(self) -> StateType:
|
||||
"""Return the state of the sensor."""
|
||||
return self._heater.status[self.entity_description.key]
|
||||
return self._heater.status[self.entity_description.value_key]
|
||||
|
||||
@property
|
||||
def extra_state_attributes(self) -> dict[str, Any] | None:
|
||||
|
|
Loading…
Reference in New Issue