Skip to content

Commit

Permalink
Replace time drift conditions in solis_modbus
Browse files Browse the repository at this point in the history
The time drift conditions now use 'total_drift', which is calculated by summing the drift in hours, minutes, and seconds. This change enhances the clarity and readability of the code in the solis_modbus component.
  • Loading branch information
Pho3niX90 committed Mar 12, 2024
1 parent 08c9a06 commit e1c15ef
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions custom_components/solis_modbus/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -753,14 +753,15 @@ def clock_drift_test(hours, minutes, seconds):
d_hours = r_hours - hours
d_minutes = r_minutes - minutes
d_seconds = r_seconds - seconds
total_drift = (d_hours * 60 * 60) + (d_minutes * 60) + d_seconds

if abs(d_seconds) > 60:
if abs(total_drift) > 60:
_LOGGER.critical(f"inverter time {hours}:{minutes}:{seconds}. drift = {d_hours}:{d_minutes}:{d_seconds}")

elif abs(d_seconds) > 30:
elif abs(total_drift) > 30:
_LOGGER.warning(f"inverter time {hours}:{minutes}:{seconds}. drift = {d_hours}:{d_minutes}:{d_seconds}")

elif abs(d_seconds) > 10:
elif abs(total_drift) > 10:
_LOGGER.info(f"inverter time {hours}:{minutes}:{seconds}. drift = {d_hours}:{d_minutes}:{d_seconds}")
else:
_LOGGER.debug(f"inverter time {hours}:{minutes}:{seconds}. drift = {d_hours}:{d_minutes}:{d_seconds}")
Expand Down

0 comments on commit e1c15ef

Please sign in to comment.