hoffmation-base 2.22.16 → 2.22.18

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.
@@ -138,11 +138,15 @@ class OwnDaikinDevice extends ac_device_1.AcDevice {
138
138
  }
139
139
  handleDeviceUnreach() {
140
140
  this.log(models_1.LogLevel.Warn, `Detected EHOSTUNREACH for ${this.name}(${this.ip}), will try reconecting`);
141
- daikin_service_1.DaikinService.reconnect(this.name, this.ip).then((device) => {
141
+ daikin_service_1.DaikinService.reconnect(this.name, this.ip)
142
+ .then((device) => {
142
143
  this.device = device;
143
144
  utils_1.Utils.guardedTimeout(() => {
144
145
  this.setDesiredInfo(true);
145
146
  }, 5000, this);
147
+ })
148
+ .catch((err) => {
149
+ this.log(models_1.LogLevel.Error, `Reconnecting failed for ${this.name}(${this.ip}): ${err}`);
146
150
  });
147
151
  }
148
152
  handleParamNg(changeObject) {
@@ -1,6 +1,7 @@
1
1
  import { Router } from './router';
2
2
  import { iAsusConfig } from '../../config';
3
3
  export declare class AsusRouter extends Router {
4
+ authorizeDevice(_mac: string, _minutes: number, _uploadLimit: number, _downloadLimit: number): Promise<boolean>;
4
5
  private _api;
5
6
  constructor(config: iAsusConfig);
6
7
  reconnectDeviceByIp(ip: string): Promise<boolean>;
@@ -6,6 +6,9 @@ const router_1 = require("./router");
6
6
  const log_service_1 = require("../log-service");
7
7
  const models_1 = require("../../../models");
8
8
  class AsusRouter extends router_1.Router {
9
+ authorizeDevice(_mac, _minutes, _uploadLimit, _downloadLimit) {
10
+ throw new Error('Method not implemented.');
11
+ }
9
12
  constructor(config) {
10
13
  super();
11
14
  this._api = new node_merlin_wrt_api_1.NodeMerlinWrtApi(config.username, config.password, config.address, config.ignoreSSL === true);
@@ -2,6 +2,15 @@ export declare abstract class Router {
2
2
  private static _router;
3
3
  static getRouter(): Router | undefined;
4
4
  protected static setRouter(router: Router): void;
5
+ /**
6
+ * Authorize a device to connect to the network.
7
+ * @param {string} mac - The MAC address of the device.
8
+ * @param {number} minutes - The number of minutes from now on the device is authorized to connect.
9
+ * @param {number} uploadLimit - The upload limit in kbps.
10
+ * @param {number} downloadLimit - The download limit in kbps.
11
+ * @returns {Promise<boolean>} - True if the device was authorized, false otherwise.
12
+ */
13
+ abstract authorizeDevice(mac: string, minutes: number, uploadLimit: number, downloadLimit: number): Promise<boolean>;
5
14
  abstract reconnectDeviceByMac(mac: string): Promise<boolean>;
6
15
  abstract reconnectDeviceByIp(ip: string): Promise<boolean>;
7
16
  }
@@ -5,6 +5,7 @@ export declare class UnifiRouter extends Router {
5
5
  private readonly _api;
6
6
  private _loggedIn;
7
7
  constructor(config: iUnifiSettings);
8
+ authorizeDevice(mac: string, minutes: number, uploadLimit: number, downloadLimit: number): Promise<boolean>;
8
9
  reconnectDeviceByMac(mac: string): Promise<boolean>;
9
10
  reconnectDeviceByIp(_ip: string): Promise<boolean>;
10
11
  private login;
@@ -21,6 +21,24 @@ class UnifiRouter extends router_1.Router {
21
21
  router_1.Router.setRouter(this);
22
22
  this.login();
23
23
  }
24
+ authorizeDevice(mac, minutes, uploadLimit, downloadLimit) {
25
+ log_service_1.ServerLogService.writeLog(models_1.LogLevel.Info, `Unifi: AuthorizeDevice Device "${mac}" for ${minutes} minutes with ${uploadLimit} kbps upload and ${downloadLimit} kbps download`);
26
+ return new Promise(async (resolve, _reject) => {
27
+ if (!this.loggedIn && !(await this.login())) {
28
+ log_service_1.ServerLogService.writeLog(models_1.LogLevel.Warn, `Unifi: Can't AuthorizeDevice Device "${mac}" as we can't log in`);
29
+ resolve(false);
30
+ }
31
+ const result = await this._api
32
+ .authorizeGuest(mac, minutes, uploadLimit, downloadLimit)
33
+ .catch((error) => {
34
+ log_service_1.ServerLogService.writeLog(models_1.LogLevel.Warn, `Unifi: Failed to AuthorizeDevice "${mac}" due to: ${error}`);
35
+ resolve(false);
36
+ return;
37
+ });
38
+ log_service_1.ServerLogService.writeLog(models_1.LogLevel.Trace, `Unifi: AuthorizeDevice ${mac} resulted in ${result}`);
39
+ resolve(true);
40
+ });
41
+ }
24
42
  reconnectDeviceByMac(mac) {
25
43
  log_service_1.ServerLogService.writeLog(models_1.LogLevel.Info, `Unifi: Reconnecting Device "${mac}"`);
26
44
  return new Promise(async (resolve, _reject) => {