Move temperature conversions to sensor base class (5/8) (#54475)
This commit is contained in:
parent
e55868b17f
commit
103e21c278
65 changed files with 289 additions and 288 deletions
|
@ -87,7 +87,7 @@ class PowerWallChargeSensor(PowerWallEntity, SensorEntity):
|
|||
"""Representation of an Powerwall charge sensor."""
|
||||
|
||||
_attr_name = "Powerwall Charge"
|
||||
_attr_unit_of_measurement = PERCENTAGE
|
||||
_attr_native_unit_of_measurement = PERCENTAGE
|
||||
_attr_device_class = DEVICE_CLASS_BATTERY
|
||||
|
||||
@property
|
||||
|
@ -96,7 +96,7 @@ class PowerWallChargeSensor(PowerWallEntity, SensorEntity):
|
|||
return f"{self.base_unique_id}_charge"
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
def native_value(self):
|
||||
"""Get the current value in percentage."""
|
||||
return round(self.coordinator.data[POWERWALL_API_CHARGE])
|
||||
|
||||
|
@ -105,7 +105,7 @@ class PowerWallEnergySensor(PowerWallEntity, SensorEntity):
|
|||
"""Representation of an Powerwall Energy sensor."""
|
||||
|
||||
_attr_state_class = STATE_CLASS_MEASUREMENT
|
||||
_attr_unit_of_measurement = POWER_KILO_WATT
|
||||
_attr_native_unit_of_measurement = POWER_KILO_WATT
|
||||
_attr_device_class = DEVICE_CLASS_POWER
|
||||
|
||||
def __init__(
|
||||
|
@ -128,7 +128,7 @@ class PowerWallEnergySensor(PowerWallEntity, SensorEntity):
|
|||
)
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
def native_value(self):
|
||||
"""Get the current value in kW."""
|
||||
return (
|
||||
self.coordinator.data[POWERWALL_API_METERS]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue