You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Api/Controllers/Http.cs
+78-48Lines changed: 78 additions & 48 deletions
Original file line number
Diff line number
Diff line change
@@ -27,7 +27,7 @@ public class Http : Base
27
27
/// <summary>
28
28
/// HttpClient to use for network communications towards the Tado API
29
29
/// </summary>
30
-
privateHttpClient?TadoHttpClient;
30
+
privatereadonlyHttpClient?TadoHttpClient;
31
31
32
32
/// <summary>
33
33
/// Access to the application configuration
@@ -59,6 +59,8 @@ public Http(IHttpClientFactory httpClientFactory, IOptionsMonitor<Configuration.
59
59
/// <param name="maximumRetries">If provided, in case of a non 2xx response, it will retry the call at most the amount configured through this parameter. Optional, if not provided, it will endlessly retry. If <paramref name="retryIntervalIfFailed"/> has not been set, this is being ignored.</param>
60
60
/// <param name="token">Optional token. If provided, it will be used to authenticate the request. If omitted, it will send the request anonymously.</param>
61
61
/// <returns>Object of type T with the parsed response</returns>
62
+
/// <exception cref="Exceptions.RequestThrottledException">Thrown when the request is getting throttled</exception>
63
+
/// <exception cref="Exceptions.RequestThrottledException">Thrown when the request is getting throttled</exception>
@@ -127,6 +135,7 @@ public Http(IHttpClientFactory httpClientFactory, IOptionsMonitor<Configuration.
127
135
/// <param name="expectedHttpStatusCode">The expected Http result status code. Optional. If provided and the webservice returns a different response, the return type will be NULL to indicate failure.</param>
128
136
/// <param name="token">Optional token. If provided, it will be used to authenticate the request. If omitted, it will send the request anonymously.</param>
129
137
/// <returns>Typed entity with the result from the webservice</returns>
138
+
/// <exception cref="Exceptions.RequestThrottledException">Thrown when the request is getting throttled</exception>
@@ -171,6 +186,7 @@ public Http(IHttpClientFactory httpClientFactory, IOptionsMonitor<Configuration.
171
186
/// <param name="expectedHttpStatusCode">The expected Http result status code. Optional. If provided and the webservice returns a different response, the return type will be NULL to indicate failure.</param>
172
187
/// <param name="token">Optional token. If provided, it will be used to authenticate the request. If omitted, it will send the request anonymously.</param>
173
188
/// <returns>Typed entity with the result from the webservice</returns>
189
+
/// <exception cref="Exceptions.RequestThrottledException">Thrown when the request is getting throttled</exception>
@@ -224,6 +246,7 @@ public Http(IHttpClientFactory httpClientFactory, IOptionsMonitor<Configuration.
224
246
/// <param name="expectedHttpStatusCode">The expected Http result status code. Optional. If provided and the webservice returns a different response, the return type will be false to indicate failure.</param>
225
247
/// <param name="token">Optional token. If provided, it will be used to authenticate the request. If omitted, it will send the request anonymously.</param>
226
248
/// <returns>Boolean indicating if the request was successful</returns>
249
+
/// <exception cref="Exceptions.RequestThrottledException">Thrown when the request is getting throttled</exception>
/// <param name="innerException">Exception raised while making the request. Optional.</param>
44
+
publicRequestThrottledException(Uriuri,HttpResponseMessage?httpResponseMessage=null,Exception?innerException=null):base($"The request to {uri} failed because of throttling",innerException)
45
+
{
46
+
Uri=uri;
47
+
48
+
if(httpResponseMessage!=null)
49
+
{
50
+
ParseRateLimitHeaders(httpResponseMessage);
51
+
}
52
+
}
53
+
54
+
/// <summary>
55
+
/// Parses the RateLimit-Policy and RateLimit headers from the HTTP response
56
+
/// </summary>
57
+
/// <param name="httpResponseMessage">The HTTP response message containing the headers</param>
Copy file name to clipboardExpand all lines: README.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,10 @@ This library compiled for .NET 9 will allow you to easily communicate with the T
9
9
10
10
## Version History
11
11
12
+
0.6.0.0 - released September 17, 2025
13
+
14
+
- Added handling for throttling since Tado started to roll out their new throttling. More info [here](https://community.home-assistant.io/t/tado-rate-limiting-api-calls/928751). In the old code it would just return empty lists when throttled, now it will throw a specific exception which holds all the details about the thottling, such as when it will be reset and what your daily quota is based on your subscription with Tado..
0 commit comments