Skip to content

Commit 33e0300

Browse files
committed
Added support for archive data requests
1 parent 496b305 commit 33e0300

File tree

5 files changed

+23
-8
lines changed

5 files changed

+23
-8
lines changed

FroniusSolarClient.Examples/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ static void Main(string[] args)
2626
}
2727
static void GetArchiveData(SolarClient client)
2828
{
29-
var channels = new List<Channel> { Channel.Current_AC_Phase_1 };
29+
var channels = new List<Channel> { Channel.Voltage_AC_Phase_1, Channel.Voltage_AC_Phase_2, Channel.Voltage_AC_Phase_3 };
3030

3131
var data = client.GetArchiveData(DateTime.Now.AddDays(-1),DateTime.Now, channels);
3232

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,28 @@
1-
using System;
1+
using Newtonsoft.Json;
2+
using System;
23
using System.Collections.Generic;
34
using System.Text;
45

56
namespace FroniusSolarClient.Entities.SolarAPI.V1.ArchiveData
67
{
8+
/// <summary>
9+
/// Archive data response channel data
10+
/// </summary>
711
public class ArchiveData
812
{
13+
[JsonProperty(PropertyName = "Data")]
14+
Dictionary<string, ChannelValues> ChannelData;
915
}
1016

11-
12-
17+
/// <summary>
18+
/// Channel data values
19+
/// </summary>
20+
public class ChannelValues
21+
{
22+
[JsonProperty(PropertyName = "Unit")]
23+
string Unit;
1324

25+
[JsonProperty(PropertyName = "Values")]
26+
Dictionary<string, string> Values;
27+
}
1428
}

FroniusSolarClient/Entities/SolarAPI/V1/Core/UnitValue.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ public class UnitValue<T>
66
/// Unit name
77
/// </summary>
88
public string Unit { get; set; }
9+
910
/// <summary>
1011
/// Unit value
1112
/// </summary>

FroniusSolarClient/Services/InverterArchiveDataService.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ protected string BuildQueryString(int deviceId, Scope scope, SeriesType seriesTy
3131

3232
string channelParam = "";
3333

34-
if (channels.Count < 1)
34+
if (channels.Count > 1)
3535
{
3636
foreach (Channel channel in channels)
3737
{
@@ -52,10 +52,10 @@ protected string BuildQueryString(int deviceId, Scope scope, SeriesType seriesTy
5252
$"&{channelParam}";
5353
}
5454

55-
public ArchiveData GetArchiveData(DateTime startDate, DateTime endDate, List<Channel> channels, int deviceId, Scope scope, SeriesType seriesType, bool humanReadable, DeviceClass deviceClass)
55+
public Dictionary<string, ArchiveData> GetArchiveData(DateTime startDate, DateTime endDate, List<Channel> channels, int deviceId, Scope scope, SeriesType seriesType, bool humanReadable, DeviceClass deviceClass)
5656
{
5757
string baseEndpointURL = _cgi + BuildQueryString(deviceId, scope, seriesType, humanReadable, startDate, endDate, channels, deviceClass);
58-
return GetDataServiceResponse<ArchiveData>(baseEndpointURL).Body.Data;
58+
return GetDataServiceResponse<Dictionary<string, ArchiveData>>(baseEndpointURL).Body.Data;
5959
}
6060
}
6161
}

FroniusSolarClient/SolarClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public MinMaxInverterData GetMinMaxInverterData(int deviceId = 1, Scope scope =
8585
/// <param name="humanReadable"></param>
8686
/// <param name="deviceClass"></param>
8787
/// <returns></returns>
88-
public ArchiveData GetArchiveData(DateTime startDate, DateTime endDate, List<Channel> channels, int deviceId = 1, Scope scope = Scope.System, SeriesType seriesType = SeriesType.DailySum, bool humanReadable = true, DeviceClass deviceClass = DeviceClass.Inverter)
88+
public Dictionary<string, ArchiveData> GetArchiveData(DateTime startDate, DateTime endDate, List<Channel> channels, int deviceId = 1, Scope scope = Scope.System, SeriesType seriesType = SeriesType.DailySum, bool humanReadable = true, DeviceClass deviceClass = DeviceClass.Inverter)
8989
{
9090
return _inverterArchiveDataService.GetArchiveData(startDate, endDate, channels, deviceId, scope, seriesType, humanReadable, deviceClass);
9191
}

0 commit comments

Comments
 (0)