daikin-airbase 0.1.5 → 0.2.0

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.
package/dist/index.cjs CHANGED
@@ -30,7 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/index.ts
31
31
  var index_exports = {};
32
32
  __export(index_exports, {
33
- API: () => API,
33
+ Client: () => Client,
34
34
  ControlMode: () => ControlMode,
35
35
  DaikinClient: () => DaikinClient,
36
36
  FanSpeed: () => FanSpeed,
@@ -39,15 +39,26 @@ __export(index_exports, {
39
39
  Zones: () => Zones,
40
40
  basic_info: () => basic_info,
41
41
  discover: () => discover,
42
- get_zone_settings: () => get_zone_settings
42
+ getNetwork_setting: () => getNetwork_setting,
43
+ get_control_info: () => get_control_info,
44
+ get_datetime: () => get_datetime,
45
+ get_dealer_info: () => get_dealer_info,
46
+ get_model_info: () => get_model_info,
47
+ get_quick_timer: () => get_quick_timer,
48
+ get_sensor_info: () => get_sensor_info,
49
+ get_wifi_setting: () => get_wifi_setting,
50
+ get_zone_settings: () => get_zone_settings,
51
+ set_control_info: () => set_control_info,
52
+ set_zone_setting: () => set_zone_setting
43
53
  });
44
54
  module.exports = __toCommonJS(index_exports);
45
55
 
46
56
  // src/ParamParser.ts
47
- function parse(str) {
57
+ var int = (v) => Math.round(v);
58
+ var bool = (v) => v ? 1 : 0;
59
+ function deserialize(data) {
48
60
  const result = {};
49
- const parts = str.split(",");
50
- for (const part of parts) {
61
+ for (const part of data) {
51
62
  const [key, value] = part.split("=");
52
63
  if (key === void 0) continue;
53
64
  const maybeNumber = Number(value);
@@ -59,10 +70,20 @@ function parse(str) {
59
70
  }
60
71
  return result;
61
72
  }
73
+ function serialize(parameters) {
74
+ const queries = [];
75
+ for (const key in parameters) {
76
+ const value = parameters[key];
77
+ if (value === void 0) continue;
78
+ const encoded = encodeURIComponent(typeof value === "string" ? value : value !== null ? `${int(value)}` : "");
79
+ queries.push(`${key}=${encoded}`);
80
+ }
81
+ return queries;
82
+ }
62
83
 
63
- // src/api/API.ts
84
+ // src/api/Client.ts
64
85
  var import_node_http = __toESM(require("http"));
65
- var API = class {
86
+ var Client = class {
66
87
  host;
67
88
  constructor(host) {
68
89
  this.host = host;
@@ -70,16 +91,8 @@ var API = class {
70
91
  async request(endpoint, parameters) {
71
92
  const body = await new Promise((resolve, reject) => {
72
93
  const url = new URL(`/skyfi${endpoint}`, `http://${this.host}/`);
73
- const queries = [];
74
- if (parameters) {
75
- for (const key in parameters) {
76
- const value = parameters[key];
77
- if (value === void 0) continue;
78
- const encoded = encodeURIComponent(`${value ?? ""}`);
79
- queries.push(`${key}=${encoded}`);
80
- }
81
- }
82
- const search = queries.length > 0 ? `?${queries.join("&")}` : "";
94
+ const serialized = parameters ? serialize(parameters) : [];
95
+ const search = serialized.length > 0 ? `?${serialized.join("&")}` : "";
83
96
  const req = import_node_http.default.request(
84
97
  {
85
98
  host: url.hostname,
@@ -102,7 +115,7 @@ var API = class {
102
115
  req.on("error", reject);
103
116
  req.end();
104
117
  });
105
- return parse(body);
118
+ return deserialize(body.split(","));
106
119
  }
107
120
  };
108
121
 
@@ -125,7 +138,7 @@ function discover(timeoutMs = 3e3) {
125
138
  });
126
139
  socket.on("message", (msg, rinfo) => {
127
140
  const raw = msg.toString("utf8");
128
- const info = parse(raw);
141
+ const info = deserialize(raw.split(","));
129
142
  const key = `${info.mac || info.id || rinfo.address}`;
130
143
  availableUnits.set(key, {
131
144
  discoveredAddress: rinfo.address,
@@ -152,15 +165,42 @@ function discover(timeoutMs = 3e3) {
152
165
  });
153
166
  }
154
167
 
155
- // src/api/common/basic_info.ts
156
- var basic_info = (http2) => http2.request("/common/basic_info");
168
+ // src/api/aircon/get_control_info.ts
169
+ var get_control_info = (http2) => http2.request("/aircon/get_control_info");
170
+
171
+ // src/api/aircon/get_model_info.ts
172
+ var get_model_info = (http2) => http2.request("/aircon/get_model_info");
173
+
174
+ // src/api/aircon/get_quick_timer.ts
175
+ var get_quick_timer = (http2) => http2.request("/aircon/get_quick_timer");
176
+
177
+ // src/api/aircon/get_sensor_info.ts
178
+ var get_sensor_info = (http2) => http2.request("/aircon/get_sensor_info");
157
179
 
158
180
  // src/api/aircon/get_zone_setting.ts
159
181
  var get_zone_settings = (http2) => http2.request("/aircon/get_zone_setting");
160
182
 
183
+ // src/api/aircon/set_control_info.ts
184
+ var set_control_info = (http2, params) => http2.request("/aircon/set_control_info", params);
185
+
161
186
  // src/api/aircon/set_zone_setting.ts
162
187
  var set_zone_setting = (http2, params) => http2.request("/aircon/set_zone_setting", params);
163
188
 
189
+ // src/api/common/basic_info.ts
190
+ var basic_info = (http2) => http2.request("/common/basic_info");
191
+
192
+ // src/api/common/get_datetime.ts
193
+ var get_datetime = (http2) => http2.request("/common/get_datetime");
194
+
195
+ // src/api/common/get_dealer_info.ts
196
+ var get_dealer_info = (http2) => http2.request("/common/get_dealer_info");
197
+
198
+ // src/api/common/get_network_setting.ts
199
+ var getNetwork_setting = (http2) => http2.request("/common/get_network_setting");
200
+
201
+ // src/api/common/get_wifi_setting.ts
202
+ var get_wifi_setting = (http2) => http2.request("/common/get_wifi_setting");
203
+
164
204
  // src/Zones.ts
165
205
  var Zones = class {
166
206
  zones = [];
@@ -168,69 +208,105 @@ var Zones = class {
168
208
  constructor(client) {
169
209
  this.client = client;
170
210
  }
171
- /** Refreshes the cached zone state */
172
- async refresh() {
211
+ /**
212
+ * Requests all the zones current state from the airbase controller.
213
+ * Results are cached.
214
+ * @returns the current state of all zones.
215
+ */
216
+ async getZones() {
173
217
  const response = await get_zone_settings(this.client.api);
174
- const zoneNames = response.zone_name.split(";");
175
- const zoneState = response.zone_onoff.split(";");
176
- return this.zones = zoneNames.map((name, index) => ({
218
+ const names = response.zone_name.split(";");
219
+ const onoff = response.zone_onoff.split(";");
220
+ const temprartures = response.lztemp_c ? response.lztemp_c.split(";") : null;
221
+ const humidities = response.lztemp_h ? response.lztemp_h.split(";") : null;
222
+ return this.zones = names.map((name, index) => Object.freeze({
223
+ index,
177
224
  name,
178
- state: zoneState[index] === "1"
225
+ isOn: onoff[index] === "1",
226
+ humidity: humidities ? +`${humidities[index]}` : void 0,
227
+ temperature: temprartures ? +`${temprartures[index]}` : void 0
179
228
  }));
180
229
  }
181
230
  /**
182
231
  * Gets the state of all cached zones.
183
232
  */
184
233
  getCachedZones() {
185
- return [...this.zones];
234
+ return this.zones;
235
+ }
236
+ /**
237
+ * Gets the current state of a zone with the matching name.
238
+ * @param name
239
+ */
240
+ async getZone(name) {
241
+ return await this.getZones().then(() => this.getCachedZone(name));
186
242
  }
187
243
  /**
188
- * Gets all zones' state
244
+ * Gets the current state of a zone at the given controller index.
245
+ * @param index
246
+ * @throws Error if the index is out of bounds.
189
247
  */
190
- async getZones() {
191
- return await this.refresh();
248
+ async getZoneAt(index) {
249
+ return await this.getZones().then(() => this.getCachedZoneAt(index));
192
250
  }
193
251
  /**
194
252
  * Gets the cached state of a zone
195
253
  * @param name
196
254
  */
197
255
  getCachedZone(name) {
198
- return this.zones.find((zone) => zone.name === name)?.state;
256
+ return this.zones.find((zone) => zone.name === name);
199
257
  }
200
258
  /**
201
- * Gets the state of a Zone
202
- * @param name
259
+ * Gets the cached state of a zone at the given controller index.
260
+ * @param index
261
+ * @throws Error if the index is out of bounds.
203
262
  */
204
- async getZone(name) {
205
- const zones = await this.refresh();
206
- return zones.find((zone) => zone.name === name)?.state;
263
+ getCachedZoneAt(index) {
264
+ if (index < 0 || index >= this.zones.length || this.zones[index] === void 0)
265
+ throw new Error(`Zone index ${index} is out of bounds`);
266
+ if (this.zones[index].index !== index)
267
+ throw new Error(`Zone at ${index} does not believe it is in the correct spot.`);
268
+ return this.zones[index];
207
269
  }
208
270
  /**
209
- * Sets a Zone's state
210
- * @param name
211
- * @param state
271
+ * Updates a zone
272
+ * @param name the name of the zone to update
273
+ * @param info the new data to replace
212
274
  */
213
- async setZone(name, state) {
214
- await this.setZones([{ name, state }]);
275
+ async updateZone(name, info) {
276
+ const zones = await this.getZones();
277
+ const index = zones.findIndex((zone) => zone.name === name);
278
+ zones[index] = { ...zones[index], ...info };
279
+ await this.setZones(zones);
280
+ return zones[index];
215
281
  }
216
282
  /**
217
- * Sets multiple zones' state
218
- * @param changes
283
+ * Bulk updates all the zones
284
+ * @param zones the new zones. These are sorted by index and pushed into the API in that order.
285
+ * @returns the updated zones
219
286
  */
220
- async setZones(changes) {
221
- await this.refresh();
222
- for (const change of changes) {
223
- const existingZone = this.zones.find((z) => z.name === change.name);
224
- if (existingZone) {
225
- existingZone.state = change.state;
226
- }
287
+ async setZones(zones) {
288
+ let names = [];
289
+ let onoff = [];
290
+ let humidity = [];
291
+ let temperature = [];
292
+ const sortedZones = zones.sort((a, b) => a.index - b.index);
293
+ for (const zone of sortedZones) {
294
+ names.push(zone.name);
295
+ onoff.push(`${bool(zone.isOn)}`);
296
+ if (zone.humidity !== void 0)
297
+ humidity.push(`${int(zone.humidity)}`);
298
+ if (zone.temperature !== void 0)
299
+ temperature.push(`${int(zone.temperature)}`);
227
300
  }
228
301
  const response = await set_zone_setting(this.client.api, {
229
- zone_name: this.zones.map((zone) => zone.name).join(";"),
230
- zone_onoff: this.zones.map((zone) => zone.state ? "1" : "0").join(";")
302
+ zone_name: names.join(";"),
303
+ zone_onoff: onoff.join(";"),
304
+ lztemp_h: humidity.length > 0 ? humidity.join(";") : void 0,
305
+ lztemp_c: temperature.length > 0 ? temperature.join(";") : void 0
231
306
  });
232
307
  if (response.ret !== "OK")
233
308
  throw new Error(`Failed to set zones: ${response.ret}`);
309
+ return this.zones = zones.map((zone) => Object.freeze({ ...zone }));
234
310
  }
235
311
  };
236
312
 
@@ -240,7 +316,7 @@ var ControlMode = /* @__PURE__ */ ((ControlMode3) => {
240
316
  ControlMode3[ControlMode3["Hot"] = 1] = "Hot";
241
317
  ControlMode3[ControlMode3["Cool"] = 2] = "Cool";
242
318
  ControlMode3[ControlMode3["Auto"] = 3] = "Auto";
243
- ControlMode3[ControlMode3["Dry"] = 4] = "Dry";
319
+ ControlMode3[ControlMode3["Dry"] = 7] = "Dry";
244
320
  return ControlMode3;
245
321
  })(ControlMode || {});
246
322
  var FanSpeed = /* @__PURE__ */ ((FanSpeed3) => {
@@ -262,12 +338,6 @@ var RemoteType = /* @__PURE__ */ ((RemoteType3) => {
262
338
  return RemoteType3;
263
339
  })(RemoteType || {});
264
340
 
265
- // src/api/aircon/get_control_info.ts
266
- var get_control_info = (http2) => http2.request("/aircon/get_control_info");
267
-
268
- // src/api/aircon/set_control_info.ts
269
- var set_control_info = (http2, params) => http2.request("/aircon/set_control_info", params);
270
-
271
341
  // src/DaikinClient.ts
272
342
  var DaikinClient = class {
273
343
  options;
@@ -277,9 +347,9 @@ var DaikinClient = class {
277
347
  constructor(options) {
278
348
  this.options = options;
279
349
  if ("host" in options) {
280
- this.api = new API(options.host);
350
+ this.api = new Client(options.host);
281
351
  } else {
282
- this.api = new API(options.device.discoveredAddress);
352
+ this.api = new Client(options.device.discoveredAddress);
283
353
  }
284
354
  this.zones = new Zones(this);
285
355
  }
@@ -342,8 +412,6 @@ var DaikinClient = class {
342
412
  async setControlInfo(info) {
343
413
  const latest = await this.getControlInfo();
344
414
  const update = { ...latest, ...info };
345
- const int = (v) => Math.round(v);
346
- const bool = (v) => v ? 1 : 0;
347
415
  const params = {
348
416
  f_airside: 0,
349
417
  f_auto: bool(update.fanAuto),
@@ -380,13 +448,14 @@ var DaikinClient = class {
380
448
  adp_kind: response.adp_kind
381
449
  };
382
450
  }
451
+ /** Broadcasts a request to discover devices on the network. */
383
452
  static async discover(timeoutMs = 3e3) {
384
453
  return discover(timeoutMs);
385
454
  }
386
455
  };
387
456
  // Annotate the CommonJS export names for ESM import in node:
388
457
  0 && (module.exports = {
389
- API,
458
+ Client,
390
459
  ControlMode,
391
460
  DaikinClient,
392
461
  FanSpeed,
@@ -395,5 +464,15 @@ var DaikinClient = class {
395
464
  Zones,
396
465
  basic_info,
397
466
  discover,
398
- get_zone_settings
467
+ getNetwork_setting,
468
+ get_control_info,
469
+ get_datetime,
470
+ get_dealer_info,
471
+ get_model_info,
472
+ get_quick_timer,
473
+ get_sensor_info,
474
+ get_wifi_setting,
475
+ get_zone_settings,
476
+ set_control_info,
477
+ set_zone_setting
399
478
  });
package/dist/index.d.mts CHANGED
@@ -3,7 +3,11 @@ type Params = Record<string, number | string>;
3
3
  type DaikinResponse = {
4
4
  ret: 'OK';
5
5
  };
6
- declare class API {
6
+ type DaikinError = DaikinResponse & {
7
+ ret: string;
8
+ msg: string;
9
+ };
10
+ declare class Client {
7
11
  readonly host: string;
8
12
  constructor(host: string);
9
13
  request(endpoint: string, parameters?: Record<string, string | number | undefined | null>): Promise<Params>;
@@ -38,7 +42,7 @@ type BasicInfoResponse = DaikinResponse & {
38
42
  en_hol: number;
39
43
  sync_time: number;
40
44
  };
41
- declare const basic_info: (http: API) => Promise<BasicInfoResponse>;
45
+ declare const basic_info: (http: Client) => Promise<BasicInfoResponse>;
42
46
 
43
47
  type DiscoveredDevice = BasicInfoResponse & {
44
48
  discoveredAddress: string;
@@ -46,51 +50,219 @@ type DiscoveredDevice = BasicInfoResponse & {
46
50
  };
47
51
  declare function discover(timeoutMs?: number): Promise<DiscoveredDevice[]>;
48
52
 
53
+ type ControlInfoResponse = DaikinResponse & {
54
+ pow: number;
55
+ mode: number;
56
+ operate: number;
57
+ bk_auto: number;
58
+ stemp: number;
59
+ dt1: number;
60
+ dt2: number;
61
+ f_rate: number;
62
+ dfr1: number;
63
+ dfr2: number;
64
+ f_airside: number;
65
+ airside1: number;
66
+ airside2: number;
67
+ f_auto: number;
68
+ auto1: number;
69
+ auto2: number;
70
+ f_dir: number;
71
+ dfd1: number;
72
+ dfd2: number;
73
+ filter_sign_info: number;
74
+ cent: number;
75
+ en_cent: number;
76
+ remo: number;
77
+ };
78
+ declare const get_control_info: (http: Client) => Promise<ControlInfoResponse>;
79
+
80
+ type ModelInfoResponse = DaikinResponse & {
81
+ model: string;
82
+ type: string;
83
+ humd: number;
84
+ s_humd: number;
85
+ en_zone: number;
86
+ en_linear_zone: number;
87
+ en_filter_sign: number;
88
+ acled: number;
89
+ land: number;
90
+ elec: number;
91
+ temp: number;
92
+ m_dtct: number;
93
+ ac_dst: string;
94
+ dmnd: number;
95
+ en_temp_setting: number;
96
+ en_frate: number;
97
+ en_fdir: number;
98
+ en_rtemp_a: number;
99
+ en_spmode: number;
100
+ en_ipw_sep: number;
101
+ en_scdltmr: number;
102
+ en_mompow: number;
103
+ en_patrol: number;
104
+ en_airside: number;
105
+ en_quick_timer: number;
106
+ en_auto: number;
107
+ en_dry: number;
108
+ en_common_zone: number;
109
+ cool_l: number;
110
+ cool_h: number;
111
+ heat_l: number;
112
+ heat_h: number;
113
+ frate_steps: number;
114
+ en_frate_auto: number;
115
+ };
116
+ declare const get_model_info: (http: Client) => Promise<ModelInfoResponse>;
117
+
118
+ type QuickTimerResponse = DaikinResponse & {
119
+ t1_ena: string;
120
+ t1_pow: string;
121
+ t1_time: string;
122
+ t2_ena: string;
123
+ t2_pow: string;
124
+ t2_time: string;
125
+ };
126
+ declare const get_quick_timer: (http: Client) => Promise<QuickTimerResponse>;
127
+
128
+ type SensorInfoResponse = DaikinResponse & {
129
+ err: number;
130
+ htemp: number;
131
+ otemp: number | '-';
132
+ };
133
+ declare const get_sensor_info: (http: Client) => Promise<SensorInfoResponse>;
134
+
49
135
  type ZoneSettingResponse = DaikinResponse & {
50
136
  zone_name: string;
51
137
  zone_onoff: string;
138
+ lztemp_c?: string;
139
+ lztemp_h?: string;
140
+ };
141
+ declare const get_zone_settings: (http: Client) => Promise<ZoneSettingResponse>;
142
+
143
+ type ControlInfoRequestParam = {
144
+ f_airside: number;
145
+ f_auto: number;
146
+ f_dir: number;
147
+ f_rate: number;
148
+ /** Seemingly unused */
149
+ lpw?: '';
150
+ mode: number;
151
+ pow: number;
152
+ /** Humidity set, unused in my model */
153
+ shum?: number | '--';
154
+ stemp: number;
155
+ };
156
+ declare const set_control_info: (http: Client, params: ControlInfoRequestParam) => Promise<DaikinResponse>;
157
+
158
+ type ZoneSettingRequestParam = {
159
+ zone_name: string;
160
+ zone_onoff: string;
161
+ lztemp_c?: string;
162
+ lztemp_h?: string;
52
163
  };
53
- declare const get_zone_settings: (http: API) => Promise<ZoneSettingResponse>;
164
+ declare const set_zone_setting: (http: Client, params: ZoneSettingRequestParam) => Promise<DaikinResponse>;
54
165
 
55
- type ZoneState = {
166
+ type DateTimeResponse = DaikinResponse & {
167
+ sta: string;
168
+ cur: number;
169
+ reg: string;
170
+ dst: number;
171
+ zone: number;
172
+ };
173
+ declare const get_datetime: (http: Client) => Promise<DateTimeResponse>;
174
+
175
+ type DealerInfoResponse = DaikinResponse & {
176
+ dealer_name: string;
177
+ installer: string;
178
+ contactNumber: string;
179
+ };
180
+ declare const get_dealer_info: (http: Client) => Promise<DealerInfoResponse>;
181
+
182
+ type NetworkSettingResponse = DaikinResponse & {
183
+ auto_ip: number;
184
+ auto_dns: number;
185
+ ipaddr: string;
186
+ netmask: string;
187
+ gateway: string;
188
+ dns1: string;
189
+ dns2: string;
190
+ use_proxy: number;
191
+ proxy: string;
192
+ proxy_port: number;
193
+ };
194
+ declare const getNetwork_setting: (http: Client) => Promise<NetworkSettingResponse>;
195
+
196
+ type WifiSettingResponse = DaikinResponse & {
197
+ ssid: string;
198
+ security: string;
199
+ key: string;
200
+ link: number;
201
+ };
202
+ declare const get_wifi_setting: (http: Client) => Promise<WifiSettingResponse>;
203
+
204
+ type Zone = {
205
+ /** The index of the zone in the airbase controller. */
206
+ index: number;
207
+ /** The name of the zone. */
56
208
  name: string;
57
- state: boolean;
209
+ /** The zone is on and flowing air. */
210
+ isOn: boolean;
211
+ /** The set humidity of the zone. Not available on all units. */
212
+ humidity?: number;
213
+ /** The set temperature of the zone. Not available on all units. */
214
+ temperature?: number;
58
215
  };
216
+ type ReadonlyZone = Readonly<Zone>;
217
+ /** Manages all the zones on the airbase controller. */
59
218
  declare class Zones {
60
219
  private zones;
61
220
  private readonly client;
62
221
  constructor(client: DaikinClient);
63
- /** Refreshes the cached zone state */
64
- refresh(): Promise<ZoneState[]>;
222
+ /**
223
+ * Requests all the zones current state from the airbase controller.
224
+ * Results are cached.
225
+ * @returns the current state of all zones.
226
+ */
227
+ getZones(): Promise<ReadonlyZone[]>;
65
228
  /**
66
229
  * Gets the state of all cached zones.
67
230
  */
68
- getCachedZones(): ZoneState[];
231
+ getCachedZones(): ReadonlyZone[];
232
+ /**
233
+ * Gets the current state of a zone with the matching name.
234
+ * @param name
235
+ */
236
+ getZone(name: string): Promise<ReadonlyZone | undefined>;
69
237
  /**
70
- * Gets all zones' state
238
+ * Gets the current state of a zone at the given controller index.
239
+ * @param index
240
+ * @throws Error if the index is out of bounds.
71
241
  */
72
- getZones(): Promise<ZoneState[]>;
242
+ getZoneAt(index: number): Promise<ReadonlyZone>;
73
243
  /**
74
244
  * Gets the cached state of a zone
75
245
  * @param name
76
246
  */
77
- getCachedZone(name: string): boolean | undefined;
247
+ getCachedZone(name: string): ReadonlyZone | undefined;
78
248
  /**
79
- * Gets the state of a Zone
80
- * @param name
249
+ * Gets the cached state of a zone at the given controller index.
250
+ * @param index
251
+ * @throws Error if the index is out of bounds.
81
252
  */
82
- getZone(name: string): Promise<boolean | undefined>;
253
+ getCachedZoneAt(index: number): ReadonlyZone;
83
254
  /**
84
- * Sets a Zone's state
85
- * @param name
86
- * @param state
255
+ * Updates a zone
256
+ * @param name the name of the zone to update
257
+ * @param info the new data to replace
87
258
  */
88
- setZone(name: string, state: boolean): Promise<void>;
259
+ updateZone(name: string, info: Partial<Zone>): Promise<ReadonlyZone>;
89
260
  /**
90
- * Sets multiple zones' state
91
- * @param changes
261
+ * Bulk updates all the zones
262
+ * @param zones the new zones. These are sorted by index and pushed into the API in that order.
263
+ * @returns the updated zones
92
264
  */
93
- setZones(changes: ZoneState[]): Promise<void>;
265
+ setZones(zones: Zone[]): Promise<ReadonlyZone[]>;
94
266
  }
95
267
 
96
268
  type BasicInfo = {
@@ -112,7 +284,7 @@ declare enum ControlMode {
112
284
  Hot = 1,
113
285
  Cool = 2,
114
286
  Auto = 3,
115
- Dry = 4
287
+ Dry = 7
116
288
  }
117
289
  declare enum FanSpeed {
118
290
  Low = 1,
@@ -160,7 +332,7 @@ type Fan = {
160
332
  };
161
333
  declare class DaikinClient {
162
334
  private readonly options;
163
- readonly api: API;
335
+ readonly api: Client;
164
336
  readonly zones: Zones;
165
337
  private cachedControlInfo;
166
338
  constructor(options: DaikinClientOptions);
@@ -178,7 +350,8 @@ declare class DaikinClient {
178
350
  getStatus(): Promise<Status>;
179
351
  setControlInfo(info: Partial<ControlInfo>): Promise<void>;
180
352
  getBasicInfo(): Promise<BasicInfo>;
353
+ /** Broadcasts a request to discover devices on the network. */
181
354
  static discover(timeoutMs?: number): Promise<DiscoveredDevice[]>;
182
355
  }
183
356
 
184
- export { API, type BasicInfo, type BasicInfoResponse, type ControlInfo, ControlMode, DaikinClient, type DaikinClientOptions, type DaikinResponse, type DiscoveredDevice, type Fan, FanSpeed, RemoteType, Status, type ZoneSettingResponse, type ZoneState, Zones, basic_info, discover, get_zone_settings };
357
+ export { type BasicInfo, type BasicInfoResponse, Client, type ControlInfo, type ControlInfoRequestParam, type ControlInfoResponse, ControlMode, DaikinClient, type DaikinClientOptions, type DaikinError, type DaikinResponse, type DateTimeResponse, type DealerInfoResponse, type DiscoveredDevice, type Fan, FanSpeed, type ModelInfoResponse, type NetworkSettingResponse, type QuickTimerResponse, RemoteType, type SensorInfoResponse, Status, type WifiSettingResponse, type Zone, type ZoneSettingRequestParam, type ZoneSettingResponse, Zones, basic_info, discover, getNetwork_setting, get_control_info, get_datetime, get_dealer_info, get_model_info, get_quick_timer, get_sensor_info, get_wifi_setting, get_zone_settings, set_control_info, set_zone_setting };
package/dist/index.d.ts CHANGED
@@ -3,7 +3,11 @@ type Params = Record<string, number | string>;
3
3
  type DaikinResponse = {
4
4
  ret: 'OK';
5
5
  };
6
- declare class API {
6
+ type DaikinError = DaikinResponse & {
7
+ ret: string;
8
+ msg: string;
9
+ };
10
+ declare class Client {
7
11
  readonly host: string;
8
12
  constructor(host: string);
9
13
  request(endpoint: string, parameters?: Record<string, string | number | undefined | null>): Promise<Params>;
@@ -38,7 +42,7 @@ type BasicInfoResponse = DaikinResponse & {
38
42
  en_hol: number;
39
43
  sync_time: number;
40
44
  };
41
- declare const basic_info: (http: API) => Promise<BasicInfoResponse>;
45
+ declare const basic_info: (http: Client) => Promise<BasicInfoResponse>;
42
46
 
43
47
  type DiscoveredDevice = BasicInfoResponse & {
44
48
  discoveredAddress: string;
@@ -46,51 +50,219 @@ type DiscoveredDevice = BasicInfoResponse & {
46
50
  };
47
51
  declare function discover(timeoutMs?: number): Promise<DiscoveredDevice[]>;
48
52
 
53
+ type ControlInfoResponse = DaikinResponse & {
54
+ pow: number;
55
+ mode: number;
56
+ operate: number;
57
+ bk_auto: number;
58
+ stemp: number;
59
+ dt1: number;
60
+ dt2: number;
61
+ f_rate: number;
62
+ dfr1: number;
63
+ dfr2: number;
64
+ f_airside: number;
65
+ airside1: number;
66
+ airside2: number;
67
+ f_auto: number;
68
+ auto1: number;
69
+ auto2: number;
70
+ f_dir: number;
71
+ dfd1: number;
72
+ dfd2: number;
73
+ filter_sign_info: number;
74
+ cent: number;
75
+ en_cent: number;
76
+ remo: number;
77
+ };
78
+ declare const get_control_info: (http: Client) => Promise<ControlInfoResponse>;
79
+
80
+ type ModelInfoResponse = DaikinResponse & {
81
+ model: string;
82
+ type: string;
83
+ humd: number;
84
+ s_humd: number;
85
+ en_zone: number;
86
+ en_linear_zone: number;
87
+ en_filter_sign: number;
88
+ acled: number;
89
+ land: number;
90
+ elec: number;
91
+ temp: number;
92
+ m_dtct: number;
93
+ ac_dst: string;
94
+ dmnd: number;
95
+ en_temp_setting: number;
96
+ en_frate: number;
97
+ en_fdir: number;
98
+ en_rtemp_a: number;
99
+ en_spmode: number;
100
+ en_ipw_sep: number;
101
+ en_scdltmr: number;
102
+ en_mompow: number;
103
+ en_patrol: number;
104
+ en_airside: number;
105
+ en_quick_timer: number;
106
+ en_auto: number;
107
+ en_dry: number;
108
+ en_common_zone: number;
109
+ cool_l: number;
110
+ cool_h: number;
111
+ heat_l: number;
112
+ heat_h: number;
113
+ frate_steps: number;
114
+ en_frate_auto: number;
115
+ };
116
+ declare const get_model_info: (http: Client) => Promise<ModelInfoResponse>;
117
+
118
+ type QuickTimerResponse = DaikinResponse & {
119
+ t1_ena: string;
120
+ t1_pow: string;
121
+ t1_time: string;
122
+ t2_ena: string;
123
+ t2_pow: string;
124
+ t2_time: string;
125
+ };
126
+ declare const get_quick_timer: (http: Client) => Promise<QuickTimerResponse>;
127
+
128
+ type SensorInfoResponse = DaikinResponse & {
129
+ err: number;
130
+ htemp: number;
131
+ otemp: number | '-';
132
+ };
133
+ declare const get_sensor_info: (http: Client) => Promise<SensorInfoResponse>;
134
+
49
135
  type ZoneSettingResponse = DaikinResponse & {
50
136
  zone_name: string;
51
137
  zone_onoff: string;
138
+ lztemp_c?: string;
139
+ lztemp_h?: string;
140
+ };
141
+ declare const get_zone_settings: (http: Client) => Promise<ZoneSettingResponse>;
142
+
143
+ type ControlInfoRequestParam = {
144
+ f_airside: number;
145
+ f_auto: number;
146
+ f_dir: number;
147
+ f_rate: number;
148
+ /** Seemingly unused */
149
+ lpw?: '';
150
+ mode: number;
151
+ pow: number;
152
+ /** Humidity set, unused in my model */
153
+ shum?: number | '--';
154
+ stemp: number;
155
+ };
156
+ declare const set_control_info: (http: Client, params: ControlInfoRequestParam) => Promise<DaikinResponse>;
157
+
158
+ type ZoneSettingRequestParam = {
159
+ zone_name: string;
160
+ zone_onoff: string;
161
+ lztemp_c?: string;
162
+ lztemp_h?: string;
52
163
  };
53
- declare const get_zone_settings: (http: API) => Promise<ZoneSettingResponse>;
164
+ declare const set_zone_setting: (http: Client, params: ZoneSettingRequestParam) => Promise<DaikinResponse>;
54
165
 
55
- type ZoneState = {
166
+ type DateTimeResponse = DaikinResponse & {
167
+ sta: string;
168
+ cur: number;
169
+ reg: string;
170
+ dst: number;
171
+ zone: number;
172
+ };
173
+ declare const get_datetime: (http: Client) => Promise<DateTimeResponse>;
174
+
175
+ type DealerInfoResponse = DaikinResponse & {
176
+ dealer_name: string;
177
+ installer: string;
178
+ contactNumber: string;
179
+ };
180
+ declare const get_dealer_info: (http: Client) => Promise<DealerInfoResponse>;
181
+
182
+ type NetworkSettingResponse = DaikinResponse & {
183
+ auto_ip: number;
184
+ auto_dns: number;
185
+ ipaddr: string;
186
+ netmask: string;
187
+ gateway: string;
188
+ dns1: string;
189
+ dns2: string;
190
+ use_proxy: number;
191
+ proxy: string;
192
+ proxy_port: number;
193
+ };
194
+ declare const getNetwork_setting: (http: Client) => Promise<NetworkSettingResponse>;
195
+
196
+ type WifiSettingResponse = DaikinResponse & {
197
+ ssid: string;
198
+ security: string;
199
+ key: string;
200
+ link: number;
201
+ };
202
+ declare const get_wifi_setting: (http: Client) => Promise<WifiSettingResponse>;
203
+
204
+ type Zone = {
205
+ /** The index of the zone in the airbase controller. */
206
+ index: number;
207
+ /** The name of the zone. */
56
208
  name: string;
57
- state: boolean;
209
+ /** The zone is on and flowing air. */
210
+ isOn: boolean;
211
+ /** The set humidity of the zone. Not available on all units. */
212
+ humidity?: number;
213
+ /** The set temperature of the zone. Not available on all units. */
214
+ temperature?: number;
58
215
  };
216
+ type ReadonlyZone = Readonly<Zone>;
217
+ /** Manages all the zones on the airbase controller. */
59
218
  declare class Zones {
60
219
  private zones;
61
220
  private readonly client;
62
221
  constructor(client: DaikinClient);
63
- /** Refreshes the cached zone state */
64
- refresh(): Promise<ZoneState[]>;
222
+ /**
223
+ * Requests all the zones current state from the airbase controller.
224
+ * Results are cached.
225
+ * @returns the current state of all zones.
226
+ */
227
+ getZones(): Promise<ReadonlyZone[]>;
65
228
  /**
66
229
  * Gets the state of all cached zones.
67
230
  */
68
- getCachedZones(): ZoneState[];
231
+ getCachedZones(): ReadonlyZone[];
232
+ /**
233
+ * Gets the current state of a zone with the matching name.
234
+ * @param name
235
+ */
236
+ getZone(name: string): Promise<ReadonlyZone | undefined>;
69
237
  /**
70
- * Gets all zones' state
238
+ * Gets the current state of a zone at the given controller index.
239
+ * @param index
240
+ * @throws Error if the index is out of bounds.
71
241
  */
72
- getZones(): Promise<ZoneState[]>;
242
+ getZoneAt(index: number): Promise<ReadonlyZone>;
73
243
  /**
74
244
  * Gets the cached state of a zone
75
245
  * @param name
76
246
  */
77
- getCachedZone(name: string): boolean | undefined;
247
+ getCachedZone(name: string): ReadonlyZone | undefined;
78
248
  /**
79
- * Gets the state of a Zone
80
- * @param name
249
+ * Gets the cached state of a zone at the given controller index.
250
+ * @param index
251
+ * @throws Error if the index is out of bounds.
81
252
  */
82
- getZone(name: string): Promise<boolean | undefined>;
253
+ getCachedZoneAt(index: number): ReadonlyZone;
83
254
  /**
84
- * Sets a Zone's state
85
- * @param name
86
- * @param state
255
+ * Updates a zone
256
+ * @param name the name of the zone to update
257
+ * @param info the new data to replace
87
258
  */
88
- setZone(name: string, state: boolean): Promise<void>;
259
+ updateZone(name: string, info: Partial<Zone>): Promise<ReadonlyZone>;
89
260
  /**
90
- * Sets multiple zones' state
91
- * @param changes
261
+ * Bulk updates all the zones
262
+ * @param zones the new zones. These are sorted by index and pushed into the API in that order.
263
+ * @returns the updated zones
92
264
  */
93
- setZones(changes: ZoneState[]): Promise<void>;
265
+ setZones(zones: Zone[]): Promise<ReadonlyZone[]>;
94
266
  }
95
267
 
96
268
  type BasicInfo = {
@@ -112,7 +284,7 @@ declare enum ControlMode {
112
284
  Hot = 1,
113
285
  Cool = 2,
114
286
  Auto = 3,
115
- Dry = 4
287
+ Dry = 7
116
288
  }
117
289
  declare enum FanSpeed {
118
290
  Low = 1,
@@ -160,7 +332,7 @@ type Fan = {
160
332
  };
161
333
  declare class DaikinClient {
162
334
  private readonly options;
163
- readonly api: API;
335
+ readonly api: Client;
164
336
  readonly zones: Zones;
165
337
  private cachedControlInfo;
166
338
  constructor(options: DaikinClientOptions);
@@ -178,7 +350,8 @@ declare class DaikinClient {
178
350
  getStatus(): Promise<Status>;
179
351
  setControlInfo(info: Partial<ControlInfo>): Promise<void>;
180
352
  getBasicInfo(): Promise<BasicInfo>;
353
+ /** Broadcasts a request to discover devices on the network. */
181
354
  static discover(timeoutMs?: number): Promise<DiscoveredDevice[]>;
182
355
  }
183
356
 
184
- export { API, type BasicInfo, type BasicInfoResponse, type ControlInfo, ControlMode, DaikinClient, type DaikinClientOptions, type DaikinResponse, type DiscoveredDevice, type Fan, FanSpeed, RemoteType, Status, type ZoneSettingResponse, type ZoneState, Zones, basic_info, discover, get_zone_settings };
357
+ export { type BasicInfo, type BasicInfoResponse, Client, type ControlInfo, type ControlInfoRequestParam, type ControlInfoResponse, ControlMode, DaikinClient, type DaikinClientOptions, type DaikinError, type DaikinResponse, type DateTimeResponse, type DealerInfoResponse, type DiscoveredDevice, type Fan, FanSpeed, type ModelInfoResponse, type NetworkSettingResponse, type QuickTimerResponse, RemoteType, type SensorInfoResponse, Status, type WifiSettingResponse, type Zone, type ZoneSettingRequestParam, type ZoneSettingResponse, Zones, basic_info, discover, getNetwork_setting, get_control_info, get_datetime, get_dealer_info, get_model_info, get_quick_timer, get_sensor_info, get_wifi_setting, get_zone_settings, set_control_info, set_zone_setting };
package/dist/index.mjs CHANGED
@@ -1,8 +1,9 @@
1
1
  // src/ParamParser.ts
2
- function parse(str) {
2
+ var int = (v) => Math.round(v);
3
+ var bool = (v) => v ? 1 : 0;
4
+ function deserialize(data) {
3
5
  const result = {};
4
- const parts = str.split(",");
5
- for (const part of parts) {
6
+ for (const part of data) {
6
7
  const [key, value] = part.split("=");
7
8
  if (key === void 0) continue;
8
9
  const maybeNumber = Number(value);
@@ -14,10 +15,20 @@ function parse(str) {
14
15
  }
15
16
  return result;
16
17
  }
18
+ function serialize(parameters) {
19
+ const queries = [];
20
+ for (const key in parameters) {
21
+ const value = parameters[key];
22
+ if (value === void 0) continue;
23
+ const encoded = encodeURIComponent(typeof value === "string" ? value : value !== null ? `${int(value)}` : "");
24
+ queries.push(`${key}=${encoded}`);
25
+ }
26
+ return queries;
27
+ }
17
28
 
18
- // src/api/API.ts
29
+ // src/api/Client.ts
19
30
  import http from "http";
20
- var API = class {
31
+ var Client = class {
21
32
  host;
22
33
  constructor(host) {
23
34
  this.host = host;
@@ -25,16 +36,8 @@ var API = class {
25
36
  async request(endpoint, parameters) {
26
37
  const body = await new Promise((resolve, reject) => {
27
38
  const url = new URL(`/skyfi${endpoint}`, `http://${this.host}/`);
28
- const queries = [];
29
- if (parameters) {
30
- for (const key in parameters) {
31
- const value = parameters[key];
32
- if (value === void 0) continue;
33
- const encoded = encodeURIComponent(`${value ?? ""}`);
34
- queries.push(`${key}=${encoded}`);
35
- }
36
- }
37
- const search = queries.length > 0 ? `?${queries.join("&")}` : "";
39
+ const serialized = parameters ? serialize(parameters) : [];
40
+ const search = serialized.length > 0 ? `?${serialized.join("&")}` : "";
38
41
  const req = http.request(
39
42
  {
40
43
  host: url.hostname,
@@ -57,7 +60,7 @@ var API = class {
57
60
  req.on("error", reject);
58
61
  req.end();
59
62
  });
60
- return parse(body);
63
+ return deserialize(body.split(","));
61
64
  }
62
65
  };
63
66
 
@@ -80,7 +83,7 @@ function discover(timeoutMs = 3e3) {
80
83
  });
81
84
  socket.on("message", (msg, rinfo) => {
82
85
  const raw = msg.toString("utf8");
83
- const info = parse(raw);
86
+ const info = deserialize(raw.split(","));
84
87
  const key = `${info.mac || info.id || rinfo.address}`;
85
88
  availableUnits.set(key, {
86
89
  discoveredAddress: rinfo.address,
@@ -107,15 +110,42 @@ function discover(timeoutMs = 3e3) {
107
110
  });
108
111
  }
109
112
 
110
- // src/api/common/basic_info.ts
111
- var basic_info = (http2) => http2.request("/common/basic_info");
113
+ // src/api/aircon/get_control_info.ts
114
+ var get_control_info = (http2) => http2.request("/aircon/get_control_info");
115
+
116
+ // src/api/aircon/get_model_info.ts
117
+ var get_model_info = (http2) => http2.request("/aircon/get_model_info");
118
+
119
+ // src/api/aircon/get_quick_timer.ts
120
+ var get_quick_timer = (http2) => http2.request("/aircon/get_quick_timer");
121
+
122
+ // src/api/aircon/get_sensor_info.ts
123
+ var get_sensor_info = (http2) => http2.request("/aircon/get_sensor_info");
112
124
 
113
125
  // src/api/aircon/get_zone_setting.ts
114
126
  var get_zone_settings = (http2) => http2.request("/aircon/get_zone_setting");
115
127
 
128
+ // src/api/aircon/set_control_info.ts
129
+ var set_control_info = (http2, params) => http2.request("/aircon/set_control_info", params);
130
+
116
131
  // src/api/aircon/set_zone_setting.ts
117
132
  var set_zone_setting = (http2, params) => http2.request("/aircon/set_zone_setting", params);
118
133
 
134
+ // src/api/common/basic_info.ts
135
+ var basic_info = (http2) => http2.request("/common/basic_info");
136
+
137
+ // src/api/common/get_datetime.ts
138
+ var get_datetime = (http2) => http2.request("/common/get_datetime");
139
+
140
+ // src/api/common/get_dealer_info.ts
141
+ var get_dealer_info = (http2) => http2.request("/common/get_dealer_info");
142
+
143
+ // src/api/common/get_network_setting.ts
144
+ var getNetwork_setting = (http2) => http2.request("/common/get_network_setting");
145
+
146
+ // src/api/common/get_wifi_setting.ts
147
+ var get_wifi_setting = (http2) => http2.request("/common/get_wifi_setting");
148
+
119
149
  // src/Zones.ts
120
150
  var Zones = class {
121
151
  zones = [];
@@ -123,69 +153,105 @@ var Zones = class {
123
153
  constructor(client) {
124
154
  this.client = client;
125
155
  }
126
- /** Refreshes the cached zone state */
127
- async refresh() {
156
+ /**
157
+ * Requests all the zones current state from the airbase controller.
158
+ * Results are cached.
159
+ * @returns the current state of all zones.
160
+ */
161
+ async getZones() {
128
162
  const response = await get_zone_settings(this.client.api);
129
- const zoneNames = response.zone_name.split(";");
130
- const zoneState = response.zone_onoff.split(";");
131
- return this.zones = zoneNames.map((name, index) => ({
163
+ const names = response.zone_name.split(";");
164
+ const onoff = response.zone_onoff.split(";");
165
+ const temprartures = response.lztemp_c ? response.lztemp_c.split(";") : null;
166
+ const humidities = response.lztemp_h ? response.lztemp_h.split(";") : null;
167
+ return this.zones = names.map((name, index) => Object.freeze({
168
+ index,
132
169
  name,
133
- state: zoneState[index] === "1"
170
+ isOn: onoff[index] === "1",
171
+ humidity: humidities ? +`${humidities[index]}` : void 0,
172
+ temperature: temprartures ? +`${temprartures[index]}` : void 0
134
173
  }));
135
174
  }
136
175
  /**
137
176
  * Gets the state of all cached zones.
138
177
  */
139
178
  getCachedZones() {
140
- return [...this.zones];
179
+ return this.zones;
180
+ }
181
+ /**
182
+ * Gets the current state of a zone with the matching name.
183
+ * @param name
184
+ */
185
+ async getZone(name) {
186
+ return await this.getZones().then(() => this.getCachedZone(name));
141
187
  }
142
188
  /**
143
- * Gets all zones' state
189
+ * Gets the current state of a zone at the given controller index.
190
+ * @param index
191
+ * @throws Error if the index is out of bounds.
144
192
  */
145
- async getZones() {
146
- return await this.refresh();
193
+ async getZoneAt(index) {
194
+ return await this.getZones().then(() => this.getCachedZoneAt(index));
147
195
  }
148
196
  /**
149
197
  * Gets the cached state of a zone
150
198
  * @param name
151
199
  */
152
200
  getCachedZone(name) {
153
- return this.zones.find((zone) => zone.name === name)?.state;
201
+ return this.zones.find((zone) => zone.name === name);
154
202
  }
155
203
  /**
156
- * Gets the state of a Zone
157
- * @param name
204
+ * Gets the cached state of a zone at the given controller index.
205
+ * @param index
206
+ * @throws Error if the index is out of bounds.
158
207
  */
159
- async getZone(name) {
160
- const zones = await this.refresh();
161
- return zones.find((zone) => zone.name === name)?.state;
208
+ getCachedZoneAt(index) {
209
+ if (index < 0 || index >= this.zones.length || this.zones[index] === void 0)
210
+ throw new Error(`Zone index ${index} is out of bounds`);
211
+ if (this.zones[index].index !== index)
212
+ throw new Error(`Zone at ${index} does not believe it is in the correct spot.`);
213
+ return this.zones[index];
162
214
  }
163
215
  /**
164
- * Sets a Zone's state
165
- * @param name
166
- * @param state
216
+ * Updates a zone
217
+ * @param name the name of the zone to update
218
+ * @param info the new data to replace
167
219
  */
168
- async setZone(name, state) {
169
- await this.setZones([{ name, state }]);
220
+ async updateZone(name, info) {
221
+ const zones = await this.getZones();
222
+ const index = zones.findIndex((zone) => zone.name === name);
223
+ zones[index] = { ...zones[index], ...info };
224
+ await this.setZones(zones);
225
+ return zones[index];
170
226
  }
171
227
  /**
172
- * Sets multiple zones' state
173
- * @param changes
228
+ * Bulk updates all the zones
229
+ * @param zones the new zones. These are sorted by index and pushed into the API in that order.
230
+ * @returns the updated zones
174
231
  */
175
- async setZones(changes) {
176
- await this.refresh();
177
- for (const change of changes) {
178
- const existingZone = this.zones.find((z) => z.name === change.name);
179
- if (existingZone) {
180
- existingZone.state = change.state;
181
- }
232
+ async setZones(zones) {
233
+ let names = [];
234
+ let onoff = [];
235
+ let humidity = [];
236
+ let temperature = [];
237
+ const sortedZones = zones.sort((a, b) => a.index - b.index);
238
+ for (const zone of sortedZones) {
239
+ names.push(zone.name);
240
+ onoff.push(`${bool(zone.isOn)}`);
241
+ if (zone.humidity !== void 0)
242
+ humidity.push(`${int(zone.humidity)}`);
243
+ if (zone.temperature !== void 0)
244
+ temperature.push(`${int(zone.temperature)}`);
182
245
  }
183
246
  const response = await set_zone_setting(this.client.api, {
184
- zone_name: this.zones.map((zone) => zone.name).join(";"),
185
- zone_onoff: this.zones.map((zone) => zone.state ? "1" : "0").join(";")
247
+ zone_name: names.join(";"),
248
+ zone_onoff: onoff.join(";"),
249
+ lztemp_h: humidity.length > 0 ? humidity.join(";") : void 0,
250
+ lztemp_c: temperature.length > 0 ? temperature.join(";") : void 0
186
251
  });
187
252
  if (response.ret !== "OK")
188
253
  throw new Error(`Failed to set zones: ${response.ret}`);
254
+ return this.zones = zones.map((zone) => Object.freeze({ ...zone }));
189
255
  }
190
256
  };
191
257
 
@@ -195,7 +261,7 @@ var ControlMode = /* @__PURE__ */ ((ControlMode3) => {
195
261
  ControlMode3[ControlMode3["Hot"] = 1] = "Hot";
196
262
  ControlMode3[ControlMode3["Cool"] = 2] = "Cool";
197
263
  ControlMode3[ControlMode3["Auto"] = 3] = "Auto";
198
- ControlMode3[ControlMode3["Dry"] = 4] = "Dry";
264
+ ControlMode3[ControlMode3["Dry"] = 7] = "Dry";
199
265
  return ControlMode3;
200
266
  })(ControlMode || {});
201
267
  var FanSpeed = /* @__PURE__ */ ((FanSpeed3) => {
@@ -217,12 +283,6 @@ var RemoteType = /* @__PURE__ */ ((RemoteType3) => {
217
283
  return RemoteType3;
218
284
  })(RemoteType || {});
219
285
 
220
- // src/api/aircon/get_control_info.ts
221
- var get_control_info = (http2) => http2.request("/aircon/get_control_info");
222
-
223
- // src/api/aircon/set_control_info.ts
224
- var set_control_info = (http2, params) => http2.request("/aircon/set_control_info", params);
225
-
226
286
  // src/DaikinClient.ts
227
287
  var DaikinClient = class {
228
288
  options;
@@ -232,9 +292,9 @@ var DaikinClient = class {
232
292
  constructor(options) {
233
293
  this.options = options;
234
294
  if ("host" in options) {
235
- this.api = new API(options.host);
295
+ this.api = new Client(options.host);
236
296
  } else {
237
- this.api = new API(options.device.discoveredAddress);
297
+ this.api = new Client(options.device.discoveredAddress);
238
298
  }
239
299
  this.zones = new Zones(this);
240
300
  }
@@ -297,8 +357,6 @@ var DaikinClient = class {
297
357
  async setControlInfo(info) {
298
358
  const latest = await this.getControlInfo();
299
359
  const update = { ...latest, ...info };
300
- const int = (v) => Math.round(v);
301
- const bool = (v) => v ? 1 : 0;
302
360
  const params = {
303
361
  f_airside: 0,
304
362
  f_auto: bool(update.fanAuto),
@@ -335,12 +393,13 @@ var DaikinClient = class {
335
393
  adp_kind: response.adp_kind
336
394
  };
337
395
  }
396
+ /** Broadcasts a request to discover devices on the network. */
338
397
  static async discover(timeoutMs = 3e3) {
339
398
  return discover(timeoutMs);
340
399
  }
341
400
  };
342
401
  export {
343
- API,
402
+ Client,
344
403
  ControlMode,
345
404
  DaikinClient,
346
405
  FanSpeed,
@@ -349,5 +408,15 @@ export {
349
408
  Zones,
350
409
  basic_info,
351
410
  discover,
352
- get_zone_settings
411
+ getNetwork_setting,
412
+ get_control_info,
413
+ get_datetime,
414
+ get_dealer_info,
415
+ get_model_info,
416
+ get_quick_timer,
417
+ get_sensor_info,
418
+ get_wifi_setting,
419
+ get_zone_settings,
420
+ set_control_info,
421
+ set_zone_setting
353
422
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "daikin-airbase",
3
- "version": "0.1.5",
3
+ "version": "0.2.0",
4
4
  "main": "./dist/index.cjs",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",