enable recirc
This commit is contained in:
parent
afc81e3b95
commit
802b9e766b
1 changed files with 29 additions and 5 deletions
34
src/main.zig
34
src/main.zig
|
|
@ -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
|
/// 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 };
|
var client = http.Client{ .allocator = allocator };
|
||||||
defer client.deinit();
|
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 {
|
const DeviceShadow = struct {
|
||||||
|
|
@ -435,10 +435,34 @@ pub fn main() !void {
|
||||||
|
|
||||||
if (recirc_enabled) {
|
if (recirc_enabled) {
|
||||||
try stdout.print("\n✓ Recirculation is already active\n", .{});
|
try stdout.print("\n✓ Recirculation is already active\n", .{});
|
||||||
// Recirculation code commented out as requested
|
|
||||||
} else {
|
} else {
|
||||||
// Recirculation code would go here but not called during testing
|
try stdout.print("\n🚿 Starting 15-minute recirculation...\n", .{});
|
||||||
try stdout.print("\n(Recirculation start function available but not called during testing)\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();
|
try stdout.flush();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue