Migrate TPLink to has entity name (#96246)
This commit is contained in:
parent
f8705a8074
commit
2dc86364f3
6 changed files with 54 additions and 15 deletions
|
@ -46,6 +46,7 @@ class TPLinkSensorEntityDescription(SensorEntityDescription):
|
|||
ENERGY_SENSORS: tuple[TPLinkSensorEntityDescription, ...] = (
|
||||
TPLinkSensorEntityDescription(
|
||||
key=ATTR_CURRENT_POWER_W,
|
||||
translation_key="current_consumption",
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
|
@ -55,6 +56,7 @@ ENERGY_SENSORS: tuple[TPLinkSensorEntityDescription, ...] = (
|
|||
),
|
||||
TPLinkSensorEntityDescription(
|
||||
key=ATTR_TOTAL_ENERGY_KWH,
|
||||
translation_key="total_consumption",
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
|
@ -64,6 +66,7 @@ ENERGY_SENSORS: tuple[TPLinkSensorEntityDescription, ...] = (
|
|||
),
|
||||
TPLinkSensorEntityDescription(
|
||||
key=ATTR_TODAY_ENERGY_KWH,
|
||||
translation_key="today_consumption",
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
|
@ -75,7 +78,6 @@ ENERGY_SENSORS: tuple[TPLinkSensorEntityDescription, ...] = (
|
|||
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
|
||||
device_class=SensorDeviceClass.VOLTAGE,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
name="Voltage",
|
||||
emeter_attr="voltage",
|
||||
precision=1,
|
||||
),
|
||||
|
@ -84,7 +86,6 @@ ENERGY_SENSORS: tuple[TPLinkSensorEntityDescription, ...] = (
|
|||
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
|
||||
device_class=SensorDeviceClass.CURRENT,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
name="Current",
|
||||
emeter_attr="current",
|
||||
precision=2,
|
||||
),
|
||||
|
@ -155,14 +156,6 @@ class SmartPlugSensor(CoordinatedTPLinkEntity, SensorEntity):
|
|||
f"{legacy_device_id(self.device)}_{self.entity_description.key}"
|
||||
)
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
"""Return the name of the Smart Plug.
|
||||
|
||||
Overridden to include the description.
|
||||
"""
|
||||
return f"{self.device.alias} {self.entity_description.name}"
|
||||
|
||||
@property
|
||||
def native_value(self) -> float | None:
|
||||
"""Return the sensors state."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue