Skip to content

Commit 3104f1c

Browse files
committed
Remove no longer needed LoginCacheMinutes, add optional endpoints to check runtime configs
1 parent 60de392 commit 3104f1c

File tree

5 files changed

+6
-9
lines changed

5 files changed

+6
-9
lines changed

docker-compose.example.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ services:
1111
- "Tesla__Email=<email>"
1212
- "Tesla__Password=<password>"
1313
- "Tesla__Host=<ip of the gateway>"
14-
- "Tesla__LoginCacheMinutes=10"
1514
- "ResponseCacheDurationSeconds=3"
1615
- "Logging__Console__TimestampFormat=[MM/dd/yy h:mm:ss tt] "
1716
- "APPLICATIONINSIGHTS_CONNECTION_STRING=<optional: if you want to log to Azure>"

src/Models/TeslaConfiguration.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,6 @@ public class TeslaConfiguration
3838
[RequiredIf(nameof(Enabled), true)]
3939
public string RequestHost { get; set; } = "powerwall";
4040

41-
/// <summary>
42-
/// How long to cache the login before fetching a new one
43-
/// </summary>
44-
public int LoginCacheMinutes { get; set; } = 10;
45-
4641
public TeslaLoginRequest GetTeslaLoginRequest()
4742
=> new()
4843
{

src/Program.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,11 @@
179179
// This endpoint provides Prometheus metrics about the app itself.
180180
// It is not the same as the Controller-based /metrics endpoint that proxies metrics from other services.
181181
app.UseOpenTelemetryPrometheusScrapingEndpoint("/appmetrics");
182+
if (app.Configuration.GetValue<bool>("EnableConfigEndpoints", false))
183+
{
184+
app.MapGet("/config/tesla", (IOptions<TeslaConfiguration> config) => Results.Ok(config.Value));
185+
app.MapGet("/config/enphase", (IOptions<EnphaseConfiguration> config) => Results.Ok(config.Value));
186+
}
182187
app.MapControllers();
183188

184189
// Run the app:

src/Services/TeslaGatewayMetricsService.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ public partial class TeslaGatewayMetricsService(
1717
IOptions<TeslaConfiguration> configuration,
1818
ILogger<TeslaGatewayMetricsService> logger) : MetricsServiceBase(factory.CreateClient(nameof(TeslaGatewayMetricsService)), logger)
1919
{
20-
private readonly TimeSpan _loginCacheLength = TimeSpan.FromMinutes(configuration.Value.LoginCacheMinutes);
2120
private readonly TeslaConfiguration _configuration = configuration.Value;
2221
private volatile TeslaLoginResponse? _cachedLoginResponse;
2322

src/appsettings.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323
"Host": "<ip_or_dns>",
2424
"Email": "",
2525
"Password": "",
26-
"Username": "customer",
27-
"LoginCacheMinutes": 10
26+
"Username": "customer"
2827
},
2928
"Enphase": {
3029
"Enabled": false,

0 commit comments

Comments
 (0)