From d698c2d9467d9ecc65a7392ac2b73b831de1bac8 Mon Sep 17 00:00:00 2001 From: Dan Raper Date: Thu, 28 Dec 2023 20:59:11 +0000 Subject: [PATCH] Tweaks to energy sensor and doc changes (#11) * Graph logic tweak * Fix native and suggested units for energy * Doc changes --- README.md | 6 +++++- custom_components/ohme/sensor.py | 6 ++++-- custom_components/ohme/utils.py | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 48c6ff0..13dea13 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/custom_components/ohme/sensor.py b/custom_components/ohme/sensor.py index fe94724..c043924 100644 --- a/custom_components/ohme/sensor.py +++ b/custom_components/ohme/sensor.py @@ -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__( @@ -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 diff --git a/custom_components/ohme/utils.py b/custom_components/ohme/utils.py index 28dd6d6..7b079f2 100644 --- a/custom_components/ohme/utils.py +++ b/custom_components/ohme/utils.py @@ -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