Added alarm changing
This commit is contained in:
parent
47c8d438d1
commit
eb54250031
|
@ -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))]
|
||||
|
|
|
@ -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>(TValue, JsonSerializerOptions)")]
|
||||
private static async Task<Boolean> updateAlarms(VrmInstallation installation)
|
||||
{
|
||||
// installation.GetDevices().batteryMonitor.setTemperatureAlarms(245,250,315,313);
|
||||
var alarmJson = Deserialize<JsonObject>("""
|
||||
{
|
||||
"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<VrmAccount> GetVrmAccount()
|
||||
{
|
||||
var fileContent = await File.ReadAllTextAsync("./token.json");
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue