daikin-airbase 0.1.2 → 0.1.4

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
@@ -70,7 +70,7 @@ var API = class {
70
70
  for (const key in parameters) {
71
71
  const value = parameters[key];
72
72
  if (value === void 0) continue;
73
- const encoded = encodeURIComponent(`${value || ""}`);
73
+ const encoded = encodeURIComponent(`${value ?? ""}`);
74
74
  queries.push(`${key}=${encoded}`);
75
75
  }
76
76
  }
@@ -287,11 +287,12 @@ var DaikinClient = class {
287
287
  const info = await this.getControlInfo();
288
288
  return {
289
289
  speed: info.fanSpeed,
290
- auto: info.fanAuto
290
+ auto: info.fanAuto,
291
+ airside: info.fanAirside
291
292
  };
292
293
  }
293
294
  async setFan(fan) {
294
- return await this.setControlInfo({ fanSpeed: fan.speed, fanAuto: fan.auto });
295
+ return await this.setControlInfo({ fanSpeed: fan.speed, fanAuto: fan.auto, fanAirside: fan.airside ?? false });
295
296
  }
296
297
  async getTargetTemperature() {
297
298
  return (await this.getControlInfo()).targetTemperature;
@@ -308,16 +309,23 @@ var DaikinClient = class {
308
309
  async setControlInfo(info) {
309
310
  const latest = await this.getControlInfo();
310
311
  const update = { ...latest, ...info };
312
+ const int = (v) => Math.round(v);
311
313
  const bool = (v) => v ? 1 : 0;
312
- const response = await set_control_info(this.api, {
313
- f_airside: bool(update.fanAirside),
314
+ const params = {
315
+ f_airside: 0,
314
316
  f_auto: bool(update.fanAuto),
315
317
  f_dir: bool(update.swinging),
316
- f_rate: update.fanSpeed,
317
- mode: update.mode,
318
+ f_rate: int(update.fanSpeed),
319
+ mode: int(update.mode),
318
320
  pow: bool(update.power),
319
- stemp: update.targetTemperature
320
- });
321
+ stemp: int(update.targetTemperature)
322
+ };
323
+ if (update.fanAirside) {
324
+ params.f_airside = 1;
325
+ params.f_auto = 0;
326
+ params.f_dir = 0;
327
+ }
328
+ const response = await set_control_info(this.api, params);
321
329
  if (response.ret !== "OK")
322
330
  throw new Error(`Failed to update control info: ${response.ret}`);
323
331
  this.cachedControlInfo = update;
package/dist/index.d.mts CHANGED
@@ -156,6 +156,7 @@ type DaikinClientOptions = (DeviceOption | HostOption) & {
156
156
  type Fan = {
157
157
  speed: FanSpeed;
158
158
  auto: boolean;
159
+ airside?: boolean;
159
160
  };
160
161
  declare class DaikinClient {
161
162
  private readonly options;
package/dist/index.d.ts CHANGED
@@ -156,6 +156,7 @@ type DaikinClientOptions = (DeviceOption | HostOption) & {
156
156
  type Fan = {
157
157
  speed: FanSpeed;
158
158
  auto: boolean;
159
+ airside?: boolean;
159
160
  };
160
161
  declare class DaikinClient {
161
162
  private readonly options;
package/dist/index.mjs CHANGED
@@ -30,7 +30,7 @@ var API = class {
30
30
  for (const key in parameters) {
31
31
  const value = parameters[key];
32
32
  if (value === void 0) continue;
33
- const encoded = encodeURIComponent(`${value || ""}`);
33
+ const encoded = encodeURIComponent(`${value ?? ""}`);
34
34
  queries.push(`${key}=${encoded}`);
35
35
  }
36
36
  }
@@ -247,11 +247,12 @@ var DaikinClient = class {
247
247
  const info = await this.getControlInfo();
248
248
  return {
249
249
  speed: info.fanSpeed,
250
- auto: info.fanAuto
250
+ auto: info.fanAuto,
251
+ airside: info.fanAirside
251
252
  };
252
253
  }
253
254
  async setFan(fan) {
254
- return await this.setControlInfo({ fanSpeed: fan.speed, fanAuto: fan.auto });
255
+ return await this.setControlInfo({ fanSpeed: fan.speed, fanAuto: fan.auto, fanAirside: fan.airside ?? false });
255
256
  }
256
257
  async getTargetTemperature() {
257
258
  return (await this.getControlInfo()).targetTemperature;
@@ -268,16 +269,23 @@ var DaikinClient = class {
268
269
  async setControlInfo(info) {
269
270
  const latest = await this.getControlInfo();
270
271
  const update = { ...latest, ...info };
272
+ const int = (v) => Math.round(v);
271
273
  const bool = (v) => v ? 1 : 0;
272
- const response = await set_control_info(this.api, {
273
- f_airside: bool(update.fanAirside),
274
+ const params = {
275
+ f_airside: 0,
274
276
  f_auto: bool(update.fanAuto),
275
277
  f_dir: bool(update.swinging),
276
- f_rate: update.fanSpeed,
277
- mode: update.mode,
278
+ f_rate: int(update.fanSpeed),
279
+ mode: int(update.mode),
278
280
  pow: bool(update.power),
279
- stemp: update.targetTemperature
280
- });
281
+ stemp: int(update.targetTemperature)
282
+ };
283
+ if (update.fanAirside) {
284
+ params.f_airside = 1;
285
+ params.f_auto = 0;
286
+ params.f_dir = 0;
287
+ }
288
+ const response = await set_control_info(this.api, params);
281
289
  if (response.ret !== "OK")
282
290
  throw new Error(`Failed to update control info: ${response.ret}`);
283
291
  this.cachedControlInfo = update;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "daikin-airbase",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "main": "./dist/index.cjs",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",