hoffmation-base 2.22.14 → 2.22.16
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/lib/index.js +6 -3
- package/lib/server/config/iConfig.d.ts +2 -0
- package/lib/server/config/iUnifiConnectionOptions.d.ts +11 -0
- package/lib/server/config/iUnifiConnectionOptions.js +2 -0
- package/lib/server/config/iUnifiSettings.d.ts +4 -0
- package/lib/server/config/iUnifiSettings.js +2 -0
- package/lib/server/config/index.d.ts +2 -0
- package/lib/server/config/index.js +2 -0
- package/lib/server/services/ac/own-daikin-device.d.ts +1 -0
- package/lib/server/services/ac/own-daikin-device.js +10 -0
- package/lib/server/services/network/index.d.ts +1 -0
- package/lib/server/services/network/index.js +1 -0
- package/lib/server/services/network/unifiRouter.d.ts +11 -0
- package/lib/server/services/network/unifiRouter.js +57 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -2
package/lib/index.js
CHANGED
|
@@ -19,7 +19,6 @@ const server_1 = require("./server");
|
|
|
19
19
|
const models_1 = require("./models");
|
|
20
20
|
const dachs_1 = require("./server/devices/dachs");
|
|
21
21
|
require("@iobroker/types");
|
|
22
|
-
const govee_1 = require("./server/services/govee");
|
|
23
22
|
__exportStar(require("./models/index"), exports);
|
|
24
23
|
__exportStar(require("./server/index"), exports);
|
|
25
24
|
__exportStar(require("./liquid-pid"), exports);
|
|
@@ -64,6 +63,10 @@ class HoffmationBase {
|
|
|
64
63
|
server_1.ServerLogService.writeLog(models_1.LogLevel.Info, `Asus Router settings detected --> initializing`);
|
|
65
64
|
new server_1.AsusRouter(server_1.SettingsService.settings.asusConfig);
|
|
66
65
|
}
|
|
66
|
+
else if (server_1.SettingsService.settings.unifiSettings) {
|
|
67
|
+
server_1.ServerLogService.writeLog(models_1.LogLevel.Info, `Unifi Router settings detected --> initializing`);
|
|
68
|
+
new server_1.UnifiRouter(server_1.SettingsService.settings.unifiSettings);
|
|
69
|
+
}
|
|
67
70
|
server_1.TimeCallbackService.init();
|
|
68
71
|
server_1.ServerLogService.writeLog(models_1.LogLevel.Info, `Hoffmation-Base First Initializations finished`);
|
|
69
72
|
}
|
|
@@ -82,8 +85,8 @@ class HoffmationBase {
|
|
|
82
85
|
server_1.SonosService.initialize();
|
|
83
86
|
}
|
|
84
87
|
if (server_1.SettingsService.settings.goveeDevicesPresent) {
|
|
85
|
-
|
|
86
|
-
|
|
88
|
+
server_1.GooveeService.addOwnDevices(server_1.OwnGoveeDevices.ownDevices);
|
|
89
|
+
server_1.GooveeService.initialize();
|
|
87
90
|
}
|
|
88
91
|
if ((_b = server_1.SettingsService.settings.daikin) === null || _b === void 0 ? void 0 : _b.active) {
|
|
89
92
|
server_1.DaikinService.addOwnDevices(server_1.OwnAcDevices.ownDevices);
|
|
@@ -21,6 +21,7 @@ import { iTibberSettings } from './iTibberSettings';
|
|
|
21
21
|
import { iVictronSettings } from './iVictronSettings';
|
|
22
22
|
import { iDachsSettings } from './iDachsSettings';
|
|
23
23
|
import { iEnergyManagerSettings } from './iEnergyManagerSettings';
|
|
24
|
+
import { iUnifiSettings } from './iUnifiSettings';
|
|
24
25
|
export interface iConfig {
|
|
25
26
|
asusConfig?: iAsusConfig;
|
|
26
27
|
blueIris?: iBlueIrisSettings;
|
|
@@ -45,6 +46,7 @@ export interface iConfig {
|
|
|
45
46
|
tibber?: iTibberSettings;
|
|
46
47
|
timeSettings: iTimeSettings;
|
|
47
48
|
translationSettings: iTranslationSettings;
|
|
49
|
+
unifiSettings?: iUnifiSettings;
|
|
48
50
|
weather?: iWeatherSettings;
|
|
49
51
|
victron?: iVictronSettings;
|
|
50
52
|
}
|
|
@@ -38,4 +38,6 @@ __exportStar(require("./iTelegramSettings"), exports);
|
|
|
38
38
|
__exportStar(require("./iTibberSettings"), exports);
|
|
39
39
|
__exportStar(require("./iTimeSettings"), exports);
|
|
40
40
|
__exportStar(require("./iTimePair"), exports);
|
|
41
|
+
__exportStar(require("./iUnifiSettings"), exports);
|
|
42
|
+
__exportStar(require("./iUnifiConnectionOptions"), exports);
|
|
41
43
|
__exportStar(require("./iVictronSettings"), exports);
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.OwnDaikinDevice = void 0;
|
|
4
7
|
const daikin_controller_1 = require("daikin-controller");
|
|
@@ -11,6 +14,7 @@ const ac_device_1 = require("./ac-device");
|
|
|
11
14
|
const ac_mode_1 = require("./ac-mode");
|
|
12
15
|
const acDeviceType_1 = require("./acDeviceType");
|
|
13
16
|
const devices_1 = require("../../devices");
|
|
17
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
14
18
|
class OwnDaikinDevice extends ac_device_1.AcDevice {
|
|
15
19
|
constructor(name, roomName, ip, device) {
|
|
16
20
|
super(name, roomName, ip, acDeviceType_1.AcDeviceType.Daikin);
|
|
@@ -152,5 +156,11 @@ class OwnDaikinDevice extends ac_device_1.AcDevice {
|
|
|
152
156
|
}
|
|
153
157
|
});
|
|
154
158
|
}
|
|
159
|
+
toJSON() {
|
|
160
|
+
// eslint-disable-next-line
|
|
161
|
+
const result = lodash_1.default.omit(this, ['room', '_room', 'device', '_device']);
|
|
162
|
+
result['on'] = this.on;
|
|
163
|
+
return utils_1.Utils.jsonFilter(result);
|
|
164
|
+
}
|
|
155
165
|
}
|
|
156
166
|
exports.OwnDaikinDevice = OwnDaikinDevice;
|
|
@@ -15,4 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./asusRouter"), exports);
|
|
18
|
+
__exportStar(require("./unifiRouter"), exports);
|
|
18
19
|
__exportStar(require("./router"), exports);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Router } from './router';
|
|
2
|
+
import { iUnifiSettings } from '../../config';
|
|
3
|
+
export declare class UnifiRouter extends Router {
|
|
4
|
+
get loggedIn(): boolean;
|
|
5
|
+
private readonly _api;
|
|
6
|
+
private _loggedIn;
|
|
7
|
+
constructor(config: iUnifiSettings);
|
|
8
|
+
reconnectDeviceByMac(mac: string): Promise<boolean>;
|
|
9
|
+
reconnectDeviceByIp(_ip: string): Promise<boolean>;
|
|
10
|
+
private login;
|
|
11
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.UnifiRouter = void 0;
|
|
7
|
+
const router_1 = require("./router");
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
9
|
+
// @ts-expect-error
|
|
10
|
+
const node_unifi_1 = __importDefault(require("node-unifi"));
|
|
11
|
+
const log_service_1 = require("../log-service");
|
|
12
|
+
const models_1 = require("../../../models");
|
|
13
|
+
class UnifiRouter extends router_1.Router {
|
|
14
|
+
get loggedIn() {
|
|
15
|
+
return this._loggedIn;
|
|
16
|
+
}
|
|
17
|
+
constructor(config) {
|
|
18
|
+
super();
|
|
19
|
+
this._loggedIn = false;
|
|
20
|
+
this._api = new node_unifi_1.default.Controller(config.loginOptions);
|
|
21
|
+
router_1.Router.setRouter(this);
|
|
22
|
+
this.login();
|
|
23
|
+
}
|
|
24
|
+
reconnectDeviceByMac(mac) {
|
|
25
|
+
log_service_1.ServerLogService.writeLog(models_1.LogLevel.Info, `Unifi: Reconnecting Device "${mac}"`);
|
|
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 reconnect Device "${mac}" as we can't log in`);
|
|
29
|
+
resolve(false);
|
|
30
|
+
}
|
|
31
|
+
const result = await this._api.reconnectClient(mac).catch((error) => {
|
|
32
|
+
log_service_1.ServerLogService.writeLog(models_1.LogLevel.Warn, `Unifi: Failed to reconnect "${mac}" due to: ${error}`);
|
|
33
|
+
resolve(false);
|
|
34
|
+
return;
|
|
35
|
+
});
|
|
36
|
+
log_service_1.ServerLogService.writeLog(models_1.LogLevel.Trace, `Unifi: Reconnecting ${mac} resulted in ${result}`);
|
|
37
|
+
resolve(true);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
reconnectDeviceByIp(_ip) {
|
|
41
|
+
throw new Error('Method not implemented, use reconnectDeviceByMac instead.');
|
|
42
|
+
}
|
|
43
|
+
login() {
|
|
44
|
+
log_service_1.ServerLogService.writeLog(models_1.LogLevel.Info, 'Unifi: Trying to login to Unifi-Controller');
|
|
45
|
+
return new Promise(async (resolve, _reject) => {
|
|
46
|
+
await this._api.login().catch((error) => {
|
|
47
|
+
log_service_1.ServerLogService.writeLog(models_1.LogLevel.Warn, `Unifi: Login failed: ${error}`);
|
|
48
|
+
this._loggedIn = false;
|
|
49
|
+
resolve(false);
|
|
50
|
+
});
|
|
51
|
+
log_service_1.ServerLogService.writeLog(models_1.LogLevel.Info, 'Unifi: Login successful');
|
|
52
|
+
this._loggedIn = true;
|
|
53
|
+
resolve(true);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.UnifiRouter = UnifiRouter;
|