diff --git a/csharp/App/VrmGrabber/Controller.cs b/csharp/App/VrmGrabber/Controller.cs index b907339e8..dcc6bfb66 100644 --- a/csharp/App/VrmGrabber/Controller.cs +++ b/csharp/App/VrmGrabber/Controller.cs @@ -4,6 +4,7 @@ using HandlebarsDotNet; using InnovEnergy.App.VrmGrabber.Database; using InnovEnergy.App.VrmGrabber.DataTypes; using InnovEnergy.Lib.Utils; +using InnovEnergy.Lib.Victron.VictronVRM; using Microsoft.AspNetCore.Mvc; using FILE=System.IO.File; using VrmInstallation = InnovEnergy.Lib.Victron.VictronVRM.Installation; @@ -238,9 +239,9 @@ th { /* header cell */ private static async Task SendNewBatteryFirmware(String installationIp) { - await Cli.Wrap("scp") - .WithArguments($@"{FirmwareVersion}.bin") - .AppendArgument($@"root@{installationIp}:/opt/innovenergy/{FirmwareVersion}.bin") + await Cli.Wrap("rsync") + .WithArguments($@"-r {FirmwareVersion}.bin") + .AppendArgument($@"root@{installationIp}:/opt/innovenergy/bms-firmware/{FirmwareVersion}.bin") .ExecuteAsync(); } // [HttpGet(nameof(GetInstallation))] diff --git a/csharp/App/VrmGrabber/Database/Db.cs b/csharp/App/VrmGrabber/Database/Db.cs index b454a1d8f..130740a53 100644 --- a/csharp/App/VrmGrabber/Database/Db.cs +++ b/csharp/App/VrmGrabber/Database/Db.cs @@ -1,11 +1,13 @@ using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; +using System.Text.Json.Nodes; using System.Web; using CliWrap; using CliWrap.Buffered; using InnovEnergy.App.RemoteSupportConsole; using InnovEnergy.Lib.Utils; using InnovEnergy.Lib.Victron.VictronVRM; +using Newtonsoft.Json; using SQLite; using static System.Text.Json.JsonSerializer; using static InnovEnergy.App.VrmGrabber.Database.Systemd; @@ -81,6 +83,7 @@ public static partial class Db Console.WriteLine(installation.Name); sd_notify(0, "WATCHDOG=1"); var details = await GetInstallationDetails(installation); + await updateAlarms(installation); var ip = Ip(details); var updatedInstallation = new Installation( installation.Name, @@ -111,6 +114,26 @@ public static partial class Db } } + [RequiresUnreferencedCode("Calls System.Text.Json.JsonSerializer.SerializeToElement(TValue, JsonSerializerOptions)")] + private static async Task updateAlarms(VrmInstallation installation) + { + // installation.GetDevices().batteryMonitor.setTemperatureAlarms(245,250,315,313); + var alarmJson = Deserialize(""" + { + "AlarmEnabled": 1, + "NotifyAfterSeconds": 60, + "highAlarm": 315, + "highAlarmHysteresis": 313, + "lowAlarm": 245, + "lowAlarmHysteresis": 250 + } + """)!; + var tags = await installation.GetTags(); + if (tags.Contains("FM-AF09")) + return await installation.SetAlarms(alarmJson); + return true; + } + public static async Task GetVrmAccount() { var fileContent = await File.ReadAllTextAsync("./token.json"); diff --git a/csharp/App/VrmGrabber/db.sqlite b/csharp/App/VrmGrabber/db.sqlite index 85bb6b269..0032af2b3 100644 Binary files a/csharp/App/VrmGrabber/db.sqlite and b/csharp/App/VrmGrabber/db.sqlite differ