diff --git a/pyopensprinkler/program.py b/pyopensprinkler/program.py index 69a5298..9b90df3 100644 --- a/pyopensprinkler/program.py +++ b/pyopensprinkler/program.py @@ -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) @@ -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)