Skip to content

Commit

Permalink
Messy debug logging for EnergyUsageSensor
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-r committed Oct 27, 2024
1 parent 63a0572 commit 15c168a
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion custom_components/ohme/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,36 @@ def __init__(

@callback
def _handle_coordinator_update(self) -> None:
charge_graph = -1
battery_soc = -1
car_battery_soc = -1
car_vehicle_status = -1

try:
charge_graph = self.coordinator.data['chargeGraph']['now']['y']
except:
pass

try:
battery_soc = self.coordinator.data['batterySoc']['wh']
except:
pass

try:
car_battery_soc = self.coordinator.data['car']['batterySoc']['wh']
except:
pass

try:
car_vehicle_status = self.coordinator.data['car']['vehicleStatus']['soc']['wh']
except:
pass

_LOGGER.debug("EnergyUsageSensor: CG: %s, BS: %s, CB: %s, CV: %s", charge_graph, battery_soc, car_battery_soc, car_vehicle_status)

# Ensure we have data, then ensure value is going up and above 0
if self.coordinator.data and self.coordinator.data['batterySoc']:
new_state = self.coordinator.data['batterySoc']['wh']
_LOGGER.debug("EnergyUsageSensor: Raw Wh reading %s", new_state)

# Let the state reset to 0, but not drop otherwise
if not new_state or new_state <= 0:
Expand Down

0 comments on commit 15c168a

Please sign in to comment.