Update
This commit is contained in:
@@ -8,7 +8,6 @@ using Microsoft.Extensions.Options;
|
||||
using NordPool.Models;
|
||||
using PowerMonitorManager.Interface;
|
||||
using PowerMonitorManager.Models;
|
||||
using PowerMonitorManager.Models.Consts;
|
||||
|
||||
namespace HomeAssistant.HistoryReplay.Runners;
|
||||
|
||||
@@ -17,6 +16,7 @@ public sealed class PowerReplayRunner : IMonitorReplayRunner
|
||||
private readonly HistoryTimeline _timeline;
|
||||
private readonly ReplayTimeProvider _timeProvider;
|
||||
private readonly ReplayTimeline _replayTimeline;
|
||||
private readonly ReplayDataSeries _dataSeries;
|
||||
private readonly IOtherPowerCalculationService _calculationService;
|
||||
private readonly IPowerCostCalculationService _costService;
|
||||
private readonly ILogger<PowerReplayRunner> _logger;
|
||||
@@ -29,6 +29,7 @@ public sealed class PowerReplayRunner : IMonitorReplayRunner
|
||||
HistoryTimeline timeline,
|
||||
ReplayTimeProvider timeProvider,
|
||||
ReplayTimeline replayTimeline,
|
||||
ReplayDataSeries dataSeries,
|
||||
IOtherPowerCalculationService calculationService,
|
||||
IPowerCostCalculationService costService,
|
||||
ILogger<PowerReplayRunner> logger,
|
||||
@@ -38,6 +39,7 @@ public sealed class PowerReplayRunner : IMonitorReplayRunner
|
||||
_timeline = timeline;
|
||||
_timeProvider = timeProvider;
|
||||
_replayTimeline = replayTimeline;
|
||||
_dataSeries = dataSeries;
|
||||
_calculationService = calculationService;
|
||||
_costService = costService;
|
||||
_logger = logger;
|
||||
@@ -69,6 +71,10 @@ public sealed class PowerReplayRunner : IMonitorReplayRunner
|
||||
var deviceReadings = DiscoverAndReadDevicePower(currentTime);
|
||||
var calculation = _calculationService.Calculate(totalPower.Value, deviceReadings);
|
||||
|
||||
_dataSeries.AddPoint(MonitorName, "TotalPower", currentTime, calculation.TotalPowerWatts);
|
||||
_dataSeries.AddPoint(MonitorName, "KnownDevices", currentTime, calculation.KnownDevicesSumWatts);
|
||||
_dataSeries.AddPoint(MonitorName, "OtherPower", currentTime, calculation.SmoothedOtherPowerWatts);
|
||||
|
||||
var nordPoolPriceEntry = _timeline.GetStateAt(NordPoolConsts.CurrentPriceEntityId, currentTime);
|
||||
var nordPoolPrice = ParseDouble(nordPoolPriceEntry?.State) ?? 0;
|
||||
|
||||
@@ -78,7 +84,6 @@ public sealed class PowerReplayRunner : IMonitorReplayRunner
|
||||
if (isAnomaly && anomalyStartTime is null)
|
||||
{
|
||||
anomalyStartTime = currentTime.LocalDateTime;
|
||||
|
||||
_replayTimeline.AddEvent(new ReplayEvent
|
||||
{
|
||||
Timestamp = currentTime,
|
||||
@@ -120,8 +125,8 @@ public sealed class PowerReplayRunner : IMonitorReplayRunner
|
||||
private IReadOnlyDictionary<string, double> DiscoverAndReadDevicePower(DateTimeOffset timestamp)
|
||||
{
|
||||
var readings = new Dictionary<string, double>();
|
||||
|
||||
var allEntities = _timeline.GetEntityIds();
|
||||
|
||||
foreach (var entityId in allEntities)
|
||||
{
|
||||
if (!entityId.StartsWith("sensor.", StringComparison.OrdinalIgnoreCase) ||
|
||||
|
||||
Reference in New Issue
Block a user