2023-09-08 09:52:49 +00:00
|
|
|
using System.Text.Json;
|
|
|
|
using System.Text.Json.Nodes;
|
2023-10-09 12:23:31 +00:00
|
|
|
using Flurl.Http;
|
2023-09-08 09:52:49 +00:00
|
|
|
|
|
|
|
namespace InnovEnergy.Lib.Victron.VictronVRM;
|
|
|
|
|
|
|
|
|
|
|
|
public readonly partial record struct Installation
|
|
|
|
{
|
|
|
|
|
|
|
|
public async Task<IReadOnlyList<String>> GetAlarms()
|
|
|
|
{
|
|
|
|
var reply = await VrmAccount.AlarmsRequest(IdSite).TryGetJson();
|
2023-10-09 12:23:31 +00:00
|
|
|
// Console.WriteLine("Got");
|
2023-09-08 09:52:49 +00:00
|
|
|
|
|
|
|
var vrmReply = new Reply(reply);
|
2023-10-09 12:23:31 +00:00
|
|
|
Console.WriteLine(vrmReply.ToString());
|
2023-09-08 09:52:49 +00:00
|
|
|
if (!vrmReply.Success)
|
|
|
|
throw new Exception(nameof(GetAlarms) + " failed");
|
2023-10-09 12:23:31 +00:00
|
|
|
Console.WriteLine(vrmReply.Alarms);
|
2023-09-08 09:52:49 +00:00
|
|
|
return vrmReply.Alarms;
|
|
|
|
}
|
|
|
|
|
|
|
|
public async Task<Boolean> SetAlarms(JsonObject tags)
|
|
|
|
{
|
2023-10-09 12:23:31 +00:00
|
|
|
var reply = await VrmAccount.AlarmsRequest(IdSite).TryPutJson(tags);
|
2023-09-08 09:52:49 +00:00
|
|
|
var vrmReply = new Reply(reply);
|
2023-10-09 12:23:31 +00:00
|
|
|
// Console.WriteLine(vrmReply.Success.ToString());
|
2023-09-08 09:52:49 +00:00
|
|
|
if (!vrmReply.Success)
|
|
|
|
throw new Exception(nameof(SetAlarms) + " failed");
|
|
|
|
return vrmReply.Success;
|
|
|
|
}
|
|
|
|
}
|