@@ -70,19 +70,19 @@ def update_settings(self, config_entry: ConfigEntry):
70
70
71
71
def determine_update_interval (self , hass : HomeAssistant ):
72
72
# Default of low scan minutes interval
73
- scan_interval = self .options .get ("low_scan_interval" , 30 )
73
+ scan_interval = self .options .get ("low_scan_interval" , 30 ) * 60
74
74
hs = datetime .strptime (self .options .get ("high_scan_start" , "07:00:00" ), "%H:%M:%S" ).time ()
75
75
ls = datetime .strptime (self .options .get ("low_scan_start" , "22:00:00" ), "%H:%M:%S" ).time ()
76
76
if self .in_between (datetime .now ().time (), hs , ls ):
77
- scan_interval = self .options .get ("high_scan_interval" , 10 )
77
+ scan_interval = self .options .get ("high_scan_interval" , 10 ) * 60
78
78
79
- # When we hit our daily rate limit we skip the next update because any call which results
80
- # again in just a rate limit error back is counted as call for the limit of next day
79
+ # When we hit our daily rate limit we check the retry_after which is the amount of seconds
80
+ # we have to wait before we can make a call again
81
81
daikin_api = hass .data [DOMAIN ][DAIKIN_API ]
82
82
if daikin_api .rate_limits ["remaining_day" ] == 0 :
83
- scan_interval *= 2
83
+ scan_interval = max ( daikin_api . rate_limits [ "retry_after" ] + 60 , scan_interval )
84
84
85
- return timedelta (minutes = scan_interval )
85
+ return timedelta (seconds = scan_interval )
86
86
87
87
def in_between (self , now , start , end ):
88
88
if start <= end :
0 commit comments