Warn if unit_of_measurement is set on instances of SensorEntityDescription (#54867)
* Add class BaseEntityDescription without unit_of_measurement * Refactor according to review comments * Tweak * Fix offending integrations * Fix offending integrations
This commit is contained in:
parent
e134246cbd
commit
2fa07777cd
6 changed files with 57 additions and 29 deletions
|
@ -53,35 +53,35 @@ ATTR_TOTAL_ENERGY_KWH = "total_energy_kwh"
|
|||
ENERGY_SENSORS: Final[list[SensorEntityDescription]] = [
|
||||
SensorEntityDescription(
|
||||
key=ATTR_CURRENT_POWER_W,
|
||||
unit_of_measurement=POWER_WATT,
|
||||
native_unit_of_measurement=POWER_WATT,
|
||||
device_class=DEVICE_CLASS_POWER,
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
name="Current Consumption",
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key=ATTR_TOTAL_ENERGY_KWH,
|
||||
unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
device_class=DEVICE_CLASS_ENERGY,
|
||||
state_class=STATE_CLASS_TOTAL_INCREASING,
|
||||
name="Total Consumption",
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key=ATTR_TODAY_ENERGY_KWH,
|
||||
unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
device_class=DEVICE_CLASS_ENERGY,
|
||||
state_class=STATE_CLASS_TOTAL_INCREASING,
|
||||
name="Today's Consumption",
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key=ATTR_VOLTAGE,
|
||||
unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
|
||||
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
|
||||
device_class=DEVICE_CLASS_VOLTAGE,
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
name="Voltage",
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key=ATTR_CURRENT_A,
|
||||
unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
|
||||
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
|
||||
device_class=DEVICE_CLASS_CURRENT,
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
name="Current",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue