diff --git a/README.md b/README.md index 28f0d2b..ca830ad 100644 --- a/README.md +++ b/README.md @@ -231,6 +231,10 @@ The following endpoints (according to ...) are currently not implemented and ca * /aircon/get_day_paower_ex ## Changelog + +### __WORK IN PROGRESS__ +* (Apollon77) export DaikinACTypes directly via DaikinAC class again as in 1.x + ### 2.0.0 (2022-06-09) * Major update, see notes above * (theimo1221) Rewrite to typescript diff --git a/src/DaikinAC.ts b/src/DaikinAC.ts index ad6c2cd..3424194 100644 --- a/src/DaikinAC.ts +++ b/src/DaikinAC.ts @@ -13,6 +13,8 @@ import { } from './models'; import { DaikinACOptions, DaikinACRequest, Logger } from './DaikinACRequest'; +export * as DaikinACTypes from './DaikinACTypes'; + type defaultCallback = (err: Error | null, res: T | null) => void; type updateErrorCallback = (err: Error | null) => void; @@ -35,6 +37,7 @@ export class DaikinAC { get updateTimeout(): NodeJS.Timeout | null { return this._updateTimeout; } + private _currentACModelInfo: null | ModelInfoResponse = null; private _currentACControlInfo: null | ControlInfo = null; private _currentACSensorInfo: null | SensorInfoResponse = null; diff --git a/src/DaikinACTypes.ts b/src/DaikinACTypes.ts index 03c6ba3..14360ca 100644 --- a/src/DaikinACTypes.ts +++ b/src/DaikinACTypes.ts @@ -3,6 +3,26 @@ export const Power: { [key: string]: boolean } = { ON: true, }; +export const Mode: { [key: string]: number } = { + AUTO: 0, + AUTO1: 1, + AUTO2: 7, + DEHUMDID: 2, + COLD: 3, + HOT: 4, + FAN: 6, +}; + +export enum SpecialModeState { + OFF = 0, + ON = 1, +} +export enum SpecialModeKind { + STREAMER = 0, // Flash STREAMER Air-Purifier + POWERFUL = 1, // POWERFUL Operation + ECONO = 2, // ECONO Operation +} + export const SpecialModeResponse: { [key: string]: string } = { 'N/A': '', POWERFUL: '2', @@ -12,9 +32,36 @@ export const SpecialModeResponse: { [key: string]: string } = { 'ECONO/STREAMER': '12/13', }; +export const FanRate: { [key: string]: number | 'A' | 'B' } = { + AUTO: 'A', + SILENCE: 'B', + LEVEL_1: 3, + LEVEL_2: 4, + LEVEL_3: 5, + LEVEL_4: 6, + LEVEL_5: 7, +}; + export const FanDirection: { [key: string]: number } = { STOP: 0, VERTICAL: 1, HORIZONTAL: 2, VERTICAL_AND_HORIZONTAL: 3, }; + +export const ErrorCode: { [key: string]: number } = { + OK: 0, +}; + +export const Type: { [key: string]: string } = { + AC: 'aircon', + // ... +}; + +export const AdpMode: { [key: string]: string } = { + RUN: 'run', +}; + +export const Method: { [key: string]: string } = { + POLLING: 'polling', +}; diff --git a/src/models/ControlInfo.ts b/src/models/ControlInfo.ts index ad1d924..76ffb43 100644 --- a/src/models/ControlInfo.ts +++ b/src/models/ControlInfo.ts @@ -1,6 +1,6 @@ import { DaikinDataParser, ResponseDict } from '../DaikinDataParser'; import { DaikinResponseCb } from '../DaikinACRequest'; -import { FanDirection, Power, SpecialModeResponse } from '../DaikinACTypes'; +import { FanDirection, Power, SpecialModeResponse, Mode, FanRate } from '../DaikinACTypes'; import { RequestDict } from './requests'; const AlternativeHumidityTarget: { [key: string]: 'AUTO' } = { @@ -9,24 +9,6 @@ const AlternativeHumidityTarget: { [key: string]: 'AUTO' } = { const AlternativeTemperatureTargets: { [key: string]: 'M' } = { M: 'M', }; -const Mode: { [key: string]: number } = { - AUTO: 0, - AUTO1: 1, - AUTO2: 7, - DEHUMDID: 2, - COLD: 3, - HOT: 4, - FAN: 6, -}; -const FanRate: { [key: string]: number | 'A' | 'B' } = { - AUTO: 'A', - SILENCE: 'B', - LEVEL_1: 3, - LEVEL_2: 4, - LEVEL_3: 5, - LEVEL_4: 6, - LEVEL_5: 7, -}; export class ControlInfo { public power?: boolean; diff --git a/src/models/requests/SetSpecialModeRequest.ts b/src/models/requests/SetSpecialModeRequest.ts index e82cd99..0331750 100644 --- a/src/models/requests/SetSpecialModeRequest.ts +++ b/src/models/requests/SetSpecialModeRequest.ts @@ -1,14 +1,5 @@ import { RequestDict } from './index'; - -export enum SpecialModeState { - OFF = 0, - ON = 1, -} -export enum SpecialModeKind { - STREAMER = 0, // Flash STREAMER Air-Purifier - POWERFUL = 1, // POWERFUL Operation - ECONO = 2, // ECONO Operation -} +import { SpecialModeState, SpecialModeKind } from '../../DaikinACTypes'; export class SetSpecialModeRequest { private readonly state: number; diff --git a/src/models/responses/BasicInfoResponse.ts b/src/models/responses/BasicInfoResponse.ts index be0d3c3..411ac17 100644 --- a/src/models/responses/BasicInfoResponse.ts +++ b/src/models/responses/BasicInfoResponse.ts @@ -1,18 +1,7 @@ import { DaikinDataParser, ResponseDict } from '../../DaikinDataParser'; -import { Power } from '../../DaikinACTypes'; +import { Power, Type, Method, AdpMode} from '../../DaikinACTypes'; import { DaikinResponseCb } from '../../DaikinACRequest'; -const AdpMode: { [key: string]: string } = { - RUN: 'run', -}; -const Method: { [key: string]: string } = { - POLLING: 'polling', -}; -const Type: { [key: string]: string } = { - AC: 'aircon', - // ... -}; - export class BasicInfoResponse { public type?: string; public region?: string;