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

33 lines
996 B
C#
Raw Normal View History

2023-09-08 09:52:49 +00:00
using System.Text.Json;
using System.Text.Json.Nodes;
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();
// Console.WriteLine("Got");
2023-09-08 09:52:49 +00:00
var vrmReply = new Reply(reply);
Console.WriteLine(vrmReply.ToString());
2023-09-08 09:52:49 +00:00
if (!vrmReply.Success)
throw new Exception(nameof(GetAlarms) + " failed");
Console.WriteLine(vrmReply.Alarms);
2023-09-08 09:52:49 +00:00
return vrmReply.Alarms;
}
public async Task<Boolean> SetAlarms(JsonObject tags)
{
var reply = await VrmAccount.AlarmsRequest(IdSite).TryPutJson(tags);
2023-09-08 09:52:49 +00:00
var vrmReply = new Reply(reply);
// 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;
}
}