homematic-manager 3.6.0 → 3.6.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.
@@ -77,8 +77,13 @@ export interface ImageUpstream {
77
77
  }
78
78
  /** The URL of the CCU's web server, or `undefined` when no host is configured. */
79
79
  export declare function ccuOrigin(upstream: ImageUpstream | undefined): string | undefined;
80
- /** A file name that cannot escape the cache directory, whatever the device type looked like. */
81
- export declare function cacheFileName(deviceType: string, iconFile: string): string;
80
+ /**
81
+ * The cache file of a picture: named after the CCU's file, not after the device type (B-103). The
82
+ * cache used to be keyed by the type, so a type the mapping missed stored the "unknown device"
83
+ * picture under its own name, and that copy would have outlived the fix of the lookup forever.
84
+ * Types that share a picture now share the file, too. Cannot escape the cache directory.
85
+ */
86
+ export declare function cacheFileName(iconFile: string): string;
82
87
  /** Where a picture came from; `memory` and `disk` are the two cache levels. */
83
88
  export type DeviceImageSource = 'memory' | 'disk' | 'ccu' | 'bundled';
84
89
  export interface DeviceImage {
@@ -37,6 +37,7 @@
37
37
  */
38
38
  import fs from 'node:fs/promises';
39
39
  import path from 'node:path';
40
+ import { dataKey } from '@homematic-manager/core';
40
41
  /** Where the CCU keeps its device pictures, in one directory per size. */
41
42
  export const CCU_IMAGE_BASE = '/config/img/devices';
42
43
  /** The key `device-icons.json` uses for "no idea what this is". */
@@ -112,10 +113,19 @@ export function ccuOrigin(upstream) {
112
113
  }
113
114
  return `${upstream.tls === true ? 'https' : 'http'}://${upstream.host}`;
114
115
  }
115
- /** A file name that cannot escape the cache directory, whatever the device type looked like. */
116
- export function cacheFileName(deviceType, iconFile) {
117
- const extension = path.extname(iconFile) || '.png';
118
- return `${deviceType.replace(/[^A-Za-z0-9._-]/g, '_').slice(0, 120)}${extension}`;
116
+ /**
117
+ * The cache file of a picture: named after the CCU's file, not after the device type (B-103). The
118
+ * cache used to be keyed by the type, so a type the mapping missed stored the "unknown device"
119
+ * picture under its own name, and that copy would have outlived the fix of the lookup forever.
120
+ * Types that share a picture now share the file, too. Cannot escape the cache directory.
121
+ */
122
+ export function cacheFileName(iconFile) {
123
+ const parsed = path.parse(iconFile);
124
+ const extension = parsed.ext || '.png';
125
+ return `${parsed.name
126
+ .replace(/[^A-Za-z0-9._-]/g, '_')
127
+ .replace(/^\.+/, '_')
128
+ .slice(0, 120)}${extension}`;
119
129
  }
120
130
  const silentLog = { warn: () => undefined, debug: () => undefined };
121
131
  /**
@@ -155,8 +165,9 @@ export class DeviceImageService {
155
165
  /** The file name the CCU knows this device type under, or `undefined`. */
156
166
  async fileFor(deviceType) {
157
167
  const icons = await this.icons();
158
- // openccu-data keys the mapping by the upper-cased type; the CCU reports `HM-LC-Sw1-Pl`
159
- const file = icons[deviceType] ?? icons[deviceType.toUpperCase()] ?? icons[UNKNOWN_DEVICE_KEY];
168
+ // the pipeline keys the mapping by the upper-cased type with spaces as `_`; the CCU reports
169
+ // `HM-LC-Sw1-Pl` and `HmIP-eTRV-B-2 R4M` (B-103)
170
+ const file = icons[deviceType] ?? icons[dataKey(deviceType)] ?? icons[UNKNOWN_DEVICE_KEY];
160
171
  if (file === undefined) {
161
172
  return undefined;
162
173
  }
@@ -185,7 +196,7 @@ export class DeviceImageService {
185
196
  if (iconFile === undefined) {
186
197
  return undefined;
187
198
  }
188
- const cacheFile = path.join(this.#options.cacheDir, cacheFileName(deviceType, iconFile));
199
+ const cacheFile = path.join(this.#options.cacheDir, cacheFileName(iconFile));
189
200
  let fromDisk = await readIfPresent(cacheFile);
190
201
  if (fromDisk && !looksLikeImage(fromDisk)) {
191
202
  // B-57: an earlier version cached what the box answered, a page included
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homematic-manager/backend",
3
- "version": "3.6.0",
3
+ "version": "3.6.1",
4
4
  "type": "module",
5
5
  "description": "Homematic Manager backend: XML-RPC/BIN-RPC clients and callback servers, caches, optional ReGa",
6
6
  "license": "AGPL-3.0-or-later",
@@ -262,6 +262,14 @@ export interface Translations {
262
262
  }
263
263
  /** device type -> image file name (relative, no directory), as the CCU serves it under /config/img/devices/<size>/. */
264
264
  export type DeviceIcons = Record<string, string>;
265
+ /**
266
+ * The key the data pipeline files an identifier under (`data/scripts/lib/translations.mjs`'s
267
+ * `identifierKey`): spaces become `_`, everything upper case. A device type is reported mixed case
268
+ * and may contain a space - `HmIP-eTRV-B-2 R4M`, `ZEL STG RM FWT` - while `device-icons.json` and the
269
+ * `deviceModels` of the translations hold `HMIP-ETRV-B-2_R4M` and `ZEL_STG_RM_FWT` (B-103): a lookup
270
+ * that only upper-cases misses every type with a space in it.
271
+ */
272
+ export declare function dataKey(identifier: string): string;
265
273
  /** Where the data came from; written by the pipeline, shown in the About dialog. */
266
274
  export interface DataManifest {
267
275
  generatedAt: string;
@@ -7,6 +7,16 @@
7
7
  *
8
8
  * Field names are camelCase and stable; extend with optional fields, never rename or repurpose.
9
9
  */
10
+ /**
11
+ * The key the data pipeline files an identifier under (`data/scripts/lib/translations.mjs`'s
12
+ * `identifierKey`): spaces become `_`, everything upper case. A device type is reported mixed case
13
+ * and may contain a space - `HmIP-eTRV-B-2 R4M`, `ZEL STG RM FWT` - while `device-icons.json` and the
14
+ * `deviceModels` of the translations hold `HMIP-ETRV-B-2_R4M` and `ZEL_STG_RM_FWT` (B-103): a lookup
15
+ * that only upper-cases misses every type with a space in it.
16
+ */
17
+ export function dataKey(identifier) {
18
+ return identifier.replaceAll(' ', '_').toUpperCase();
19
+ }
10
20
  /**
11
21
  * File layout the pipeline writes under `data/dist/` and every `DataSource` reads:
12
22
  *
@@ -19,7 +19,7 @@
19
19
  * second - and now the same two steps again in the fallback language, so a missing German string
20
20
  * shows the English one instead of the raw identifier.
21
21
  */
22
- import type { Language, Translations } from '../data/types.js';
22
+ import { type Language, type Translations } from '../data/types.js';
23
23
  /** The order in which languages are consulted; the first that has the key wins. */
24
24
  export type TranslationChain = readonly Translations[];
25
25
  /** Reads labels and help texts out of one or more `Translations`. */
@@ -19,6 +19,7 @@
19
19
  * second - and now the same two steps again in the fallback language, so a missing German string
20
20
  * shows the English one instead of the raw identifier.
21
21
  */
22
+ import { dataKey } from '../data/types.js';
22
23
  /** Reads labels and help texts out of one or more `Translations`. */
23
24
  export class TranslationLookup {
24
25
  #chain;
@@ -114,9 +115,12 @@ function keys(suffix, channelType) {
114
115
  return [...qualified, ...qualified.map((key) => key.toUpperCase()), ...bare];
115
116
  }));
116
117
  }
117
- /** The key as it was given, plus its upper-case form where that differs. */
118
+ /**
119
+ * The key as it was given, its upper-case form, and the pipeline's own key form with spaces as `_`
120
+ * (B-103: `HmIP-eTRV-B-2 R4M` is filed as `HMIP-ETRV-B-2_R4M`), where these differ.
121
+ */
118
122
  function identifiers(value) {
119
- return dedupe([value, value.toUpperCase()]);
123
+ return dedupe([value, value.toUpperCase(), dataKey(value)]);
120
124
  }
121
125
  function dedupe(values) {
122
126
  return [...new Set(values)];
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homematic-manager/core",
3
- "version": "3.6.0",
3
+ "version": "3.6.1",
4
4
  "type": "module",
5
5
  "description": "Pure domain logic of the Homematic Manager: no I/O, no DOM",
6
6
  "license": "AGPL-3.0-or-later",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "homematic-manager",
3
- "version": "3.6.0",
3
+ "version": "3.6.1",
4
4
  "type": "module",
5
5
  "description": "Configure and administer Homematic and HomematicIP devices - devices and channels, direct links, paramsets, RSSI, service messages, events and an RPC console - from a local HTTP/WebSocket server that also serves the web UI",
6
6
  "keywords": [
@@ -67,8 +67,8 @@
67
67
  "hm-simulator": "^1.5.0"
68
68
  },
69
69
  "dependencies": {
70
- "@homematic-manager/backend": "3.6.0",
71
- "@homematic-manager/core": "3.6.0",
70
+ "@homematic-manager/backend": "3.6.1",
71
+ "@homematic-manager/core": "3.6.1",
72
72
  "binrpc": "^4.2.0",
73
73
  "homematic-rega": "^2.0.0",
74
74
  "homematic-xmlrpc": "^2.0.0",