iobroker.zigbee2mqtt 3.0.0 → 3.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 CHANGED
@@ -22,6 +22,9 @@ This adapter allows to control the data points of the devices of a Zigbee2MQTT i
22
22
  [Adapter Documentation](https://github.com/arteck/ioBroker.zigbee2mqtt/blob/main/docs/wiki.md)
23
23
 
24
24
  ## Changelog
25
+ ### 3.0.1 (2025-01-04)
26
+ - (arteck) corr icon download
27
+
25
28
  ### 3.0.0 (2025-01-04)
26
29
  - (arteck) adaptation z2m 2.x
27
30
 
package/io-package.json CHANGED
@@ -1,8 +1,21 @@
1
1
  {
2
2
  "common": {
3
3
  "name": "zigbee2mqtt",
4
- "version": "3.0.0",
4
+ "version": "3.0.1",
5
5
  "news": {
6
+ "3.0.1": {
7
+ "en": "corr icon download",
8
+ "de": "corr icon herunterladen",
9
+ "ru": "скачать значок",
10
+ "pt": "corrimento ícone download",
11
+ "nl": "corr pictogramdownload",
12
+ "fr": "corr icon télécharger",
13
+ "it": "icona corr scaricare",
14
+ "es": "corr icono descargar",
15
+ "pl": "pobierz ikonę corr",
16
+ "uk": "cкачати ігру corr",
17
+ "zh-cn": "corr 图标下载"
18
+ },
6
19
  "3.0.0": {
7
20
  "en": "adaptation z2m 2.x",
8
21
  "de": "anpassung z2m 2.x",
@@ -18,7 +18,7 @@ class ImageController {
18
18
  return deviceName ? deviceNameString.replace(/\u0000/g, '') : 'NA';
19
19
  }
20
20
 
21
- getZ2mDeviceImage(device) {
21
+ getZ2mDeviceImageModelJPG(device) {
22
22
  if (device && device.definition && device.definition.model) {
23
23
  const icoString = `https://www.zigbee2mqtt.io/images/devices/${this.sanitizeZ2MDeviceName(device.definition.model)}.jpg`;
24
24
  // eslint-disable-next-line no-control-regex
@@ -26,55 +26,58 @@ class ImageController {
26
26
  }
27
27
  }
28
28
 
29
+ getZ2mDeviceImageModelPNG(device) {
30
+ if (device && device.definition && device.definition.model) {
31
+ const icoString = `https://www.zigbee2mqtt.io/images/devices/${this.sanitizeZ2MDeviceName(device.definition.model)}.png`;
32
+ // eslint-disable-next-line no-control-regex
33
+ return icoString.replace(/\u0000/g, '');
34
+ }
35
+ }
36
+
37
+
29
38
  getSlsDeviceImage(device) {
30
39
  if (device && device.model_id) {
31
- const icoString = `https://slsys.github.io/Gateway/devices/png/${this.sanitizeModelIDForImageUrl(device.model_id)}.png`;
40
+ const icoString = `https://www.zigbee2mqtt.io/images/devices/${this.sanitizeModelIDForImageUrl(device.model_id)}.png`;
32
41
  // eslint-disable-next-line no-control-regex
33
42
  return icoString.replace(/\u0000/g, '');
34
43
  }
35
44
  }
36
45
 
37
46
  async getDeviceIcon(device) {
38
- if (this.adapter.config.useDeviceIcons == false) {
39
- return '';
40
- }
47
+ if (!this.adapter.config.useDeviceIcons) return '';
41
48
 
42
- const imageSize = this.adapter.config.deviceIconsSize;
49
+ const imageSize = this.adapter.config.deviceIconsSize;
43
50
 
44
- const z2mIconFileName = `${this.sanitizeZ2MDeviceName(device.definition.model)}.jpg`;
51
+ const z2mIconFileNameJPG = `${this.sanitizeZ2MDeviceName(device.definition.model)}.jpg`;
52
+ const z2mIconFileNamePNG = `${this.sanitizeZ2MDeviceName(device.definition.model)}.png`;
45
53
  const slsIconFileName = `${this.sanitizeModelIDForImageUrl(device.model_id)}.png`;
46
54
 
47
- let icon;
48
- let iconFileName;
49
- // Check whether an image has already been downloaded from Z2M.
50
- if (await this.adapter.fileExistsAsync(this.adapter.namespace, z2mIconFileName)) {
51
- iconFileName = z2mIconFileName;
52
- }
53
- // Check whether an image has already been downloaded from SLSys.
54
- else if (await this.adapter.fileExistsAsync(this.adapter.namespace, slsIconFileName)) {
55
- iconFileName = slsIconFileName;
56
- }
57
- // If not donwload image
58
- else {
59
- let iconUrl = this.getSlsDeviceImage(device);
60
-
61
- this.adapter.log.info(`Download image for device model: ${device.definition.model}`);
55
+ let iconFileName = await this.getExistingIconFileName(z2mIconFileNameJPG, z2mIconFileNamePNG, slsIconFileName);
62
56
 
63
- try {
64
- await this.downloadIcon(this.adapter, iconUrl, this.adapter.namespace);
65
- } catch (err) {
66
- iconUrl = this.getZ2mDeviceImage(device);
67
- await this.downloadIcon(this.adapter, iconUrl, this.adapter.namespace);
68
- }
57
+ if (!iconFileName) {
58
+ const iconUrls = [
59
+ this.getZ2mDeviceImageModelJPG(device),
60
+ this.getZ2mDeviceImageModelPNG(device),
61
+ this.getSlsDeviceImage(device)
62
+ ];
69
63
 
70
- iconFileName = this.getFileNameWithExtension(iconUrl);
64
+ for (const iconUrl of iconUrls) {
65
+ try {
66
+ await this.downloadIcon(this.adapter, iconUrl, this.adapter.namespace);
67
+ iconFileName = this.getFileNameWithExtension(iconUrl);
68
+ break;
69
+ } catch (err) {
70
+ this.adapter.log.warn(`Failed to download image from ${iconUrl}`);
71
+ }
72
+ }
71
73
  }
72
74
 
73
- if ((await this.adapter.fileExistsAsync(this.adapter.namespace, iconFileName)) == false) {
75
+ if (!iconFileName) {
74
76
  this.adapter.log.warn(`No image for device model: ${device.definition.model} found!`);
75
77
  return '';
76
78
  }
77
79
 
80
+ let icon;
78
81
  try {
79
82
  // Load image from the Meta-Store
80
83
  icon = await this.adapter.readFileAsync(this.adapter.namespace, iconFileName);
@@ -122,6 +125,16 @@ class ImageController {
122
125
  adapter.log.warn(ex);
123
126
  }
124
127
  }
128
+ async getExistingIconFileName(z2mIconFileNameJPG, z2mIconFileNamePNG, slsIconFileName) {
129
+ if (await this.adapter.fileExistsAsync(this.adapter.namespace, z2mIconFileNameJPG)) {
130
+ return z2mIconFileNameJPG;
131
+ } else if (await this.adapter.fileExistsAsync(this.adapter.namespace, z2mIconFileNamePNG)) {
132
+ return z2mIconFileNamePNG;
133
+ } else if (await this.adapter.fileExistsAsync(this.adapter.namespace, slsIconFileName)) {
134
+ return slsIconFileName;
135
+ }
136
+ return null;
137
+ }
125
138
  }
126
139
  module.exports = {
127
140
  ImageController,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iobroker.zigbee2mqtt",
3
- "version": "3.0.0",
3
+ "version": "3.0.1",
4
4
  "description": "Zigbee2MQTT adapter for ioBroker",
5
5
  "author": {
6
6
  "name": "Dennis Rathjen and Arthur Rupp",