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.
This commit is contained in:
1 parent
75c528a430
commit
94d5a844cf
2 files changed
+71
-1
No files matched your search
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user