mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 12:47:08 +00:00
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 2b6ccd4c3bb921a1b607239a33ef15834dd23e8c.
This commit is contained in:
parent
9a510cfe32
commit
7a7a9c610a
@ -16,7 +16,7 @@ from homeassistant.const import UnitOfPressure, UnitOfTemperature
|
|||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.device_registry import DeviceInfo
|
from homeassistant.helpers.device_registry import DeviceInfo
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.util import slugify
|
from homeassistant.helpers.typing import StateType
|
||||||
|
|
||||||
from . import InComfortConfigEntry
|
from . import InComfortConfigEntry
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
@ -28,10 +28,11 @@ INCOMFORT_PRESSURE = "CV Pressure"
|
|||||||
INCOMFORT_TAP_TEMP = "Tap Temp"
|
INCOMFORT_TAP_TEMP = "Tap Temp"
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True, kw_only=True)
|
||||||
class IncomfortSensorEntityDescription(SensorEntityDescription):
|
class IncomfortSensorEntityDescription(SensorEntityDescription):
|
||||||
"""Describes Incomfort sensor entity."""
|
"""Describes Incomfort sensor entity."""
|
||||||
|
|
||||||
|
value_key: str
|
||||||
extra_key: str | None = None
|
extra_key: str | None = None
|
||||||
# IncomfortSensor does not support UNDEFINED or None,
|
# IncomfortSensor does not support UNDEFINED or None,
|
||||||
# restrict the type to str
|
# restrict the type to str
|
||||||
@ -40,17 +41,19 @@ class IncomfortSensorEntityDescription(SensorEntityDescription):
|
|||||||
|
|
||||||
SENSOR_TYPES: tuple[IncomfortSensorEntityDescription, ...] = (
|
SENSOR_TYPES: tuple[IncomfortSensorEntityDescription, ...] = (
|
||||||
IncomfortSensorEntityDescription(
|
IncomfortSensorEntityDescription(
|
||||||
key="pressure",
|
key="cv_pressure",
|
||||||
name=INCOMFORT_PRESSURE,
|
name=INCOMFORT_PRESSURE,
|
||||||
device_class=SensorDeviceClass.PRESSURE,
|
device_class=SensorDeviceClass.PRESSURE,
|
||||||
native_unit_of_measurement=UnitOfPressure.BAR,
|
native_unit_of_measurement=UnitOfPressure.BAR,
|
||||||
|
value_key="pressure",
|
||||||
),
|
),
|
||||||
IncomfortSensorEntityDescription(
|
IncomfortSensorEntityDescription(
|
||||||
key="heater_temp",
|
key="cv_temp",
|
||||||
name=INCOMFORT_HEATER_TEMP,
|
name=INCOMFORT_HEATER_TEMP,
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||||
extra_key="is_pumping",
|
extra_key="is_pumping",
|
||||||
|
value_key="heater_temp",
|
||||||
),
|
),
|
||||||
IncomfortSensorEntityDescription(
|
IncomfortSensorEntityDescription(
|
||||||
key="tap_temp",
|
key="tap_temp",
|
||||||
@ -58,6 +61,7 @@ SENSOR_TYPES: tuple[IncomfortSensorEntityDescription, ...] = (
|
|||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||||
extra_key="is_tapping",
|
extra_key="is_tapping",
|
||||||
|
value_key="tap_temp",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -94,7 +98,7 @@ class IncomfortSensor(IncomfortEntity, SensorEntity):
|
|||||||
|
|
||||||
self._heater = heater
|
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(
|
self._attr_device_info = DeviceInfo(
|
||||||
identifiers={(DOMAIN, heater.serial_no)},
|
identifiers={(DOMAIN, heater.serial_no)},
|
||||||
manufacturer="Intergas",
|
manufacturer="Intergas",
|
||||||
@ -102,9 +106,9 @@ class IncomfortSensor(IncomfortEntity, SensorEntity):
|
|||||||
)
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def native_value(self) -> str | None:
|
def native_value(self) -> StateType:
|
||||||
"""Return the state of the sensor."""
|
"""Return the state of the sensor."""
|
||||||
return self._heater.status[self.entity_description.key]
|
return self._heater.status[self.entity_description.value_key]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def extra_state_attributes(self) -> dict[str, Any] | None:
|
def extra_state_attributes(self) -> dict[str, Any] | None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user