Skip to content

Commit 265c20a

Browse files
committed
v4.0.0
1 parent 41cfb20 commit 265c20a

File tree

17 files changed

+1321
-170
lines changed

17 files changed

+1321
-170
lines changed

PRODUCTION_READY.md

Lines changed: 0 additions & 135 deletions
This file was deleted.

src/api.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -217,20 +217,23 @@ export class OpenAPIClient {
217217
/**
218218
* Curtain-specific commands
219219
*/
220-
async curtainOpen(deviceId: string): Promise<APICommandResponse> {
221-
return this.sendCommand(deviceId, 'setPosition', '0,ff,0')
220+
async curtainOpen(deviceId: string, speed = 255): Promise<APICommandResponse> {
221+
const clampedSpeed = Math.min(255, Math.max(1, speed))
222+
return this.sendCommand(deviceId, 'setPosition', `0,${clampedSpeed.toString(16).padStart(2, '0')},0`)
222223
}
223224

224-
async curtainClose(deviceId: string): Promise<APICommandResponse> {
225-
return this.sendCommand(deviceId, 'setPosition', '0,ff,100')
225+
async curtainClose(deviceId: string, speed = 255): Promise<APICommandResponse> {
226+
const clampedSpeed = Math.min(255, Math.max(1, speed))
227+
return this.sendCommand(deviceId, 'setPosition', `0,${clampedSpeed.toString(16).padStart(2, '0')},100`)
226228
}
227229

228230
async curtainPause(deviceId: string): Promise<APICommandResponse> {
229231
return this.sendCommand(deviceId, 'pause')
230232
}
231233

232-
async curtainSetPosition(deviceId: string, position: number): Promise<APICommandResponse> {
233-
return this.sendCommand(deviceId, 'setPosition', `0,ff,${position}`)
234+
async curtainSetPosition(deviceId: string, position: number, speed = 255): Promise<APICommandResponse> {
235+
const clampedSpeed = Math.min(255, Math.max(1, speed))
236+
return this.sendCommand(deviceId, 'setPosition', `0,${clampedSpeed.toString(16).padStart(2, '0')},${position}`)
234237
}
235238

236239
/**

0 commit comments

Comments
 (0)