Skip to content

Commit

Permalink
Merge pull request #303 from casanet/support-multy-commands-action
Browse files Browse the repository at this point in the history
Support unique ON command
  • Loading branch information
haimkastner committed Sep 24, 2023
2 parents 5ca22c8 + e4fa430 commit 20223d3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions backend/src/models/backendInterfaces.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ export declare interface ToggleCommands {
/** Ac commands set */
export declare interface AcCommands {
off: string | string [];
on?: string | string [];
statusCommands: AirConditioningCommand[];
}

Expand Down
12 changes: 12 additions & 0 deletions backend/src/utilities/cacheManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,18 @@ export class CommandsCacheManager extends CacheManager {
message: 'there is no available command for current status. record a new command.',
} as ErrorResponse;
}

// 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
if (minionCache.acCommands.on
&& minionCache?.lastStatus?.airConditioning?.status === 'off') {
if (typeof hexCommandCode === 'string') {
hexCommandCode = [hexCommandCode];
}
const onCommand = typeof minionCache.acCommands.on === 'string' ? [minionCache.acCommands.on] : minionCache.acCommands.on;
hexCommandCode.unshift(...onCommand);
}



return hexCommandCode;
}
Expand Down

0 comments on commit 20223d3

Please sign in to comment.