Innovenergy_trunk/csharp/Lib/Victron/VictronVRM/Installation.Alarms.cs

33 lines
996 B
C#

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