diff --git a/backend/src/models/backendInterfaces.d.ts b/backend/src/models/backendInterfaces.d.ts index 684707e4..2aba1df8 100644 --- a/backend/src/models/backendInterfaces.d.ts +++ b/backend/src/models/backendInterfaces.d.ts @@ -135,6 +135,7 @@ export declare interface ToggleCommands { /** Ac commands set */ export declare interface AcCommands { off: string | string []; + on?: string | string []; statusCommands: AirConditioningCommand[]; } diff --git a/backend/src/utilities/cacheManager.ts b/backend/src/utilities/cacheManager.ts index 32f1d911..f0f559c1 100644 --- a/backend/src/utilities/cacheManager.ts +++ b/backend/src/utilities/cacheManager.ts @@ -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; }