Files
HomeAssistant/PowerMonitor.Manager/OtherPowerCalculationService.cs
T
Marius 861c344832 Init
2026-03-08 19:10:16 +02:00

17 lines
575 B
C#

using PowerMonitorManager.Interface;
using PowerMonitorManager.Models;
namespace PowerMonitorManager;
public sealed class OtherPowerCalculationService : IOtherPowerCalculationService
{
public PowerCalculationResult CalculateOtherPower(double? totalHomePower, IReadOnlyList<double?> monitoredSensorValues)
{
var total = totalHomePower ?? 0.0;
var sumOfMonitored = monitoredSensorValues.Sum(v => v ?? 0.0);
var otherPower = Math.Max(0.0, total - sumOfMonitored);
return new PowerCalculationResult(otherPower, sumOfMonitored);
}
}