Skip to content

Commit

Permalink
Fix native and suggested units for energy
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-r committed Dec 28, 2023
1 parent 8ad87f1 commit 16aadf4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions custom_components/ohme/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ def native_value(self):
class EnergyUsageSensor(CoordinatorEntity[OhmeStatisticsCoordinator], SensorEntity):
"""Sensor for total energy usage."""
_attr_name = "Accumulative Energy Usage"
_attr_native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR
_attr_native_unit_of_measurement = UnitOfEnergy.WATT_HOUR
_attr_suggested_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR
_attr_suggested_display_precision = 1
_attr_device_class = SensorDeviceClass.ENERGY

def __init__(
Expand Down Expand Up @@ -111,7 +113,7 @@ def icon(self):
def native_value(self):
"""Get value from data returned from API by coordinator"""
if self.coordinator.data and self.coordinator.data['energyChargedTotalWh']:
return self.coordinator.data['energyChargedTotalWh'] / 1000
return self.coordinator.data['energyChargedTotalWh']

return None

Expand Down

0 comments on commit 16aadf4

Please sign in to comment.