iobroker.zigbee2mqtt 3.0.4 → 3.0.5

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.
@@ -37,30 +37,64 @@ class StatesController {
37
37
 
38
38
  const actionStates = [];
39
39
 
40
- for (const [key, value] of Object.entries(messageObj.payload)) {
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((x) => x.prop && x.prop == key);
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
- !this.createCache[device.ieee_address] ||
61
- !this.createCache[device.ieee_address][state.id] ||
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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iobroker.zigbee2mqtt",
3
- "version": "3.0.4",
3
+ "version": "3.0.5",
4
4
  "description": "Zigbee2MQTT adapter for ioBroker",
5
5
  "author": {
6
6
  "name": "Dennis Rathjen and Arthur Rupp",