diff --git a/EdenicExporter/Program.cs b/EdenicExporter/Program.cs index fa66670..f3c8f1c 100644 --- a/EdenicExporter/Program.cs +++ b/EdenicExporter/Program.cs @@ -25,7 +25,7 @@ namespace PrometheusExporterEdenic private readonly HttpClient _client; private readonly string _authToken; private readonly string _orgid; - private readonly string _apimainurl = "https://api.edenic.io/api/v1/device"; + private readonly string _apimainurl = "https://api.edenic.io/api/v1"; private string _devicename; public string DeviceId { get; private set; } @@ -48,8 +48,9 @@ namespace PrometheusExporterEdenic { try { - HttpResponseMessage response = await _client.GetAsync($"{_apimainurl}/{_orgid}{path}"); - + HttpResponseMessage response = await _client.GetAsync($"{_apimainurl}{path}"); + Console.WriteLine($"Request send to: {_apimainurl}{path}"); + if (response.IsSuccessStatusCode) { string content = await response.Content.ReadAsStringAsync(); @@ -75,7 +76,7 @@ namespace PrometheusExporterEdenic { try { - dynamic result = await MakeApiRequest(""); + dynamic result = await MakeApiRequest($"/device/{_orgid}"); string jsonString = result.ToString(); // Convert dynamic to string Console.WriteLine($"Raw JSON: {jsonString}"); // Debug output @@ -100,6 +101,37 @@ namespace PrometheusExporterEdenic return null; } } + + public async Task GetTelemetry() + { + try + { + dynamic result = await MakeApiRequest($"/telemetry/{DeviceId}"); + string jsonString = result.ToString(); // Convert dynamic to string + Console.WriteLine($"Raw JSON: {jsonString}"); // Debug output + return jsonString; + + // var devices = JsonSerializer.Deserialize>(jsonString); + // Console.WriteLine($"Deserialized {devices.Count} devices"); // Debug output + // + // var targetDevice = devices.FirstOrDefault(d => d.label == name); + // if (targetDevice != null) + // { + // Console.WriteLine($"Found device: {targetDevice.label}, ID: {targetDevice.id}"); // Debug output + // return targetDevice.id; + // } + // else + // { + // Console.WriteLine($"No device found with label: {name}"); // Debug output + // return null; + // } + } + catch (Exception ex) + { + Console.WriteLine($"Error in GetDeviceIdByName: {ex.Message}"); // Debug output + return null; + } + } } public class Program diff --git a/EdenicExporter/bin/Debug/net8.0/EdenicExporter.dll b/EdenicExporter/bin/Debug/net8.0/EdenicExporter.dll index 4f28820..87d5411 100644 Binary files a/EdenicExporter/bin/Debug/net8.0/EdenicExporter.dll and b/EdenicExporter/bin/Debug/net8.0/EdenicExporter.dll differ diff --git a/EdenicExporter/bin/Debug/net8.0/EdenicExporter.pdb b/EdenicExporter/bin/Debug/net8.0/EdenicExporter.pdb index af5a239..5e2c6ca 100644 Binary files a/EdenicExporter/bin/Debug/net8.0/EdenicExporter.pdb and b/EdenicExporter/bin/Debug/net8.0/EdenicExporter.pdb differ diff --git a/EdenicExporter/obj/Debug/net8.0/DotNet.Docker.AssemblyInfo.cs b/EdenicExporter/obj/Debug/net8.0/DotNet.Docker.AssemblyInfo.cs index cf37bb4..52b62f8 100644 --- a/EdenicExporter/obj/Debug/net8.0/DotNet.Docker.AssemblyInfo.cs +++ b/EdenicExporter/obj/Debug/net8.0/DotNet.Docker.AssemblyInfo.cs @@ -13,7 +13,7 @@ using System.Reflection; [assembly: System.Reflection.AssemblyCompanyAttribute("EdenicExporter")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] -[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+f1be1e80b9c9b26103bc6df1148538674cdf99b9")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+9451138fe5f22ab586beafbc14d8ed95103e23f5")] [assembly: System.Reflection.AssemblyProductAttribute("EdenicExporter")] [assembly: System.Reflection.AssemblyTitleAttribute("EdenicExporter")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] diff --git a/EdenicExporter/obj/Debug/net8.0/DotNet.Docker.AssemblyInfoInputs.cache b/EdenicExporter/obj/Debug/net8.0/DotNet.Docker.AssemblyInfoInputs.cache index bdae545..3a12010 100644 --- a/EdenicExporter/obj/Debug/net8.0/DotNet.Docker.AssemblyInfoInputs.cache +++ b/EdenicExporter/obj/Debug/net8.0/DotNet.Docker.AssemblyInfoInputs.cache @@ -1 +1 @@ -119886f42dc5b610e5b763673658a8f8230bdd04e244e8c6f0c34a054a44ab6b +184710734eedccb7e8218a40f90b97508609f3208f7414d1463795baa0b9e857 diff --git a/EdenicExporter/obj/Debug/net8.0/EdenicExporter.dll b/EdenicExporter/obj/Debug/net8.0/EdenicExporter.dll index 4f28820..87d5411 100644 Binary files a/EdenicExporter/obj/Debug/net8.0/EdenicExporter.dll and b/EdenicExporter/obj/Debug/net8.0/EdenicExporter.dll differ diff --git a/EdenicExporter/obj/Debug/net8.0/EdenicExporter.pdb b/EdenicExporter/obj/Debug/net8.0/EdenicExporter.pdb index af5a239..5e2c6ca 100644 Binary files a/EdenicExporter/obj/Debug/net8.0/EdenicExporter.pdb and b/EdenicExporter/obj/Debug/net8.0/EdenicExporter.pdb differ diff --git a/EdenicExporter/obj/Debug/net8.0/ref/EdenicExporter.dll b/EdenicExporter/obj/Debug/net8.0/ref/EdenicExporter.dll index 580c7b5..acb1d27 100644 Binary files a/EdenicExporter/obj/Debug/net8.0/ref/EdenicExporter.dll and b/EdenicExporter/obj/Debug/net8.0/ref/EdenicExporter.dll differ diff --git a/EdenicExporter/obj/Debug/net8.0/refint/EdenicExporter.dll b/EdenicExporter/obj/Debug/net8.0/refint/EdenicExporter.dll index 580c7b5..acb1d27 100644 Binary files a/EdenicExporter/obj/Debug/net8.0/refint/EdenicExporter.dll and b/EdenicExporter/obj/Debug/net8.0/refint/EdenicExporter.dll differ