Skip to content

Commit

Permalink
* * (Apollon77) export DaikinACTypes directly via DaikinAC class agai…
Browse files Browse the repository at this point in the history
…n as in 1.x
  • Loading branch information
Apollon77 committed Jun 9, 2022
1 parent 532cc08 commit 2d7a79d
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 41 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/DaikinAC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import {
} from './models';
import { DaikinACOptions, DaikinACRequest, Logger } from './DaikinACRequest';

export * as DaikinACTypes from './DaikinACTypes';

type defaultCallback<T> = (err: Error | null, res: T | null) => void;
type updateErrorCallback = (err: Error | null) => void;

Expand All @@ -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;
Expand Down
47 changes: 47 additions & 0 deletions src/DaikinACTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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',
};
20 changes: 1 addition & 19 deletions src/models/ControlInfo.ts
Original file line number Diff line number Diff line change
@@ -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' } = {
Expand All @@ -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;
Expand Down
11 changes: 1 addition & 10 deletions src/models/requests/SetSpecialModeRequest.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
13 changes: 1 addition & 12 deletions src/models/responses/BasicInfoResponse.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down

0 comments on commit 2d7a79d

Please sign in to comment.