iobroker.iot 3.5.2 → 4.0.1
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 +24 -9
- package/admin/assets/index-Y479CE6x.js +681 -0
- package/admin/index_m.html +1 -1
- package/admin/rules/assets/{ActionVisu-D9x2f6zu.js → ActionVisu-DE8dgNVF.js} +1 -1
- package/admin/rules/assets/{ActionVisu__loadShare__react__loadShare__-Cg21Ef1U.js → ActionVisu__loadShare__react__loadShare__-BKaC-p5K.js} +1 -1
- package/admin/rules/assets/{ActionVisu__loadShare__react_mf_2_dom__loadShare__-B1zRWn0u.js → ActionVisu__loadShare__react_mf_2_dom__loadShare__-Bs1o8DtQ.js} +2 -2
- package/admin/rules/assets/ActionVisu__mf_v__runtimeInit__mf_v__-DtUoI3FU.js +5 -0
- package/admin/rules/assets/bootstrap-Ba57tu25.js +1 -0
- package/admin/rules/assets/hostInit-hos3Txsy.js +1 -1
- package/admin/rules/assets/{index-Duo7mFlZ.js → index-CbxmbJvB.js} +2 -2
- package/admin/rules/assets/{index-CAAeiKCc.js → index-DjPMvPni.js} +2 -2
- package/admin/rules/assets/index-_Y2FN5EZ.js +1152 -0
- package/admin/rules/assets/{virtualExposes-BqVak7rX.js → virtualExposes-BNZJTatg.js} +2 -2
- package/admin/rules/customRuleBlocks.js +2 -2
- package/io-package.json +27 -27
- package/package.json +17 -14
- package/admin/assets/index-Df2NS929.js +0 -681
- package/admin/rules/assets/ActionVisu__mf_v__runtimeInit__mf_v__-Cz053nO7.js +0 -10
- package/admin/rules/assets/bootstrap-BCFKIiwZ.js +0 -1
- package/admin/rules/assets/index-BwcOGyWI.js +0 -1152
- package/lib/AlexaSmartHomeV3/Alexa/AlexaResponse.js +0 -262
- package/lib/AlexaSmartHomeV3/Alexa/Capabilities/Base.js +0 -124
- package/lib/AlexaSmartHomeV3/Alexa/Capabilities/BrightnessController.js +0 -15
- package/lib/AlexaSmartHomeV3/Alexa/Capabilities/ColorController.js +0 -10
- package/lib/AlexaSmartHomeV3/Alexa/Capabilities/ColorTemperatureController.js +0 -15
- package/lib/AlexaSmartHomeV3/Alexa/Capabilities/ContactSensor.js +0 -10
- package/lib/AlexaSmartHomeV3/Alexa/Capabilities/LockController.js +0 -10
- package/lib/AlexaSmartHomeV3/Alexa/Capabilities/ModeController.js +0 -69
- package/lib/AlexaSmartHomeV3/Alexa/Capabilities/MotionSensor.js +0 -10
- package/lib/AlexaSmartHomeV3/Alexa/Capabilities/PercentageController.js +0 -10
- package/lib/AlexaSmartHomeV3/Alexa/Capabilities/PowerController.js +0 -15
- package/lib/AlexaSmartHomeV3/Alexa/Capabilities/Speaker.js +0 -20
- package/lib/AlexaSmartHomeV3/Alexa/Capabilities/TemperatureSensor.js +0 -10
- package/lib/AlexaSmartHomeV3/Alexa/Capabilities/ThermostatController.js +0 -34
- package/lib/AlexaSmartHomeV3/Alexa/Capabilities/index.js +0 -14
- package/lib/AlexaSmartHomeV3/Alexa/Directives/Base.js +0 -27
- package/lib/AlexaSmartHomeV3/Alexa/Directives/ChangeReport.js +0 -75
- package/lib/AlexaSmartHomeV3/Alexa/Directives/Discovery.js +0 -39
- package/lib/AlexaSmartHomeV3/Alexa/Directives/ReportState.js +0 -50
- package/lib/AlexaSmartHomeV3/Alexa/Directives/index.js +0 -13
- package/lib/AlexaSmartHomeV3/Alexa/ModeValues/Base.js +0 -38
- package/lib/AlexaSmartHomeV3/Alexa/ModeValues/Closed.js +0 -55
- package/lib/AlexaSmartHomeV3/Alexa/ModeValues/Open.js +0 -56
- package/lib/AlexaSmartHomeV3/Alexa/ModeValues/index.js +0 -14
- package/lib/AlexaSmartHomeV3/Alexa/Properties/AdjustableProperty.js +0 -11
- package/lib/AlexaSmartHomeV3/Alexa/Properties/Base.js +0 -108
- package/lib/AlexaSmartHomeV3/Alexa/Properties/Brightness.js +0 -14
- package/lib/AlexaSmartHomeV3/Alexa/Properties/Color.js +0 -40
- package/lib/AlexaSmartHomeV3/Alexa/Properties/ColorTemperatureInKelvin.js +0 -62
- package/lib/AlexaSmartHomeV3/Alexa/Properties/DetectionState.js +0 -22
- package/lib/AlexaSmartHomeV3/Alexa/Properties/LockState.js +0 -40
- package/lib/AlexaSmartHomeV3/Alexa/Properties/Mode.js +0 -32
- package/lib/AlexaSmartHomeV3/Alexa/Properties/Muted.js +0 -17
- package/lib/AlexaSmartHomeV3/Alexa/Properties/Percentage.js +0 -14
- package/lib/AlexaSmartHomeV3/Alexa/Properties/PowerState.js +0 -25
- package/lib/AlexaSmartHomeV3/Alexa/Properties/TargetSetpoint.js +0 -28
- package/lib/AlexaSmartHomeV3/Alexa/Properties/Temperature.js +0 -20
- package/lib/AlexaSmartHomeV3/Alexa/Properties/ThermostatMode.js +0 -52
- package/lib/AlexaSmartHomeV3/Alexa/Properties/Volume.js +0 -19
- package/lib/AlexaSmartHomeV3/Alexa/Properties/index.js +0 -14
- package/lib/AlexaSmartHomeV3/Controls/AdjustableControl.js +0 -22
- package/lib/AlexaSmartHomeV3/Controls/AdjustablePercentageControl.js +0 -28
- package/lib/AlexaSmartHomeV3/Controls/AirCondition.js +0 -144
- package/lib/AlexaSmartHomeV3/Controls/Blind.js +0 -12
- package/lib/AlexaSmartHomeV3/Controls/ContactSensor.js +0 -17
- package/lib/AlexaSmartHomeV3/Controls/Control.js +0 -352
- package/lib/AlexaSmartHomeV3/Controls/Ct.js +0 -172
- package/lib/AlexaSmartHomeV3/Controls/Dimmer.js +0 -124
- package/lib/AlexaSmartHomeV3/Controls/Door.js +0 -9
- package/lib/AlexaSmartHomeV3/Controls/Gate.js +0 -42
- package/lib/AlexaSmartHomeV3/Controls/Hue.js +0 -207
- package/lib/AlexaSmartHomeV3/Controls/Light.js +0 -54
- package/lib/AlexaSmartHomeV3/Controls/Lock.js +0 -36
- package/lib/AlexaSmartHomeV3/Controls/Motion.js +0 -17
- package/lib/AlexaSmartHomeV3/Controls/ReadOnlyDetector.js +0 -25
- package/lib/AlexaSmartHomeV3/Controls/Slider.js +0 -10
- package/lib/AlexaSmartHomeV3/Controls/Socket.js +0 -21
- package/lib/AlexaSmartHomeV3/Controls/Temperature.js +0 -22
- package/lib/AlexaSmartHomeV3/Controls/Thermostat.js +0 -86
- package/lib/AlexaSmartHomeV3/Controls/VacuumCleaner.js +0 -28
- package/lib/AlexaSmartHomeV3/Controls/Volume.js +0 -109
- package/lib/AlexaSmartHomeV3/Controls/VolumeGroup.js +0 -9
- package/lib/AlexaSmartHomeV3/Controls/Window.js +0 -9
- package/lib/AlexaSmartHomeV3/Controls/index.js +0 -14
- package/lib/AlexaSmartHomeV3/Device.js +0 -84
- package/lib/AlexaSmartHomeV3/DeviceManager.js +0 -415
- package/lib/AlexaSmartHomeV3/Exceptions/AlexaV3Exception.js +0 -8
- package/lib/AlexaSmartHomeV3/Exceptions/HourlyDeviceRateLimitExceeded.js +0 -5
- package/lib/AlexaSmartHomeV3/Exceptions/OverallDailyRateLimitExceeded.js +0 -5
- package/lib/AlexaSmartHomeV3/Helpers/AdapterProvider.js +0 -46
- package/lib/AlexaSmartHomeV3/Helpers/FileHelper.js +0 -70
- package/lib/AlexaSmartHomeV3/Helpers/IotProxy.js +0 -44
- package/lib/AlexaSmartHomeV3/Helpers/Logger.js +0 -95
- package/lib/AlexaSmartHomeV3/Helpers/RateLimiter.js +0 -82
- package/lib/AlexaSmartHomeV3/Helpers/Utils.js +0 -583
- package/lib/Utils.js +0 -608
- package/lib/adminCommonSocket.js +0 -781
- package/lib/alexaCustom.js +0 -622
- package/lib/alexaSmartHomeV2.js +0 -2792
- package/lib/alexaSmartHomeV3.js +0 -117
- package/lib/alisa.js +0 -2412
- package/lib/devices.js +0 -20
- package/lib/functions.js +0 -21
- package/lib/googleHome.js +0 -3323
- package/lib/notifications.js +0 -37
- package/lib/remote.js +0 -1363
- package/lib/rooms.js +0 -45
- package/lib/texts.js +0 -79
- package/lib/translate.js +0 -19
- package/lib/visuApp.js +0 -157
- package/main.js +0 -1444
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
class IotProxy {
|
|
2
|
-
/**
|
|
3
|
-
* @type {Object}
|
|
4
|
-
*/
|
|
5
|
-
static device;
|
|
6
|
-
/**
|
|
7
|
-
* @type {string}
|
|
8
|
-
*/
|
|
9
|
-
static stateChangedTopic;
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @param {Object} device
|
|
13
|
-
* @param {string} clientId
|
|
14
|
-
* @param {string} login
|
|
15
|
-
*/
|
|
16
|
-
static init(device, clientId, login) {
|
|
17
|
-
IotProxy.device = device;
|
|
18
|
-
IotProxy.stateChangedTopic = `response/${clientId}/changeReport`;
|
|
19
|
-
this.login = login;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* @param {Object} stateChange
|
|
24
|
-
*/
|
|
25
|
-
static publishStateChange(stateChange) {
|
|
26
|
-
// replace INVALID token with the client id
|
|
27
|
-
stateChange.event.endpoint.scope.token = this.login;
|
|
28
|
-
return IotProxy.publish(IotProxy.stateChangedTopic, stateChange);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* @param {string} topic
|
|
33
|
-
* @param {string} message
|
|
34
|
-
*/
|
|
35
|
-
static publish(topic, message) {
|
|
36
|
-
if (typeof message !== 'string') {
|
|
37
|
-
message = JSON.stringify(message);
|
|
38
|
-
}
|
|
39
|
-
setTimeout(() =>
|
|
40
|
-
IotProxy.device?.publish(topic, message, { qos: 0 }, (error, result) => { }), 100);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
module.exports = IotProxy;
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
const AdapterProvider = require("./AdapterProvider");
|
|
2
|
-
|
|
3
|
-
class Logger {
|
|
4
|
-
constructor(instance) {
|
|
5
|
-
this.component = instance.constructor.name;
|
|
6
|
-
this.logged = new Map();
|
|
7
|
-
this.maxLoggedEntries = 500;
|
|
8
|
-
this.ttl = 30;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
get component() {
|
|
12
|
-
return this._component;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
set component(value) {
|
|
16
|
-
this._component = value;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
hashCode(str) {
|
|
20
|
-
let hash = 0;
|
|
21
|
-
let i;
|
|
22
|
-
let chr;
|
|
23
|
-
if (str.length === 0) {
|
|
24
|
-
return hash;
|
|
25
|
-
}
|
|
26
|
-
for (i = 0; i < str.length; i++) {
|
|
27
|
-
chr = str.charCodeAt(i);
|
|
28
|
-
hash = ((hash << 5) - hash) + chr;
|
|
29
|
-
hash |= 0; // Convert to 32bit integer
|
|
30
|
-
}
|
|
31
|
-
return hash;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
toSkip(hash) {
|
|
35
|
-
// clear old entries
|
|
36
|
-
let keys = Array.from(this.logged.keys());
|
|
37
|
-
const now = (new Date()).getTime();
|
|
38
|
-
for (const key of keys) {
|
|
39
|
-
// @ts-ignore
|
|
40
|
-
const expired = ((now - key) / 1000) > this.ttl;
|
|
41
|
-
if (expired) {
|
|
42
|
-
this.logged.delete(key);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
keys = Array.from(this.logged.keys());
|
|
47
|
-
if (keys.length > this.maxLoggedEntries) {
|
|
48
|
-
const toRemove = keys.length - this.maxLoggedEntries;
|
|
49
|
-
keys.sort();
|
|
50
|
-
for (let i = 0; i < toRemove; i++) {
|
|
51
|
-
this.logged.delete(keys[i]);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return Array.from(this.logged.values()).includes(hash);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
compose(message) {
|
|
59
|
-
return `[AlexaV3::${this.component}]: ${message}`;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
print(logger, message) {
|
|
63
|
-
if (typeof message === 'string' && message.length > 0) {
|
|
64
|
-
const hash = this.hashCode(message);
|
|
65
|
-
if (this.toSkip(hash)) {
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
this.logged.set((new Date()).getTime(), hash);
|
|
70
|
-
return logger(message);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
silly(message) {
|
|
75
|
-
return this.print(AdapterProvider.get().log.silly, this.compose(message));
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
debug(message) {
|
|
79
|
-
return this.print(AdapterProvider.get().log.debug, this.compose(message));
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
info(message) {
|
|
83
|
-
return this.print(AdapterProvider.get().log.info, this.compose(message));
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
warn(message) {
|
|
87
|
-
return this.print(AdapterProvider.get().log.warn, this.compose(message));
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
error(message) {
|
|
91
|
-
return this.print(AdapterProvider.get().log.error, this.compose(message));
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
module.exports = Logger;
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
const path = require('path');
|
|
2
|
-
const HourlyDeviceRateLimitExceeded = require('../Exceptions/HourlyDeviceRateLimitExceeded');
|
|
3
|
-
const OverallDailyRateLimitExceeded = require('../Exceptions/OverallDailyRateLimitExceeded');
|
|
4
|
-
const FileHelper = require('./FileHelper');
|
|
5
|
-
const Utils = require('./Utils');
|
|
6
|
-
|
|
7
|
-
class RateLimiter {
|
|
8
|
-
static MAX_DEVICE_STATE_CHANGES_PER_HOUR = 60;
|
|
9
|
-
static MAX_CHANGES_PER_DAY = 1000;
|
|
10
|
-
static USAGE_STORAGE_FOLDER = 'usage';
|
|
11
|
-
static USAGE_STORAGE_FILE_NAME = 'usage.json';
|
|
12
|
-
|
|
13
|
-
static usage = new Map();
|
|
14
|
-
|
|
15
|
-
static async init() {
|
|
16
|
-
try {
|
|
17
|
-
await FileHelper.createFolder(FileHelper.absolutePath(this.USAGE_STORAGE_FOLDER));
|
|
18
|
-
const raw = await FileHelper.read(this.storageFileName);
|
|
19
|
-
this.usage = new Map(JSON.parse(raw));
|
|
20
|
-
} catch (error) {
|
|
21
|
-
this.usage = new Map();
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
static get storageFileName() {
|
|
26
|
-
return FileHelper.absolutePath(path.join(this.USAGE_STORAGE_FOLDER, this.USAGE_STORAGE_FILE_NAME));
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
static async store() {
|
|
30
|
-
try {
|
|
31
|
-
await FileHelper.write(this.storageFileName, JSON.stringify(Array.from(this.usage.entries())));
|
|
32
|
-
} catch (error) {
|
|
33
|
-
// nop
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
static get(endpointId) {
|
|
38
|
-
let item = this.usage.get(endpointId);
|
|
39
|
-
if (!item) {
|
|
40
|
-
item = {
|
|
41
|
-
changeCounter: 0,
|
|
42
|
-
timestamp: Utils.currentHour().toISOString()
|
|
43
|
-
}
|
|
44
|
-
this.usage.set(endpointId, item);
|
|
45
|
-
}
|
|
46
|
-
return item;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
static async incrementAndGet(endpointId) {
|
|
50
|
-
let item = this.get(endpointId);
|
|
51
|
-
|
|
52
|
-
if (!Utils.isCurrentHour(Utils.parseISOString(item.timestamp))) {
|
|
53
|
-
item.changeCounter = 1;
|
|
54
|
-
item.timestamp = Utils.currentHour().toISOString();
|
|
55
|
-
} else {
|
|
56
|
-
item.changeCounter += 1;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
this.usage.set(endpointId, item);
|
|
60
|
-
|
|
61
|
-
try {
|
|
62
|
-
await this.store();
|
|
63
|
-
} catch (error) {
|
|
64
|
-
// nop
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (item.changeCounter > this.MAX_DEVICE_STATE_CHANGES_PER_HOUR) {
|
|
68
|
-
throw new HourlyDeviceRateLimitExceeded(`Hourly state change limit for ${endpointId} exceeded`)
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
const changesToday = Array.from(this.usage.values()).filter(item => Utils.isToday(Utils.parseISOString(item.timestamp))).reduce((sum, { changeCounter }) => sum + changeCounter, 0);
|
|
72
|
-
|
|
73
|
-
if (changesToday > this.MAX_CHANGES_PER_DAY) {
|
|
74
|
-
throw new OverallDailyRateLimitExceeded(`Overall daily state change limit exceeded`);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return item;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
module.exports = RateLimiter;
|