The range of days of the week according to the datasheet is 0-6, and you have 1-7 when recording. Although for the alarm at the very end of the code is correct.
145 day [0,7]
180 if day < 1 or day > 7:
181 raise ValueError('Day is out of range [1,7].')
280 if weekday < 0 or weekday > 6:
281 raise ValueError('weekday is out of range [0,6].')
The range of days of the week according to the datasheet is 0-6, and you have 1-7 when recording. Although for the alarm at the very end of the code is correct.