Skip to content

Commit

Permalink
Support unique ON command
Browse files Browse the repository at this point in the history
  • Loading branch information
haimkastner committed Sep 24, 2023
1 parent 3152d44 commit e4fa430
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 e4fa430

Please sign in to comment.