chore: fix
This commit is contained in:
@@ -17,26 +17,43 @@ app.MapPost(
|
||||
Console.WriteLine("high power alert was received.");
|
||||
|
||||
using var client = new HttpClient();
|
||||
var heatPumpState = await client.GetFromJsonAsync<HeatPumpStatus>("http://192.168.1.121/control");
|
||||
Console.WriteLine(heatPumpState.power);
|
||||
switch (body.Status)
|
||||
{
|
||||
case "firing":
|
||||
Console.WriteLine("Peak too high. Shutting down heat pump.");
|
||||
await client.GetAsync(
|
||||
"http://192.168.1.121/control?cmd=heatpump&set_power_mode=off"
|
||||
);
|
||||
var message = "@everyone peak is too high. Disabling heat pump. 🥶";
|
||||
if (heatPumpState.power == "on")
|
||||
{
|
||||
await client.GetAsync(
|
||||
"http://192.168.1.121/control?cmd=heatpump&set_power_mode=off"
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
message = "@everyone heat pump could not be disabled because state was not 'ON'";
|
||||
}
|
||||
await client.PostAsJsonAsync<DiscordMessage>(
|
||||
"https://discord.com/api/webhooks/1455072237207158981/C9qvSIGMZVc60VwpZizxqKigyzvA182RDSdt9k8qtWTq-fBgzlJHh53wAYIqYkGNkBM3",
|
||||
new DiscordMessage("Peak too high. Shutting down heat pump. 🥶", "willemBot")
|
||||
new DiscordMessage(message, "willemBot")
|
||||
);
|
||||
break;
|
||||
case "resolved":
|
||||
Console.WriteLine("Peak acceptable. Re enabling heat pump. ");
|
||||
await client.GetAsync(
|
||||
"http://192.168.1.121/control?cmd=heatpump&set_power_mode=on"
|
||||
);
|
||||
Console.WriteLine("Peak acceptable. Re enabling heat pump. 🌶️");
|
||||
var message = "Re enabled heat pump.";
|
||||
if (heatPumpState.power == "off")
|
||||
{
|
||||
await client.GetAsync(
|
||||
"http://192.168.1.121/control?cmd=heatpump&set_power_mode=on"
|
||||
);
|
||||
}
|
||||
else {
|
||||
message = "@everyone Heat pump could not be re enabled because state was not 'ON'";
|
||||
}
|
||||
await client.PostAsJsonAsync<DiscordMessage>(
|
||||
"https://discord.com/api/webhooks/1455072237207158981/C9qvSIGMZVc60VwpZizxqKigyzvA182RDSdt9k8qtWTq-fBgzlJHh53wAYIqYkGNkBM3",
|
||||
new DiscordMessage("Peak is acceptable. Re enabling heat pump. 🌶️", "willemBot")
|
||||
new DiscordMessage(message, "willemBot")
|
||||
);
|
||||
break;
|
||||
default:
|
||||
@@ -63,3 +80,5 @@ app.Run();
|
||||
record AlertBody(string Status);
|
||||
|
||||
record DiscordMessage(string content, string userName);
|
||||
|
||||
record HeatPumpStatus(string power);
|
||||
|
||||
Reference in New Issue
Block a user