Add manual MQTT recreation and NordPool price fetch buttons
This commit is contained in:
@@ -23,7 +23,8 @@ public sealed class NordPoolEntityService(IEntityManager entityManager, ILogger<
|
||||
TodayPricesEntityId,
|
||||
TomorrowPricesEntityId,
|
||||
TodayTomorrowPricesEntityId,
|
||||
CheapestIntervalsEntityId
|
||||
CheapestIntervalsEntityId,
|
||||
NordPoolConsts.FetchPricesButtonEntityId
|
||||
];
|
||||
|
||||
public async Task CreateEntitiesAsync(string? unitOfMeasurement, CancellationToken cancellationToken = default)
|
||||
@@ -57,7 +58,8 @@ public sealed class NordPoolEntityService(IEntityManager entityManager, ILogger<
|
||||
ResetTodayPricesAsync(),
|
||||
ResetTomorrowPricesAsync(),
|
||||
ResetTodayTomorrowPricesAsync(),
|
||||
ResetCheapestIntervalsAsync()
|
||||
ResetCheapestIntervalsAsync(),
|
||||
ResetFetchPricesButtonAsync()
|
||||
).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
@@ -138,6 +140,15 @@ public sealed class NordPoolEntityService(IEntityManager entityManager, ILogger<
|
||||
}).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private async Task ResetFetchPricesButtonAsync()
|
||||
{
|
||||
await SetEntityStateSafe(NordPoolConsts.FetchPricesButtonEntityId, "unknown").ConfigureAwait(false);
|
||||
await SetEntityAttributesSafe(NordPoolConsts.FetchPricesButtonEntityId, new
|
||||
{
|
||||
friendly_name = "NordPool fetch prices"
|
||||
}).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task UpdateEntitiesAsync(EntityUpdateContext ctx, CancellationToken cancellationToken = default)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
@@ -289,7 +300,8 @@ public sealed class NordPoolEntityService(IEntityManager entityManager, ILogger<
|
||||
new NordPoolEntity("sensor", "nordpool_today_prices", "NordPool today prices"),
|
||||
new NordPoolEntity("sensor", "nordpool_tomorrow_prices", "NordPool tomorrow prices"),
|
||||
new NordPoolEntity("sensor", "nordpool_today_tomorrow_prices", "NordPool today and tomorrow prices"),
|
||||
new NordPoolEntity("sensor", "nordpool_cheapest_intervals", "NordPool cheapest boiler intervals")
|
||||
new NordPoolEntity("sensor", "nordpool_cheapest_intervals", "NordPool cheapest boiler intervals"),
|
||||
new NordPoolEntity("button", "nordpool_fetch_prices", "NordPool fetch prices")
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user