Skip to content

Commit

Permalink
Tweaks to energy sensor and doc changes (#11)
Browse files Browse the repository at this point in the history
* Graph logic tweak

* Fix native and suggested units for energy

* Doc changes
  • Loading branch information
dan-r authored Dec 28, 2023
1 parent c4958b5 commit d698c2d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ A basic integration for interacting with Ohme EV Chargers.

This is an unofficial integration. I have no affiliation with Ohme besides owning one of their EV chargers.

This has only be tested with an Ohme Home Pro and does not currently support social login or accounts with multiple chargers.
This integration does not currently support social login or accounts with multiple chargers. It has been tested with the following hardware:
* Ohme Home Pro [UK]
* Ohme Home/Go [UK]

If you find any bugs or would like to request a feature, please open an issue.

## Entities
This integration exposes the following entities:
Expand Down
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
2 changes: 1 addition & 1 deletion custom_components/ohme/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def charge_graph_next_slot(charge_start, points):
# If the next point has a Y delta of 10+, consider this the start of a slot
# This should be 0+ but I had some strange results in testing... revisit
if delta > 10:
next_ts = data[idx]["t"]
next_ts = data[idx]["t"] + 1 # 1s added here as it otherwise often rounds down to xx:59:59
break

# This needs to be presented with tzinfo or Home Assistant will reject it
Expand Down

0 comments on commit d698c2d

Please sign in to comment.