iobroker.sonoff 3.3.0 → 4.2.0
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/LICENSE +1 -1
- package/README.md +96 -170
- package/admin/i18n/{de/translations.json → de.json} +37 -12
- package/admin/i18n/{en/translations.json → en.json} +37 -12
- package/admin/i18n/{es/translations.json → es.json} +37 -12
- package/admin/i18n/{fr/translations.json → fr.json} +37 -12
- package/admin/i18n/{it/translations.json → it.json} +37 -12
- package/admin/i18n/{nl/translations.json → nl.json} +37 -12
- package/admin/i18n/{pl/translations.json → pl.json} +37 -12
- package/admin/i18n/{pt/translations.json → pt.json} +37 -12
- package/admin/i18n/{ru/translations.json → ru.json} +37 -12
- package/admin/i18n/{uk/translations.json → uk.json} +37 -12
- package/admin/i18n/{zh-cn/translations.json → zh-cn.json} +37 -12
- package/admin/jsonConfig.json +427 -228
- package/build/lib/bridge.js +512 -0
- package/build/lib/bridge.js.map +1 -0
- package/build/lib/checkStates.js +68 -0
- package/build/lib/checkStates.js.map +1 -0
- package/{lib → build/lib}/datapoints.js +61 -1
- package/build/lib/datapoints.js.map +1 -0
- package/build/lib/deviceManager.js +898 -0
- package/build/lib/deviceManager.js.map +1 -0
- package/build/lib/i18n/de.json +61 -0
- package/build/lib/i18n/en.json +61 -0
- package/build/lib/i18n/es.json +61 -0
- package/build/lib/i18n/fr.json +61 -0
- package/build/lib/i18n/it.json +61 -0
- package/build/lib/i18n/nl.json +61 -0
- package/build/lib/i18n/pl.json +61 -0
- package/build/lib/i18n/pt.json +61 -0
- package/build/lib/i18n/ru.json +61 -0
- package/build/lib/i18n/uk.json +61 -0
- package/build/lib/i18n/zh-cn.json +61 -0
- package/build/lib/mqttBase.js +1308 -0
- package/build/lib/mqttBase.js.map +1 -0
- package/build/lib/server.js +485 -0
- package/build/lib/server.js.map +1 -0
- package/build/main.js +110 -0
- package/build/main.js.map +1 -0
- package/io-package.json +47 -30
- package/package.json +26 -21
- package/admin/index.html +0 -177
- package/admin/index_m.html +0 -218
- package/admin/words.js +0 -75
- package/lib/server.js +0 -2086
- package/main.js +0 -104
package/main.js
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ioBroker sonoff Adapter
|
|
3
|
-
*
|
|
4
|
-
* (c) 2017-2024 bluefox
|
|
5
|
-
*
|
|
6
|
-
* MIT License
|
|
7
|
-
*/
|
|
8
|
-
'use strict';
|
|
9
|
-
|
|
10
|
-
const utils = require('@iobroker/adapter-core'); // Get common adapter utils
|
|
11
|
-
const adapterName = require('./package.json').name.split('.').pop();
|
|
12
|
-
const Server = require('./lib/server');
|
|
13
|
-
let server = null;
|
|
14
|
-
let adapter;
|
|
15
|
-
|
|
16
|
-
function decrypt(key, value) {
|
|
17
|
-
let result = '';
|
|
18
|
-
for (let i = 0; i < value.length; ++i) {
|
|
19
|
-
result += String.fromCharCode(key[i % key.length].charCodeAt(0) ^ value.charCodeAt(i));
|
|
20
|
-
}
|
|
21
|
-
return result;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function startAdapter(options) {
|
|
25
|
-
options = options || {};
|
|
26
|
-
Object.assign(options, { name: adapterName });
|
|
27
|
-
|
|
28
|
-
adapter = new utils.Adapter(options);
|
|
29
|
-
|
|
30
|
-
adapter.on('ready', () => {
|
|
31
|
-
// delete pass if a password set
|
|
32
|
-
if (adapter.config.password && adapter.config.pass) {
|
|
33
|
-
// delete adapter.config.pass
|
|
34
|
-
adapter.getForeignObject(`system.adapter.${adapter.namespace}`, (err, config) => {
|
|
35
|
-
delete config.native.pass;
|
|
36
|
-
adapter.setForeignObject(config._id, config);
|
|
37
|
-
});
|
|
38
|
-
} else if (!adapter.config.password && adapter.config.pass) {
|
|
39
|
-
// migrate
|
|
40
|
-
adapter.getForeignObject('system.config', (err, systemConfig) => {
|
|
41
|
-
adapter.getForeignObject(`system.adapter.${adapter.namespace}`, (err, config) => {
|
|
42
|
-
if (systemConfig && systemConfig.native && systemConfig.native.secret) {
|
|
43
|
-
// noinspection JSUnresolvedVariable
|
|
44
|
-
config.native.password = decrypt(systemConfig.native.secret, adapter.config.pass);
|
|
45
|
-
} else {
|
|
46
|
-
// noinspection JSUnresolvedVariable
|
|
47
|
-
config.native.password = decrypt('Zgfr56gFe87jJOM', adapter.config.pass);
|
|
48
|
-
}
|
|
49
|
-
delete config.native.pass;
|
|
50
|
-
adapter.setForeignObject(config._id, config);
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
} else {
|
|
54
|
-
main();
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
adapter.on('unload', cb => {
|
|
59
|
-
if (server) {
|
|
60
|
-
server.destroy(cb);
|
|
61
|
-
server = null;
|
|
62
|
-
} else if (typeof cb === 'function') {
|
|
63
|
-
cb();
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
// called if the subscribed state changes itself
|
|
68
|
-
adapter.on('stateChange', (id, state) => {
|
|
69
|
-
adapter.log.debug(`stateChange ${id}: ${JSON.stringify(state)}`);
|
|
70
|
-
// you can use the ack flag to detect if state is desired or acknowledged
|
|
71
|
-
state && !state.ack && server && server.onStateChange(id, state);
|
|
72
|
-
});
|
|
73
|
-
return adapter;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function main() {
|
|
77
|
-
adapter.config.TELE_SENSOR = adapter.config.TELE_SENSOR === true || adapter.config.TELE_SENSOR === 'true';
|
|
78
|
-
adapter.config.TELE_STATE = adapter.config.TELE_STATE === true || adapter.config.TELE_STATE === 'true';
|
|
79
|
-
adapter.config.STAT_RESULT = adapter.config.STAT_RESULT === true || adapter.config.STAT_RESULT === 'true';
|
|
80
|
-
adapter.config.OBJ_TREE = adapter.config.OBJ_TREE === true || adapter.config.OBJ_TREE === 'true';
|
|
81
|
-
|
|
82
|
-
// subscribe for all own variables
|
|
83
|
-
adapter.subscribeStates('*');
|
|
84
|
-
|
|
85
|
-
// read all states and set alive to false
|
|
86
|
-
adapter.getStatesOf(
|
|
87
|
-
'',
|
|
88
|
-
'',
|
|
89
|
-
(err, states) =>
|
|
90
|
-
states &&
|
|
91
|
-
states.length &&
|
|
92
|
-
states.forEach(state => state._id.match(/\.alive$/) && adapter.setForeignState(state._id, false, true)),
|
|
93
|
-
);
|
|
94
|
-
|
|
95
|
-
server = new Server(adapter);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// If started as allInOne/compact mode => return function to create instance
|
|
99
|
-
if (module && module.parent) {
|
|
100
|
-
module.exports = startAdapter;
|
|
101
|
-
} else {
|
|
102
|
-
// or start the instance directly
|
|
103
|
-
startAdapter();
|
|
104
|
-
}
|