iobroker.zigbee2mqtt 3.1.1 → 3.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/lib/states.js CHANGED
@@ -1,4 +1,3 @@
1
-
2
1
  'use strict';
3
2
 
4
3
  /*eslint no-unused-vars: ['off']*/
@@ -109,8 +108,6 @@ const states = {
109
108
  },
110
109
  },
111
110
 
112
-
113
-
114
111
  simulated_brightness: {
115
112
  id: 'simulated_brightness',
116
113
  prop: 'brightness',
@@ -122,13 +119,17 @@ const states = {
122
119
  type: 'number',
123
120
  def: 0,
124
121
  unit: '%',
122
+ // Fix: null-Guard – bulbLevelToAdapterLevel(undefined) würde 0 liefern (Lampe scheinbar aus)
125
123
  getter: (payload) => {
124
+ if (payload.brightness == null) { return undefined; }
126
125
  return utils.bulbLevelToAdapterLevel(payload.brightness);
127
126
  },
128
127
  },
129
128
 
129
+ // Fix: prop ergänzt – statesController sucht zuerst per state.prop === payload-key
130
130
  state: {
131
131
  id: 'state',
132
+ prop: 'state',
132
133
  name: 'Switch state',
133
134
  icon: undefined,
134
135
  role: 'switch',
@@ -142,6 +143,7 @@ const states = {
142
143
 
143
144
  brightness: {
144
145
  id: 'brightness',
146
+ prop: 'brightness',
145
147
  name: 'Brightness',
146
148
  options: ['transition'],
147
149
  icon: undefined,
@@ -149,16 +151,16 @@ const states = {
149
151
  write: true,
150
152
  read: true,
151
153
  type: 'number',
154
+ def: 100,
152
155
  unit: '%',
153
156
  min: 0,
154
157
  max: 100,
155
- def: 100,
158
+ // Fix: null-Guard – payload ohne brightness-Key liefert sonst fälschlich 0
156
159
  getter: (payload) => {
160
+ if (payload.brightness == null) { return undefined; }
157
161
  return utils.bulbLevelToAdapterLevel(payload.brightness);
158
162
  },
159
- setter: (value) => {
160
- return utils.adapterLevelToBulbLevel(value);
161
- },
163
+ setter: (value) => utils.adapterLevelToBulbLevel(value),
162
164
  },
163
165
 
164
166
  brightness_move: {
@@ -170,9 +172,9 @@ const states = {
170
172
  write: true,
171
173
  read: false,
172
174
  type: 'number',
175
+ def: 0,
173
176
  min: -50,
174
177
  max: 50,
175
- def: 0,
176
178
  },
177
179
 
178
180
  colortemp_move: {
@@ -184,9 +186,9 @@ const states = {
184
186
  write: true,
185
187
  read: false,
186
188
  type: 'number',
189
+ def: 0,
187
190
  min: -50,
188
191
  max: 50,
189
- def: 0,
190
192
  },
191
193
 
192
194
  transition: {
@@ -198,12 +200,13 @@ const states = {
198
200
  write: true,
199
201
  read: false,
200
202
  type: 'number',
203
+ def: -1,
201
204
  unit: 'sec',
202
205
  min: -1,
203
206
  max: 65535,
204
- def: -1,
205
207
  isOption: true,
206
208
  },
209
+
207
210
  send_payload: {
208
211
  id: 'send_payload',
209
212
  name: 'Send a raw json payload',
@@ -214,39 +217,49 @@ const states = {
214
217
  type: 'string',
215
218
  def: '{}',
216
219
  },
220
+
221
+ // Fix: prop ergänzt – Z2M sendet payload.voltage
217
222
  voltage: {
218
223
  id: 'voltage',
224
+ prop: 'voltage',
219
225
  name: 'Voltage',
220
226
  icon: undefined,
221
227
  role: 'value.voltage',
222
228
  write: false,
223
229
  read: true,
224
230
  type: 'number',
225
- unit: 'V',
226
231
  def: 0,
232
+ unit: 'V',
227
233
  },
234
+
235
+ // Fix: prop ergänzt – Z2M sendet payload.voltage (Battery-Variante)
228
236
  battery_voltage: {
229
237
  id: 'voltage',
238
+ prop: 'voltage',
230
239
  name: 'Battery voltage',
231
240
  icon: undefined,
232
241
  role: 'battery.voltage',
233
242
  write: false,
234
243
  read: true,
235
244
  type: 'number',
236
- unit: 'V',
237
245
  def: 0,
246
+ unit: 'V',
238
247
  },
248
+
249
+ // Fix: prop ergänzt – Z2M sendet payload.energy
239
250
  energy: {
240
251
  id: 'energy',
252
+ prop: 'energy',
241
253
  name: 'Sum of consumed energy',
242
254
  icon: undefined,
243
255
  role: 'value.power.consumption',
244
256
  write: false,
245
257
  read: true,
246
258
  type: 'number',
247
- unit: 'kWh',
248
259
  def: 0,
260
+ unit: 'kWh',
249
261
  },
262
+
250
263
  battery: {
251
264
  id: 'battery',
252
265
  prop: 'battery',
@@ -256,35 +269,43 @@ const states = {
256
269
  write: false,
257
270
  read: true,
258
271
  type: 'number',
272
+ def: 0,
259
273
  unit: '%',
260
274
  min: 0,
261
275
  max: 100,
262
- def: 0,
263
276
  },
277
+
278
+ // Fix: prop ergänzt – Z2M sendet payload.device_temperature
264
279
  device_temperature: {
265
280
  id: 'device_temperature',
281
+ prop: 'device_temperature',
266
282
  name: 'Temperature of the device',
267
283
  icon: undefined,
268
284
  role: 'value.temperature',
269
285
  write: false,
270
286
  read: true,
271
287
  type: 'number',
272
- unit: '°C',
273
288
  def: 0,
289
+ unit: '°C',
274
290
  },
291
+
292
+ // Fix: prop ergänzt – Z2M sendet payload.temperature
275
293
  temperature: {
276
294
  id: 'temperature',
295
+ prop: 'temperature',
277
296
  name: 'Temperature',
278
297
  icon: undefined,
279
298
  role: 'value.temperature',
280
299
  write: false,
281
300
  read: true,
282
301
  type: 'number',
283
- unit: '°C',
284
302
  def: 0,
303
+ unit: '°C',
285
304
  },
305
+
286
306
  humidity: {
287
307
  id: 'humidity',
308
+ prop: 'humidity',
288
309
  name: 'Humidity',
289
310
  icon: undefined,
290
311
  role: 'value.humidity',
@@ -296,8 +317,10 @@ const states = {
296
317
  min: 0,
297
318
  max: 100,
298
319
  },
320
+
299
321
  pressure: {
300
322
  id: 'pressure',
323
+ prop: 'pressure',
301
324
  name: 'Pressure',
302
325
  icon: undefined,
303
326
  role: 'value.pressure',
@@ -309,6 +332,7 @@ const states = {
309
332
  min: 0,
310
333
  max: 10000,
311
334
  },
335
+
312
336
  illuminance: {
313
337
  id: 'illuminance',
314
338
  prop: 'illuminance_lux',
@@ -321,6 +345,32 @@ const states = {
321
345
  def: 0,
322
346
  unit: 'lux',
323
347
  },
348
+
349
+ /**
350
+ * Illuminance berechnet aus dem Z2M-Rohwert (prop='illuminance').
351
+ * Formel: lux = round(10^(raw / 10000))
352
+ * Wird zusätzlich zu illuminance_raw angelegt wenn das Gerät keinen
353
+ * illuminance_lux-Expose liefert.
354
+ */
355
+ illuminance_from_raw: {
356
+ id: 'illuminance',
357
+ prop: 'illuminance',
358
+ name: 'Illuminance',
359
+ icon: undefined,
360
+ role: 'value.brightness',
361
+ write: false,
362
+ read: true,
363
+ type: 'number',
364
+ def: 0,
365
+ unit: 'lux',
366
+ getter: (payload) => {
367
+ if (payload.illuminance == null) { return undefined; }
368
+ const raw = payload.illuminance;
369
+ if (raw <= 0) { return 0; }
370
+ return Math.round(Math.pow(10, (raw - 1) / 10000));
371
+ },
372
+ },
373
+
324
374
  illuminance_raw: {
325
375
  id: 'illuminance_raw',
326
376
  prop: 'illuminance',
@@ -333,8 +383,53 @@ const states = {
333
383
  def: 0,
334
384
  unit: '',
335
385
  },
386
+
387
+ /**
388
+ * Rohwert-State wenn das Gerät 'illuminance_raw' als payload-Schlüssel sendet
389
+ * (z.B. Geräte mit eigenem illuminance_raw-Expose).
390
+ */
391
+ illuminance_raw_direct: {
392
+ id: 'illuminance_raw',
393
+ prop: 'illuminance_raw',
394
+ name: 'Illuminance raw',
395
+ icon: undefined,
396
+ role: 'value.brightness',
397
+ write: false,
398
+ read: true,
399
+ type: 'number',
400
+ def: 0,
401
+ unit: '',
402
+ },
403
+
404
+ /**
405
+ * Illuminance in Lux berechnet aus payload.illuminance_raw.
406
+ * Formel: lux = round(10^(illuminance_raw / 10000))
407
+ * Wird angelegt wenn das Gerät 'illuminance_raw' als Expose-Typ hat,
408
+ * aber kein separates 'illuminance_lux' liefert.
409
+ */
410
+ illuminance_from_illuminance_raw: {
411
+ id: 'illuminance',
412
+ prop: 'illuminance_raw',
413
+ name: 'Illuminance',
414
+ icon: undefined,
415
+ role: 'value.brightness',
416
+ write: false,
417
+ read: true,
418
+ type: 'number',
419
+ def: 0,
420
+ unit: 'lux',
421
+ getter: (payload) => {
422
+ if (payload.illuminance_raw == null) { return undefined; }
423
+ const raw = payload.illuminance_raw;
424
+ if (raw <= 0) { return 0; }
425
+ return Math.round(Math.pow(10, (raw - 1) / 10000));
426
+ },
427
+ },
428
+
429
+ // Fix: prop ergänzt – Z2M sendet payload.occupancy
336
430
  occupancy: {
337
431
  id: 'occupancy',
432
+ prop: 'occupancy',
338
433
  name: 'Occupancy',
339
434
  icon: undefined,
340
435
  role: 'sensor.motion',
@@ -343,6 +438,7 @@ const states = {
343
438
  type: 'boolean',
344
439
  def: false,
345
440
  },
441
+
346
442
  contact: {
347
443
  id: 'contact',
348
444
  prop: 'contact',
@@ -354,6 +450,7 @@ const states = {
354
450
  type: 'boolean',
355
451
  def: false,
356
452
  },
453
+
357
454
  opened: {
358
455
  id: 'opened',
359
456
  prop: 'contact',
@@ -364,8 +461,13 @@ const states = {
364
461
  read: true,
365
462
  type: 'boolean',
366
463
  def: false,
367
- getter: (payload) => !payload.contact,
464
+ // Fix: null-Guard – !undefined wäre true (Tür fälschlich offen)
465
+ getter: (payload) => {
466
+ if (payload.contact == null) { return undefined; }
467
+ return !payload.contact;
468
+ },
368
469
  },
470
+
369
471
  tamper: {
370
472
  id: 'tampered',
371
473
  prop: 'tamper',
@@ -375,7 +477,9 @@ const states = {
375
477
  write: false,
376
478
  read: true,
377
479
  type: 'boolean',
480
+ def: false,
378
481
  },
482
+
379
483
  water_leak: {
380
484
  id: 'detected',
381
485
  prop: 'water_leak',
@@ -387,6 +491,7 @@ const states = {
387
491
  type: 'boolean',
388
492
  def: false,
389
493
  },
494
+
390
495
  batt_low_t_f: {
391
496
  id: 'battery_low',
392
497
  prop: 'battery_low',
@@ -398,6 +503,7 @@ const states = {
398
503
  type: 'boolean',
399
504
  def: false,
400
505
  },
506
+
401
507
  load_power: {
402
508
  id: 'load_power',
403
509
  prop: 'power',
@@ -420,11 +526,10 @@ const states = {
420
526
  write: false,
421
527
  read: true,
422
528
  type: 'number',
423
- unit: 'A',
424
529
  def: 0,
530
+ unit: 'A',
425
531
  },
426
532
 
427
-
428
533
  temp_calibration: {
429
534
  id: 'temperature_calibration',
430
535
  prop: 'temperature_calibration',
@@ -438,6 +543,7 @@ const states = {
438
543
  unit: '°C',
439
544
  isOption: true,
440
545
  },
546
+
441
547
  local_temperature: {
442
548
  id: 'local_temperature',
443
549
  prop: 'local_temperature',
@@ -450,6 +556,7 @@ const states = {
450
556
  def: 0,
451
557
  unit: '°C',
452
558
  },
559
+
453
560
  local_temperature_calibration: {
454
561
  id: 'local_temperature_calibration',
455
562
  prop: 'local_temperature_calibration',
@@ -463,7 +570,6 @@ const states = {
463
570
  unit: '°C',
464
571
  },
465
572
 
466
-
467
573
  climate_away_mode: {
468
574
  id: 'away_mode',
469
575
  prop: 'away_mode',
@@ -473,34 +579,41 @@ const states = {
473
579
  write: true,
474
580
  read: true,
475
581
  type: 'boolean',
582
+ def: false,
476
583
  isEvent: true,
477
- getter: (payload) => (payload.action === 'ON' ? true : false),
584
+ getter: (payload) => payload.away_mode === 'ON',
478
585
  setter: (value) => (value ? 'ON' : 'OFF'),
479
586
  },
587
+
588
+ // Fix: def ergänzt – ioBroker meldet Fehler beim Anlegen ohne def bei type:'string'
480
589
  climate_system_mode: {
481
590
  id: 'mode',
482
- name: 'Mode',
483
591
  prop: 'system_mode',
592
+ name: 'Mode',
484
593
  icon: undefined,
485
594
  role: 'state',
486
595
  write: true,
487
596
  read: true,
488
597
  type: 'string',
598
+ def: '',
489
599
  states: { auto: 'auto', off: 'off', heat: 'heat' },
490
600
  },
601
+
602
+ // Fix: write:false – running_state ist ein reiner Sensor-State (Z2M sendet nur, setzt nie)
603
+ // Fix: def ergänzt
491
604
  climate_running_mode: {
492
605
  id: 'running_state',
493
- name: 'Running Mode',
494
606
  prop: 'running_state',
607
+ name: 'Running Mode',
495
608
  icon: undefined,
496
609
  role: 'state',
497
- write: true,
610
+ write: false,
498
611
  read: true,
499
- type: 'string', // valid: low, medium, high
612
+ type: 'string',
613
+ def: '',
500
614
  states: { idle: 'idle', heat: 'heat' },
501
615
  },
502
616
 
503
-
504
617
  brightness_step: {
505
618
  id: 'brightness_step',
506
619
  prop: 'brightness_step',
@@ -514,6 +627,7 @@ const states = {
514
627
  min: -50,
515
628
  max: 50,
516
629
  },
630
+
517
631
  hue_move: {
518
632
  id: 'hue_move',
519
633
  prop: 'hue_move',
@@ -523,15 +637,15 @@ const states = {
523
637
  write: true,
524
638
  read: false,
525
639
  type: 'number',
640
+ def: 0,
526
641
  min: -50,
527
642
  max: 50,
528
- def: 0,
529
643
  },
530
644
 
531
645
  child_lock: {
532
646
  id: 'lock',
533
- name: 'Locked',
534
647
  prop: 'child_lock',
648
+ name: 'Locked',
535
649
  icon: undefined,
536
650
  role: 'state',
537
651
  write: true,