Skip to content

Commit 20223d3

Browse files
authored
Merge pull request #303 from casanet/support-multy-commands-action
Support unique ON command
2 parents 5ca22c8 + e4fa430 commit 20223d3

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

backend/src/models/backendInterfaces.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ export declare interface ToggleCommands {
135135
/** Ac commands set */
136136
export declare interface AcCommands {
137137
off: string | string [];
138+
on?: string | string [];
138139
statusCommands: AirConditioningCommand[];
139140
}
140141

backend/src/utilities/cacheManager.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,18 @@ export class CommandsCacheManager extends CacheManager {
196196
message: 'there is no available command for current status. record a new command.',
197197
} as ErrorResponse;
198198
}
199+
200+
// If there is a unique command for on mode, and now device is off, append "on" command/s to the top of command/s array
201+
if (minionCache.acCommands.on
202+
&& minionCache?.lastStatus?.airConditioning?.status === 'off') {
203+
if (typeof hexCommandCode === 'string') {
204+
hexCommandCode = [hexCommandCode];
205+
}
206+
const onCommand = typeof minionCache.acCommands.on === 'string' ? [minionCache.acCommands.on] : minionCache.acCommands.on;
207+
hexCommandCode.unshift(...onCommand);
208+
}
209+
210+
199211

200212
return hexCommandCode;
201213
}

0 commit comments

Comments
 (0)