iobroker.iot 4.0.1 → 4.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.
- package/README.md +1 -1
- package/admin/assets/index-5zouxn2w.js +680 -0
- package/admin/index_m.html +1 -1
- package/admin/rules/assets/{ActionVisu-DE8dgNVF.js → ActionVisu-D9x2f6zu.js} +1 -1
- package/admin/rules/assets/{ActionVisu__loadShare__react__loadShare__-BKaC-p5K.js → ActionVisu__loadShare__react__loadShare__-Cg21Ef1U.js} +1 -1
- package/admin/rules/assets/{ActionVisu__loadShare__react_mf_2_dom__loadShare__-Bs1o8DtQ.js → ActionVisu__loadShare__react_mf_2_dom__loadShare__-B1zRWn0u.js} +2 -2
- package/admin/rules/assets/ActionVisu__mf_v__runtimeInit__mf_v__-Cz053nO7.js +10 -0
- package/admin/rules/assets/bootstrap-BCFKIiwZ.js +1 -0
- package/admin/rules/assets/hostInit-hos3Txsy.js +1 -1
- package/admin/rules/assets/{index-DjPMvPni.js → index-CAAeiKCc.js} +2 -2
- package/admin/rules/assets/{index-CbxmbJvB.js → index-Duo7mFlZ.js} +2 -2
- package/admin/rules/assets/index-DwYdaT5M.js +1151 -0
- package/admin/rules/assets/{virtualExposes-BNZJTatg.js → virtualExposes-BqVak7rX.js} +2 -2
- package/admin/rules/customRuleBlocks.js +2 -2
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/AlexaResponse.js +268 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/AlexaResponse.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/Base.js +110 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/Base.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/BrightnessController.js +19 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/BrightnessController.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/ColorController.js +14 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/ColorController.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/ColorTemperatureController.js +19 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/ColorTemperatureController.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/ContactSensor.js +16 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/ContactSensor.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/LockController.js +14 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/LockController.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/ModeController.js +68 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/ModeController.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/MotionSensor.js +14 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/MotionSensor.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/PercentageController.js +14 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/PercentageController.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/PowerController.js +19 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/PowerController.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/Speaker.js +25 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/Speaker.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/TemperatureSensor.js +14 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/TemperatureSensor.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/ThermostatController.js +37 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/ThermostatController.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/index.js +32 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Capabilities/index.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Directives/Base.js +29 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Directives/Base.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Directives/ChangeReport.js +82 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Directives/ChangeReport.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Directives/Discovery.js +39 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Directives/Discovery.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Directives/ReportState.js +47 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Directives/ReportState.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Directives/index.js +14 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Directives/index.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/ModeValues/Base.js +36 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/ModeValues/Base.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/ModeValues/Closed.js +57 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/ModeValues/Closed.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/ModeValues/Open.js +57 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/ModeValues/Open.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/ModeValues/index.js +12 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/ModeValues/index.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/AdjustableProperty.js +16 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/AdjustableProperty.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Base.js +127 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Base.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Brightness.js +18 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Brightness.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Color.js +38 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Color.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/ColorTemperatureInKelvin.js +53 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/ColorTemperatureInKelvin.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/DetectionState.js +23 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/DetectionState.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/LockState.js +37 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/LockState.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Mode.js +34 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Mode.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Muted.js +19 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Muted.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Percentage.js +18 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Percentage.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/PowerState.js +25 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/PowerState.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/TargetSetpoint.js +31 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/TargetSetpoint.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Temperature.js +22 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Temperature.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/ThermostatMode.js +49 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/ThermostatMode.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Volume.js +21 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/Volume.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/index.js +38 -0
- package/build-backend/lib/AlexaSmartHomeV3/Alexa/Properties/index.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/AdjustableControl.js +20 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/AdjustableControl.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/AdjustablePercentageControl.js +26 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/AdjustablePercentageControl.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/AirCondition.js +148 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/AirCondition.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Blind.js +13 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Blind.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/ContactSensor.js +17 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/ContactSensor.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Control.js +321 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Control.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Ct.js +182 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Ct.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Dimmer.js +127 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Dimmer.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Door.js +10 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Door.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Gate.js +38 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Gate.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Hue.js +208 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Hue.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Light.js +47 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Light.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Lock.js +35 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Lock.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Motion.js +17 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Motion.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/ReadOnlyDetector.js +26 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/ReadOnlyDetector.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Slider.js +10 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Slider.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Socket.js +21 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Socket.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Temperature.js +21 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Temperature.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Thermostat.js +85 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Thermostat.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/VacuumCleaner.js +27 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/VacuumCleaner.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Volume.js +116 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Volume.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/VolumeGroup.js +10 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/VolumeGroup.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Window.js +10 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/Window.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/index.js +121 -0
- package/build-backend/lib/AlexaSmartHomeV3/Controls/index.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Device.js +83 -0
- package/build-backend/lib/AlexaSmartHomeV3/Device.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/DeviceManager.js +392 -0
- package/build-backend/lib/AlexaSmartHomeV3/DeviceManager.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Exceptions/AlexaV3Exception.js +10 -0
- package/build-backend/lib/AlexaSmartHomeV3/Exceptions/AlexaV3Exception.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Exceptions/HourlyDeviceRateLimitExceeded.js +10 -0
- package/build-backend/lib/AlexaSmartHomeV3/Exceptions/HourlyDeviceRateLimitExceeded.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Exceptions/OverallDailyRateLimitExceeded.js +10 -0
- package/build-backend/lib/AlexaSmartHomeV3/Exceptions/OverallDailyRateLimitExceeded.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Helpers/AdapterProvider.js +37 -0
- package/build-backend/lib/AlexaSmartHomeV3/Helpers/AdapterProvider.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Helpers/FileHelper.js +53 -0
- package/build-backend/lib/AlexaSmartHomeV3/Helpers/FileHelper.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Helpers/IotProxy.js +27 -0
- package/build-backend/lib/AlexaSmartHomeV3/Helpers/IotProxy.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Helpers/Logger.js +93 -0
- package/build-backend/lib/AlexaSmartHomeV3/Helpers/Logger.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Helpers/RateLimiter.js +112 -0
- package/build-backend/lib/AlexaSmartHomeV3/Helpers/RateLimiter.js.map +1 -0
- package/build-backend/lib/AlexaSmartHomeV3/Helpers/Utils.js +625 -0
- package/build-backend/lib/AlexaSmartHomeV3/Helpers/Utils.js.map +1 -0
- package/build-backend/lib/Utils.js +96 -0
- package/build-backend/lib/Utils.js.map +1 -0
- package/build-backend/lib/adminCommonSocket.js +715 -0
- package/build-backend/lib/adminCommonSocket.js.map +1 -0
- package/build-backend/lib/alexaCustom.js +542 -0
- package/build-backend/lib/alexaCustom.js.map +1 -0
- package/build-backend/lib/alexaSmartHomeV2.js +2788 -0
- package/build-backend/lib/alexaSmartHomeV3.js +97 -0
- package/build-backend/lib/alexaSmartHomeV3.js.map +1 -0
- package/build-backend/lib/alisa.js +2409 -0
- package/build-backend/lib/devices.js +23 -0
- package/build-backend/lib/devices.js.map +1 -0
- package/build-backend/lib/functions.js +24 -0
- package/build-backend/lib/functions.js.map +1 -0
- package/build-backend/lib/googleHome.js +3322 -0
- package/build-backend/lib/notifications.js +30 -0
- package/build-backend/lib/notifications.js.map +1 -0
- package/build-backend/lib/remote.js +1342 -0
- package/build-backend/lib/remote.js.map +1 -0
- package/build-backend/lib/rooms.js +48 -0
- package/build-backend/lib/rooms.js.map +1 -0
- package/build-backend/lib/texts.js +81 -0
- package/build-backend/lib/texts.js.map +1 -0
- package/build-backend/lib/translate.js +21 -0
- package/build-backend/lib/translate.js.map +1 -0
- package/build-backend/lib/visuApp.js +147 -0
- package/build-backend/lib/visuApp.js.map +1 -0
- package/build-backend/main.js +1361 -0
- package/build-backend/main.js.map +1 -0
- package/io-package.json +2 -2
- package/package.json +2 -2
- package/admin/assets/index-Y479CE6x.js +0 -681
- package/admin/rules/assets/ActionVisu__mf_v__runtimeInit__mf_v__-DtUoI3FU.js +0 -5
- package/admin/rules/assets/bootstrap-Ba57tu25.js +0 -1
- package/admin/rules/assets/index-_Y2FN5EZ.js +0 -1152
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
const Device_1 = __importDefault(require("./Device"));
|
|
40
|
+
const Utils = __importStar(require("./Helpers/Utils"));
|
|
41
|
+
const Directives_1 = __importDefault(require("./Alexa/Directives"));
|
|
42
|
+
const Controls_1 = __importDefault(require("./Controls"));
|
|
43
|
+
const Logger_1 = __importDefault(require("./Helpers/Logger"));
|
|
44
|
+
const AdapterProvider_1 = __importDefault(require("./Helpers/AdapterProvider"));
|
|
45
|
+
const AlexaResponse_1 = __importDefault(require("./Alexa/AlexaResponse"));
|
|
46
|
+
const IotProxy_1 = __importDefault(require("./Helpers/IotProxy"));
|
|
47
|
+
const RateLimiter_1 = __importDefault(require("./Helpers/RateLimiter"));
|
|
48
|
+
const OverallDailyRateLimitExceeded_1 = __importDefault(require("./Exceptions/OverallDailyRateLimitExceeded"));
|
|
49
|
+
const HourlyDeviceRateLimitExceeded_1 = __importDefault(require("./Exceptions/HourlyDeviceRateLimitExceeded"));
|
|
50
|
+
const ChangeReport_1 = __importDefault(require("./Alexa/Directives/ChangeReport"));
|
|
51
|
+
const Discovery_1 = __importDefault(require("./Alexa/Directives/Discovery"));
|
|
52
|
+
const ReportState_1 = __importDefault(require("./Alexa/Directives/ReportState"));
|
|
53
|
+
const node_crypto_1 = require("node:crypto");
|
|
54
|
+
class DeviceManager {
|
|
55
|
+
lang = 'en';
|
|
56
|
+
devices = [];
|
|
57
|
+
subscribed = [];
|
|
58
|
+
log;
|
|
59
|
+
eventsPausedTill = 0; // timestamp
|
|
60
|
+
collecting = false;
|
|
61
|
+
recollect = false;
|
|
62
|
+
/** Creates a Device Manager */
|
|
63
|
+
constructor() {
|
|
64
|
+
this.log = new Logger_1.default(this);
|
|
65
|
+
}
|
|
66
|
+
informAboutStatesChange() {
|
|
67
|
+
void AdapterProvider_1.default.get().setState('smart.updates3', true, true);
|
|
68
|
+
}
|
|
69
|
+
get language() {
|
|
70
|
+
return this.lang;
|
|
71
|
+
}
|
|
72
|
+
set language(value) {
|
|
73
|
+
this.lang = value;
|
|
74
|
+
}
|
|
75
|
+
matchDirective(event) {
|
|
76
|
+
if (ChangeReport_1.default.matches(event)) {
|
|
77
|
+
return new ChangeReport_1.default();
|
|
78
|
+
}
|
|
79
|
+
if (Discovery_1.default.matches(event)) {
|
|
80
|
+
return new Discovery_1.default();
|
|
81
|
+
}
|
|
82
|
+
if (ReportState_1.default.matches(event)) {
|
|
83
|
+
return new ReportState_1.default();
|
|
84
|
+
}
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
get endpoints() {
|
|
88
|
+
return this.devices;
|
|
89
|
+
}
|
|
90
|
+
endpointById(id) {
|
|
91
|
+
return this.devices.find(device => device.id === id);
|
|
92
|
+
}
|
|
93
|
+
addDevice(device) {
|
|
94
|
+
this.devices.push(device);
|
|
95
|
+
}
|
|
96
|
+
toDevice(detectedControls, friendlyName, autoDetected, roomName, funcName, toggle) {
|
|
97
|
+
const controls = [];
|
|
98
|
+
this.log.debug(`merging controls to a device with name ${friendlyName}`);
|
|
99
|
+
detectedControls.forEach(item => {
|
|
100
|
+
this.log.silly(`processing control: ${JSON.stringify(item)}`);
|
|
101
|
+
const control = Controls_1.default.factory(item);
|
|
102
|
+
if (control) {
|
|
103
|
+
this.log.debug(`${item.type} added to ${friendlyName}`);
|
|
104
|
+
controls.push(control);
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
this.log.debug(`control of type ${item.type} not supported yet. Skipped.`);
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
if (controls.length === 0) {
|
|
111
|
+
// the controls are not supported yet...
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
// create and add a new device to the collected devices
|
|
115
|
+
this.addDevice(new Device_1.default({
|
|
116
|
+
id: friendlyName,
|
|
117
|
+
friendlyName,
|
|
118
|
+
controls,
|
|
119
|
+
autoDetected,
|
|
120
|
+
roomName,
|
|
121
|
+
funcName,
|
|
122
|
+
toggle,
|
|
123
|
+
}));
|
|
124
|
+
}
|
|
125
|
+
getName(name) {
|
|
126
|
+
if (!name) {
|
|
127
|
+
return '';
|
|
128
|
+
}
|
|
129
|
+
if (typeof name === 'object') {
|
|
130
|
+
return name[this.lang] || name.en || '';
|
|
131
|
+
}
|
|
132
|
+
return name;
|
|
133
|
+
}
|
|
134
|
+
async collectEndpoints() {
|
|
135
|
+
if (this.collecting) {
|
|
136
|
+
this.log.debug(`collecting devices already in progress. Skipping...`);
|
|
137
|
+
this.recollect = true;
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
this.collecting = true;
|
|
141
|
+
this.log.debug(`(re)collecting devices...`);
|
|
142
|
+
try {
|
|
143
|
+
// const discoveryNeeded = this.devices.length > 0;
|
|
144
|
+
this.devices = [];
|
|
145
|
+
const defaultToggle = AdapterProvider_1.default.get().config.defaultToggle || false;
|
|
146
|
+
// collect all iobroker controls in terms of iobroker type detector (https://github.com/ioBroker/ioBroker.type-detector)
|
|
147
|
+
let detectedControls = await Utils.controls(AdapterProvider_1.default.get(), this.lang);
|
|
148
|
+
this.log.debug(`type detector found ${detectedControls.length} controls`);
|
|
149
|
+
// Normally, every control is a smart device. But due to the iobroker concept of 'rooms and functions'
|
|
150
|
+
// multiple controls might be merged to a single device.
|
|
151
|
+
// as long as not all controls mapped to a device...
|
|
152
|
+
// detectedControls = detectedControls.filter(c => ['light', 'dimmer'].includes(c.type));
|
|
153
|
+
const createdGroups = [];
|
|
154
|
+
while (detectedControls.length) {
|
|
155
|
+
// take the next control
|
|
156
|
+
const control = detectedControls[0];
|
|
157
|
+
let processedControls = [];
|
|
158
|
+
if (control.room?.common?.name) {
|
|
159
|
+
if (control.functionality?.common?.name) {
|
|
160
|
+
// controls in the same room with the same functionality
|
|
161
|
+
processedControls = detectedControls.filter(item => control.room &&
|
|
162
|
+
item.room?.id === control.room.id &&
|
|
163
|
+
control.functionality &&
|
|
164
|
+
item.functionality?.id === control.functionality.id);
|
|
165
|
+
this.toDevice(processedControls, Utils.friendlyNameByRoomAndFunctionName(control, this.lang), true, this.getName(control.room?.common?.name), this.getName(control.functionality?.common?.name), processedControls[0].object?.toggle ?? defaultToggle);
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
this.log.debug(`Control of type [${control.type}] assigned to room [${this.getName(control.room.common.name)}] has no function. Skipped.`);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
else if (control.groupNames) {
|
|
172
|
+
// no room, but smart name (not only one)
|
|
173
|
+
control.groupNames.forEach(groupName => {
|
|
174
|
+
if (!createdGroups.includes(groupName)) {
|
|
175
|
+
createdGroups.push(groupName);
|
|
176
|
+
processedControls = detectedControls.filter(item => item.groupNames?.includes(groupName));
|
|
177
|
+
this.toDevice(processedControls, this.getName(groupName), false, undefined, undefined, processedControls[0].object?.toggle ?? defaultToggle);
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
// neither room nor smart name
|
|
183
|
+
this.log.debug(`Control of type [${control.type}] has neither room no smart name. Skipped.`);
|
|
184
|
+
}
|
|
185
|
+
if (processedControls.length === 0) {
|
|
186
|
+
processedControls = [control];
|
|
187
|
+
}
|
|
188
|
+
// remove processed controls
|
|
189
|
+
const objectIds = processedControls.map(item => item.object?.id);
|
|
190
|
+
detectedControls = detectedControls.filter(item => item.object && !objectIds.includes(item.object.id));
|
|
191
|
+
}
|
|
192
|
+
// done
|
|
193
|
+
this.log.debug(`finished collecting devices. there is/are ${this.devices.length} device(s) in total`);
|
|
194
|
+
for (const device of this.devices) {
|
|
195
|
+
this.log.debug(`${device.toString()}`);
|
|
196
|
+
}
|
|
197
|
+
// a new discovery process is needed in case we had already devices and device collection was
|
|
198
|
+
// triggered again by, e.g., a change in room/function enums
|
|
199
|
+
// if (discoveryNeeded) {
|
|
200
|
+
// this.log.info(`Please delete all managed by ioBroker devices in your Alexa app and then start discovery`);
|
|
201
|
+
// }
|
|
202
|
+
// collect all relevant states to subscribe to updates
|
|
203
|
+
const stateIds = new Set(this.devices
|
|
204
|
+
.flatMap(d => d.controls)
|
|
205
|
+
.flatMap(item => item.supported)
|
|
206
|
+
.flatMap(item => item.properties)
|
|
207
|
+
.map(item => item.getId)
|
|
208
|
+
.filter(id => id));
|
|
209
|
+
this.log.debug(`registering for updates of total ${stateIds.size} states`);
|
|
210
|
+
const promises = [];
|
|
211
|
+
const newSubscribed = Array.from(stateIds);
|
|
212
|
+
// subscribe to updates
|
|
213
|
+
for (const id of newSubscribed) {
|
|
214
|
+
this.log.silly(`subscribing to updates of ${id}`);
|
|
215
|
+
if (!this.subscribed.includes(id)) {
|
|
216
|
+
this.subscribed.push(id);
|
|
217
|
+
promises.push(AdapterProvider_1.default.subscribe(id));
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
this.subscribed.sort();
|
|
221
|
+
// wait till all promises are settled
|
|
222
|
+
const results = await Promise.allSettled(promises);
|
|
223
|
+
// unsubscribe from unused states
|
|
224
|
+
for (let i = this.subscribed.length - 1; i >= 0; i--) {
|
|
225
|
+
const id = this.subscribed[i];
|
|
226
|
+
if (!newSubscribed.includes(id)) {
|
|
227
|
+
this.log.silly(`unsubscribing from updates of ${id}`);
|
|
228
|
+
this.subscribed.splice(i, 1);
|
|
229
|
+
await AdapterProvider_1.default.unsubscribe(id);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
const failedReasons = results.filter(item => item.status !== 'fulfilled').flatMap(item => item.reason);
|
|
233
|
+
if (failedReasons.length) {
|
|
234
|
+
this.log.debug(`failed to subscribe for updates of ${failedReasons.length} states`);
|
|
235
|
+
try {
|
|
236
|
+
for (const reason of failedReasons) {
|
|
237
|
+
this.log.silly(`failed subscribing: ${typeof reason === 'string' ? reason : JSON.stringify(reason)}`);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
catch {
|
|
241
|
+
// nop
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
catch (e) {
|
|
246
|
+
this.log.error(`failed to collect devices: ${e}`);
|
|
247
|
+
}
|
|
248
|
+
this.collecting = false;
|
|
249
|
+
// if during the collection a new collection was triggered, start collecting again
|
|
250
|
+
if (this.recollect) {
|
|
251
|
+
this.recollect = false;
|
|
252
|
+
setTimeout(() => this.collectEndpoints(), 1000);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
async destroy() {
|
|
256
|
+
const promises = [];
|
|
257
|
+
for (const id of this.subscribed) {
|
|
258
|
+
this.log.silly(`unsubscribing from updates of ${id}`);
|
|
259
|
+
promises.push(AdapterProvider_1.default.subscribe(id));
|
|
260
|
+
}
|
|
261
|
+
await Promise.allSettled(promises);
|
|
262
|
+
this.subscribed = [];
|
|
263
|
+
}
|
|
264
|
+
publishStateChange(stateChange) {
|
|
265
|
+
if (this.eventsPausedTill < Date.now()) {
|
|
266
|
+
this.log.silly(`publishing ${JSON.stringify(stateChange)}`);
|
|
267
|
+
IotProxy_1.default.publishStateChange(stateChange);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
pauseEvents() {
|
|
271
|
+
this.eventsPausedTill = Date.now() + 30 * 60 * 1000; // 30 minutes
|
|
272
|
+
}
|
|
273
|
+
async executeWithinRateLimits(endpointId, awaitable, errorResponse) {
|
|
274
|
+
try {
|
|
275
|
+
await RateLimiter_1.default.incrementAndGet(endpointId);
|
|
276
|
+
return await awaitable();
|
|
277
|
+
}
|
|
278
|
+
catch (error) {
|
|
279
|
+
if (error instanceof OverallDailyRateLimitExceeded_1.default || error instanceof HourlyDeviceRateLimitExceeded_1.default) {
|
|
280
|
+
this.log.warn(error.message);
|
|
281
|
+
}
|
|
282
|
+
else {
|
|
283
|
+
this.log.error(error.message);
|
|
284
|
+
}
|
|
285
|
+
return errorResponse;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
async handleAlexaEvent(event) {
|
|
289
|
+
this.log.debug(`incoming Alexa event`);
|
|
290
|
+
this.log.silly(`${JSON.stringify(event)}`);
|
|
291
|
+
if (!event?.directive?.header) {
|
|
292
|
+
throw new Error('Alexa event header is missing');
|
|
293
|
+
}
|
|
294
|
+
let response;
|
|
295
|
+
const directive = this.matchDirective(event);
|
|
296
|
+
if (directive) {
|
|
297
|
+
response = await directive.handle(event, this);
|
|
298
|
+
}
|
|
299
|
+
else {
|
|
300
|
+
const endpointId = event?.directive?.endpoint?.endpointId;
|
|
301
|
+
const device = endpointId ? this.endpointById(endpointId) : undefined;
|
|
302
|
+
if (device) {
|
|
303
|
+
if (device.supports(event)) {
|
|
304
|
+
response = await this.executeWithinRateLimits(endpointId, async () => {
|
|
305
|
+
response = await device.handle(event);
|
|
306
|
+
if (!AlexaResponse_1.default.isErrorResponse(response)) {
|
|
307
|
+
// report state change via voice interaction
|
|
308
|
+
const propertyName = response.context?.properties[0].name;
|
|
309
|
+
const responseEvent = ChangeReport_1.default.get(device.id, propertyName || '', false, event.directive.header.messageId);
|
|
310
|
+
const directive = this.matchDirective(responseEvent);
|
|
311
|
+
if (directive) {
|
|
312
|
+
// BF[2024.02.04]: temporarily disabled as produced a huge number of events
|
|
313
|
+
// const stateChange = await directive.handle(responseEvent, this);
|
|
314
|
+
// get device state (not just one control)
|
|
315
|
+
const deviceState = await device.reportState();
|
|
316
|
+
if (JSON.stringify(device.lastReportedState) !== JSON.stringify(deviceState)) {
|
|
317
|
+
device.lastReportedState = deviceState;
|
|
318
|
+
// fire state change report to Alexa
|
|
319
|
+
// BF[2024.02.04]: temporarily disabled as produced a huge number of events
|
|
320
|
+
// this.publishStateChange(stateChange);
|
|
321
|
+
this.informAboutStatesChange();
|
|
322
|
+
}
|
|
323
|
+
else {
|
|
324
|
+
this.log.debug(`ignoring state change event for ${endpointId} due to the same_ value [${JSON.stringify(deviceState)}]`);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
return response;
|
|
329
|
+
}, AlexaResponse_1.default.endpointUnreachable(event.directive.header.messageId).get());
|
|
330
|
+
}
|
|
331
|
+
else {
|
|
332
|
+
response = AlexaResponse_1.default.directiveNotSupportedByDevice(device.friendlyName, event.directive.header.namespace, event.directive.header.messageId, event.directive.header.payloadVersion).get();
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
else {
|
|
336
|
+
response = AlexaResponse_1.default.endpointUnreachable(event.directive.header.messageId).get();
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
this.log.silly(`response: ${JSON.stringify(response)}`);
|
|
340
|
+
return response;
|
|
341
|
+
}
|
|
342
|
+
async handleStateUpdate(id, state) {
|
|
343
|
+
// ignore updates not confirmed by a corresponding device
|
|
344
|
+
if (!state?.ack) {
|
|
345
|
+
this.log.silly(`ignoring state change event for ${id} due to state.ack == ${state?.ack}`);
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
let notFound = true;
|
|
349
|
+
for (const device of this.devices) {
|
|
350
|
+
const property = device.controls
|
|
351
|
+
.flatMap(item => item.supported)
|
|
352
|
+
.flatMap(item => item.properties)
|
|
353
|
+
.find(item => item.getId === id);
|
|
354
|
+
if (property) {
|
|
355
|
+
notFound = false;
|
|
356
|
+
if (property.currentValue === state.val) {
|
|
357
|
+
this.log.debug(`ignoring state change event for ${id} due to the same value [${state.val}]`);
|
|
358
|
+
}
|
|
359
|
+
else {
|
|
360
|
+
property.currentValue = state.val;
|
|
361
|
+
const responseEvent = Directives_1.default.ChangeReport.get(device.id, property.propertyName, true, (0, node_crypto_1.randomUUID)());
|
|
362
|
+
const directive = this.matchDirective(responseEvent);
|
|
363
|
+
if (directive) {
|
|
364
|
+
// BF[2024.02.04]: temporarily disabled as produced a huge number of events
|
|
365
|
+
// const stateChange = await directive.handle(event, this);
|
|
366
|
+
// get device state (not just one control)
|
|
367
|
+
const deviceState = await device.reportState();
|
|
368
|
+
if (JSON.stringify(device.lastReportedState) !== JSON.stringify(deviceState)) {
|
|
369
|
+
device.lastReportedState = deviceState;
|
|
370
|
+
this.informAboutStatesChange();
|
|
371
|
+
// fire state change report to Alexa
|
|
372
|
+
// BF[2024.02.04]: temporarily disabled as produced a huge number of events
|
|
373
|
+
// await this.executeWithinRateLimits(device.id, async () =>
|
|
374
|
+
// this.publishStateChange(stateChange), undefined);
|
|
375
|
+
}
|
|
376
|
+
else {
|
|
377
|
+
this.log.debug(`ignoring state change event for ${id} due to the same_ value [${JSON.stringify(deviceState)}]`);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
// should be the only device having the id => stop processing here
|
|
382
|
+
break;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
// this should never happen
|
|
386
|
+
if (notFound) {
|
|
387
|
+
this.log.debug(`state id ${id} doesn't belong to any device`);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
exports.default = DeviceManager;
|
|
392
|
+
//# sourceMappingURL=DeviceManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DeviceManager.js","sourceRoot":"","sources":["../../../src/lib/AlexaSmartHomeV3/DeviceManager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sDAA8B;AAC9B,uDAAyC;AACzC,oEAA4C;AAC5C,0DAAkC;AAElC,8DAAsC;AACtC,gFAAwD;AACxD,0EAAkD;AAClD,kEAA0C;AAC1C,wEAAgD;AAChD,+GAAuF;AACvF,+GAAuF;AAEvF,mFAA2D;AAC3D,6EAAqD;AACrD,iFAAyD;AACzD,6CAAyC;AAEzC,MAAqB,aAAa;IACtB,IAAI,GAAuB,IAAI,CAAC;IAChC,OAAO,GAAa,EAAE,CAAC;IACvB,UAAU,GAAa,EAAE,CAAC;IAC1B,GAAG,CAAS;IACZ,gBAAgB,GAAG,CAAC,CAAC,CAAC,YAAY;IAElC,UAAU,GA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AAC;oBAElC,MAAM,aAAa,GAAG,oBAAU,CAAC,YAAY,CAAC,GAAG,CAC7C,MAAM,CAAC,EAAE,EACT,QAAQ,CAAC,YAAY,EACrB,IAAI,EACJ,IAAA,wBAAU,GAAE,CACf,CAAC;oBACF,MAAM,SAAS,GAAG,IAAI,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC;oBACrD,IAAI,SAAS,EAAE,CAAC;wBACZ,2EAA2E;wBAC3E,2DAA2D;wBAE3D,0CAA0C;wBAC1C,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,WAAW,EAAE,CAAC;wBAE/C,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,EAAE,CAAC;4BAC3E,MAAM,CAAC,iBAAiB,GAAG,WAAW,CAAC;4BACvC,IAAI,CAAC,uBAAuB,EAAE,CAAC;4BAC/B,oCAAoC;4BAEpC,2EAA2E;4BAC3E,4DAA4D;4BAC5D,wDAAwD;wBAC5D,CAAC;6BAAM,CAAC;4BACJ,IAAI,CAAC,GAAG,CAAC,KAAK,CACV,mCAAmC,EAAE,4BAA4B,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,GAAG,CAClG,CAAC;wBACN,CAAC;oBACL,CAAC;gBACL,CAAC;gBAED,kEAAkE;gBAClE,MAAM;YACV,CAAC;QACL,CAAC;QAED,2BAA2B;QAC3B,IAAI,QAAQ,EAAE,CAAC;YACX,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,YAAY,EAAE,+BAA+B,CAAC,CAAC;QAClE,CAAC;IACL,CAAC;CACJ;AArbD,gCAqbC","sourcesContent":["import Device from './Device';\nimport * as Utils from './Helpers/Utils';\nimport Directives from './Alexa/Directives';\nimport Controls from './Controls';\nimport type Control from './Controls/Control';\nimport Logger from './Helpers/Logger';\nimport AdapterProvider from './Helpers/AdapterProvider';\nimport AlexaResponse from './Alexa/AlexaResponse';\nimport IotProxy from './Helpers/IotProxy';\nimport RateLimiter from './Helpers/RateLimiter';\nimport OverallDailyRateLimitExceeded from './Exceptions/OverallDailyRateLimitExceeded';\nimport HourlyDeviceRateLimitExceeded from './Exceptions/HourlyDeviceRateLimitExceeded';\nimport type { AlexaV3EndpointID, AlexaV3Request, IotExternalPatternControl } from './types';\nimport ChangeReport from './Alexa/Directives/ChangeReport';\nimport Discovery from './Alexa/Directives/Discovery';\nimport ReportState from './Alexa/Directives/ReportState';\nimport { randomUUID } from 'node:crypto';\n\nexport default class DeviceManager {\n private lang: ioBroker.Languages = 'en';\n private devices: Device[] = [];\n private subscribed: string[] = [];\n private log: Logger;\n private eventsPausedTill = 0; // timestamp\n\n private collecting = false;\n private recollect = false;\n\n /** Creates a Device Manager */\n constructor() {\n this.log = new Logger(this);\n }\n\n informAboutStatesChange(): void {\n void AdapterProvider.get().setState('smart.updates3', true, true);\n }\n\n get language(): ioBroker.Languages {\n return this.lang;\n }\n\n set language(value: ioBroker.Languages) {\n this.lang = value;\n }\n\n matchDirective(event: AlexaV3Request): ChangeReport | Discovery | ReportState | null {\n if (ChangeReport.matches(event)) {\n return new ChangeReport();\n }\n if (Discovery.matches(event)) {\n return new Discovery();\n }\n if (ReportState.matches(event)) {\n return new ReportState();\n }\n\n return null;\n }\n\n get endpoints(): Device[] {\n return this.devices;\n }\n\n endpointById(id: AlexaV3EndpointID): Device | undefined {\n return this.devices.find(device => device.id === id);\n }\n\n addDevice(device: Device): void {\n this.devices.push(device);\n }\n\n toDevice(\n detectedControls: IotExternalPatternControl[],\n friendlyName: string,\n autoDetected: boolean,\n roomName: string | undefined,\n funcName: string | undefined,\n toggle?: boolean,\n ): Device | undefined {\n const controls: Control[] = [];\n\n this.log.debug(`merging controls to a device with name ${friendlyName}`);\n\n detectedControls.forEach(item => {\n this.log.silly(`processing control: ${JSON.stringify(item)}`);\n const control = Controls.factory(item);\n if (control) {\n this.log.debug(`${item.type} added to ${friendlyName}`);\n controls.push(control);\n } else {\n this.log.debug(`control of type ${item.type} not supported yet. Skipped.`);\n }\n });\n\n if (controls.length === 0) {\n // the controls are not supported yet...\n return;\n }\n\n // create and add a new device to the collected devices\n this.addDevice(\n new Device({\n id: friendlyName,\n friendlyName,\n controls,\n autoDetected,\n roomName,\n funcName,\n toggle,\n }),\n );\n }\n\n getName(name: ioBroker.StringOrTranslated | undefined): string {\n if (!name) {\n return '';\n }\n if (typeof name === 'object') {\n return name[this.lang] || name.en || '';\n }\n return name;\n }\n\n async collectEndpoints(): Promise<void> {\n if (this.collecting) {\n this.log.debug(`collecting devices already in progress. Skipping...`);\n this.recollect = true;\n return;\n }\n this.collecting = true;\n this.log.debug(`(re)collecting devices...`);\n try {\n // const discoveryNeeded = this.devices.length > 0;\n\n this.devices = [];\n const defaultToggle = AdapterProvider.get().config.defaultToggle || false;\n\n // collect all iobroker controls in terms of iobroker type detector (https://github.com/ioBroker/ioBroker.type-detector)\n let detectedControls = await Utils.controls(AdapterProvider.get(), this.lang);\n\n this.log.debug(`type detector found ${detectedControls.length} controls`);\n\n // Normally, every control is a smart device. But due to the iobroker concept of 'rooms and functions'\n // multiple controls might be merged to a single device.\n\n // as long as not all controls mapped to a device...\n\n // detectedControls = detectedControls.filter(c => ['light', 'dimmer'].includes(c.type));\n const createdGroups: string[] = [];\n\n while (detectedControls.length) {\n // take the next control\n const control = detectedControls[0];\n let processedControls: IotExternalPatternControl[] = [];\n\n if (control.room?.common?.name) {\n if (control.functionality?.common?.name) {\n // controls in the same room with the same functionality\n processedControls = detectedControls.filter(\n item =>\n control.room &&\n item.room?.id === control.room.id &&\n control.functionality &&\n item.functionality?.id === control.functionality.id,\n );\n this.toDevice(\n processedControls,\n Utils.friendlyNameByRoomAndFunctionName(control, this.lang),\n true,\n this.getName(control.room?.common?.name),\n this.getName(control.functionality?.common?.name),\n processedControls[0].object?.toggle ?? defaultToggle,\n );\n } else {\n this.log.debug(\n `Control of type [${control.type}] assigned to room [${this.getName(control.room.common.name)}] has no function. Skipped.`,\n );\n }\n } else if (control.groupNames) {\n // no room, but smart name (not only one)\n control.groupNames.forEach(groupName => {\n if (!createdGroups.includes(groupName)) {\n createdGroups.push(groupName);\n processedControls = detectedControls.filter(item => item.groupNames?.includes(groupName));\n this.toDevice(\n processedControls,\n this.getName(groupName),\n false,\n undefined,\n undefined,\n processedControls[0].object?.toggle ?? defaultToggle,\n );\n }\n });\n } else {\n // neither room nor smart name\n this.log.debug(`Control of type [${control.type}] has neither room no smart name. Skipped.`);\n }\n\n if (processedControls.length === 0) {\n processedControls = [control];\n }\n\n // remove processed controls\n const objectIds = processedControls.map(item => item.object?.id);\n detectedControls = detectedControls.filter(item => item.object && !objectIds.includes(item.object.id));\n }\n\n // done\n this.log.debug(`finished collecting devices. there is/are ${this.devices.length} device(s) in total`);\n for (const device of this.devices) {\n this.log.debug(`${device.toString()}`);\n }\n\n // a new discovery process is needed in case we had already devices and device collection was\n // triggered again by, e.g., a change in room/function enums\n // if (discoveryNeeded) {\n // this.log.info(`Please delete all managed by ioBroker devices in your Alexa app and then start discovery`);\n // }\n\n // collect all relevant states to subscribe to updates\n const stateIds = new Set(\n this.devices\n .flatMap(d => d.controls)\n .flatMap(item => item.supported)\n .flatMap(item => item.properties)\n .map(item => item.getId)\n .filter(id => id),\n );\n this.log.debug(`registering for updates of total ${stateIds.size} states`);\n const promises = [];\n const newSubscribed = Array.from(stateIds);\n // subscribe to updates\n for (const id of newSubscribed) {\n this.log.silly(`subscribing to updates of ${id}`);\n if (!this.subscribed.includes(id)) {\n this.subscribed.push(id);\n promises.push(AdapterProvider.subscribe(id));\n }\n }\n\n this.subscribed.sort();\n\n // wait till all promises are settled\n const results = await Promise.allSettled(promises);\n\n // unsubscribe from unused states\n for (let i = this.subscribed.length - 1; i >= 0; i--) {\n const id = this.subscribed[i];\n if (!newSubscribed.includes(id)) {\n this.log.silly(`unsubscribing from updates of ${id}`);\n this.subscribed.splice(i, 1);\n await AdapterProvider.unsubscribe(id);\n }\n }\n\n const failedReasons = results.filter(item => item.status !== 'fulfilled').flatMap(item => item.reason);\n if (failedReasons.length) {\n this.log.debug(`failed to subscribe for updates of ${failedReasons.length} states`);\n try {\n for (const reason of failedReasons) {\n this.log.silly(\n `failed subscribing: ${typeof reason === 'string' ? reason : JSON.stringify(reason)}`,\n );\n }\n } catch {\n // nop\n }\n }\n } catch (e) {\n this.log.error(`failed to collect devices: ${e}`);\n }\n\n this.collecting = false;\n\n // if during the collection a new collection was triggered, start collecting again\n if (this.recollect) {\n this.recollect = false;\n setTimeout(() => this.collectEndpoints(), 1000);\n }\n }\n\n async destroy(): Promise<void> {\n const promises = [];\n for (const id of this.subscribed) {\n this.log.silly(`unsubscribing from updates of ${id}`);\n promises.push(AdapterProvider.subscribe(id));\n }\n await Promise.allSettled(promises);\n\n this.subscribed = [];\n }\n\n publishStateChange(stateChange: AlexaResponse): void {\n if (this.eventsPausedTill < Date.now()) {\n this.log.silly(`publishing ${JSON.stringify(stateChange)}`);\n IotProxy.publishStateChange(stateChange);\n }\n }\n\n pauseEvents(): void {\n this.eventsPausedTill = Date.now() + 30 * 60 * 1000; // 30 minutes\n }\n\n async executeWithinRateLimits(\n endpointId: AlexaV3EndpointID,\n awaitable: () => Promise<AlexaResponse>,\n errorResponse: AlexaResponse,\n ): Promise<AlexaResponse> {\n try {\n await RateLimiter.incrementAndGet(endpointId);\n return await awaitable();\n } catch (error) {\n if (error instanceof OverallDailyRateLimitExceeded || error instanceof HourlyDeviceRateLimitExceeded) {\n this.log.warn(error.message);\n } else {\n this.log.error(error.message);\n }\n\n return errorResponse;\n }\n }\n\n async handleAlexaEvent(event: AlexaV3Request): Promise<AlexaResponse> {\n this.log.debug(`incoming Alexa event`);\n this.log.silly(`${JSON.stringify(event)}`);\n if (!event?.directive?.header) {\n throw new Error('Alexa event header is missing');\n }\n\n let response: AlexaResponse;\n const directive = this.matchDirective(event);\n if (directive) {\n response = await directive.handle(event, this);\n } else {\n const endpointId = event?.directive?.endpoint?.endpointId;\n const device = endpointId ? this.endpointById(endpointId) : undefined;\n\n if (device) {\n if (device.supports(event)) {\n response = await this.executeWithinRateLimits(\n endpointId!,\n async () => {\n response = await device.handle(event);\n if (!AlexaResponse.isErrorResponse(response)) {\n // report state change via voice interaction\n const propertyName = response.context?.properties[0].name;\n const responseEvent = ChangeReport.get(\n device.id,\n propertyName || '',\n false,\n event.directive.header.messageId,\n );\n const directive = this.matchDirective(responseEvent);\n if (directive) {\n // BF[2024.02.04]: temporarily disabled as produced a huge number of events\n // const stateChange = await directive.handle(responseEvent, this);\n // get device state (not just one control)\n const deviceState = await device.reportState();\n if (JSON.stringify(device.lastReportedState) !== JSON.stringify(deviceState)) {\n device.lastReportedState = deviceState;\n // fire state change report to Alexa\n // BF[2024.02.04]: temporarily disabled as produced a huge number of events\n // this.publishStateChange(stateChange);\n this.informAboutStatesChange();\n } else {\n this.log.debug(\n `ignoring state change event for ${endpointId} due to the same_ value [${JSON.stringify(deviceState)}]`,\n );\n }\n }\n }\n return response;\n },\n AlexaResponse.endpointUnreachable(event.directive.header.messageId).get(),\n );\n } else {\n response = AlexaResponse.directiveNotSupportedByDevice(\n device.friendlyName,\n event.directive.header.namespace,\n event.directive.header.messageId,\n event.directive.header.payloadVersion,\n ).get();\n }\n } else {\n response = AlexaResponse.endpointUnreachable(event.directive.header.messageId).get();\n }\n }\n\n this.log.silly(`response: ${JSON.stringify(response)}`);\n return response;\n }\n\n async handleStateUpdate(id: string, state: ioBroker.State | null | undefined): Promise<void> {\n // ignore updates not confirmed by a corresponding device\n if (!state?.ack) {\n this.log.silly(`ignoring state change event for ${id} due to state.ack == ${state?.ack}`);\n return;\n }\n\n let notFound = true;\n\n for (const device of this.devices) {\n const property = device.controls\n .flatMap(item => item.supported)\n .flatMap(item => item.properties)\n .find(item => item.getId === id);\n\n if (property) {\n notFound = false;\n if (property.currentValue === state.val) {\n this.log.debug(`ignoring state change event for ${id} due to the same value [${state.val}]`);\n } else {\n property.currentValue = state.val;\n\n const responseEvent = Directives.ChangeReport.get(\n device.id,\n property.propertyName,\n true,\n randomUUID(),\n );\n const directive = this.matchDirective(responseEvent);\n if (directive) {\n // BF[2024.02.04]: temporarily disabled as produced a huge number of events\n // const stateChange = await directive.handle(event, this);\n\n // get device state (not just one control)\n const deviceState = await device.reportState();\n\n if (JSON.stringify(device.lastReportedState) !== JSON.stringify(deviceState)) {\n device.lastReportedState = deviceState;\n this.informAboutStatesChange();\n // fire state change report to Alexa\n\n // BF[2024.02.04]: temporarily disabled as produced a huge number of events\n // await this.executeWithinRateLimits(device.id, async () =>\n // this.publishStateChange(stateChange), undefined);\n } else {\n this.log.debug(\n `ignoring state change event for ${id} due to the same_ value [${JSON.stringify(deviceState)}]`,\n );\n }\n }\n }\n\n // should be the only device having the id => stop processing here\n break;\n }\n }\n\n // this should never happen\n if (notFound) {\n this.log.debug(`state id ${id} doesn't belong to any device`);\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class AlexaV3Exception extends Error {
|
|
4
|
+
constructor(message) {
|
|
5
|
+
super(message);
|
|
6
|
+
this.name = this.constructor.name;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
exports.default = AlexaV3Exception;
|
|
10
|
+
//# sourceMappingURL=AlexaV3Exception.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AlexaV3Exception.js","sourceRoot":"","sources":["../../../../src/lib/AlexaSmartHomeV3/Exceptions/AlexaV3Exception.ts"],"names":[],"mappings":";;AAAA,MAAqB,gBAAiB,SAAQ,KAAK;IAC/C,YAAY,OAAe;QACvB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;IACtC,CAAC;CACJ;AALD,mCAKC","sourcesContent":["export default class AlexaV3Exception extends Error {\n constructor(message: string) {\n super(message);\n this.name = this.constructor.name;\n }\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
const AlexaV3Exception_1 = __importDefault(require("./AlexaV3Exception"));
|
|
7
|
+
class HourlyDeviceRateLimitExceeded extends AlexaV3Exception_1.default {
|
|
8
|
+
}
|
|
9
|
+
exports.default = HourlyDeviceRateLimitExceeded;
|
|
10
|
+
//# sourceMappingURL=HourlyDeviceRateLimitExceeded.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HourlyDeviceRateLimitExceeded.js","sourceRoot":"","sources":["../../../../src/lib/AlexaSmartHomeV3/Exceptions/HourlyDeviceRateLimitExceeded.ts"],"names":[],"mappings":";;;;;AAAA,0EAAkD;AAElD,MAAqB,6BAA8B,SAAQ,0BAAgB;CAAG;AAA9E,gDAA8E","sourcesContent":["import AlexaV3Exception from './AlexaV3Exception';\n\nexport default class HourlyDeviceRateLimitExceeded extends AlexaV3Exception {}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
const AlexaV3Exception_1 = __importDefault(require("./AlexaV3Exception"));
|
|
7
|
+
class OverallDailyRateLimitExceeded extends AlexaV3Exception_1.default {
|
|
8
|
+
}
|
|
9
|
+
exports.default = OverallDailyRateLimitExceeded;
|
|
10
|
+
//# sourceMappingURL=OverallDailyRateLimitExceeded.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OverallDailyRateLimitExceeded.js","sourceRoot":"","sources":["../../../../src/lib/AlexaSmartHomeV3/Exceptions/OverallDailyRateLimitExceeded.ts"],"names":[],"mappings":";;;;;AAAA,0EAAkD;AAElD,MAAqB,6BAA8B,SAAQ,0BAAgB;CAAG;AAA9E,gDAA8E","sourcesContent":["import AlexaV3Exception from './AlexaV3Exception';\n\nexport default class OverallDailyRateLimitExceeded extends AlexaV3Exception {}\n"]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class AdapterProvider {
|
|
4
|
+
static adapterInstance;
|
|
5
|
+
static init(adapter) {
|
|
6
|
+
AdapterProvider.adapterInstance = adapter;
|
|
7
|
+
}
|
|
8
|
+
static get() {
|
|
9
|
+
return AdapterProvider.adapterInstance;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Sets iobroker state to the passed on value
|
|
13
|
+
*
|
|
14
|
+
* @param id - id of the state to write the value to
|
|
15
|
+
* @param value - value to set the provided state to
|
|
16
|
+
*/
|
|
17
|
+
static async setState(id, value) {
|
|
18
|
+
await AdapterProvider.get().setForeignStateAsync(id, value, false);
|
|
19
|
+
AdapterProvider.get().log.silly(`[AlexaV3::AdapterProvider]: set [${id}] to [${value}]`);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* @param id State id to get the value from
|
|
23
|
+
* @returns Object's val returned by the iobroker getForeignStateAsync function
|
|
24
|
+
*/
|
|
25
|
+
static async getState(id) {
|
|
26
|
+
const state = await AdapterProvider.get().getForeignStateAsync(id);
|
|
27
|
+
return state?.val;
|
|
28
|
+
}
|
|
29
|
+
static async subscribe(id) {
|
|
30
|
+
await AdapterProvider.get().subscribeForeignStatesAsync(id);
|
|
31
|
+
}
|
|
32
|
+
static async unsubscribe(id) {
|
|
33
|
+
await AdapterProvider.get().unsubscribeForeignStatesAsync(id);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.default = AdapterProvider;
|
|
37
|
+
//# sourceMappingURL=AdapterProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AdapterProvider.js","sourceRoot":"","sources":["../../../../src/lib/AlexaSmartHomeV3/Helpers/AdapterProvider.ts"],"names":[],"mappings":";;AAEA,MAAqB,eAAe;IAChC,MAAM,CAAC,eAAe,CAAa;IAEnC,MAAM,CAAC,IAAI,CAAC,OAAmB;QAC3B,eAAe,CAAC,eAAe,GAAG,OAAO,CAAC;IAC9C,CAAC;IAED,MAAM,CAAC,GAAG;QACN,OAAO,eAAe,CAAC,eAAe,CAAC;IAC3C,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAU,EAAE,KAA0B;QACxD,MAAM,eAAe,CAAC,GAAG,EAAE,CAAC,oBAAoB,CAAC,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;QACnE,eAAe,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,oCAAoC,EAAE,SAAS,KAAK,GAAG,CAAC,CAAC;IAC7F,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAU;QAC5B,MAAM,KAAK,GAAG,MAAM,eAAe,CAAC,GAAG,EAAE,CAAC,oBAAoB,CAAC,EAAE,CAAC,CAAC;QACnE,OAAO,KAAK,EAAE,GAAG,CAAC;IACtB,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,EAAU;QAC7B,MAAM,eAAe,CAAC,GAAG,EAAE,CAAC,2BAA2B,CAAC,EAAE,CAAC,CAAC;IAChE,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,EAAU;QAC/B,MAAM,eAAe,CAAC,GAAG,EAAE,CAAC,6BAA6B,CAAC,EAAE,CAAC,CAAC;IAClE,CAAC;CACJ;AAtCD,kCAsCC","sourcesContent":["import type { IotAdapter } from '../../../main';\n\nexport default class AdapterProvider {\n static adapterInstance: IotAdapter;\n\n static init(adapter: IotAdapter): void {\n AdapterProvider.adapterInstance = adapter;\n }\n\n static get(): IotAdapter {\n return AdapterProvider.adapterInstance;\n }\n\n /**\n * Sets iobroker state to the passed on value\n *\n * @param id - id of the state to write the value to\n * @param value - value to set the provided state to\n */\n static async setState(id: string, value: ioBroker.StateValue): Promise<void> {\n await AdapterProvider.get().setForeignStateAsync(id, value, false);\n AdapterProvider.get().log.silly(`[AlexaV3::AdapterProvider]: set [${id}] to [${value}]`);\n }\n\n /**\n * @param id State id to get the value from\n * @returns Object's val returned by the iobroker getForeignStateAsync function\n */\n static async getState(id: string): Promise<ioBroker.StateValue | undefined> {\n const state = await AdapterProvider.get().getForeignStateAsync(id);\n return state?.val;\n }\n\n static async subscribe(id: string): Promise<void> {\n await AdapterProvider.get().subscribeForeignStatesAsync(id);\n }\n\n static async unsubscribe(id: string): Promise<void> {\n await AdapterProvider.get().unsubscribeForeignStatesAsync(id);\n }\n}\n"]}
|
|
@@ -0,0 +1,53 @@
|
|
|
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
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
7
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
+
const adapter_core_1 = __importDefault(require("@iobroker/adapter-core"));
|
|
9
|
+
const AdapterProvider_1 = __importDefault(require("./AdapterProvider"));
|
|
10
|
+
class FileHelper {
|
|
11
|
+
static _rootFolder;
|
|
12
|
+
static get rootFolder() {
|
|
13
|
+
this._rootFolder ||= adapter_core_1.default.getAbsoluteInstanceDataDir(AdapterProvider_1.default.get());
|
|
14
|
+
return this._rootFolder;
|
|
15
|
+
}
|
|
16
|
+
static async createFolder(folderPath) {
|
|
17
|
+
return new Promise((resolve, reject) => {
|
|
18
|
+
node_fs_1.default.access(folderPath, error => {
|
|
19
|
+
if (error) {
|
|
20
|
+
// If the directory does not exist, then create it
|
|
21
|
+
node_fs_1.default.mkdir(folderPath, { recursive: true }, error => {
|
|
22
|
+
if (error) {
|
|
23
|
+
reject(error);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
resolve();
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
resolve();
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
static absolutePath(relativePath) {
|
|
37
|
+
return node_path_1.default.join(this.rootFolder, relativePath);
|
|
38
|
+
}
|
|
39
|
+
static exists(fileName) {
|
|
40
|
+
return node_fs_1.default.existsSync(fileName);
|
|
41
|
+
}
|
|
42
|
+
static async read(fileName) {
|
|
43
|
+
return node_fs_1.default.promises.readFile(fileName, 'utf-8');
|
|
44
|
+
}
|
|
45
|
+
static async write(fileName, content) {
|
|
46
|
+
if (typeof content !== 'string') {
|
|
47
|
+
content = JSON.stringify(content);
|
|
48
|
+
}
|
|
49
|
+
return node_fs_1.default.promises.writeFile(fileName, content);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.default = FileHelper;
|
|
53
|
+
//# sourceMappingURL=FileHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileHelper.js","sourceRoot":"","sources":["../../../../src/lib/AlexaSmartHomeV3/Helpers/FileHelper.ts"],"names":[],"mappings":";;;;;AAAA,sDAAyB;AACzB,0DAA6B;AAC7B,0EAA2C;AAC3C,wEAAgD;AAEhD,MAAqB,UAAU;IAC3B,MAAM,CAAC,WAAW,CAAS;IAC3B,MAAM,KAAK,UAAU;QACjB,IAAI,CAAC,WAAW,KAAK,sBAAK,CAAC,0BAA0B,CAAC,yBAAe,CAAC,GAAG,EAAE,CAAC,CAAC;QAC7E,OAAO,IAAI,CAAC,WAAW,CAAC;IAC5B,CAAC;IAED,MAAM,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D,CAAC;CACJ;AA5CD,6BA4CC","sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport utils from '@iobroker/adapter-core';\nimport AdapterProvider from './AdapterProvider';\n\nexport default class FileHelper {\n static _rootFolder: string;\n static get rootFolder(): string {\n this._rootFolder ||= utils.getAbsoluteInstanceDataDir(AdapterProvider.get());\n return this._rootFolder;\n }\n\n static async createFolder(folderPath: string): Promise<void> {\n return new Promise((resolve, reject) => {\n fs.access(folderPath, error => {\n if (error) {\n // If the directory does not exist, then create it\n fs.mkdir(folderPath, { recursive: true }, error => {\n if (error) {\n reject(error);\n } else {\n resolve();\n }\n });\n } else {\n resolve();\n }\n });\n });\n }\n\n static absolutePath(relativePath: string): string {\n return path.join(this.rootFolder, relativePath);\n }\n\n static exists(fileName: string): boolean {\n return fs.existsSync(fileName);\n }\n\n static async read(fileName: string): Promise<string> {\n return fs.promises.readFile(fileName, 'utf-8');\n }\n\n static async write(fileName: string, content: any): Promise<void> {\n if (typeof content !== 'string') {\n content = JSON.stringify(content);\n }\n return fs.promises.writeFile(fileName, content);\n }\n}\n"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class IotProxy {
|
|
4
|
+
static device;
|
|
5
|
+
static stateChangedTopic;
|
|
6
|
+
static login;
|
|
7
|
+
static init(device, clientId, login) {
|
|
8
|
+
IotProxy.device = device;
|
|
9
|
+
IotProxy.stateChangedTopic = `response/${clientId}/changeReport`;
|
|
10
|
+
this.login = login;
|
|
11
|
+
}
|
|
12
|
+
static publishStateChange(stateChange) {
|
|
13
|
+
// replace INVALID token with the client id
|
|
14
|
+
if (stateChange.event?.endpoint) {
|
|
15
|
+
stateChange.event.endpoint.scope.token = this.login;
|
|
16
|
+
}
|
|
17
|
+
return IotProxy.publish(IotProxy.stateChangedTopic, stateChange);
|
|
18
|
+
}
|
|
19
|
+
static publish(topic, message) {
|
|
20
|
+
if (typeof message !== 'string') {
|
|
21
|
+
message = JSON.stringify(message);
|
|
22
|
+
}
|
|
23
|
+
setTimeout(() => IotProxy.device?.publish(topic, message, { qos: 0 }, (_error) => { }), 100);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.default = IotProxy;
|
|
27
|
+
//# sourceMappingURL=IotProxy.js.map
|