trane-thermostat-api 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/README.md +11 -20
  2. package/dist/client/auth.d.ts.map +1 -1
  3. package/dist/client/auth.js +27 -13
  4. package/dist/client/auth.js.map +1 -1
  5. package/dist/client/trane-client.d.ts +49 -0
  6. package/dist/client/trane-client.d.ts.map +1 -0
  7. package/dist/client/trane-client.js +332 -0
  8. package/dist/client/trane-client.js.map +1 -0
  9. package/dist/devices/trane-automation.d.ts +15 -0
  10. package/dist/devices/trane-automation.d.ts.map +1 -0
  11. package/dist/devices/trane-automation.js +39 -0
  12. package/dist/devices/trane-automation.js.map +1 -0
  13. package/dist/devices/trane-sensor.d.ts +34 -0
  14. package/dist/devices/trane-sensor.d.ts.map +1 -0
  15. package/dist/devices/trane-sensor.js +152 -0
  16. package/dist/devices/trane-sensor.js.map +1 -0
  17. package/dist/devices/trane-thermostat.d.ts +74 -0
  18. package/dist/devices/trane-thermostat.d.ts.map +1 -0
  19. package/dist/devices/trane-thermostat.js +457 -0
  20. package/dist/devices/trane-thermostat.js.map +1 -0
  21. package/dist/devices/trane-zone.d.ts +61 -0
  22. package/dist/devices/trane-zone.d.ts.map +1 -0
  23. package/dist/devices/trane-zone.js +370 -0
  24. package/dist/devices/trane-zone.js.map +1 -0
  25. package/dist/index.d.ts +5 -5
  26. package/dist/index.js +11 -11
  27. package/dist/types/api.d.ts +36 -6
  28. package/dist/types/api.d.ts.map +1 -1
  29. package/dist/types/constants.d.ts +2 -5
  30. package/dist/types/constants.d.ts.map +1 -1
  31. package/dist/types/constants.js +3 -6
  32. package/dist/types/constants.js.map +1 -1
  33. package/dist/types/interfaces.d.ts +18 -18
  34. package/dist/utils/errors.d.ts +13 -13
  35. package/dist/utils/errors.js +21 -21
  36. package/dist/utils/validation.d.ts +1 -1
  37. package/dist/utils/validation.js +3 -3
  38. package/package.json +2 -5
@@ -1,13 +1,13 @@
1
1
  import { BrandType, OperationMode, PresetMode, AirCleanerMode, TemperatureUnit, SensorType } from './constants';
2
2
  import { TemperatureOptions, HumidityOptions, FanOptions, HoldOptions, UpdateOptions, SensorSelectionOptions, DeviceCapabilities, SystemStatusSummary, ZoneStatusSummary } from './api';
3
- export interface INexiaClient {
3
+ export interface ITraneClient {
4
4
  login(): Promise<void>;
5
5
  logout(): Promise<void>;
6
6
  isAuthenticated(): boolean;
7
7
  getThermostats(): Promise<ITraneThermostat[]>;
8
- getAutomations(): Promise<INexiaAutomation[]>;
8
+ getAutomations(): Promise<ITraneAutomation[]>;
9
9
  getThermostatById(id: string): ITraneThermostat | undefined;
10
- getAutomationById(id: string): INexiaAutomation | undefined;
10
+ getAutomationById(id: string): ITraneAutomation | undefined;
11
11
  update(options?: UpdateOptions): Promise<void>;
12
12
  readonly brand: BrandType;
13
13
  readonly username: string;
@@ -66,12 +66,12 @@ export interface ITraneThermostat {
66
66
  setAirCleanerMode(mode: AirCleanerMode): Promise<void>;
67
67
  setEmergencyHeat(enabled: boolean): Promise<void>;
68
68
  setFollowSchedule(follow: boolean): Promise<void>;
69
- readonly zones: INexiaZone[];
69
+ readonly zones: ITraneZone[];
70
70
  readonly zoneIds: string[];
71
- getZoneById(zoneId: string): INexiaZone | undefined;
71
+ getZoneById(zoneId: string): ITraneZone | undefined;
72
72
  refresh(): Promise<void>;
73
73
  }
74
- export interface INexiaZone {
74
+ export interface ITraneZone {
75
75
  readonly id: string;
76
76
  readonly name: string;
77
77
  readonly isNativeZone: boolean;
@@ -94,16 +94,16 @@ export interface INexiaZone {
94
94
  readonly availablePresets: PresetMode[];
95
95
  readonly currentPreset: PresetMode | null;
96
96
  setPreset(preset: PresetMode): Promise<void>;
97
- readonly sensors: INexiaSensor[];
97
+ readonly sensors: ITraneSensor[];
98
98
  readonly activeSensorIds: Set<number>;
99
99
  readonly sensorIds: number[];
100
- getSensorById(sensorId: number): INexiaSensor | undefined;
100
+ getSensorById(sensorId: number): ITraneSensor | undefined;
101
101
  selectActiveSensors(options: SensorSelectionOptions): Promise<void>;
102
102
  readonly thermostat: ITraneThermostat;
103
103
  validateTemperatureSetpoints(heatTemp: number, coolTemp: number): boolean;
104
104
  roundTemperature(temperature: number): number;
105
105
  }
106
- export interface INexiaSensor {
106
+ export interface ITraneSensor {
107
107
  readonly id: number;
108
108
  readonly name: string;
109
109
  readonly type: SensorType;
@@ -123,7 +123,7 @@ export interface INexiaSensor {
123
123
  readonly hasOnlineStatus: boolean;
124
124
  isDataValid(): boolean;
125
125
  }
126
- export interface INexiaAutomation {
126
+ export interface ITraneAutomation {
127
127
  readonly id: string;
128
128
  readonly name: string;
129
129
  readonly description: string;
@@ -131,7 +131,7 @@ export interface INexiaAutomation {
131
131
  setEnabled(enabled: boolean): Promise<void>;
132
132
  activate(): Promise<void>;
133
133
  }
134
- export interface NexiaConfig {
134
+ export interface TraneConfig {
135
135
  username: string;
136
136
  password: string;
137
137
  brand?: BrandType;
@@ -141,13 +141,13 @@ export interface NexiaConfig {
141
141
  timeout?: number;
142
142
  retryAttempts?: number;
143
143
  }
144
- export interface NexiaEvent {
144
+ export interface TraneEvent {
145
145
  type: 'update' | 'error' | 'connected' | 'disconnected';
146
146
  timestamp: Date;
147
147
  data?: any;
148
148
  error?: Error;
149
149
  }
150
- export interface INexiaEventListener {
150
+ export interface ITraneEventListener {
151
151
  onUpdate?(data: any): void;
152
152
  onError?(error: Error): void;
153
153
  onConnected?(): void;
@@ -195,15 +195,15 @@ export interface IHomebridgePlatform {
195
195
  export interface IHomebridgeAccessory {
196
196
  readonly platform: IHomebridgePlatform;
197
197
  readonly accessory: any;
198
- readonly device: ITraneThermostat | INexiaZone | INexiaSensor;
198
+ readonly device: ITraneThermostat | ITraneZone | ITraneSensor;
199
199
  setupServices(): void;
200
200
  updateCharacteristics(): void;
201
201
  }
202
- export interface INexiaTypeGuards {
202
+ export interface ITraneTypeGuards {
203
203
  isThermostat(device: any): device is ITraneThermostat;
204
- isZone(device: any): device is INexiaZone;
205
- isSensor(device: any): device is INexiaSensor;
206
- isAutomation(device: any): device is INexiaAutomation;
204
+ isZone(device: any): device is ITraneZone;
205
+ isSensor(device: any): device is ITraneSensor;
206
+ isAutomation(device: any): device is ITraneAutomation;
207
207
  isValidTemperature(value: any, unit: TemperatureUnit): boolean;
208
208
  isValidHumidity(value: any): boolean;
209
209
  isValidFanSpeed(value: any): boolean;
@@ -1,9 +1,9 @@
1
- export declare class NexiaError extends Error {
1
+ export declare class TraneError extends Error {
2
2
  code: string;
3
3
  readonly timestamp: Date;
4
4
  constructor(message: string, code?: string);
5
5
  }
6
- export declare class AuthenticationError extends NexiaError {
6
+ export declare class AuthenticationError extends TraneError {
7
7
  constructor(message?: string);
8
8
  }
9
9
  export declare class RateLimitError extends AuthenticationError {
@@ -13,7 +13,7 @@ export declare class RateLimitError extends AuthenticationError {
13
13
  export declare class SessionExpiredError extends AuthenticationError {
14
14
  constructor(message?: string);
15
15
  }
16
- export declare class ValidationError extends NexiaError {
16
+ export declare class ValidationError extends TraneError {
17
17
  readonly field?: string;
18
18
  readonly value?: unknown;
19
19
  constructor(message: string, field?: string, value?: unknown);
@@ -35,7 +35,7 @@ export declare class DeadbandValidationError extends ValidationError {
35
35
  readonly coolTemp: number;
36
36
  constructor(message: string, deadband: number, heatTemp: number, coolTemp: number);
37
37
  }
38
- export declare class ApiError extends NexiaError {
38
+ export declare class ApiError extends TraneError {
39
39
  readonly statusCode?: number;
40
40
  readonly response?: unknown;
41
41
  constructor(message: string, statusCode?: number, response?: unknown);
@@ -43,7 +43,7 @@ export declare class ApiError extends NexiaError {
43
43
  export declare class HttpError extends ApiError {
44
44
  constructor(message: string, statusCode: number, response?: unknown);
45
45
  }
46
- export declare class NetworkError extends NexiaError {
46
+ export declare class NetworkError extends TraneError {
47
47
  readonly originalError?: Error;
48
48
  constructor(message: string, originalError?: Error);
49
49
  }
@@ -51,26 +51,26 @@ export declare class TimeoutError extends NetworkError {
51
51
  readonly timeout: number;
52
52
  constructor(message: string, timeout: number);
53
53
  }
54
- export declare class DeviceNotFoundError extends NexiaError {
54
+ export declare class DeviceNotFoundError extends TraneError {
55
55
  readonly deviceId: string;
56
56
  readonly deviceType: string;
57
57
  constructor(message: string, deviceId: string, deviceType?: string);
58
58
  }
59
- export declare class FeatureNotSupportedError extends NexiaError {
59
+ export declare class FeatureNotSupportedError extends TraneError {
60
60
  readonly feature: string;
61
61
  readonly deviceModel?: string;
62
62
  constructor(feature: string, deviceModel?: string);
63
63
  }
64
- export declare class OperationNotAllowedError extends NexiaError {
64
+ export declare class OperationNotAllowedError extends TraneError {
65
65
  readonly operation: string;
66
66
  readonly reason?: string;
67
67
  constructor(operation: string, reason?: string);
68
68
  }
69
- export declare class ConfigurationError extends NexiaError {
69
+ export declare class ConfigurationError extends TraneError {
70
70
  readonly configField?: string;
71
71
  constructor(message: string, configField?: string);
72
72
  }
73
- export declare class ParseError extends NexiaError {
73
+ export declare class ParseError extends TraneError {
74
74
  readonly data?: unknown;
75
75
  constructor(message: string, data?: unknown);
76
76
  }
@@ -81,14 +81,14 @@ export declare class ErrorFactory {
81
81
  static createDeadbandError(heatTemp: number, coolTemp: number, deadband: number, unit: string): DeadbandValidationError;
82
82
  private static getHttpStatusMessage;
83
83
  }
84
- export declare function isNexiaError(error: unknown): error is NexiaError;
84
+ export declare function isTraneError(error: unknown): error is TraneError;
85
85
  export declare function isAuthenticationError(error: unknown): error is AuthenticationError;
86
86
  export declare function isValidationError(error: unknown): error is ValidationError;
87
87
  export declare function isApiError(error: unknown): error is ApiError;
88
88
  export declare function isNetworkError(error: unknown): error is NetworkError;
89
89
  export declare class ErrorHandler {
90
- static handle(error: unknown): NexiaError;
91
- static isRetryable(error: NexiaError): boolean;
90
+ static handle(error: unknown): TraneError;
91
+ static isRetryable(error: TraneError): boolean;
92
92
  static getRetryDelay(attempt: number, baseDelay?: number): number;
93
93
  }
94
94
  //# sourceMappingURL=errors.d.ts.map
@@ -1,24 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ErrorHandler = exports.ErrorFactory = exports.ParseError = exports.ConfigurationError = exports.OperationNotAllowedError = exports.FeatureNotSupportedError = exports.DeviceNotFoundError = exports.TimeoutError = exports.NetworkError = exports.HttpError = exports.ApiError = exports.DeadbandValidationError = exports.TemperatureValidationError = exports.ValidationError = exports.SessionExpiredError = exports.RateLimitError = exports.AuthenticationError = exports.NexiaError = void 0;
4
- exports.isNexiaError = isNexiaError;
3
+ exports.ErrorHandler = exports.ErrorFactory = exports.ParseError = exports.ConfigurationError = exports.OperationNotAllowedError = exports.FeatureNotSupportedError = exports.DeviceNotFoundError = exports.TimeoutError = exports.NetworkError = exports.HttpError = exports.ApiError = exports.DeadbandValidationError = exports.TemperatureValidationError = exports.ValidationError = exports.SessionExpiredError = exports.RateLimitError = exports.AuthenticationError = exports.TraneError = void 0;
4
+ exports.isTraneError = isTraneError;
5
5
  exports.isAuthenticationError = isAuthenticationError;
6
6
  exports.isValidationError = isValidationError;
7
7
  exports.isApiError = isApiError;
8
8
  exports.isNetworkError = isNetworkError;
9
- class NexiaError extends Error {
9
+ class TraneError extends Error {
10
10
  constructor(message, code = 'UNKNOWN_ERROR') {
11
11
  super(message);
12
- this.name = 'NexiaError';
12
+ this.name = 'TraneError';
13
13
  this.code = code;
14
14
  this.timestamp = new Date();
15
15
  if (Error.captureStackTrace) {
16
- Error.captureStackTrace(this, NexiaError);
16
+ Error.captureStackTrace(this, TraneError);
17
17
  }
18
18
  }
19
19
  }
20
- exports.NexiaError = NexiaError;
21
- class AuthenticationError extends NexiaError {
20
+ exports.TraneError = TraneError;
21
+ class AuthenticationError extends TraneError {
22
22
  constructor(message = 'Authentication failed') {
23
23
  super(message, 'AUTH_ERROR');
24
24
  this.name = 'AuthenticationError';
@@ -42,7 +42,7 @@ class SessionExpiredError extends AuthenticationError {
42
42
  }
43
43
  }
44
44
  exports.SessionExpiredError = SessionExpiredError;
45
- class ValidationError extends NexiaError {
45
+ class ValidationError extends TraneError {
46
46
  constructor(message, field, value) {
47
47
  super(message, 'VALIDATION_ERROR');
48
48
  this.name = 'ValidationError';
@@ -72,7 +72,7 @@ class DeadbandValidationError extends ValidationError {
72
72
  }
73
73
  }
74
74
  exports.DeadbandValidationError = DeadbandValidationError;
75
- class ApiError extends NexiaError {
75
+ class ApiError extends TraneError {
76
76
  constructor(message, statusCode, response) {
77
77
  super(message, 'API_ERROR');
78
78
  this.name = 'ApiError';
@@ -89,7 +89,7 @@ class HttpError extends ApiError {
89
89
  }
90
90
  }
91
91
  exports.HttpError = HttpError;
92
- class NetworkError extends NexiaError {
92
+ class NetworkError extends TraneError {
93
93
  constructor(message, originalError) {
94
94
  super(message, 'NETWORK_ERROR');
95
95
  this.name = 'NetworkError';
@@ -106,7 +106,7 @@ class TimeoutError extends NetworkError {
106
106
  }
107
107
  }
108
108
  exports.TimeoutError = TimeoutError;
109
- class DeviceNotFoundError extends NexiaError {
109
+ class DeviceNotFoundError extends TraneError {
110
110
  constructor(message, deviceId, deviceType = 'device') {
111
111
  super(message, 'DEVICE_NOT_FOUND');
112
112
  this.name = 'DeviceNotFoundError';
@@ -115,7 +115,7 @@ class DeviceNotFoundError extends NexiaError {
115
115
  }
116
116
  }
117
117
  exports.DeviceNotFoundError = DeviceNotFoundError;
118
- class FeatureNotSupportedError extends NexiaError {
118
+ class FeatureNotSupportedError extends TraneError {
119
119
  constructor(feature, deviceModel) {
120
120
  const message = deviceModel
121
121
  ? `Feature '${feature}' is not supported on device model '${deviceModel}'`
@@ -127,7 +127,7 @@ class FeatureNotSupportedError extends NexiaError {
127
127
  }
128
128
  }
129
129
  exports.FeatureNotSupportedError = FeatureNotSupportedError;
130
- class OperationNotAllowedError extends NexiaError {
130
+ class OperationNotAllowedError extends TraneError {
131
131
  constructor(operation, reason) {
132
132
  const message = reason
133
133
  ? `Operation '${operation}' is not allowed: ${reason}`
@@ -139,7 +139,7 @@ class OperationNotAllowedError extends NexiaError {
139
139
  }
140
140
  }
141
141
  exports.OperationNotAllowedError = OperationNotAllowedError;
142
- class ConfigurationError extends NexiaError {
142
+ class ConfigurationError extends TraneError {
143
143
  constructor(message, configField) {
144
144
  super(message, 'CONFIG_ERROR');
145
145
  this.name = 'ConfigurationError';
@@ -147,7 +147,7 @@ class ConfigurationError extends NexiaError {
147
147
  }
148
148
  }
149
149
  exports.ConfigurationError = ConfigurationError;
150
- class ParseError extends NexiaError {
150
+ class ParseError extends TraneError {
151
151
  constructor(message, data) {
152
152
  super(message, 'PARSE_ERROR');
153
153
  this.name = 'ParseError';
@@ -189,8 +189,8 @@ class ErrorFactory {
189
189
  }
190
190
  }
191
191
  exports.ErrorFactory = ErrorFactory;
192
- function isNexiaError(error) {
193
- return error instanceof NexiaError;
192
+ function isTraneError(error) {
193
+ return error instanceof TraneError;
194
194
  }
195
195
  function isAuthenticationError(error) {
196
196
  return error instanceof AuthenticationError;
@@ -206,16 +206,16 @@ function isNetworkError(error) {
206
206
  }
207
207
  class ErrorHandler {
208
208
  static handle(error) {
209
- if (isNexiaError(error)) {
209
+ if (isTraneError(error)) {
210
210
  return error;
211
211
  }
212
212
  if (error instanceof Error) {
213
- return new NexiaError(error.message, 'UNKNOWN_ERROR');
213
+ return new TraneError(error.message, 'UNKNOWN_ERROR');
214
214
  }
215
215
  if (typeof error === 'string') {
216
- return new NexiaError(error, 'UNKNOWN_ERROR');
216
+ return new TraneError(error, 'UNKNOWN_ERROR');
217
217
  }
218
- return new NexiaError('An unknown error occurred', 'UNKNOWN_ERROR');
218
+ return new TraneError('An unknown error occurred', 'UNKNOWN_ERROR');
219
219
  }
220
220
  static isRetryable(error) {
221
221
  return (isNetworkError(error) ||
@@ -32,7 +32,7 @@ export declare class GeneralValidator {
32
32
  static validateDate(value: any, fieldName: string): Date;
33
33
  static validateRequiredProperties<T extends Record<string, any>>(obj: any, requiredProps: (keyof T)[], objectName: string): void;
34
34
  }
35
- export declare class NexiaValidator {
35
+ export declare class TraneValidator {
36
36
  static validateTemperatureConfig(config: {
37
37
  heatTemp?: number;
38
38
  coolTemp?: number;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NexiaValidator = exports.GeneralValidator = exports.FanSpeedValidator = exports.HumidityValidator = exports.TemperatureValidator = void 0;
3
+ exports.TraneValidator = exports.GeneralValidator = exports.FanSpeedValidator = exports.HumidityValidator = exports.TemperatureValidator = void 0;
4
4
  const constants_1 = require("../types/constants");
5
5
  const errors_1 = require("./errors");
6
6
  class TemperatureValidator {
@@ -214,7 +214,7 @@ class GeneralValidator {
214
214
  }
215
215
  }
216
216
  exports.GeneralValidator = GeneralValidator;
217
- class NexiaValidator {
217
+ class TraneValidator {
218
218
  static validateTemperatureConfig(config) {
219
219
  const { heatTemp, coolTemp, deadband, unit, setTemp } = config;
220
220
  if (setTemp !== undefined) {
@@ -268,5 +268,5 @@ class NexiaValidator {
268
268
  }
269
269
  }
270
270
  }
271
- exports.NexiaValidator = NexiaValidator;
271
+ exports.TraneValidator = TraneValidator;
272
272
  //# sourceMappingURL=validation.js.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "trane-thermostat-api",
3
- "version": "1.0.1",
4
- "description": "Node.js TypeScript library for controlling Trane/Nexia/American Standard thermostats",
3
+ "version": "1.0.2",
4
+ "description": "Node.js TypeScript library for controlling Trane thermostats",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "scripts": {
@@ -16,10 +16,7 @@
16
16
  },
17
17
  "keywords": [
18
18
  "trane",
19
- "nexia",
20
- "american-standard",
21
19
  "thermostat",
22
- "typescript",
23
20
  "hvac"
24
21
  ],
25
22
  "author": "sbs44",