Skip to content

Commit 4badf1b

Browse files
committed
added GetPowerFlowRealtimeData and examples
updated readme
1 parent 7304dc4 commit 4badf1b

File tree

5 files changed

+194
-2
lines changed

5 files changed

+194
-2
lines changed

FroniusSolarClient.Examples/Program.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,15 @@ static void Main(string[] args)
1818

1919
var client = new SolarClient("10.1.1.124", 1, serviceProvider.GetService<ILogger<SolarClient>>());
2020

21-
//GetArchiveDataOverPast24Hours(client);
22-
GetRealTimeData(client);
21+
GetPowerFlowRealtimeData(client);
2322
}
2423

24+
static void GetPowerFlowRealtimeData(SolarClient client)
25+
{
26+
var data = client.GetPowerFlowRealtimeData();
27+
28+
Console.WriteLine(data);
29+
}
2530
#region RealtimeData
2631
static void GetRealTimeData(SolarClient client)
2732
{
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
using Newtonsoft.Json;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Text;
5+
6+
namespace FroniusSolarClient.Entities.SolarAPI.V1.PowerFlowRealtimeData
7+
{
8+
public class PowerFlowRealtimeData
9+
{
10+
public Dictionary<string, Inverters> Inverters { get; set; }
11+
public Site Site { get; set; }
12+
13+
/// <summary>
14+
/// Describes the available fields for this request (PowerFlowVersion)
15+
/// </summary>
16+
public string Version { get; set; }
17+
}
18+
19+
public class Inverters
20+
{
21+
/// <summary>
22+
/// Device type of inverter
23+
/// </summary>
24+
[JsonProperty("DT")]
25+
public int DT { get; set; }
26+
27+
/// <summary>
28+
/// Energy [Wh] this day, null if no inverter is connected
29+
/// </summary>
30+
[JsonProperty("E_Day")]
31+
public decimal EDay { get; set; }
32+
33+
/// <summary>
34+
/// Energy [Wh] ever since, null if no inverter is connected
35+
/// </summary>
36+
[JsonProperty("E_Total")]
37+
public decimal ETotal { get; set; }
38+
39+
/// <summary>
40+
/// Energy [Wh] this year, null if no inverter is connected
41+
/// </summary>
42+
[JsonProperty("E_Year")]
43+
public decimal EYear { get; set; }
44+
45+
/// <summary>
46+
/// Current state of charge in % ( 0 - 100% )
47+
/// </summary>
48+
[JsonProperty("SOC")]
49+
public decimal SOC { get; set; }
50+
51+
/// <summary>
52+
/// Current power in Watt, null if not running
53+
/// </summary>
54+
[JsonProperty("P")]
55+
public int P { get; set; }
56+
57+
/// <summary>
58+
/// "disabled", "normal", "service", "charge boost",
59+
/// "nearly depleted", "suspended", "calibrate",
60+
/// "grid support", "deplete recovery", "non operable (voltage)",
61+
/// "non operable (temperature)", "preheating" or "startup"
62+
/// </summary>
63+
[JsonProperty("Battery_Mode")]
64+
public string BatteryMode { get; set; }
65+
}
66+
public class Site
67+
{
68+
/// <summary>
69+
/// Energy [Wh] this day, null if no inverter is connected
70+
/// </summary>
71+
[JsonProperty("E_Day")]
72+
public decimal EDay { get; set; }
73+
74+
/// <summary>
75+
/// Energy [Wh] ever since, null if no inverter is connected
76+
/// </summary>
77+
[JsonProperty("E_Total")]
78+
public decimal ETotal { get; set; }
79+
80+
/// <summary>
81+
/// Energy [Wh] this year, null if no inverter is connected
82+
/// </summary>
83+
[JsonProperty("E_Year")]
84+
public decimal EYear { get; set; }
85+
86+
/// <summary>
87+
/// "load", "grid" or "unknown" (during backup power)
88+
/// </summary>
89+
[JsonProperty("Meter_Location")]
90+
public string MeterLocation { get; set; }
91+
92+
/// <summary>
93+
/// "produce-only", "meter", "vague-meter", "bidirectional" or "ac-coupled"
94+
/// </summary>
95+
public string Mode { get; set; }
96+
97+
/// <summary>
98+
/// This value is null if no battery is active ( + charge, - discharge )
99+
/// </summary>
100+
[JsonProperty("P_Akku")]
101+
public int PAkku { get; set; }
102+
103+
/// <summary>
104+
/// This value is null if no meter is enabled ( + from grid, - to grid )
105+
/// </summary>
106+
[JsonProperty("P_Grid")]
107+
public int PGrid { get; set; }
108+
109+
/// <summary>
110+
/// This value is null if no meter is enabled ( + generator, - consumer )
111+
/// </summary>
112+
[JsonProperty("P_Load")]
113+
public int PLoad { get; set; }
114+
115+
/// <summary>
116+
/// This value is null if inverter is not running ( + production ( default ) )
117+
/// </summary>
118+
[JsonProperty("P_PV")]
119+
public int PPV { get; set; }
120+
121+
/// <summary>
122+
/// Current relative autonomy in %, null if no smart meter is connected
123+
/// </summary>
124+
[JsonProperty("rel_Autonomy")]
125+
public int RelAutonomy { get; set; }
126+
127+
/// <summary>
128+
/// Current relative self consumption in %, null if no smart meter is connected
129+
/// </summary>
130+
[JsonProperty("rel_SelfConsumption")]
131+
public int RelSelfConsumption { get; set; }
132+
133+
/// <summary>
134+
/// Field is available if configured (false) or active (true)
135+
/// If not available, mandatory config is not set
136+
/// </summary>
137+
[JsonProperty("BackupMode")]
138+
public int BackupMode { get; set; }
139+
140+
/// <summary>
141+
/// True when battery is in standby
142+
/// </summary>
143+
[JsonProperty("BatteryStandby")]
144+
public int BatteryStandby { get; set; }
145+
}
146+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using FroniusSolarClient.Entities.SolarAPI.V1;
2+
using FroniusSolarClient.Entities.SolarAPI.V1.PowerFlowRealtimeData;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Text;
6+
7+
namespace FroniusSolarClient.Services
8+
{
9+
internal class PowerFlowRealtimeDataService : BaseDataService
10+
{
11+
private readonly string _cgi = "GetPowerFlowRealtimeData.fcgi";
12+
13+
public PowerFlowRealtimeDataService(RestClient restClient)
14+
: base(restClient)
15+
{
16+
}
17+
18+
/// <summary>
19+
/// This request provides detailed information about the local energy grid. The values replied represent the current state.
20+
/// Because of data has multiple asynchronous origins it is a matter of facts that the sum of all powers (grid,load and generate) will differ from zero.
21+
/// This request does not care about the configured visibility of single inverters. All inverters are reported.
22+
/// </summary>
23+
/// <returns></returns>
24+
public Response<PowerFlowRealtimeData> GetPowerFlowRealtimeData()
25+
{
26+
return GetDataServiceResponse<PowerFlowRealtimeData>(_cgi);
27+
}
28+
}
29+
}

FroniusSolarClient/SolarClient.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System;
66
using System.Collections.Generic;
77
using Microsoft.Extensions.Logging;
8+
using FroniusSolarClient.Entities.SolarAPI.V1.PowerFlowRealtimeData;
89

910
namespace FroniusSolarClient
1011
{
@@ -19,6 +20,7 @@ public class SolarClient
1920
// Services
2021
private InverterRealtimeDataService _inverterRealtimeDataService;
2122
private InverterArchiveDataService _inverterArchiveDataService;
23+
private PowerFlowRealtimeDataService _powerFlowRealtimeDataService;
2224

2325
public SolarClient(string url, int version, ILogger logger)
2426
{
@@ -28,6 +30,7 @@ public SolarClient(string url, int version, ILogger logger)
2830

2931
_inverterRealtimeDataService = new InverterRealtimeDataService(_restClient);
3032
_inverterArchiveDataService = new InverterArchiveDataService(_restClient);
33+
_powerFlowRealtimeDataService = new PowerFlowRealtimeDataService(_restClient);
3134
}
3235

3336
/// <summary>
@@ -91,5 +94,9 @@ public Response<Dictionary<string, ArchiveData>> GetArchiveData(DateTime startDa
9194
return _inverterArchiveDataService.GetArchiveData(startDate, endDate, channels, deviceId, scope, seriesType, humanReadable, deviceClass);
9295
}
9396

97+
public Response<PowerFlowRealtimeData> GetPowerFlowRealtimeData()
98+
{
99+
return _powerFlowRealtimeDataService.GetPowerFlowRealtimeData();
100+
}
94101
}
95102
}

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Internal logging has been implemented so you can parse in your own logger implem
3333
[Realtime Requests](#realtime-requests)
3434

3535
- [GetInverterRealtimeData](#GetInverterRealtimeData)
36+
- [GetPowerFlowRealtimeData](#GetPowerFlowRealtimeData)
3637

3738
[Archive Data Requests](#Archive-Data-Requests)
3839

@@ -51,6 +52,10 @@ This request does not care about the configured visibility of single inverters.
5152
- P3InverterData (3PInverterData) - Values which are provided by 3phase Fronius inverters.
5253
- MinMaxInverterData - Minimum and Maximum values of various inverter values.
5354

55+
#### GetPowerFlowRealtimeData
56+
This request provides detailed information about the local energy grid. The values replied represent the current state. Because of data has multiple asynchronous origins it is a matter of facts that the sum of all powers (grid,load and generate) will differ from zero. This request does not care about the configured visibility of single inverters. All inverters are reported.
57+
58+
5459
### Archive Data Requests
5560
Archive requests are provided whenever access to historic device-data is possible. The Datalogger web can only provide what is stored in its internal memory and has not been overwritten by newer data yet, it can loose data due to capacity reasons. The number of days stored is dependant on the number of connected units that are logging data.
5661

0 commit comments

Comments
 (0)