This commit is contained in:
2026-06-28 14:22:13 +03:00
parent e6bf8258bb
commit 7f280bea7b
10 changed files with 54 additions and 17 deletions
@@ -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)