Update
This commit is contained in:
@@ -5,6 +5,7 @@ using HomeAssistant.HistoryReplay.Replay;
|
||||
using HomeAssistant.HistoryReplay.Reporting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using NetDaemon.HassModel;
|
||||
using ShowerMonitor.Models.Enums;
|
||||
using ShowerMonitorManager.Interface;
|
||||
using ShowerMonitorManager.Models;
|
||||
@@ -16,8 +17,10 @@ public sealed class ShowerReplayRunner : IMonitorReplayRunner
|
||||
private readonly HistoryTimeline _timeline;
|
||||
private readonly ReplayTimeProvider _timeProvider;
|
||||
private readonly ReplayTimeline _replayTimeline;
|
||||
private readonly ReplayDataSeries _dataSeries;
|
||||
private readonly IShowerDetectionService _detectionService;
|
||||
private readonly IExhaustFanControlService _fanControlService;
|
||||
private readonly IHaContext _haContext;
|
||||
private readonly ILogger<ShowerReplayRunner> _logger;
|
||||
private readonly ReplayOptions _replayOptions;
|
||||
private readonly ShowerMonitorOptions _showerOptions;
|
||||
@@ -28,8 +31,10 @@ public sealed class ShowerReplayRunner : IMonitorReplayRunner
|
||||
HistoryTimeline timeline,
|
||||
ReplayTimeProvider timeProvider,
|
||||
ReplayTimeline replayTimeline,
|
||||
ReplayDataSeries dataSeries,
|
||||
IShowerDetectionService detectionService,
|
||||
IExhaustFanControlService fanControlService,
|
||||
IHaContext haContext,
|
||||
ILogger<ShowerReplayRunner> logger,
|
||||
IOptions<ReplayOptions> replayOptions,
|
||||
IOptions<ShowerMonitorOptions> showerOptions)
|
||||
@@ -37,8 +42,10 @@ public sealed class ShowerReplayRunner : IMonitorReplayRunner
|
||||
_timeline = timeline;
|
||||
_timeProvider = timeProvider;
|
||||
_replayTimeline = replayTimeline;
|
||||
_dataSeries = dataSeries;
|
||||
_detectionService = detectionService;
|
||||
_fanControlService = fanControlService;
|
||||
_haContext = haContext;
|
||||
_logger = logger;
|
||||
_replayOptions = replayOptions.Value;
|
||||
_showerOptions = showerOptions.Value;
|
||||
@@ -64,10 +71,16 @@ public sealed class ShowerReplayRunner : IMonitorReplayRunner
|
||||
|
||||
if (bathroomHumidity.HasValue && homeHumidity.HasValue)
|
||||
{
|
||||
_dataSeries.AddPoint(MonitorName, "BathroomHumidity", currentTime, bathroomHumidity.Value);
|
||||
_dataSeries.AddPoint(MonitorName, "HomeHumidity", currentTime, homeHumidity.Value);
|
||||
_dataSeries.AddPoint(MonitorName, "Differential", currentTime, bathroomHumidity.Value - homeHumidity.Value);
|
||||
|
||||
var state = _detectionService.Evaluate(bathroomHumidity.Value, homeHumidity.Value, currentTime);
|
||||
var differential = bathroomHumidity.Value - homeHumidity.Value;
|
||||
|
||||
_fanControlService.Evaluate(state, currentTime);
|
||||
_dataSeries.AddPoint(MonitorName, "State", currentTime, (double)state);
|
||||
|
||||
_fanControlService.Evaluate(state, currentTime, _haContext);
|
||||
|
||||
if (state != previousState)
|
||||
{
|
||||
@@ -83,7 +96,7 @@ public sealed class ShowerReplayRunner : IMonitorReplayRunner
|
||||
Timestamp = currentTime,
|
||||
Monitor = MonitorName,
|
||||
EventType = eventType,
|
||||
Message = $"State: {previousState} → {state} (bathroom: {bathroomHumidity.Value:F1}%, home: {homeHumidity.Value:F1}%, diff: {differential:F1}%)",
|
||||
Message = $"State: {previousState} -> {state} (bathroom: {bathroomHumidity.Value:F1}%, home: {homeHumidity.Value:F1}%, diff: {differential:F1}%)",
|
||||
Details = GetStateChangeDetails(state)
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user