Skip to content

Commit

Permalink
feat: Update to use suggested unit of measurement (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
mindmelting authored Apr 8, 2023
1 parent 79eb353 commit 0eff60c
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions custom_components/powerpal/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,20 @@ def state_class(self) -> str:
"""Return the state class."""
return STATE_CLASS_TOTAL_INCREASING

@property
def suggested_unit_of_measurement(self) -> str:
"""Return the suggestted unit of measurement."""
return UnitOfEnergy.KILO_WATT_HOUR

@property
def native_unit_of_measurement(self) -> str:
"""Return the native unit of measurement."""
return UnitOfEnergy.KILO_WATT_HOUR
return UnitOfEnergy.WATT_HOUR

@property
def native_value(self):
"""Return the native value of the sensor."""
return self.coordinator.data.get("total_watt_hours") / 1000
return self.coordinator.data.get("total_watt_hours")


class PowerpalLiveConsumptionSensor(PowerpalSensor, SensorEntity):
Expand All @@ -108,12 +113,17 @@ def state_class(self) -> str:
"""Return the state class."""
return STATE_CLASS_MEASUREMENT

@property
def suggested_unit_of_measurement(self) -> str:
"""Return the suggestted unit of measurement."""
return UnitOfPower.KILO_WATT

@property
def native_unit_of_measurement(self) -> str:
"""Return the native unit of measurement."""
return UnitOfPower.KILO_WATT
return UnitOfPower.WATT

@property
def native_value(self):
"""Return the native value of the sensor."""
return (self.coordinator.data.get("last_reading_watt_hours") * 60) / 1000
return self.coordinator.data.get("last_reading_watt_hours") * 60

0 comments on commit 0eff60c

Please sign in to comment.