iobroker.zigbee2mqtt 3.0.4 → 3.0.6
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 +9 -0
- package/admin/i18n/de/translations.json +8 -5
- package/admin/i18n/en/translations.json +5 -2
- package/admin/i18n/es/translations.json +3 -1
- package/admin/i18n/fr/translations.json +5 -2
- package/admin/i18n/it/translations.json +5 -2
- package/admin/i18n/nl/translations.json +5 -2
- package/admin/i18n/pl/translations.json +5 -2
- package/admin/i18n/pt/translations.json +5 -2
- package/admin/i18n/ru/translations.json +5 -2
- package/admin/i18n/uk/translations.json +5 -2
- package/admin/i18n/zh-cn/translations.json +5 -2
- package/admin/jsonConfig.json +476 -428
- package/io-package.json +31 -29
- package/lib/deviceController.js +5 -5
- package/lib/exposes.js +4 -4
- package/lib/imageController.js +19 -19
- package/lib/states.js +90 -6337
- package/lib/statesController.js +41 -15
- package/package.json +1 -1
package/lib/statesController.js
CHANGED
|
@@ -37,30 +37,64 @@ class StatesController {
|
|
|
37
37
|
|
|
38
38
|
const actionStates = [];
|
|
39
39
|
|
|
40
|
-
for (
|
|
40
|
+
for (let [key, value] of Object.entries(messageObj.payload)) {
|
|
41
41
|
if (value === undefined || value === null) {
|
|
42
42
|
continue;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
let states = device.states.filter(
|
|
45
|
+
let states = device.states.filter(state => {
|
|
46
|
+
return state.prop && state.prop === key;
|
|
47
|
+
});
|
|
46
48
|
|
|
47
49
|
if (states.length == 0) {
|
|
48
50
|
states = device.states.filter((x) => x.id == key);
|
|
49
51
|
}
|
|
50
52
|
|
|
51
53
|
if (states.length == 0) {
|
|
54
|
+
if (key == 'device' || device.ieee_address.includes('group')) {
|
|
55
|
+
// do nothing
|
|
56
|
+
} else {
|
|
57
|
+
// some devices has addition information in payload
|
|
58
|
+
const fullPath = `${device.ieee_address}.additional`;
|
|
59
|
+
|
|
60
|
+
await this.adapter.setObjectNotExistsAsync(fullPath, {
|
|
61
|
+
type: 'channel',
|
|
62
|
+
common: {
|
|
63
|
+
name: 'hidden channelstate',
|
|
64
|
+
},
|
|
65
|
+
native: {},
|
|
66
|
+
});
|
|
67
|
+
await this.adapter.setObjectNotExistsAsync(`${fullPath}.${key}`, {
|
|
68
|
+
type: 'state',
|
|
69
|
+
common: {
|
|
70
|
+
name: key,
|
|
71
|
+
role: 'state',
|
|
72
|
+
type: value !== null ? typeof value : 'mixed',
|
|
73
|
+
write: false,
|
|
74
|
+
read: true,
|
|
75
|
+
},
|
|
76
|
+
native: {},
|
|
77
|
+
});
|
|
78
|
+
if (typeof value == 'object') {
|
|
79
|
+
value = JSON.stringify(value);
|
|
80
|
+
}
|
|
81
|
+
this.adapter.setState(`${fullPath}.${key}`, value, true);
|
|
82
|
+
}
|
|
52
83
|
continue;
|
|
53
84
|
}
|
|
54
85
|
|
|
55
86
|
for (const state of states) {
|
|
56
87
|
const stateName = `${device.ieee_address}.${state.id}`;
|
|
57
88
|
|
|
89
|
+
// set available status if last_seen is set
|
|
90
|
+
if (state.id === 'last_seen' && this.adapter.config.allwaysUpdateAvailableState === true) {
|
|
91
|
+
await this.setStateSafelyAsync(`${device.ieee_address}.available`, true);
|
|
92
|
+
}
|
|
93
|
+
|
|
58
94
|
// It may be that the state has not yet been created!
|
|
59
|
-
if (
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
!this.createCache[device.ieee_address][state.id].created == true
|
|
63
|
-
) {
|
|
95
|
+
if (!this.createCache[device.ieee_address]
|
|
96
|
+
|| !this.createCache[device.ieee_address][state.id]
|
|
97
|
+
|| !this.createCache[device.ieee_address][state.id].created == true) {
|
|
64
98
|
incStatsQueue[incStatsQueue.length] = messageObj;
|
|
65
99
|
continue;
|
|
66
100
|
}
|
|
@@ -166,14 +200,6 @@ class StatesController {
|
|
|
166
200
|
}
|
|
167
201
|
|
|
168
202
|
async setAllAvailableToFalse() {
|
|
169
|
-
// for (const device of this.deviceCache) {
|
|
170
|
-
// for (const state of device.states) {
|
|
171
|
-
// if (state.id == 'available') {
|
|
172
|
-
// await this.adapter.setStateChangedAsync(`${device.ieee_address}.${state.id}`, false, true);
|
|
173
|
-
// }
|
|
174
|
-
// }
|
|
175
|
-
// }
|
|
176
|
-
|
|
177
203
|
const availableStates = await this.adapter.getStatesAsync('*.available');
|
|
178
204
|
for (const availableState in availableStates) {
|
|
179
205
|
await this.adapter.setStateChangedAsync(availableState, false, true);
|