iobroker.hm-rpc 4.3.0 → 4.3.2
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 +21 -12
- package/admin/jsonConfig.json +13 -1
- package/build/lib/lite.d.ts +44 -8
- package/build/lib/lite.js +97 -19
- package/build/lib/lite.js.map +1 -1
- package/build/lib/liteConnection.d.ts +7 -0
- package/build/lib/liteConnection.js +8 -0
- package/build/lib/liteConnection.js.map +1 -1
- package/build/lib/liteNames.d.ts +39 -6
- package/build/lib/liteNames.js +62 -15
- package/build/lib/liteNames.js.map +1 -1
- package/build/main.d.ts +19 -2
- package/build/main.js +102 -6
- package/build/main.js.map +1 -1
- package/io-package.json +27 -27
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -210,10 +210,18 @@ Select the daemon **openccu-lite** and enter the address of the system in "HomeM
|
|
|
210
210
|
Node.js, or the system is reached over HTTP).
|
|
211
211
|
- **Take names, rooms and functions from the system** (default on): the devices, channels and states are named as on
|
|
212
212
|
the system (`<channel name>.<DATAPOINT>` for the states, as hm-rega names them), and the rooms and functions of the
|
|
213
|
-
system fill `enum.rooms` and `enum.functions` - live, whenever a name or a room changes on the system.
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
213
|
+
system fill `enum.rooms` and `enum.functions` - live, whenever a name or a room changes on the system. The enums get
|
|
214
|
+
the ids hm-rega gives the rooms and functions of a CCU, so scripts and visualizations keep working after a move from a
|
|
215
|
+
CCU with hm-rega: the name as it is, only a dot (and a character an object id cannot hold) becomes `_` (room
|
|
216
|
+
"Living Room" → `enum.rooms.Living Room`). An enum that exists with that id - the one hm-rega made - is carried on:
|
|
217
|
+
its name, icon and the members of other adapters stay. The CCU's own rooms and functions that hm-rega named by their
|
|
218
|
+
key (`enum.rooms.LivingRoom`, `enum.functions.Light`, …) are taken for the rooms openccu-lite named "Wohnzimmer",
|
|
219
|
+
"Licht", … when no enum of that name exists. A room tree is flattened: every node becomes an enum of its own, a
|
|
220
|
+
nested one named by the names along its path (`EG` / `Bad` → `enum.rooms.EG_Bad`), and a channel is a member of its
|
|
221
|
+
innermost room only. A rename on the system gives a new enum, as with hm-rega. The adapter manages only the members
|
|
222
|
+
of its own instance, and only in the enums it manages (the ones of the system's rooms and functions, and the ones it
|
|
223
|
+
created): rooms and functions made in ioBroker keep what was put into them. An enum the adapter created is removed
|
|
224
|
+
when nothing is left in it. Without this option the objects keep the address as name, as with a CCU.
|
|
217
225
|
|
|
218
226
|
The devices are synchronized at every start of the instance (the system sends its device list with the stream), so
|
|
219
227
|
"Synchronize objects (once)" is not needed on openccu-lite. "Don't delete devices" works as with a CCU. The values the
|
|
@@ -395,6 +403,15 @@ npm run update-images
|
|
|
395
403
|
```
|
|
396
404
|
|
|
397
405
|
## Changelog
|
|
406
|
+
### 4.3.2 (2026-11-24)
|
|
407
|
+
- (@hobbyquaker) openccu-lite: the rooms and functions of the system get the enum ids hm-rega gives them (`enum.rooms.Living Room` instead of `enum.rooms.living-room`), so the enums of a CCU with hm-rega are carried on after the move; enums the adapter does not manage (rooms made in ioBroker) are no longer emptied. Enums an earlier version created with the old ids are removed when nothing else is in them
|
|
408
|
+
- (@hobbyquaker) openccu-lite: the stale-object cleanup leaves the objects alone while the interface lists no device at all (e.g. right after its process on the system was restarted)
|
|
409
|
+
- (@hobbyquaker) openccu-lite: the help text of the interface field is shown in the admin's language
|
|
410
|
+
- (@GermanBluefox) `LEVEL` is sent together with `HUE` and `SATURATION`, HmIP-RGBW still rejected the color with `MISSING_NON_OPTIONAL_PARAMETER` (#1557)
|
|
411
|
+
|
|
412
|
+
### 4.3.1 (2026-11-21)
|
|
413
|
+
- (@hobbyquaker) openccu-lite: a device paired later no longer deletes the objects of the other devices of the instance; objects of devices removed on the system are cleaned up when the instance connects, without leaving broken objects behind ("obj.type has to exist")
|
|
414
|
+
|
|
398
415
|
### 4.3.0 (2026-11-18)
|
|
399
416
|
- (copilot) Adapter requires node.js >= 22.19.0 now
|
|
400
417
|
- (@hobbyquaker) New daemon `openccu-lite`: connects an interface of an [openccu-lite](https://github.com/openccu-lite/openccu-lite) system through its lite-rpc (requests with a token, events as a stream - no callback server). The pairing runs from the instance settings: press "Pair", approve the six-digit code on the Status page of the system, the token and the certificate fingerprint are stored by themselves. The names of the devices, channels and states, the rooms and functions come from the system's metadata and follow its changes live
|
|
@@ -410,14 +427,6 @@ npm run update-images
|
|
|
410
427
|
### 4.2.3 (2026-10-19)
|
|
411
428
|
* (@GermanBluefox) After an unclean stop, the CCU kept sending the events with the old interface ID and they were discarded silently. The adapter now removes an old registration before it registers, and registers again with a warning if events with an old ID of this instance arrive (#1542)
|
|
412
429
|
|
|
413
|
-
### 4.2.2 (2026-10-13)
|
|
414
|
-
* (@GermanBluefox) The virtual devices of CCU-Jack can be connected with the new daemon `CCU-Jack` (port 2121, HTTPS 2122, XML-RPC only) (#1003)
|
|
415
|
-
* (@GermanBluefox) The state `updated` (new devices for hm-rega) is no longer marked as writable, as expected for the role `indicator`
|
|
416
|
-
* (@GermanBluefox) Homebrew devices (AskSin++) of the add-ons from jp112sdl (JP-HB-Devices-addon) and TomMajor (HB-TM-Devices-AddOn) get the same icon as in the CCU WebUI (#903)
|
|
417
|
-
|
|
418
|
-
### 4.2.0 (2026-10-13)
|
|
419
|
-
* (@GermanBluefox) The firmware update state of Homematic IP devices is available in the new state `<device>.0.FIRMWARE_UPDATE_STATE`, e.g. `READY_FOR_UPDATE` when the firmware is transferred. The firmware information of the device object is updated, too (#1137)
|
|
420
|
-
|
|
421
430
|
### Older changelog
|
|
422
431
|
[here](OLD_CHANGELOG.md)
|
|
423
432
|
|
package/admin/jsonConfig.json
CHANGED
|
@@ -150,7 +150,19 @@
|
|
|
150
150
|
],
|
|
151
151
|
"manual": true,
|
|
152
152
|
"noTranslation": true,
|
|
153
|
-
"help":
|
|
153
|
+
"help": {
|
|
154
|
+
"en": "The interface of the system this instance connects: one instance per interface",
|
|
155
|
+
"de": "Das Interface des Systems, das diese Instanz verbindet: eine Instanz pro Interface",
|
|
156
|
+
"ru": "Интерфейс системы, к которой подключается этот экземпляр: по одному экземпляру на интерфейс.",
|
|
157
|
+
"pt": "A interface do sistema que esta instância conecta: uma instância por interface",
|
|
158
|
+
"nl": "De interface van het systeem waarmee deze instantie verbinding maakt: één instantie per interface",
|
|
159
|
+
"fr": "L'interface du système auquel cette instance se connecte : une instance par interface",
|
|
160
|
+
"it": "L'interfaccia del sistema a cui si connette questa istanza: un'istanza per interfaccia",
|
|
161
|
+
"es": "La interfaz del sistema al que se conecta esta instancia: una instancia por interfaz",
|
|
162
|
+
"pl": "Interfejs systemu, z którym łączy się ta instancja: jedna instancja na interfejs",
|
|
163
|
+
"uk": "Інтерфейс системи, до якого підключається цей екземпляр: один екземпляр на інтерфейс",
|
|
164
|
+
"zh-cn": "该实例连接的系统接口:每个接口一个实例"
|
|
165
|
+
},
|
|
154
166
|
"hidden": "data.daemon !== 'openccu-lite'",
|
|
155
167
|
"xs": 12,
|
|
156
168
|
"sm": 10,
|
package/build/lib/lite.d.ts
CHANGED
|
@@ -109,30 +109,66 @@ export declare function refOfAddress(iface: string, address: string): string;
|
|
|
109
109
|
*/
|
|
110
110
|
export declare function datapointName(channelName: string | undefined, datapoint: string): string;
|
|
111
111
|
/**
|
|
112
|
-
* The
|
|
113
|
-
*
|
|
114
|
-
*
|
|
112
|
+
* The part of an enum id a name gives, as ioBroker.hm-rega makes it of a CCU room: the name as it is (case,
|
|
113
|
+
* spaces and umlauts kept), a dot as `_`; a character an object id cannot hold becomes `_` as well, as the
|
|
114
|
+
* controller stores it
|
|
115
|
+
*
|
|
116
|
+
* @param name the room's or function's name
|
|
117
|
+
*/
|
|
118
|
+
export declare function enumIdPart(name: string): string;
|
|
119
|
+
/**
|
|
120
|
+
* The id of the ioBroker enum for a node of the system's taxonomy, as ioBroker.hm-rega names the enum of a CCU
|
|
121
|
+
* room: `enum.rooms.<name>` (`Living Room` → `enum.rooms.Living Room`), so the enums hm-rega made are carried on.
|
|
122
|
+
* A room tree is flattened: a nested node is named by the names along its path (`EG` / `Bad` → `enum.rooms.EG_Bad`),
|
|
123
|
+
* so two rooms `Bad` on two floors stay apart. Undefined for an enum of the system ioBroker has no counterpart for.
|
|
115
124
|
*
|
|
116
125
|
* @param path the node's path, e.g. `room/eg/bad`
|
|
126
|
+
* @param nameOf the name of a node by its path, in the language asked for; a node without one is named by its id
|
|
127
|
+
*/
|
|
128
|
+
export declare function enumIdOfPath(path: string, nameOf: (path: string) => string | undefined): string | undefined;
|
|
129
|
+
/**
|
|
130
|
+
* The enum ioBroker.hm-rega made for one of the CCU's own rooms or functions, which openccu-lite's import named
|
|
131
|
+
* in German: `Wohnzimmer` at the top of the room tree → `enum.rooms.LivingRoom`, made from the key
|
|
132
|
+
* `roomLivingRoom`. Undefined for any other node.
|
|
133
|
+
*
|
|
134
|
+
* @param path the node's path
|
|
135
|
+
* @param name the node's name
|
|
136
|
+
*/
|
|
137
|
+
export declare function builtinEnumOf(path: string, name: string): {
|
|
138
|
+
id: string;
|
|
139
|
+
key: string;
|
|
140
|
+
} | undefined;
|
|
141
|
+
/**
|
|
142
|
+
* Whether an enum object is the one ioBroker.hm-rega made for a CCU room or function of the given translation
|
|
143
|
+
* key (it keeps the CCU's name, `roomLivingRoom` or `${roomLivingRoom}`, in `native.Name`)
|
|
144
|
+
*
|
|
145
|
+
* @param obj the enum object
|
|
146
|
+
* @param key the translation key, e.g. `roomLivingRoom`
|
|
117
147
|
*/
|
|
118
|
-
export declare function
|
|
148
|
+
export declare function isHmRegaEnumOf(obj: ioBroker.Object | undefined, key: string): boolean;
|
|
119
149
|
/** An ioBroker enum an object belongs to directly (one of its innermost nodes) */
|
|
120
150
|
export interface EnumMembership {
|
|
121
|
-
/** the enum object's id, e.g. `enum.rooms.
|
|
151
|
+
/** the enum object's id, e.g. `enum.rooms.EG_Bad` */
|
|
122
152
|
id: string;
|
|
123
153
|
/** the node's name in the language asked for */
|
|
124
154
|
name: string;
|
|
125
155
|
/** the node's path in the system, e.g. `room/eg/bad` */
|
|
126
156
|
path: string;
|
|
157
|
+
/** for one of the CCU's own rooms or functions: the enum hm-rega made of it, taken when `id` does not exist */
|
|
158
|
+
builtin?: {
|
|
159
|
+
id: string;
|
|
160
|
+
key: string;
|
|
161
|
+
};
|
|
127
162
|
}
|
|
128
163
|
/**
|
|
129
164
|
* The ioBroker enums an object belongs to: its direct nodes in the system's taxonomy, each mapped to a flat enum
|
|
130
|
-
* (a channel in `room/eg/bad` is a member of `enum.rooms.
|
|
131
|
-
* hm-rega handles the CCU's flat rooms)
|
|
165
|
+
* (a channel in `room/eg/bad` is a member of `enum.rooms.EG_Bad` and not of `enum.rooms.EG` - the innermost room,
|
|
166
|
+
* as hm-rega handles the CCU's flat rooms)
|
|
132
167
|
*
|
|
133
168
|
* @param nodes the direct nodes of the object (`membership(ref, {inherit: false})` of occulite-client, rooms and functions together)
|
|
169
|
+
* @param nameOf the name of any node by its path (for the names along a nested node's path)
|
|
134
170
|
*/
|
|
135
171
|
export declare function enumsOfNodes(nodes: {
|
|
136
172
|
path: string;
|
|
137
173
|
name: string;
|
|
138
|
-
}[]): EnumMembership[];
|
|
174
|
+
}[], nameOf?: (path: string) => string | undefined): EnumMembership[];
|
package/build/lib/lite.js
CHANGED
|
@@ -17,7 +17,10 @@ exports.rpcCallbackError = rpcCallbackError;
|
|
|
17
17
|
exports.objectIdOfAddress = objectIdOfAddress;
|
|
18
18
|
exports.refOfAddress = refOfAddress;
|
|
19
19
|
exports.datapointName = datapointName;
|
|
20
|
+
exports.enumIdPart = enumIdPart;
|
|
20
21
|
exports.enumIdOfPath = enumIdOfPath;
|
|
22
|
+
exports.builtinEnumOf = builtinEnumOf;
|
|
23
|
+
exports.isHmRegaEnumOf = isHmRegaEnumOf;
|
|
21
24
|
exports.enumsOfNodes = enumsOfNodes;
|
|
22
25
|
const tools_1 = require("./tools");
|
|
23
26
|
/** The interfaces lite-rpc carries (the names of `InterfacesList.xml`, as `GET /api/rpc/v1/interfaces` lists them) */
|
|
@@ -214,44 +217,119 @@ function refOfAddress(iface, address) {
|
|
|
214
217
|
function datapointName(channelName, datapoint) {
|
|
215
218
|
return channelName ? `${channelName}.${datapoint}` : datapoint;
|
|
216
219
|
}
|
|
220
|
+
/**
|
|
221
|
+
* The characters the controller does not keep in an object id: it stores a `_` for each run of them (its own
|
|
222
|
+
* `FORBIDDEN_CHARS`). Unlike hm-rpc's rule for addresses it allows a space, as ioBroker.hm-rega's room ids have.
|
|
223
|
+
*/
|
|
224
|
+
const ID_FORBIDDEN_CHARS = /[^._\-/ :!#$%&()+=@^{}|~\p{Ll}\p{Lu}\p{Nd}]+/gu;
|
|
217
225
|
/** The enum kinds of ioBroker the system's taxonomy maps to: the `room` tree to `enum.rooms`, `function` to `enum.functions` */
|
|
218
226
|
const ENUM_KINDS = { room: 'enum.rooms', function: 'enum.functions' };
|
|
219
227
|
/**
|
|
220
|
-
* The
|
|
221
|
-
*
|
|
222
|
-
*
|
|
228
|
+
* The rooms and functions a CCU creates on its own, as ioBroker.hm-rega named their enums: the translation key
|
|
229
|
+
* ReGa keeps as the name of a room or function the user never renamed, the name openccu-lite's import gives such a
|
|
230
|
+
* room (German, the CCU WebUI's own word), and the id hm-rega made of the key (the English word of its table,
|
|
231
|
+
* spaces as `_`; `Climate_сontrol` is spelled with a Cyrillic `с` there).
|
|
232
|
+
*/
|
|
233
|
+
const BUILTIN_ENUMS = [
|
|
234
|
+
{ key: 'roomLivingRoom', name: 'Wohnzimmer', id: 'enum.rooms.LivingRoom' },
|
|
235
|
+
{ key: 'roomKitchen', name: 'Küche', id: 'enum.rooms.Kitchen' },
|
|
236
|
+
{ key: 'roomBedroom', name: 'Schlafzimmer', id: 'enum.rooms.Bedroom' },
|
|
237
|
+
{ key: 'roomChildrensRoom1', name: 'Kinderzimmer 1', id: 'enum.rooms.Childrens_room_1' },
|
|
238
|
+
{ key: 'roomChildrensRoom2', name: 'Kinderzimmer 2', id: 'enum.rooms.Childrens_room_2' },
|
|
239
|
+
{ key: 'roomOffice', name: 'Büro', id: 'enum.rooms.Office' },
|
|
240
|
+
{ key: 'roomBathroom', name: 'Badezimmer', id: 'enum.rooms.Bathroom' },
|
|
241
|
+
{ key: 'roomGarage', name: 'Garage', id: 'enum.rooms.Garage' },
|
|
242
|
+
{ key: 'roomHWR', name: 'Hauswirtschaftsraum', id: 'enum.rooms.HWR' },
|
|
243
|
+
{ key: 'roomGarden', name: 'Garten', id: 'enum.rooms.Garden' },
|
|
244
|
+
{ key: 'roomTerrace', name: 'Terrasse', id: 'enum.rooms.Terrace' },
|
|
245
|
+
{ key: 'funcLight', name: 'Licht', id: 'enum.functions.Light' },
|
|
246
|
+
{ key: 'funcHeating', name: 'Heizung', id: 'enum.functions.Heating' },
|
|
247
|
+
{ key: 'funcClimateControl', name: 'Klima', id: 'enum.functions.Climate_сontrol' },
|
|
248
|
+
{ key: 'funcWeather', name: 'Wetter', id: 'enum.functions.Weather' },
|
|
249
|
+
{ key: 'funcEnvironment', name: 'Umwelt', id: 'enum.functions.Environment' },
|
|
250
|
+
{ key: 'funcSecurity', name: 'Sicherheit', id: 'enum.functions.Security' },
|
|
251
|
+
{ key: 'funcLock', name: 'Verschluss', id: 'enum.functions.Lock' },
|
|
252
|
+
{ key: 'funcButton', name: 'Taster', id: 'enum.functions.Button' },
|
|
253
|
+
{ key: 'funcCentral', name: 'Zentrale', id: 'enum.functions.Central' },
|
|
254
|
+
{ key: 'funcEnergy', name: 'Energiemanagement', id: 'enum.functions.Energy' },
|
|
255
|
+
];
|
|
256
|
+
/**
|
|
257
|
+
* The part of an enum id a name gives, as ioBroker.hm-rega makes it of a CCU room: the name as it is (case,
|
|
258
|
+
* spaces and umlauts kept), a dot as `_`; a character an object id cannot hold becomes `_` as well, as the
|
|
259
|
+
* controller stores it
|
|
260
|
+
*
|
|
261
|
+
* @param name the room's or function's name
|
|
262
|
+
*/
|
|
263
|
+
function enumIdPart(name) {
|
|
264
|
+
return name.replace(/\./g, '_').replace(ID_FORBIDDEN_CHARS, '_');
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* The id of the ioBroker enum for a node of the system's taxonomy, as ioBroker.hm-rega names the enum of a CCU
|
|
268
|
+
* room: `enum.rooms.<name>` (`Living Room` → `enum.rooms.Living Room`), so the enums hm-rega made are carried on.
|
|
269
|
+
* A room tree is flattened: a nested node is named by the names along its path (`EG` / `Bad` → `enum.rooms.EG_Bad`),
|
|
270
|
+
* so two rooms `Bad` on two floors stay apart. Undefined for an enum of the system ioBroker has no counterpart for.
|
|
223
271
|
*
|
|
224
272
|
* @param path the node's path, e.g. `room/eg/bad`
|
|
273
|
+
* @param nameOf the name of a node by its path, in the language asked for; a node without one is named by its id
|
|
225
274
|
*/
|
|
226
|
-
function enumIdOfPath(path) {
|
|
227
|
-
const
|
|
228
|
-
|
|
275
|
+
function enumIdOfPath(path, nameOf) {
|
|
276
|
+
const segments = path.split('/');
|
|
277
|
+
const kind = ENUM_KINDS[segments[0]];
|
|
278
|
+
if (!kind || segments.length < 2 || segments.some(s => !s)) {
|
|
229
279
|
return undefined;
|
|
230
280
|
}
|
|
231
|
-
const
|
|
232
|
-
|
|
281
|
+
const parts = [];
|
|
282
|
+
for (let i = 1; i < segments.length; i++) {
|
|
283
|
+
parts.push(enumIdPart(nameOf(segments.slice(0, i + 1).join('/')) || segments[i]));
|
|
284
|
+
}
|
|
285
|
+
return `${kind}.${parts.join('_')}`;
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* The enum ioBroker.hm-rega made for one of the CCU's own rooms or functions, which openccu-lite's import named
|
|
289
|
+
* in German: `Wohnzimmer` at the top of the room tree → `enum.rooms.LivingRoom`, made from the key
|
|
290
|
+
* `roomLivingRoom`. Undefined for any other node.
|
|
291
|
+
*
|
|
292
|
+
* @param path the node's path
|
|
293
|
+
* @param name the node's name
|
|
294
|
+
*/
|
|
295
|
+
function builtinEnumOf(path, name) {
|
|
296
|
+
const segments = path.split('/');
|
|
297
|
+
if (segments.length !== 2) {
|
|
233
298
|
return undefined;
|
|
234
299
|
}
|
|
235
|
-
const
|
|
236
|
-
|
|
237
|
-
.
|
|
238
|
-
.
|
|
239
|
-
|
|
240
|
-
|
|
300
|
+
const prefix = segments[0] === 'room' ? 'room' : segments[0] === 'function' ? 'func' : undefined;
|
|
301
|
+
const entry = BUILTIN_ENUMS.find(b => prefix !== undefined &&
|
|
302
|
+
b.key.startsWith(prefix) &&
|
|
303
|
+
(b.name === name || b.key === name || `\${${b.key}}` === name));
|
|
304
|
+
return entry && { id: entry.id, key: entry.key };
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Whether an enum object is the one ioBroker.hm-rega made for a CCU room or function of the given translation
|
|
308
|
+
* key (it keeps the CCU's name, `roomLivingRoom` or `${roomLivingRoom}`, in `native.Name`)
|
|
309
|
+
*
|
|
310
|
+
* @param obj the enum object
|
|
311
|
+
* @param key the translation key, e.g. `roomLivingRoom`
|
|
312
|
+
*/
|
|
313
|
+
function isHmRegaEnumOf(obj, key) {
|
|
314
|
+
const name = obj?.native?.Name;
|
|
315
|
+
return name === key || name === `\${${key}}`;
|
|
241
316
|
}
|
|
242
317
|
/**
|
|
243
318
|
* The ioBroker enums an object belongs to: its direct nodes in the system's taxonomy, each mapped to a flat enum
|
|
244
|
-
* (a channel in `room/eg/bad` is a member of `enum.rooms.
|
|
245
|
-
* hm-rega handles the CCU's flat rooms)
|
|
319
|
+
* (a channel in `room/eg/bad` is a member of `enum.rooms.EG_Bad` and not of `enum.rooms.EG` - the innermost room,
|
|
320
|
+
* as hm-rega handles the CCU's flat rooms)
|
|
246
321
|
*
|
|
247
322
|
* @param nodes the direct nodes of the object (`membership(ref, {inherit: false})` of occulite-client, rooms and functions together)
|
|
323
|
+
* @param nameOf the name of any node by its path (for the names along a nested node's path)
|
|
248
324
|
*/
|
|
249
|
-
function enumsOfNodes(nodes) {
|
|
325
|
+
function enumsOfNodes(nodes, nameOf = () => undefined) {
|
|
250
326
|
const out = [];
|
|
251
327
|
for (const node of nodes) {
|
|
252
|
-
const
|
|
328
|
+
const name = node.name || nameOf(node.path) || node.path.slice(node.path.lastIndexOf('/') + 1);
|
|
329
|
+
const id = enumIdOfPath(node.path, p => (p === node.path ? name : nameOf(p)));
|
|
253
330
|
if (id && !out.some(e => e.id === id)) {
|
|
254
|
-
|
|
331
|
+
const builtin = builtinEnumOf(node.path, name);
|
|
332
|
+
out.push({ id, name, path: node.path, ...(builtin ? { builtin } : {}) });
|
|
255
333
|
}
|
|
256
334
|
}
|
|
257
335
|
return out;
|
package/build/lib/lite.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lite.js","sourceRoot":"","sources":["../../src/lib/lite.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AA0CH,0CAWC;AAgBD,8BAaC;AAOD,oCAQC;AAQD,4CAgBC;AA0DD,kCAgBC;AASD,4CAOC;AAOD,8CAEC;AAQD,oCAEC;AASD,sCAEC;
|
|
1
|
+
{"version":3,"file":"lite.js","sourceRoot":"","sources":["../../src/lib/lite.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AA0CH,0CAWC;AAgBD,8BAaC;AAOD,oCAQC;AAQD,4CAgBC;AA0DD,kCAgBC;AASD,4CAOC;AAOD,8CAEC;AAQD,oCAEC;AASD,sCAEC;AAgDD,gCAEC;AAWD,oCAWC;AAUD,sCAaC;AASD,wCAGC;AAsBD,oCAcC;AA7XD,mCAA0C;AAE1C,sHAAsH;AACzG,QAAA,eAAe,GAAG,CAAC,SAAS,EAAE,WAAW,EAAE,cAAc,EAAE,gBAAgB,CAAU,CAAC;AAEnG,+FAA+F;AAClF,QAAA,WAAW,GAAG,EAAE,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,EAAW,CAAC;AAE5E,iHAAiH;AACpG,QAAA,kBAAkB,GAAG,GAAG,GAAG,MAAM,CAAC;AAuB/C;;;;;;GAMG;AACH,SAAgB,eAAe,CAAC,KAAa;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AAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QAC7E,CAAC;IACL,CAAC;IACD,OAAO,GAAG,CAAC;AACf,CAAC"}
|
|
@@ -72,6 +72,13 @@ export declare class LiteConnection {
|
|
|
72
72
|
get meta(): OccuLite['meta'] | undefined;
|
|
73
73
|
/** The last value of every datapoint the system's state store keeps, keyed `<iface>.<address>.<KEY>` */
|
|
74
74
|
get values(): OccuLite['values'] | undefined;
|
|
75
|
+
/** The device and channel descriptions the system holds now, keyed `<iface>.<address>`: the live picture */
|
|
76
|
+
get devices(): OccuLite['devices'] | undefined;
|
|
77
|
+
/** The interfaces followed, with their state */
|
|
78
|
+
get interfaces(): {
|
|
79
|
+
name: string;
|
|
80
|
+
running: boolean;
|
|
81
|
+
}[];
|
|
75
82
|
/** Subscribes to the client's events (`meta`, `value`, ...); the answer unsubscribes */
|
|
76
83
|
on(event: string, fn: (arg: any) => void): () => void;
|
|
77
84
|
/**
|
|
@@ -95,6 +95,14 @@ class LiteConnection {
|
|
|
95
95
|
get values() {
|
|
96
96
|
return this.box?.values;
|
|
97
97
|
}
|
|
98
|
+
/** The device and channel descriptions the system holds now, keyed `<iface>.<address>`: the live picture */
|
|
99
|
+
get devices() {
|
|
100
|
+
return this.box?.devices;
|
|
101
|
+
}
|
|
102
|
+
/** The interfaces followed, with their state */
|
|
103
|
+
get interfaces() {
|
|
104
|
+
return this.box?.interfaces ?? [];
|
|
105
|
+
}
|
|
98
106
|
/** Subscribes to the client's events (`meta`, `value`, ...); the answer unsubscribes */
|
|
99
107
|
on(event, fn) {
|
|
100
108
|
return this.box ? this.box.on(event, fn) : () => undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"liteConnection.js","sourceRoot":"","sources":["../../src/lib/liteConnection.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAwBH,oCAgBC;
|
|
1
|
+
{"version":3,"file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AAM,IAAI,YAAY,CAAC,EAAE,CAAC;IACtD,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,QAAQ,CAAC;QAC7B,GAAG,EAAE,IAAI,CAAC,GAAG;QACb,IAAI,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE;QAC3B,SAAS,EAAE,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC9F,OAAO,EAAE,MAAM;KAClB,CAAC,CAAC;IACH,IAAI,CAAC;QACD,OAAO,CAAC,MAAM,GAAG,CAAC,cAAc,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;IACzF,CAAC;YAAS,CAAC;QACP,GAAG,CAAC,KAAK,EAAE,CAAC;IAChB,CAAC;AACL,CAAC"}
|
package/build/lib/liteNames.d.ts
CHANGED
|
@@ -31,6 +31,32 @@ export interface MetaReader {
|
|
|
31
31
|
name: string;
|
|
32
32
|
}[];
|
|
33
33
|
};
|
|
34
|
+
/** every node of the room tree, for the names along a path */
|
|
35
|
+
rooms(opts: {
|
|
36
|
+
inherit?: boolean;
|
|
37
|
+
lang?: string;
|
|
38
|
+
}): {
|
|
39
|
+
path: string;
|
|
40
|
+
name: string;
|
|
41
|
+
}[];
|
|
42
|
+
/** every node of the function tree */
|
|
43
|
+
functions(opts: {
|
|
44
|
+
inherit?: boolean;
|
|
45
|
+
lang?: string;
|
|
46
|
+
}): {
|
|
47
|
+
path: string;
|
|
48
|
+
name: string;
|
|
49
|
+
}[];
|
|
50
|
+
}
|
|
51
|
+
/** How a pass fits in with the rest of the adapter */
|
|
52
|
+
export interface LiteNamesOptions {
|
|
53
|
+
/**
|
|
54
|
+
* Resolves once the removal of the objects of devices the system no longer has is through: a pass waits for it,
|
|
55
|
+
* so it does not rename objects while they are deleted (a rename of a deleted id would create a new object)
|
|
56
|
+
*/
|
|
57
|
+
settled?: () => Promise<void>;
|
|
58
|
+
/** Whether the system still lists a device or channel address; a pass leaves the ones it does not alone */
|
|
59
|
+
known?: (address: string) => boolean;
|
|
34
60
|
}
|
|
35
61
|
/**
|
|
36
62
|
* Keeps the objects of one instance named as the system names them
|
|
@@ -40,6 +66,7 @@ export declare class LiteNames {
|
|
|
40
66
|
private readonly meta;
|
|
41
67
|
private readonly iface;
|
|
42
68
|
private readonly lang;
|
|
69
|
+
private readonly opts;
|
|
43
70
|
private timer;
|
|
44
71
|
private running;
|
|
45
72
|
private again;
|
|
@@ -48,8 +75,9 @@ export declare class LiteNames {
|
|
|
48
75
|
* @param meta the system's metadata, live
|
|
49
76
|
* @param iface the interface of this instance
|
|
50
77
|
* @param lang the language the node names are taken in
|
|
78
|
+
* @param opts the cleanup to wait for and the addresses the system still lists
|
|
51
79
|
*/
|
|
52
|
-
constructor(adapter: NamesAdapter, meta: MetaReader, iface: string, lang: string);
|
|
80
|
+
constructor(adapter: NamesAdapter, meta: MetaReader, iface: string, lang: string, opts?: LiteNamesOptions);
|
|
53
81
|
/**
|
|
54
82
|
* Applies the names soon: several changes in a row (an import, a renamed floor) become one pass
|
|
55
83
|
*
|
|
@@ -65,12 +93,17 @@ export declare class LiteNames {
|
|
|
65
93
|
apply(): Promise<void>;
|
|
66
94
|
private pass;
|
|
67
95
|
/**
|
|
68
|
-
* Brings the rooms and functions in line
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
96
|
+
* Brings the rooms and functions in line, as ioBroker.hm-rega does with the CCU's rooms: an enum of the id
|
|
97
|
+
* wanted is carried on, whoever made it (its name, icon and the members of others stay; it is marked as
|
|
98
|
+
* managed from then on). For one of the CCU's own rooms the import named in German, hm-rega's enum of the
|
|
99
|
+
* key is taken when there is none of the name (`Wohnzimmer` → `enum.rooms.LivingRoom`). Only the members of
|
|
100
|
+
* this instance are managed (another instance on the same system, or the user, may have added others), and
|
|
101
|
+
* only in the enums this adapter manages: an enum it does not want and never managed - one made by hand, or
|
|
102
|
+
* one hm-rega made for a room the system does not have - is not touched. An enum this adapter created goes
|
|
103
|
+
* when it has no members left. An enum is always written whole: `extendObject` merges arrays index-wise, so
|
|
104
|
+
* a shorter member list would leave the old entries behind.
|
|
72
105
|
*
|
|
73
|
-
* @param
|
|
106
|
+
* @param wantedByName enum id → name, path and the members of this instance
|
|
74
107
|
* @returns how many enum objects were written or removed
|
|
75
108
|
*/
|
|
76
109
|
private syncEnums;
|
package/build/lib/liteNames.js
CHANGED
|
@@ -16,12 +16,14 @@ class LiteNames {
|
|
|
16
16
|
* @param meta the system's metadata, live
|
|
17
17
|
* @param iface the interface of this instance
|
|
18
18
|
* @param lang the language the node names are taken in
|
|
19
|
+
* @param opts the cleanup to wait for and the addresses the system still lists
|
|
19
20
|
*/
|
|
20
|
-
constructor(adapter, meta, iface, lang) {
|
|
21
|
+
constructor(adapter, meta, iface, lang, opts = {}) {
|
|
21
22
|
this.adapter = adapter;
|
|
22
23
|
this.meta = meta;
|
|
23
24
|
this.iface = iface;
|
|
24
25
|
this.lang = lang;
|
|
26
|
+
this.opts = opts;
|
|
25
27
|
this.again = false;
|
|
26
28
|
}
|
|
27
29
|
/**
|
|
@@ -66,6 +68,7 @@ class LiteNames {
|
|
|
66
68
|
return this.running;
|
|
67
69
|
}
|
|
68
70
|
async pass() {
|
|
71
|
+
await this.opts.settled?.();
|
|
69
72
|
const ns = `${this.adapter.namespace}.`;
|
|
70
73
|
const devices = await this.adapter.getForeignObjectsAsync(`${ns}*`, 'device');
|
|
71
74
|
const channels = await this.adapter.getForeignObjectsAsync(`${ns}*`, 'channel');
|
|
@@ -74,10 +77,21 @@ class LiteNames {
|
|
|
74
77
|
const channelNames = new Map();
|
|
75
78
|
/** enum id → its name and the members of this instance */
|
|
76
79
|
const enums = new Map();
|
|
80
|
+
/** path → name of every node, for the names along the path of a nested one */
|
|
81
|
+
const nodeNames = new Map();
|
|
82
|
+
for (const node of [
|
|
83
|
+
...this.meta.rooms({ inherit: false, lang: this.lang }),
|
|
84
|
+
...this.meta.functions({ inherit: false, lang: this.lang }),
|
|
85
|
+
]) {
|
|
86
|
+
nodeNames.set(node.path, node.name);
|
|
87
|
+
}
|
|
88
|
+
const nameOf = (path) => nodeNames.get(path);
|
|
77
89
|
let renamed = 0;
|
|
78
90
|
for (const obj of [...Object.values(devices), ...Object.values(channels)]) {
|
|
79
91
|
const address = obj.native?.ADDRESS;
|
|
80
|
-
if (typeof address !== 'string') {
|
|
92
|
+
if (typeof address !== 'string' || this.opts.known?.(address) === false) {
|
|
93
|
+
// a device removed on the system: its objects are being deleted, and so are its datapoints, which
|
|
94
|
+
// are skipped with their channel
|
|
81
95
|
continue;
|
|
82
96
|
}
|
|
83
97
|
const ref = (0, lite_1.refOfAddress)(this.iface, address);
|
|
@@ -91,8 +105,13 @@ class LiteNames {
|
|
|
91
105
|
renamed++;
|
|
92
106
|
}
|
|
93
107
|
const membership = this.meta.membership(ref, { inherit: false, lang: this.lang });
|
|
94
|
-
for (const e of (0, lite_1.enumsOfNodes)([...membership.rooms, ...membership.functions])) {
|
|
95
|
-
const entry = enums.get(e.id) ?? {
|
|
108
|
+
for (const e of (0, lite_1.enumsOfNodes)([...membership.rooms, ...membership.functions], nameOf)) {
|
|
109
|
+
const entry = enums.get(e.id) ?? {
|
|
110
|
+
name: e.name,
|
|
111
|
+
path: e.path,
|
|
112
|
+
builtin: e.builtin,
|
|
113
|
+
members: new Set(),
|
|
114
|
+
};
|
|
96
115
|
entry.members.add(obj._id);
|
|
97
116
|
enums.set(e.id, entry);
|
|
98
117
|
}
|
|
@@ -116,41 +135,69 @@ class LiteNames {
|
|
|
116
135
|
}
|
|
117
136
|
}
|
|
118
137
|
/**
|
|
119
|
-
* Brings the rooms and functions in line
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
138
|
+
* Brings the rooms and functions in line, as ioBroker.hm-rega does with the CCU's rooms: an enum of the id
|
|
139
|
+
* wanted is carried on, whoever made it (its name, icon and the members of others stay; it is marked as
|
|
140
|
+
* managed from then on). For one of the CCU's own rooms the import named in German, hm-rega's enum of the
|
|
141
|
+
* key is taken when there is none of the name (`Wohnzimmer` → `enum.rooms.LivingRoom`). Only the members of
|
|
142
|
+
* this instance are managed (another instance on the same system, or the user, may have added others), and
|
|
143
|
+
* only in the enums this adapter manages: an enum it does not want and never managed - one made by hand, or
|
|
144
|
+
* one hm-rega made for a room the system does not have - is not touched. An enum this adapter created goes
|
|
145
|
+
* when it has no members left. An enum is always written whole: `extendObject` merges arrays index-wise, so
|
|
146
|
+
* a shorter member list would leave the old entries behind.
|
|
123
147
|
*
|
|
124
|
-
* @param
|
|
148
|
+
* @param wantedByName enum id → name, path and the members of this instance
|
|
125
149
|
* @returns how many enum objects were written or removed
|
|
126
150
|
*/
|
|
127
|
-
async syncEnums(
|
|
151
|
+
async syncEnums(wantedByName) {
|
|
128
152
|
const ns = `${this.adapter.namespace}.`;
|
|
129
153
|
const existing = {
|
|
130
154
|
...(await this.adapter.getForeignObjectsAsync('enum.rooms.*', 'enum')),
|
|
131
155
|
...(await this.adapter.getForeignObjectsAsync('enum.functions.*', 'enum')),
|
|
132
156
|
};
|
|
157
|
+
const wanted = new Map();
|
|
158
|
+
for (const [byName, want] of wantedByName) {
|
|
159
|
+
const id = !existing[byName] && want.builtin && (0, lite_1.isHmRegaEnumOf)(existing[want.builtin.id], want.builtin.key)
|
|
160
|
+
? want.builtin.id
|
|
161
|
+
: byName;
|
|
162
|
+
const same = wanted.get(id);
|
|
163
|
+
if (same) {
|
|
164
|
+
want.members.forEach(m => same.members.add(m));
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
wanted.set(id, want);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
133
170
|
let changed = 0;
|
|
134
171
|
for (const [id, obj] of Object.entries(existing)) {
|
|
172
|
+
const want = wanted.get(id);
|
|
173
|
+
const mark = obj.native?.hmRpc;
|
|
174
|
+
if (!want && !mark) {
|
|
175
|
+
// not ours, never was: the user's, or a room of hm-rega the system does not have
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
135
178
|
const members = membersOf(obj);
|
|
136
179
|
const foreign = members.filter(m => !m.startsWith(ns));
|
|
137
180
|
const ours = members.filter(m => m.startsWith(ns)).sort();
|
|
138
|
-
const want = wanted.get(id);
|
|
139
181
|
const wantedOurs = want ? [...want.members].sort() : [];
|
|
140
|
-
const
|
|
141
|
-
if (!want &&
|
|
182
|
+
const adopted = mark?.adopted === true;
|
|
183
|
+
if (!want && !adopted && foreign.length === 0) {
|
|
142
184
|
await this.adapter.delForeignObjectAsync(id);
|
|
143
185
|
changed++;
|
|
144
186
|
continue;
|
|
145
187
|
}
|
|
146
188
|
const membersChanged = JSON.stringify(ours) !== JSON.stringify(wantedOurs);
|
|
147
|
-
const nameChanged = want !== undefined &&
|
|
148
|
-
|
|
189
|
+
const nameChanged = want !== undefined && mark !== undefined && !adopted && obj.common.name !== want.name;
|
|
190
|
+
const adopt = want !== undefined && mark === undefined;
|
|
191
|
+
if (membersChanged || nameChanged || adopt) {
|
|
149
192
|
const next = structuredClone(obj);
|
|
150
193
|
next.common.members = [...foreign, ...wantedOurs];
|
|
151
194
|
if (nameChanged) {
|
|
152
195
|
next.common.name = want.name;
|
|
153
196
|
}
|
|
197
|
+
if (adopt) {
|
|
198
|
+
const native = { hmRpc: { path: want.path, adopted: true } };
|
|
199
|
+
next.native = { ...next.native, ...native };
|
|
200
|
+
}
|
|
154
201
|
await this.adapter.setForeignObjectAsync(id, next);
|
|
155
202
|
changed++;
|
|
156
203
|
}
|