Skip to content

Commit

Permalink
add error message
Browse files Browse the repository at this point in the history
  • Loading branch information
EdLeckert committed Oct 15, 2023
1 parent d682327 commit b7a5aa7
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions pyopensprinkler/program.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def _encode_offset_minutes(self, offset_type, start_time_offset):
return start_time_offset

def _get_offset_type(self, start_times, start_index):
"""Get start time offset type ('midnight', 'sunset', or 'sunrise')"""
"""Get start time offset type ('disabled', 'midnight', 'sunset', or 'sunrise')"""
use_sunset = bool(self._is_set(start_times[start_index], START_TIME_SUNSET_BIT))
use_sunrise = bool(
self._is_set(start_times[start_index], START_TIME_SUNRISE_BIT)
Expand Down Expand Up @@ -250,11 +250,14 @@ async def set_program_start_time_offset(self, start_index, start_time_offset):
f"cannot update start{start_index} with minutes when start time type is 'repeating'"
)

if ():
raise ValueError(f"cannot adjust offset when start{start_index} is Disabled")

dlist = self._get_program_data().copy()
current_offset_type = self._get_offset_type(dlist[3], start_index)

if (current_offset_type == "disabled"):
raise ValueError(
f"cannot adjust offset when start{start_index} is Disabled"
)

new_start = self._encode_offset_minutes(current_offset_type, start_time_offset)
dlist[3][start_index] = new_start
params = self._format_program_data(dlist)
Expand Down

0 comments on commit b7a5aa7

Please sign in to comment.