diff --git a/csharp/App/Backend/Backend.csproj b/csharp/App/Backend/Backend.csproj index ef4777f93..88adde6d6 100644 --- a/csharp/App/Backend/Backend.csproj +++ b/csharp/App/Backend/Backend.csproj @@ -1,4 +1,8 @@ + + Debug;Release;Release-Server + AnyCPU;linux-arm + diff --git a/csharp/App/Backend/db.sqlite b/csharp/App/Backend/db.sqlite index f344d58ad..984f315b5 100644 Binary files a/csharp/App/Backend/db.sqlite and b/csharp/App/Backend/db.sqlite differ diff --git a/csharp/App/Backend/exoscale.toml b/csharp/App/Backend/exoscale.toml new file mode 100644 index 000000000..58336b073 --- /dev/null +++ b/csharp/App/Backend/exoscale.toml @@ -0,0 +1,10 @@ +defaultaccount = "Kim" + +[[accounts]] + account = "innovenergy-ag" + defaultZone = "ch-dk-2" + endpoint = "https://api.exoscale.com/v1" + environment = "" + key = "EXOf67c5b528282988503ddab12" + name = "Kim" + secret = "KBFh5HvoSQcTtGYcWSm4Qn4m-WFutKe89UqsOdOL-ts" diff --git a/csharp/App/BmsTunnel/BmsTunnel.csproj b/csharp/App/BmsTunnel/BmsTunnel.csproj index 0466a4173..1732d02f8 100644 --- a/csharp/App/BmsTunnel/BmsTunnel.csproj +++ b/csharp/App/BmsTunnel/BmsTunnel.csproj @@ -1,4 +1,8 @@ + + Debug;Release;Release-Server + AnyCPU;linux-arm + diff --git a/csharp/App/Collector/Collector.csproj b/csharp/App/Collector/Collector.csproj index 27b560c8d..9d08f7253 100644 --- a/csharp/App/Collector/Collector.csproj +++ b/csharp/App/Collector/Collector.csproj @@ -1,4 +1,8 @@ + + Debug;Release;Release-Server + AnyCPU;linux-arm + diff --git a/csharp/App/EmuMeterDriver/EmuMeterDriver.csproj b/csharp/App/EmuMeterDriver/EmuMeterDriver.csproj index b2f8696ed..f89f90434 100644 --- a/csharp/App/EmuMeterDriver/EmuMeterDriver.csproj +++ b/csharp/App/EmuMeterDriver/EmuMeterDriver.csproj @@ -1,4 +1,8 @@ + + Debug;Release;Release-Server + AnyCPU;linux-arm + diff --git a/csharp/App/InnovEnergy.App.props b/csharp/App/InnovEnergy.App.props index fe6d1e334..0cf09ae83 100644 --- a/csharp/App/InnovEnergy.App.props +++ b/csharp/App/InnovEnergy.App.props @@ -4,7 +4,7 @@ - + linux-x64 true true false diff --git a/csharp/App/OpenVpnCertificatesServer/OpenVpnCertificatesServer.csproj b/csharp/App/OpenVpnCertificatesServer/OpenVpnCertificatesServer.csproj index de611520f..9ae0cd90a 100644 --- a/csharp/App/OpenVpnCertificatesServer/OpenVpnCertificatesServer.csproj +++ b/csharp/App/OpenVpnCertificatesServer/OpenVpnCertificatesServer.csproj @@ -21,6 +21,8 @@ false + Debug;Release;Release-Server + AnyCPU;linux-arm diff --git a/csharp/App/RemoteSupportConsole/RemoteSupportConsole.csproj b/csharp/App/RemoteSupportConsole/RemoteSupportConsole.csproj index 1f571c26d..81deeb7c1 100644 --- a/csharp/App/RemoteSupportConsole/RemoteSupportConsole.csproj +++ b/csharp/App/RemoteSupportConsole/RemoteSupportConsole.csproj @@ -1,4 +1,8 @@ + + Debug;Release;Release-Server + AnyCPU;linux-arm + diff --git a/csharp/App/SaliMax/SaliMax.csproj b/csharp/App/SaliMax/SaliMax.csproj index 6802aca05..ba80db36b 100644 --- a/csharp/App/SaliMax/SaliMax.csproj +++ b/csharp/App/SaliMax/SaliMax.csproj @@ -1,4 +1,8 @@ + + Debug;Release;Release-Server + AnyCPU;linux-arm + diff --git a/csharp/App/VrmGrabber/Controller.cs b/csharp/App/VrmGrabber/Controller.cs new file mode 100644 index 000000000..653aede9b --- /dev/null +++ b/csharp/App/VrmGrabber/Controller.cs @@ -0,0 +1,131 @@ +using System.Web; +using HandlebarsDotNet; +using InnovEnergy.App.RemoteSupportConsole; +using InnovEnergy.App.VrmGrabber.Database; +using InnovEnergy.Lib.Victron.VictronVRM; +using Microsoft.AspNetCore.Mvc; +using FILE=System.IO.File; + +namespace InnovEnergy.App.VrmGrabber; + +public record Install( + String Name, + String Ip, + UInt64 Vrm, + String Identifier, + String Serial, + String EscapedName +); + +[Controller] +public class Controller : ControllerBase +{ + [HttpGet] + [Route("/")] + [Produces("text/html")] + public ActionResult Index() + { + var instList = Db.InstallationsAndDetails.Keys.ToList(); + if (instList.Count == 0) return new ContentResult + { + ContentType = "text/html", + Content = "

Please wait page is still loading

" + }; + + String source = @" + + + + + {{#inst}} + {{> installations}} + {{/inst}} + +
"; + + String partialSource = + @"{{Name}} + {{Ip}} + VRM + {{Identifier}} + {{Serial}} + Grafana"; + + Handlebars.RegisterTemplate("installations", partialSource); + var template = Handlebars.Compile(source); + var insts = instList.Select(i => + { + return new Install(i.Name, Ip(i), i.IdSite, i.Identifier, Serial(i), HttpUtility.UrlEncode(i.Name)); + }); + + + var data = new + { + inst = insts + }; + + var result = template(data); + + return new ContentResult + { + ContentType = "text/html", + Content = result + }; + } + + private String Ip(Installation installation) + { + + return VpnInfo.LookUpIp(installation.Identifier, Serial(installation)).Result ?? "Unknown"; + } + + private String Serial(Installation installation) + { + return Db.InstallationsAndDetails[installation].MachineSerial() ?? "Unknown"; + } + + // [HttpGet(nameof(GetInstallation))] + // [UnconditionalSuppressMessage("Trimming", "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code", Justification = "")] + // public Object GetInstallation(UInt64 serialNumber) + // { + // var instList = Db.InstallationsAndDetails.Values.ToList(); + // foreach (var detailList in instList.Select((value, index) => new { Value = value, Index = index})) + // { + // if (detailList.Value.All(detail => detail.Json["idSite"]?.GetValue() != serialNumber)) continue; + // var retour = Db.InstallationsAndDetails.Keys.ToList()[detailList.Index].Json; + // retour["details"] = JsonSerializer.Deserialize(JsonSerializer.Serialize(detailList.Value.Select(d => d.Json).ToArray())); + // return retour; + // } + // + // return new NotFoundResult(); + // } +} + + + + +// installation Name, ip (link uf gui), idSite (vrm link), identifier , machineserial (HQ...) + + diff --git a/csharp/App/VrmGrabber/DataTypes/Installation.cs b/csharp/App/VrmGrabber/DataTypes/Installation.cs new file mode 100644 index 000000000..2d118add8 --- /dev/null +++ b/csharp/App/VrmGrabber/DataTypes/Installation.cs @@ -0,0 +1,17 @@ +using InnovEnergy.Lib.Victron.VictronVRM; + +namespace InnovEnergy.App.VrmGrabber.DataTypes; + + +public class Installation : TreeNode +{ + + + public Installation() + { + } + + public String Name { get; set; } + // Settings + public IReadOnlyList Notes { get; set; } +} \ No newline at end of file diff --git a/csharp/App/VrmGrabber/DataTypes/Methods/Installation.cs b/csharp/App/VrmGrabber/DataTypes/Methods/Installation.cs new file mode 100644 index 000000000..7f89dd8d5 --- /dev/null +++ b/csharp/App/VrmGrabber/DataTypes/Methods/Installation.cs @@ -0,0 +1,7 @@ +namespace InnovEnergy.App.VrmGrabber.DataTypes.Methods; + + +public static class InstallationMethods +{ +} + diff --git a/csharp/App/VrmGrabber/DataTypes/TreeNode.cs b/csharp/App/VrmGrabber/DataTypes/TreeNode.cs new file mode 100644 index 000000000..e141688b7 --- /dev/null +++ b/csharp/App/VrmGrabber/DataTypes/TreeNode.cs @@ -0,0 +1,11 @@ +using SQLite; + +namespace InnovEnergy.App.VrmGrabber.DataTypes; + +public abstract partial class TreeNode +{ + [PrimaryKey, AutoIncrement] + public virtual Int64 Id { get; set; } + public String Information { get; set; } = ""; // unstructured random info + +} \ No newline at end of file diff --git a/csharp/App/VrmGrabber/Database/Create.cs b/csharp/App/VrmGrabber/Database/Create.cs new file mode 100644 index 000000000..b8d7dc25f --- /dev/null +++ b/csharp/App/VrmGrabber/Database/Create.cs @@ -0,0 +1,13 @@ +using InnovEnergy.App.VrmGrabber.DataTypes; + +namespace InnovEnergy.App.VrmGrabber.Database; + + +public static partial class Db +{ + public static Boolean Create(Installation installation) + { + // SQLite wrapper is smart and *modifies* t's Id to the one generated (autoincrement) by the insertion + return Connection.Insert(installation) > 0; + } +} \ No newline at end of file diff --git a/csharp/App/VrmGrabber/Database/Db.cs b/csharp/App/VrmGrabber/Database/Db.cs new file mode 100644 index 000000000..41f91a55c --- /dev/null +++ b/csharp/App/VrmGrabber/Database/Db.cs @@ -0,0 +1,67 @@ +using System.Diagnostics.CodeAnalysis; +using System.Reactive.Concurrency; +using System.Reactive.Linq; +using System.Reactive.Threading.Tasks; +using InnovEnergy.Lib.Utils; +using InnovEnergy.Lib.Victron.VictronVRM; +using SQLite; +using static System.Text.Json.JsonSerializer; +using Installation = InnovEnergy.App.VrmGrabber.DataTypes.Installation; + + +namespace InnovEnergy.App.VrmGrabber.Database; + + +public static partial class Db +{ + public static Dictionary> InstallationsAndDetails; + internal const String DbPath = "./db.sqlite"; + + + private static SQLiteConnection Connection { get; } = new SQLiteConnection(DbPath); + public static TableQuery Installations => Connection.Table(); + public static void Init() + { + // used to force static constructor + } + + static Db() + { + // on startup create/migrate tables + + Connection.RunInTransaction(() => + { + // Connection.CreateTable(); + }); + + InstallationsAndDetails = new Dictionary>(); + + Observable.Interval(TimeSpan.FromMinutes(5)) + .ObserveOn(TaskPoolScheduler.Default) + .SubscribeOn(TaskPoolScheduler.Default) + .StartWith(0) // Do it right away (on startup) + .Select(UpdateInstallationsAndDetailsFromVrm) + .Select(t => t.ToObservable()) + .Concat() + .Subscribe(d => InstallationsAndDetails = d, exception => exception.WriteLine()); + } + + [UnconditionalSuppressMessage("Trimming", "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code", Justification = "")] + private static async Task>> UpdateInstallationsAndDetailsFromVrm(Int64 _) + { + var fileContent = await File.ReadAllTextAsync("./token.json"); + + var acc = Deserialize(fileContent); + var user = VrmAccount.Token(acc.idUser, acc.token); + var installations = await user.GetInstallations(); + return installations + .Do(i=>i.Name.WriteLine()) + .ToDictionary(i => i, i => i.GetDetails().Result); + } +} + +public class AccToken +{ + public UInt64 idUser { get; init;} + public String token { get; init;} +} \ No newline at end of file diff --git a/csharp/App/VrmGrabber/Database/Delete.cs b/csharp/App/VrmGrabber/Database/Delete.cs new file mode 100644 index 000000000..e15fa4b31 --- /dev/null +++ b/csharp/App/VrmGrabber/Database/Delete.cs @@ -0,0 +1,13 @@ +using InnovEnergy.App.VrmGrabber.DataTypes; + +namespace InnovEnergy.App.VrmGrabber.Database; + + +public static partial class Db +{ + + public static Boolean Delete(Installation installation) + { + return Installations.Delete(i => i.Id == installation.Id) > 0; + } +} \ No newline at end of file diff --git a/csharp/App/VrmGrabber/Database/Read.cs b/csharp/App/VrmGrabber/Database/Read.cs new file mode 100644 index 000000000..4ef6c174c --- /dev/null +++ b/csharp/App/VrmGrabber/Database/Read.cs @@ -0,0 +1,14 @@ +using InnovEnergy.App.VrmGrabber.DataTypes; + +namespace InnovEnergy.App.VrmGrabber.Database; + + +public static partial class Db +{ + + public static Installation? GetInstallationById(Int64? id) + { + return Installations + .FirstOrDefault(i => i.Id == id); + } +} \ No newline at end of file diff --git a/csharp/App/VrmGrabber/Program.cs b/csharp/App/VrmGrabber/Program.cs new file mode 100644 index 000000000..02a2a9a6b --- /dev/null +++ b/csharp/App/VrmGrabber/Program.cs @@ -0,0 +1,36 @@ +using InnovEnergy.App.VrmGrabber.Database; +using Microsoft.OpenApi.Models; + +namespace InnovEnergy.App.VrmGrabber; + +public static class Program +{ + public static void Main(String[] args) + { + + var builder = WebApplication.CreateBuilder(args); + + builder.Services.AddControllers(); + builder.Services.AddSwaggerGen(c => + { + c.SwaggerDoc("v1", OpenApiInfo); + c.UseAllOfToExtendReferenceSchemas(); + c.SupportNonNullableReferenceTypes(); + }); + + var app = builder.Build(); + app.UseSwagger(); + app.UseSwaggerUI(); + app.UseHttpsRedirection(); + app.MapControllers(); + // app.MapGet("/", () => Controller.Index()); + app.Run(); + } + + private static OpenApiInfo OpenApiInfo { get; } = new OpenApiInfo + { + Title = "InnovEnergy VRM Grabber", + Version = "v1" + }; + +} \ No newline at end of file diff --git a/csharp/App/VrmGrabber/VrmGrabber.csproj b/csharp/App/VrmGrabber/VrmGrabber.csproj new file mode 100644 index 000000000..92c7a0262 --- /dev/null +++ b/csharp/App/VrmGrabber/VrmGrabber.csproj @@ -0,0 +1,41 @@ + + + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ContentIncludedByDefault Remove="wwwroot\index.html" /> + + + diff --git a/csharp/App/VrmGrabber/__pycache__/server.cpython-310.pyc b/csharp/App/VrmGrabber/__pycache__/server.cpython-310.pyc new file mode 100644 index 000000000..a276f3c5d Binary files /dev/null and b/csharp/App/VrmGrabber/__pycache__/server.cpython-310.pyc differ diff --git a/csharp/App/VrmGrabber/db.sqlite b/csharp/App/VrmGrabber/db.sqlite new file mode 100644 index 000000000..8294c39d2 Binary files /dev/null and b/csharp/App/VrmGrabber/db.sqlite differ diff --git a/csharp/App/VrmGrabber/server.py b/csharp/App/VrmGrabber/server.py new file mode 100644 index 000000000..27abdbd52 --- /dev/null +++ b/csharp/App/VrmGrabber/server.py @@ -0,0 +1,14 @@ +import requests as requests +from flask import Flask +from json2html import json2html + +app = Flask(__name__) +serverUrl = "https://127.0.0.1:7087/api" #todo change me + +@app.route('/') +def hello(): + json = requests.get(serverUrl + '/GetInstallationList', verify=False) #TODO VERIFY + + if json.content == b'0': + return "Still loading Installations" + return json2html.convert(json = json.json(), escape=False) diff --git a/csharp/App/VrmGrabber/token.json b/csharp/App/VrmGrabber/token.json new file mode 100644 index 000000000..9a0fbea24 --- /dev/null +++ b/csharp/App/VrmGrabber/token.json @@ -0,0 +1 @@ +{"idUser":55450,"token":"909379784fa601a52ab4756c1cc9690ecc769db4b661214f9b165eda20be9913"} \ No newline at end of file diff --git a/csharp/InnovEnergy.sln b/csharp/InnovEnergy.sln index bababc313..3a0401858 100644 --- a/csharp/InnovEnergy.sln +++ b/csharp/InnovEnergy.sln @@ -73,6 +73,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Meta", "Meta", "{AED84693-C ../.gitignore = ../.gitignore EndProjectSection EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VrmGrabber", "App\VrmGrabber\VrmGrabber.csproj", "{4F9BB20B-8030-48AB-A37B-23796459D516}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -184,6 +186,10 @@ Global {B816BB44-E97E-4E02-B80A-BEDB5B923A96}.Debug|Any CPU.Build.0 = Debug|Any CPU {B816BB44-E97E-4E02-B80A-BEDB5B923A96}.Release|Any CPU.ActiveCfg = Release|Any CPU {B816BB44-E97E-4E02-B80A-BEDB5B923A96}.Release|Any CPU.Build.0 = Release|Any CPU + {4F9BB20B-8030-48AB-A37B-23796459D516}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4F9BB20B-8030-48AB-A37B-23796459D516}.Release|Any CPU.Build.0 = Release|Any CPU + {4F9BB20B-8030-48AB-A37B-23796459D516}.Debug|Any CPU.ActiveCfg = Release-Server|linux-arm + {4F9BB20B-8030-48AB-A37B-23796459D516}.Debug|Any CPU.Build.0 = Release-Server|linux-arm EndGlobalSection GlobalSection(NestedProjects) = preSolution {CF4834CB-91B7-4172-AC13-ECDA8613CD17} = {145597B4-3E30-45E6-9F72-4DD43194539A} @@ -216,5 +222,6 @@ Global {C04FB6DA-23C6-46BB-9B21-8F4FBA32FFF7} = {AD5B98A8-AB7F-4DA2-B66D-5B4E63E7D854} {4A67D79F-F0C9-4BBC-9601-D5948E6C05D3} = {AD5B98A8-AB7F-4DA2-B66D-5B4E63E7D854} {B816BB44-E97E-4E02-B80A-BEDB5B923A96} = {DDDBEFD0-5DEA-4C7C-A9F2-FDB4636CF092} + {4F9BB20B-8030-48AB-A37B-23796459D516} = {145597B4-3E30-45E6-9F72-4DD43194539A} EndGlobalSection EndGlobal diff --git a/csharp/Lib/Channels/Channels.csproj b/csharp/Lib/Channels/Channels.csproj index 9eb898d4e..db7ad1473 100644 --- a/csharp/Lib/Channels/Channels.csproj +++ b/csharp/Lib/Channels/Channels.csproj @@ -1,5 +1,10 @@ + + Debug;Release;Release-Server + AnyCPU;linux-arm + + diff --git a/csharp/Lib/Devices/AMPT/Ampt.csproj b/csharp/Lib/Devices/AMPT/Ampt.csproj index ea8cbf21c..d5340e3ca 100644 --- a/csharp/Lib/Devices/AMPT/Ampt.csproj +++ b/csharp/Lib/Devices/AMPT/Ampt.csproj @@ -1,4 +1,8 @@ + + Debug;Release;Release-Server + AnyCPU;linux-arm + diff --git a/csharp/Lib/Devices/Adam6060/Adam6060.csproj b/csharp/Lib/Devices/Adam6060/Adam6060.csproj index 1a36e43e1..9c65e0cb7 100644 --- a/csharp/Lib/Devices/Adam6060/Adam6060.csproj +++ b/csharp/Lib/Devices/Adam6060/Adam6060.csproj @@ -1,4 +1,8 @@ + + Debug;Release;Release-Server + AnyCPU;linux-arm + diff --git a/csharp/Lib/Devices/Battery48TL/Battery48TL.csproj b/csharp/Lib/Devices/Battery48TL/Battery48TL.csproj index ce3b83de6..92dd034ad 100644 --- a/csharp/Lib/Devices/Battery48TL/Battery48TL.csproj +++ b/csharp/Lib/Devices/Battery48TL/Battery48TL.csproj @@ -1,4 +1,8 @@ + + Debug;Release;Release-Server + AnyCPU;linux-arm + diff --git a/csharp/Lib/Devices/EmuMeter/EmuMeter.csproj b/csharp/Lib/Devices/EmuMeter/EmuMeter.csproj index ce3b83de6..92dd034ad 100644 --- a/csharp/Lib/Devices/EmuMeter/EmuMeter.csproj +++ b/csharp/Lib/Devices/EmuMeter/EmuMeter.csproj @@ -1,4 +1,8 @@ + + Debug;Release;Release-Server + AnyCPU;linux-arm + diff --git a/csharp/Lib/Devices/Trumpf/SystemControl/SystemControl.csproj b/csharp/Lib/Devices/Trumpf/SystemControl/SystemControl.csproj index be34f2198..2197231aa 100644 --- a/csharp/Lib/Devices/Trumpf/SystemControl/SystemControl.csproj +++ b/csharp/Lib/Devices/Trumpf/SystemControl/SystemControl.csproj @@ -1,4 +1,8 @@ + + Debug;Release;Release-Server + AnyCPU;linux-arm + diff --git a/csharp/Lib/Devices/Trumpf/TruConvert/TruConvert.csproj b/csharp/Lib/Devices/Trumpf/TruConvert/TruConvert.csproj index ca3eb7a2a..a4f729801 100644 --- a/csharp/Lib/Devices/Trumpf/TruConvert/TruConvert.csproj +++ b/csharp/Lib/Devices/Trumpf/TruConvert/TruConvert.csproj @@ -1,4 +1,8 @@ + + Debug;Release;Release-Server + AnyCPU;linux-arm + diff --git a/csharp/Lib/Devices/Trumpf/TruConvertAc/TruConvertAc.csproj b/csharp/Lib/Devices/Trumpf/TruConvertAc/TruConvertAc.csproj index 36322cc01..34e08f495 100644 --- a/csharp/Lib/Devices/Trumpf/TruConvertAc/TruConvertAc.csproj +++ b/csharp/Lib/Devices/Trumpf/TruConvertAc/TruConvertAc.csproj @@ -1,4 +1,8 @@ + + Debug;Release;Release-Server + AnyCPU;linux-arm + diff --git a/csharp/Lib/Devices/Trumpf/TruConvertDc/TruConvertDc.csproj b/csharp/Lib/Devices/Trumpf/TruConvertDc/TruConvertDc.csproj index 1628a2b19..f640e856c 100644 --- a/csharp/Lib/Devices/Trumpf/TruConvertDc/TruConvertDc.csproj +++ b/csharp/Lib/Devices/Trumpf/TruConvertDc/TruConvertDc.csproj @@ -1,4 +1,8 @@ + + Debug;Release;Release-Server + AnyCPU;linux-arm + diff --git a/csharp/Lib/Protocols/DBus/DBus.csproj b/csharp/Lib/Protocols/DBus/DBus.csproj index 01a9e0400..ba9da4823 100644 --- a/csharp/Lib/Protocols/DBus/DBus.csproj +++ b/csharp/Lib/Protocols/DBus/DBus.csproj @@ -4,6 +4,8 @@ DBus Library true + Debug;Release;Release-Server + AnyCPU;linux-arm diff --git a/csharp/Lib/Protocols/Modbus/Modbus.csproj b/csharp/Lib/Protocols/Modbus/Modbus.csproj index 460195f09..70b28e699 100644 --- a/csharp/Lib/Protocols/Modbus/Modbus.csproj +++ b/csharp/Lib/Protocols/Modbus/Modbus.csproj @@ -1,4 +1,8 @@ + + Debug;Release;Release-Server + AnyCPU;linux-arm + diff --git a/csharp/Lib/StatusApi/StatusApi.csproj b/csharp/Lib/StatusApi/StatusApi.csproj index a1e52bb50..d30b8534e 100644 --- a/csharp/Lib/StatusApi/StatusApi.csproj +++ b/csharp/Lib/StatusApi/StatusApi.csproj @@ -1,4 +1,8 @@ + + Debug;Release;Release-Server + AnyCPU;linux-arm + diff --git a/csharp/Lib/SysTools/SysTools.csproj b/csharp/Lib/SysTools/SysTools.csproj index 72e17cc9b..fe718d694 100644 --- a/csharp/Lib/SysTools/SysTools.csproj +++ b/csharp/Lib/SysTools/SysTools.csproj @@ -1,4 +1,8 @@ + + Debug;Release;Release-Server + AnyCPU;linux-arm + diff --git a/csharp/Lib/Time/Time.csproj b/csharp/Lib/Time/Time.csproj index e971a1f7d..4e4793547 100644 --- a/csharp/Lib/Time/Time.csproj +++ b/csharp/Lib/Time/Time.csproj @@ -1,3 +1,7 @@ + + Debug;Release;Release-Server + AnyCPU;linux-arm + diff --git a/csharp/Lib/Units/Units.csproj b/csharp/Lib/Units/Units.csproj index 422120d58..257b04c56 100644 --- a/csharp/Lib/Units/Units.csproj +++ b/csharp/Lib/Units/Units.csproj @@ -1,4 +1,8 @@ + + Debug;Release;Release-Server + AnyCPU;linux-arm + diff --git a/csharp/Lib/Utils/JsonNodeAccessors.cs b/csharp/Lib/Utils/JsonNodeAccessors.cs index 8b05e97af..723673111 100644 --- a/csharp/Lib/Utils/JsonNodeAccessors.cs +++ b/csharp/Lib/Utils/JsonNodeAccessors.cs @@ -1,4 +1,6 @@ +using System.Diagnostics.CodeAnalysis; using System.Text.Json.Nodes; +using System.Text.Json.Serialization; namespace InnovEnergy.Lib.Utils; @@ -7,7 +9,7 @@ public static class JsonNodeAccessors public static T Get(this JsonNode n, String propName) => n[propName]!.GetValue(); - + public static String GetString(this JsonNode n, String propName) => n.Get(propName); public static Boolean GetBoolean(this JsonNode n, String propName) => n.Get(propName); @@ -37,7 +39,19 @@ public static class JsonNodeAccessors } } - public static String? TryGetString(this JsonNode n, String propName) => n.TryGet(propName); + public static String? TryGetString(this JsonNode n, String propName) + { + try + { + return n.TryGet(propName); + } + catch (Exception e) + { + Console.WriteLine(e); + return n.TryGet(propName).ToString(); + } + } + public static Boolean? TryGetBoolean(this JsonNode n, String propName) => n.TryGet(propName); public static UInt32? TryGetUInt32(this JsonNode n, String propName) => n.TryGet(propName); diff --git a/csharp/Lib/Utils/Utils.csproj b/csharp/Lib/Utils/Utils.csproj index 3ace16dcb..85d63a90e 100644 --- a/csharp/Lib/Utils/Utils.csproj +++ b/csharp/Lib/Utils/Utils.csproj @@ -1,4 +1,8 @@ + + Debug;Release;Release-Server + AnyCPU;linux-arm + diff --git a/csharp/Lib/Victron/VeDBus/VeDBus.csproj b/csharp/Lib/Victron/VeDBus/VeDBus.csproj index c7d6bf0a9..23827110a 100644 --- a/csharp/Lib/Victron/VeDBus/VeDBus.csproj +++ b/csharp/Lib/Victron/VeDBus/VeDBus.csproj @@ -1,5 +1,10 @@ + + Debug;Release;Release-Server + AnyCPU;linux-arm + + diff --git a/csharp/Lib/Victron/VictronVRM/Installation.cs b/csharp/Lib/Victron/VictronVRM/Installation.cs index aa233e275..82fcd85ce 100644 --- a/csharp/Lib/Victron/VictronVRM/Installation.cs +++ b/csharp/Lib/Victron/VictronVRM/Installation.cs @@ -8,6 +8,7 @@ namespace InnovEnergy.Lib.Victron.VictronVRM; public readonly partial record struct Installation(VrmAccount VrmAccount, JsonNode Json) { + public UInt64 IdSite => Json.GetUInt64("idSite"); public UnixTime Created => Json.GetUInt32("syscreated").Apply(UnixTime.FromTicks); @@ -15,7 +16,7 @@ public readonly partial record struct Installation(VrmAccount VrmAccount, JsonNo public String Name => Json.GetString("name"); public String Notes => Json.GetString("notes"); public String PhoneNumber => Json.GetString("phonenumber"); - + public String Identifier => Json.TryGetString("identifier"); // TODO: alternative way to handle settings? make them writeable here and have an UpdateInstallation function? // public String Name // { diff --git a/csharp/Lib/Victron/VictronVRM/Requests.cs b/csharp/Lib/Victron/VictronVRM/Requests.cs index c97be8350..5ec6c4214 100644 --- a/csharp/Lib/Victron/VictronVRM/Requests.cs +++ b/csharp/Lib/Victron/VictronVRM/Requests.cs @@ -37,7 +37,7 @@ public static class Requests .AppendPathSegment("users") .AppendPathSegment(account.UserId) .AppendPathSegment("installations") - .WithHeader("X-Authorization", account.Auth); + .WithHeader("x-authorization", account.Auth); } public static IFlurlRequest TagsRequest(this VrmAccount account, UInt64 installationId) diff --git a/csharp/Lib/Victron/VictronVRM/VictronVRM.csproj b/csharp/Lib/Victron/VictronVRM/VictronVRM.csproj index c5a94a419..57128f448 100644 --- a/csharp/Lib/Victron/VictronVRM/VictronVRM.csproj +++ b/csharp/Lib/Victron/VictronVRM/VictronVRM.csproj @@ -5,6 +5,11 @@ full + + + Debug;Release;Release-Server + AnyCPU;linux-arm + diff --git a/csharp/Lib/WebServer/WebServer.csproj b/csharp/Lib/WebServer/WebServer.csproj index 00c76841c..a13aec7a9 100644 --- a/csharp/Lib/WebServer/WebServer.csproj +++ b/csharp/Lib/WebServer/WebServer.csproj @@ -3,7 +3,8 @@ - + Debug;Release;Release-Server + AnyCPU;linux-arm diff --git a/doc/Pv-Steuerung-Victron.docx b/doc/Pv-Steuerung-Victron.docx new file mode 100644 index 000000000..7265db337 Binary files /dev/null and b/doc/Pv-Steuerung-Victron.docx differ diff --git a/doc/Pv-Steuerung-Victron.pdf b/doc/Pv-Steuerung-Victron.pdf new file mode 100644 index 000000000..7377d2fc7 Binary files /dev/null and b/doc/Pv-Steuerung-Victron.pdf differ