diff --git a/csharp/App/Backend/S3/S3Cmd.cs b/csharp/App/Backend/S3/S3Cmd.cs index e5783f833..1e88d7148 100644 --- a/csharp/App/Backend/S3/S3Cmd.cs +++ b/csharp/App/Backend/S3/S3Cmd.cs @@ -13,9 +13,9 @@ public class S3Cmd private const String? S3CmdPath = "Resources/s3cmd.py"; private const String S3Prefix = "s3://"; - - public String Key { get; init;} - public String Secret { get; init;} + + public String Key { get; init; } = S3Access.ReadWrite.Key; + public String Secret { get; init; } = S3Access.ReadWrite.Secret; public String Region { get; init; } = "sos-ch-dk-2.exo.io"; // private String?[] DefaultArgs { get; } diff --git a/csharp/Lib/Victron/VictronVRM/Installation.Alarms.cs b/csharp/Lib/Victron/VictronVRM/Installation.Alarms.cs new file mode 100644 index 000000000..38c54ac20 --- /dev/null +++ b/csharp/Lib/Victron/VictronVRM/Installation.Alarms.cs @@ -0,0 +1,30 @@ +using System.Text.Json; +using System.Text.Json.Nodes; + +namespace InnovEnergy.Lib.Victron.VictronVRM; + + +public readonly partial record struct Installation +{ + + public async Task> GetAlarms() + { + var reply = await VrmAccount.AlarmsRequest(IdSite).TryGetJson(); + + var vrmReply = new Reply(reply); + if (!vrmReply.Success) + throw new Exception(nameof(GetAlarms) + " failed"); + + return vrmReply.Alarms; + } + + public async Task SetAlarms(JsonObject tags) + { + var reply = await VrmAccount.AlarmsRequest(IdSite).TryPostJson(tags); + var vrmReply = new Reply(reply); + if (!vrmReply.Success) + throw new Exception(nameof(SetAlarms) + " failed"); + + return vrmReply.Success; + } +} \ No newline at end of file diff --git a/csharp/Lib/Victron/VictronVRM/Reply.cs b/csharp/Lib/Victron/VictronVRM/Reply.cs index 8e50a8b4b..af91e9b3d 100644 --- a/csharp/Lib/Victron/VictronVRM/Reply.cs +++ b/csharp/Lib/Victron/VictronVRM/Reply.cs @@ -9,6 +9,7 @@ public readonly record struct Reply(JsonNode Json) public Boolean Success => Json.TryGetBoolean("success") is not null or true; public IReadOnlyList Tags => Json.GetArray("tags"); + public IReadOnlyList Alarms => Json.GetArray("alarms"); public JsonArray Records => Json.GetArray("records"); public IReadOnlyList Devices => Json["records"]! diff --git a/csharp/Lib/Victron/VictronVRM/Requests.cs b/csharp/Lib/Victron/VictronVRM/Requests.cs index 99684e724..26cb3393c 100644 --- a/csharp/Lib/Victron/VictronVRM/Requests.cs +++ b/csharp/Lib/Victron/VictronVRM/Requests.cs @@ -22,6 +22,12 @@ public static class Requests .AppendPathSegment("diagnostics") .SetQueryParams(new { count = nDetails }); } + + public static IFlurlRequest AlarmsRequest(this VrmAccount account, UInt64 installationId) + { + return InstallationRequest(account, installationId) + .AppendPathSegment("alarms"); + } public static IFlurlRequest InstallationRequest(this VrmAccount account, UInt64 installationId) {