enable recirc

This commit is contained in:
Emil Lerch 2025-12-09 14:01:54 -08:00
parent afc81e3b95
commit 802b9e766b
Signed by: lobo
GPG key ID: A7B62D657EF764F8

View file

@ -228,7 +228,7 @@ fn getDevices(allocator: std.mem.Allocator, id_token: []const u8, username: []co
}
/// Starts recirculation for the specified device with given duration
fn startRecirculation(allocator: std.mem.Allocator, id_token: []const u8, serial_number: []const u8, duration_minutes: u32) !bool {
fn startRecirculation(allocator: std.mem.Allocator, id_token: []const u8, serial_number: []const u8, duration_minutes: u32) !void {
var client = http.Client{ .allocator = allocator };
defer client.deinit();
@ -258,7 +258,7 @@ fn startRecirculation(allocator: std.mem.Allocator, id_token: []const u8, serial
},
});
return result.status == .ok;
if (result.status != .ok) return error.StartRecirculationFailed;
}
const DeviceShadow = struct {
@ -435,10 +435,34 @@ pub fn main() !void {
if (recirc_enabled) {
try stdout.print("\n✓ Recirculation is already active\n", .{});
// Recirculation code commented out as requested
} else {
// Recirculation code would go here but not called during testing
try stdout.print("\n(Recirculation start function available but not called during testing)\n", .{});
try stdout.print("\n🚿 Starting 15-minute recirculation...\n", .{});
try stdout.flush();
startRecirculation(
allocator,
auth.id_token,
sid,
15,
) catch |e| {
try stderr.print("❌ Failed to start recirculation\n", .{});
try stderr.flush();
return e;
};
try stdout.print("✓ Recirculation command sent\n", .{});
try stdout.print("⏳ Waiting 20 seconds for device to respond...\n", .{});
try stdout.flush();
std.Thread.sleep(20 * std.time.ns_per_s);
var post_command_state = try getRecirculationStatus(
allocator,
auth.id_token,
sid,
);
defer post_command_state.deinit();
try stdout.print("\n{f}", .{post_command_state});
}
try stdout.flush();
} else {