Snippets

OICP 2.1 Pull EVSE Status | C#

Updated by Julius Poessnecker

File (0) OICP Added

  • Ignore whitespace
  • Hide word diff
+The service description can be found in the OICP 2.1 (EMP).
+
+Section:
+3.5.1 eRoamingPullEVSEStatus
+
+To download the latest OICP Version, please visit our website:
+https://www.hubject.com/downloads/
Created by Gregor Schermuly

File (1) Pull EVSE Status | C#.cs Added

  • Ignore whitespace
  • Hide word diff
+/// <summary>
+/// Create a new task requesting the current status of all EVSEs (within an optional search radius and status).
+/// </summary>
+/// <param name="ProviderId">Your e-mobility provider identification (EMP Id).</param>
+/// <param name="SearchCenter">An optional geo coordinate of the search center.</param>
+/// <param name="DistanceKM">An optional search distance relative to the search center.</param>
+/// <param name="EVSEStatus">An optional EVSE status as filter criteria.</param>
+/// <param name="QueryTimeout">An optional timeout for this query.</param>
+public async Task<HTTPResponse<IEnumerable<KeyValuePair<EVSE_Id, OICPEVSEStatus>>>>
+
+    PullEVSEStatus(EVSP_Id          ProviderId,
+                   GeoCoordinate    SearchCenter      = null
+                   Double           DistanceKM        = 0.0,
+                   OICPEVSEStatus?  EVSEStatusFilter  = null
+                   TimeSpan?        QueryTimeout      = null)
+
+{
+
+    [...]
+
+}

File (2) Example.cs Added

  • Ignore whitespace
  • Hide word diff
+var req = new EMPClient("api.playground.hubject.com").
+
+              PullEVSEStatus(EVSP_Id.Parse("DE*GDF"),
+                             SearchCenter:     new GeoCoordinate(Latitude. Parse(49.731102),
+                                                                 Longitude.Parse(10.142533)),
+                             DistanceKM:       100,
+                             EVSEStatusFilter: OICPEVSEStatusType.Available,
+                             QueryTimeout:     TimeSpan.FromSeconds(120)).
+
+              ContinueWith(task => {
+
+                  var eRoamingEVSEStatus = task.Result.Content;
+
+                  if (eRoamingEVSEStatus.StatusCode.HasResult)
+                      Console.WriteLine(eRoamingEVSEStatus.
+                                            OperatorEVSEStatus.
+                                            Select(evsestatus => "'" + evsestatus.OperatorName +
+                                                                 "' has " +
+                                                                 evsestatus.EVSEStatusRecords.Count() +
+                                                                 " available EVSEs").
+                                            AggregateWith(Environment.NewLine) +
+                                            Environment.NewLine));
+
+                  else
+                  {
+                      Console.WriteLine(eRoamingEVSEStatus.StatusCode.Code);
+                      Console.WriteLine(eRoamingEVSEStatus.StatusCode.Description);
+                      Console.WriteLine(eRoamingEVSEStatus.StatusCode.AdditionalInfo);
+                  }
+
+              });
+
+req.Wait();
HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.