mirror of
https://github.com/home-assistant/core.git
synced 2025-08-07 06:35:10 +02:00
Add sensor_name
This commit is contained in:
@@ -27,6 +27,7 @@ from .entity import ZimiEntity
|
|||||||
class ZimiSensorEntityDescription(SensorEntityDescription):
|
class ZimiSensorEntityDescription(SensorEntityDescription):
|
||||||
"""Class describing Zimi sensor entities."""
|
"""Class describing Zimi sensor entities."""
|
||||||
|
|
||||||
|
sensor_name: str | None = None
|
||||||
value_fn: Callable[[ControlPointDevice], StateType]
|
value_fn: Callable[[ControlPointDevice], StateType]
|
||||||
|
|
||||||
|
|
||||||
@@ -36,6 +37,7 @@ GARAGE_SENSOR_DESCRIPTIONS: tuple[ZimiSensorEntityDescription, ...] = (
|
|||||||
translation_key="door_temperature",
|
translation_key="door_temperature",
|
||||||
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
|
sensor_name="Outside Temperature",
|
||||||
value_fn=lambda device: device.door_temp,
|
value_fn=lambda device: device.door_temp,
|
||||||
),
|
),
|
||||||
ZimiSensorEntityDescription(
|
ZimiSensorEntityDescription(
|
||||||
@@ -44,6 +46,7 @@ GARAGE_SENSOR_DESCRIPTIONS: tuple[ZimiSensorEntityDescription, ...] = (
|
|||||||
native_unit_of_measurement=PERCENTAGE,
|
native_unit_of_measurement=PERCENTAGE,
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
device_class=SensorDeviceClass.BATTERY,
|
device_class=SensorDeviceClass.BATTERY,
|
||||||
|
sensor_name="Battery Level",
|
||||||
value_fn=lambda device: device.battery_level,
|
value_fn=lambda device: device.battery_level,
|
||||||
),
|
),
|
||||||
ZimiSensorEntityDescription(
|
ZimiSensorEntityDescription(
|
||||||
@@ -51,6 +54,7 @@ GARAGE_SENSOR_DESCRIPTIONS: tuple[ZimiSensorEntityDescription, ...] = (
|
|||||||
translation_key="garage_temperature",
|
translation_key="garage_temperature",
|
||||||
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
|
sensor_name="Garage Temperature",
|
||||||
value_fn=lambda device: device.garage_temp,
|
value_fn=lambda device: device.garage_temp,
|
||||||
),
|
),
|
||||||
ZimiSensorEntityDescription(
|
ZimiSensorEntityDescription(
|
||||||
@@ -58,6 +62,7 @@ GARAGE_SENSOR_DESCRIPTIONS: tuple[ZimiSensorEntityDescription, ...] = (
|
|||||||
translation_key="garage_humidty",
|
translation_key="garage_humidty",
|
||||||
native_unit_of_measurement=PERCENTAGE,
|
native_unit_of_measurement=PERCENTAGE,
|
||||||
device_class=SensorDeviceClass.HUMIDITY,
|
device_class=SensorDeviceClass.HUMIDITY,
|
||||||
|
sensor_name="Garage Humidity",
|
||||||
value_fn=lambda device: device.garage_humidity,
|
value_fn=lambda device: device.garage_humidity,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@@ -98,6 +103,7 @@ class ZimiSensor(ZimiEntity, SensorEntity):
|
|||||||
|
|
||||||
self.entity_description = description
|
self.entity_description = description
|
||||||
self._attr_unique_id = device.identifier + "." + self.entity_description.key
|
self._attr_unique_id = device.identifier + "." + self.entity_description.key
|
||||||
|
self._attr_name = self.entity_description.sensor_name
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def native_value(self) -> str | int | float | None:
|
def native_value(self) -> str | int | float | None:
|
||||||
|
Reference in New Issue
Block a user