Skip to content

Commit 05371a2

Browse files
committed
fix: manual control
1 parent 051b51c commit 05371a2

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

src/tadox.ts

+9-5
Original file line numberDiff line numberDiff line change
@@ -98,29 +98,33 @@ export class TadoX extends Tado {
9898
* @param home_id - The identifier of the home.
9999
* @param room_id - The identifier of the room within the home.
100100
* @param power - The power state, either 'ON' or 'OFF'.
101-
* @param temperature - The desired temperature for the overlay, in celsius.
102101
* @param termination - The termination condition for the overlay. Options include 'MANUAL', 'NEXT_TIME_BLOCK', or a number representing duration in seconds.
102+
* @param temperature - The desired temperature for the overlay, in celsius.
103103
* @returns A promise that resolves to the created zone overlay.
104104
*/
105105
async manualControl(
106106
home_id: number,
107107
room_id: number,
108108
power: Power,
109-
temperature: number,
110109
termination: XTermination | number,
110+
temperature?: number,
111111
): Promise<unknown> {
112112
const overlay: XOverlay = {
113113
setting: {
114114
power,
115-
temperature: {
116-
value: temperature,
117-
},
115+
temperature: null,
118116
},
119117
termination: {
120118
type: "MANUAL",
121119
},
122120
};
123121

122+
if (temperature) {
123+
overlay.setting.temperature = {
124+
value: temperature,
125+
};
126+
}
127+
124128
if (typeof termination === "string" && !isNaN(parseInt(termination))) {
125129
termination = parseInt(termination);
126130
}

src/types/index.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1068,7 +1068,10 @@ export type XTerminationConfig =
10681068
};
10691069

10701070
export type XOverlay = {
1071-
setting: XRoomSetting;
1071+
setting: {
1072+
power: Power;
1073+
temperature: XRoomValue | null;
1074+
};
10721075
termination: XTerminationConfig;
10731076
isBoost?: boolean;
10741077
};

test/tadox-high.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ describe("High-level API tests (TadoX)", async function () {
7171
return req;
7272
});
7373

74-
const response = await tado.manualControl(1907, 1, "OFF");
74+
const response = await tado.manualControl(1907, 1, "OFF", "MANUAL");
7575

7676
expect(typeof response).to.equal("object");
7777
});

0 commit comments

Comments
 (0)