Skip to content

Commit

Permalink
Add debug features
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean-Marc Collin committed Jun 14, 2023
1 parent ae614db commit d488808
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions custom_components/solar_optimizer/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ def update_custom_attributes(self, device):
"requested_power": device.requested_power,
"duration_sec": device.duration_sec,
"duration_power_sec": device.duration_power_sec,
"power_min": device.power_min,
"power_max": device.power_max,
"next_date_available": device.next_date_available.astimezone(
current_tz
).isoformat(),
Expand Down
9 changes: 8 additions & 1 deletion custom_components/solar_optimizer/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ async def _async_update_data(self):
calculated_data["total_power"] = total_power

# Uses the result to turn on or off or change power
should_log = False
for _, equipement in enumerate(best_solution):
_LOGGER.debug("Dealing with best_solution for %s", equipement)
name = equipement["name"]
Expand All @@ -155,9 +156,11 @@ async def _async_update_data(self):
is_active = device.is_active
if is_active and not state:
_LOGGER.debug("Extinction de %s", name)
should_log = True
await device.deactivate()
elif not is_active and state:
_LOGGER.debug("Allumage de %s", name)
should_log = True
await device.activate(requested_power)

# Send change power if state is now on and change power is accepted and (power have change or eqt is just activated)
Expand All @@ -171,9 +174,13 @@ async def _async_update_data(self):
equipement["name"],
requested_power,
)
should_log = True
await device.change_requested_power(requested_power)

_LOGGER.debug("Calculated data are: %s", calculated_data)
if should_log:
_LOGGER.info("Calculated data are: %s", calculated_data)
else:
_LOGGER.debug("Calculated data are: %s", calculated_data)

return calculated_data

Expand Down

0 comments on commit d488808

Please sign in to comment.