move shadow state output to custom format function
This commit is contained in:
parent
750d931ffe
commit
82babf0ce6
1 changed files with 11 additions and 7 deletions
18
src/main.zig
18
src/main.zig
|
|
@ -273,6 +273,16 @@ const DeviceShadow = struct {
|
|||
pub fn deinit(self: *DeviceShadow) void {
|
||||
self.json_data.deinit();
|
||||
}
|
||||
|
||||
pub fn format(self: DeviceShadow, writer: *std.Io.Writer) std.Io.Writer.Error!void {
|
||||
try writer.writeAll("Current Shadow State:\n");
|
||||
try writer.print(" heater_serial_number: {?s}\n", .{self.heater_serial_number});
|
||||
try writer.print(" set_recirculation_enabled: {?}\n", .{self.set_recirculation_enabled});
|
||||
try writer.print(" recirculation_enabled: {?}\n", .{self.recirculation_enabled});
|
||||
try writer.print(" recirculation_duration: {?}\n", .{self.recirculation_duration});
|
||||
try writer.print(" set_domestic_temperature: {?}\n", .{self.set_domestic_temperature});
|
||||
try writer.print(" operation_enabled: {?}\n", .{self.operation_enabled});
|
||||
}
|
||||
};
|
||||
|
||||
fn parseDeviceShadow(parsed: json.Parsed(json.Value)) !DeviceShadow {
|
||||
|
|
@ -413,13 +423,7 @@ pub fn main() !void {
|
|||
var status = try getRecirculationStatus(allocator, auth.id_token, sid);
|
||||
defer status.deinit();
|
||||
|
||||
try stdout.print("\nCurrent Shadow State:\n", .{});
|
||||
try stdout.print(" heater_serial_number: {?s}\n", .{status.heater_serial_number});
|
||||
try stdout.print(" set_recirculation_enabled: {?}\n", .{status.set_recirculation_enabled});
|
||||
try stdout.print(" recirculation_enabled: {?}\n", .{status.recirculation_enabled});
|
||||
try stdout.print(" recirculation_duration: {?}\n", .{status.recirculation_duration});
|
||||
try stdout.print(" set_domestic_temperature: {?}\n", .{status.set_domestic_temperature});
|
||||
try stdout.print(" operation_enabled: {?}\n", .{status.operation_enabled});
|
||||
try stdout.print("\n{f}", .{status});
|
||||
|
||||
const recirc_enabled = status.recirculation_enabled orelse false;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue