Fix bugs
This commit is contained in:
@@ -21,6 +21,7 @@ public sealed class ShowerMonitorEntityService(
|
||||
HumidityRateEntityId,
|
||||
LastShowerDurationEntityId,
|
||||
LastShowerTimeEntityId,
|
||||
TodaySessionCountEntityId,
|
||||
CleanupButtonEntityId
|
||||
];
|
||||
|
||||
@@ -65,6 +66,7 @@ public sealed class ShowerMonitorEntityService(
|
||||
SetEntityStateSafe(StateEntityId, ctx.State.ToString().ToLowerInvariant()),
|
||||
UpdateDifferentialAsync(ctx.Differential, timestamp),
|
||||
UpdateHumidityRateAsync(ctx.HumidityRate, timestamp),
|
||||
UpdateTodaySessionCountAsync(ctx.TodaySessionCount, timestamp),
|
||||
UpdateLastShowerAsync(ctx.LastCompletedSession, timestamp)
|
||||
};
|
||||
|
||||
@@ -152,6 +154,16 @@ public sealed class ShowerMonitorEntityService(
|
||||
}).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private async Task UpdateTodaySessionCountAsync(int count, string timestamp)
|
||||
{
|
||||
await SetEntityStateSafe(TodaySessionCountEntityId, count.ToString(CultureInfo.InvariantCulture)).ConfigureAwait(false);
|
||||
await SetEntityAttributesSafe(TodaySessionCountEntityId, new
|
||||
{
|
||||
friendly_name = "Showers today",
|
||||
last_updated = timestamp
|
||||
}).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private async Task UpdateLastShowerAsync(ShowerSession? session, string timestamp)
|
||||
{
|
||||
if (session is null)
|
||||
|
||||
Reference in New Issue
Block a user