From 94d5a844cf677757a32a6dd5e47cbc9b4eff979d Mon Sep 17 00:00:00 2001 From: 15i1i-s7v <15i1i-s7v@users.noreply.github.com> Date: Fri, 19 Dec 2025 13:36:28 +0100 Subject: [PATCH] feat: add heating and cooling tolerance functions for front and back - Added `setFrontHeatingTolerance` and `setBackHeatingTolerance` functions to update heating tolerance values. - Added `setFrontCoolingTolerance` and `setBackCoolingTolerance` functions to update cooling tolerance values. - Updated `fanStateSchema` to use `max_revolutions` instead of `target_revolutions`. - Introduced mutation hooks for handling tolerance updates for front and back heating/cooling. --- .../aquapath/aquapath1/aquapath1Namespace.ts | 2 +- .../aquapath/aquapath1/useAquapath.ts | 70 +++++++++++++++++++ 2 files changed, 71 insertions(+), 1 deletion(-) diff --git a/electron/src/machines/aquapath/aquapath1/aquapath1Namespace.ts b/electron/src/machines/aquapath/aquapath1/aquapath1Namespace.ts index a909881f..99cc3916 100644 --- a/electron/src/machines/aquapath/aquapath1/aquapath1Namespace.ts +++ b/electron/src/machines/aquapath/aquapath1/aquapath1Namespace.ts @@ -53,7 +53,7 @@ export const flowStatesSchema = z.object({ export const fanStateSchema = z.object({ revolutions: z.number(), - target_revolutions: z.number(), + max_revolutions: z.number(), }); export const fanStatesSchema = z.object({ back: fanStateSchema, diff --git a/electron/src/machines/aquapath/aquapath1/useAquapath.ts b/electron/src/machines/aquapath/aquapath1/useAquapath.ts index cc1fb058..7f32bb3c 100644 --- a/electron/src/machines/aquapath/aquapath1/useAquapath.ts +++ b/electron/src/machines/aquapath/aquapath1/useAquapath.ts @@ -154,6 +154,62 @@ export function useAquapath1() { ); }; + const setFrontHeatingTolerance = (tolerance: number) => { + updateStateOptimistically( + (current) => { + current.data.tolerance_states.front.heating = tolerance; + }, + () => { + requestFrontHeatingTolerance({ + machine_identification_unique: machineIdentification, + data: { setFrontHeatingTolerance: tolerance }, + }); + }, + ); + }; + + const setBackHeatingTolerance = (tolerance: number) => { + updateStateOptimistically( + (current) => { + current.data.tolerance_states.back.heating = tolerance; + }, + () => { + requestBackHeatingTolerance({ + machine_identification_unique: machineIdentification, + data: { setBackHeatingTolerance: tolerance }, + }); + }, + ); + }; + + const setFrontCoolingTolerance = (tolerance: number) => { + updateStateOptimistically( + (current) => { + current.data.tolerance_states.front.cooling = tolerance; + }, + () => { + requestFrontCoolingTolerance({ + machine_identification_unique: machineIdentification, + data: { setFrontHeatingTolerance: tolerance }, + }); + }, + ); + }; + + const setBackCoolingTolerance = (tolerance: number) => { + updateStateOptimistically( + (current) => { + current.data.tolerance_states.back.cooling = tolerance; + }, + () => { + requestBackCoolingTolerance({ + machine_identification_unique: machineIdentification, + data: { setBackHeatingTolerance: tolerance }, + }); + }, + ); + }; + // Mutation hooks const { request: requestAquapathMode } = useMachineMutation( z.object({ SetAquaPathMode: z.enum(["Standby", "Auto"]) }), @@ -176,6 +232,16 @@ export function useAquapath1() { const { request: requestBackRevolutions } = useMachineMutation( z.object({ SetBackRevolutions: z.number() }), ); + const { request: requestFrontHeatingTolerance } = useMachineMutation( + z.object({ setFrontHeatingTolerance: z.number() }), + ) + const { request: requestBackHeatingTolerance } = useMachineMutation( + z.object({ setBackHeatingTolerance: z.number() }), + ) + const { request: requestFrontHeatingTolerance } = useMachineMutation( + z.object({ setFrontHeatingTolerance: z.number() }), + ) + // Helper function for optimistic updates using produce const updateStateOptimistically = ( producer: (current: StateEvent) => void, @@ -210,5 +276,9 @@ export function useAquapath1() { setBackFlow, setFrontRevolutions, setBackRevolutions, + setFrontHeatingTolerance, + setBackHeatingTolerance, + setFrontCoolingTolerance, + setBackCoolingTolerance, }; }