27 lines
833 B
C#
27 lines
833 B
C#
using InnovEnergy.Lib.Utils;
|
|
using InnovEnergy.Lib.Victron.VeDBus;
|
|
using InnovEnergy.WireFormat.VictronV1;
|
|
|
|
namespace InnovEnergy.VenusLogger.Parsers;
|
|
|
|
public static class PvCharger
|
|
{
|
|
public static Maybe<Device> GetPvCharger(this IEnumerable<ServiceProperties> services)
|
|
{
|
|
var solarChargers = services
|
|
.Where(VeService.IsSolarChargerService)
|
|
.TrySelect(GetPvCharger)
|
|
.ToList();
|
|
|
|
if (solarChargers.Count <= 1)
|
|
return solarChargers.FirstOrDefault().Maybe();
|
|
|
|
return new Device { Type = DeviceType.Mppt, Devices = { solarChargers } };
|
|
}
|
|
|
|
private static Device GetPvCharger(ServiceProperties sp) => new Device
|
|
{
|
|
Type = DeviceType.Mppt,
|
|
Phases = { sp.Properties.GetDcPhase() }
|
|
};
|
|
} |