homematic-manager 3.3.0 → 3.4.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/node_modules/@homematic-manager/backend/dist/api/backend.d.ts +10 -0
- package/node_modules/@homematic-manager/backend/dist/api/backend.js +79 -9
- package/node_modules/@homematic-manager/backend/dist/config/defaults.js +9 -1
- package/node_modules/@homematic-manager/backend/package.json +1 -1
- package/node_modules/@homematic-manager/core/dist/api/types.d.ts +27 -0
- package/node_modules/@homematic-manager/core/dist/api/types.js +2 -0
- package/node_modules/@homematic-manager/core/package.json +1 -1
- package/package.json +3 -3
- package/ui/assets/index-Ot-YDwXG.js +21 -0
- package/ui/index.html +1 -1
- package/ui/assets/index-Dj0A5Id7.js +0 -21
|
@@ -35,6 +35,8 @@ export declare const SERVICE_MESSAGE_POLL_MS = 300000;
|
|
|
35
35
|
export declare const REGA_CONNECT_WAIT_MS = 3000;
|
|
36
36
|
/** How long the HmIP `getParamset(:0, VALUES)` sweep waits for the device list to settle. */
|
|
37
37
|
export declare const HMIP_SWEEP_DELAY_MS = 1000;
|
|
38
|
+
/** Task 107: the addon's id on openccu-lite (`files/openccu-lite.json`), whose token the system mints. */
|
|
39
|
+
export declare const ADDON_ID = "hmm";
|
|
38
40
|
export interface BackendOptions extends Omit<ConfigStoreOptions, 'version'> {
|
|
39
41
|
/** `AppConfig.version`; the host passes its package version. */
|
|
40
42
|
readonly version?: string;
|
|
@@ -92,6 +94,14 @@ export interface BackendOptions extends Omit<ConfigStoreOptions, 'version'> {
|
|
|
92
94
|
/** Task 72: the same for the openccu-lite path of a remote connection. */
|
|
93
95
|
readonly createLiteInterfaces?: (options: LiteInterfacesOptions) => LiteInterfaces;
|
|
94
96
|
readonly liteOptions?: Partial<LiteInterfacesOptions>;
|
|
97
|
+
/**
|
|
98
|
+
* Task 107: the addon's id on openccu-lite, whose own API token the system mints from the
|
|
99
|
+
* manifest's `api_scopes` into `<addonTokenDir>/<id>.api`. Read when the connection is `local`:
|
|
100
|
+
* the token found there is what makes the interfaces go through lite-rpc on the system itself.
|
|
101
|
+
* `hmm` unless a test says otherwise; the directory is occulite-client's default.
|
|
102
|
+
*/
|
|
103
|
+
readonly addonId?: string;
|
|
104
|
+
readonly addonTokenDir?: string;
|
|
95
105
|
/** Task 72: occulite-client's `pair()`, replaced by the tests. */
|
|
96
106
|
readonly pair?: PairWithSystemOptions['pair'];
|
|
97
107
|
readonly createRega?: (options: RegaServiceOptions) => RegaService;
|
|
@@ -26,8 +26,9 @@ import { BackendError, configError, connectionError, errorMessage, internalError
|
|
|
26
26
|
import { DEFAULT_IDLE_UNSUBSCRIBE_MS, InterfaceManager, LOOPBACK_IP, callbackBindHost, firstBidcosInterfaceAddress, } from '../interfaces/manager.js';
|
|
27
27
|
import { LiteInterfaces } from '../interfaces/lite.js';
|
|
28
28
|
import { HeatingGroupsClient } from '../groups/client.js';
|
|
29
|
-
import { MetaService, hostBaseUrl } from '../meta/service.js';
|
|
29
|
+
import { MetaService, hostBaseUrl, metaBaseUrl } from '../meta/service.js';
|
|
30
30
|
import { DETECT_TIMEOUT_MS, detectSystem, pairWithSystem, testSystem, transportFor, } from '../meta/system.js';
|
|
31
|
+
import { nodeAuth } from 'occulite-client/node';
|
|
31
32
|
import { RegaService } from '../rega/client.js';
|
|
32
33
|
import { listDevicesAnswer } from '../rpc/server.js';
|
|
33
34
|
import { ApiEventEmitter } from '../util/emitter.js';
|
|
@@ -51,6 +52,8 @@ export const REGA_CONNECT_WAIT_MS = 3000;
|
|
|
51
52
|
const OWN_PARAMSETS = new Set(['MASTER', 'VALUES', 'SERVICE', 'ROUTING_TABLE']);
|
|
52
53
|
/** How long the HmIP `getParamset(:0, VALUES)` sweep waits for the device list to settle. */
|
|
53
54
|
export const HMIP_SWEEP_DELAY_MS = 1000;
|
|
55
|
+
/** Task 107: the addon's id on openccu-lite (`files/openccu-lite.json`), whose token the system mints. */
|
|
56
|
+
export const ADDON_ID = 'hmm';
|
|
54
57
|
/**
|
|
55
58
|
* An HmIP interface, by name or by interface type - the same rule the UI's settings dialog uses to
|
|
56
59
|
* count the messages it asks about (task 34), so the question and the writes agree.
|
|
@@ -88,6 +91,12 @@ export class Backend {
|
|
|
88
91
|
#manager;
|
|
89
92
|
/** Task 72: counts the connects, so a connect that waited for the probe knows it is still the current one. */
|
|
90
93
|
#connectSeq = 0;
|
|
94
|
+
/**
|
|
95
|
+
* Task 107: the addon's own API token, read at every connect of a `local` connection. Found,
|
|
96
|
+
* the host is an openccu-lite system that minted it (nothing else writes that directory), and
|
|
97
|
+
* the settings dialog may offer the choice between lite-rpc and the direct connection.
|
|
98
|
+
*/
|
|
99
|
+
#addonToken;
|
|
91
100
|
/** Task 72: the pairing with an openccu-lite system that is running, if any. */
|
|
92
101
|
#pairing;
|
|
93
102
|
#rega;
|
|
@@ -611,7 +620,7 @@ export class Backend {
|
|
|
611
620
|
return runWithOrigin('background', () => this.#connectNow());
|
|
612
621
|
}
|
|
613
622
|
async #connectNow() {
|
|
614
|
-
const
|
|
623
|
+
const configured = this.#config.connection;
|
|
615
624
|
const seq = ++this.#connectSeq;
|
|
616
625
|
this.#paramsetIds.clear();
|
|
617
626
|
this.#noServiceMessages.clear();
|
|
@@ -624,7 +633,29 @@ export class Backend {
|
|
|
624
633
|
// the probe waited for - for everybody else (the addon on the system, a profile without a
|
|
625
634
|
// token, every CCU) it runs alongside the interface start as before (D-40's rule: a host
|
|
626
635
|
// that swallows the packet holds up the names, never the interfaces).
|
|
627
|
-
|
|
636
|
+
// Task 107: on the system itself the addon's own token decides. The system mints it from
|
|
637
|
+
// the manifest's scopes at every start, so finding it means "this is openccu-lite, and
|
|
638
|
+
// lite-rpc is open to us": the profile is moved to lite-rpc once (the marker says whether
|
|
639
|
+
// that happened before), and then its choice holds - `direct` keeps the callbacks.
|
|
640
|
+
let localLite = false;
|
|
641
|
+
if (configured.local === true) {
|
|
642
|
+
this.#addonToken = await this.#readAddonToken();
|
|
643
|
+
if (this.#superseded(seq)) {
|
|
644
|
+
return;
|
|
645
|
+
}
|
|
646
|
+
if (this.#addonToken !== undefined) {
|
|
647
|
+
await this.#migrateLocalRpc();
|
|
648
|
+
if (this.#superseded(seq)) {
|
|
649
|
+
return;
|
|
650
|
+
}
|
|
651
|
+
localLite = this.#config.connection.localRpc !== 'direct';
|
|
652
|
+
}
|
|
653
|
+
else if (configured.localRpc === 'lite') {
|
|
654
|
+
this.#notice('info', 'the profile asks for lite-rpc, but the system minted no API token for this addon (an openccu-lite before task 107, or a CCU): the interfaces are reached directly, with callbacks');
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
const connection = this.#config.connection;
|
|
658
|
+
const token = localLite ? this.#addonToken : (connection.metaToken ?? '').trim();
|
|
628
659
|
const mayBeRemoteLite = connection.local !== true && token !== '';
|
|
629
660
|
let hostProbe;
|
|
630
661
|
let liteProbe;
|
|
@@ -639,6 +670,7 @@ export class Backend {
|
|
|
639
670
|
else {
|
|
640
671
|
hostProbe = this.#probeHost(connection);
|
|
641
672
|
}
|
|
673
|
+
const useLite = localLite || liteProbe?.answer !== undefined;
|
|
642
674
|
const shared = {
|
|
643
675
|
connection,
|
|
644
676
|
handler: this.#callbackHandler(),
|
|
@@ -654,10 +686,11 @@ export class Backend {
|
|
|
654
686
|
},
|
|
655
687
|
originOf: currentOrigin,
|
|
656
688
|
};
|
|
657
|
-
const manager =
|
|
689
|
+
const manager = useLite
|
|
658
690
|
? (this.#options.createLiteInterfaces ?? ((options) => new LiteInterfaces(options)))({
|
|
659
691
|
...shared,
|
|
660
|
-
|
|
692
|
+
// on the system: the loopback lighttpd (or `metaUrl`, the integration tests' door)
|
|
693
|
+
baseUrl: localLite ? metaBaseUrl(connection) : (liteProbe?.baseUrl ?? hostBaseUrl(connection)),
|
|
661
694
|
token,
|
|
662
695
|
transport: transportFor({
|
|
663
696
|
fetch: this.#options.metaOptions?.fetch,
|
|
@@ -680,16 +713,17 @@ export class Backend {
|
|
|
680
713
|
...(this.#options.watchdogIntervalMs === undefined
|
|
681
714
|
? {}
|
|
682
715
|
: { watchdogIntervalMs: this.#options.watchdogIntervalMs }),
|
|
683
|
-
...(this.#options.localAddresses === undefined
|
|
684
|
-
? {}
|
|
685
|
-
: { localAddresses: this.#options.localAddresses }),
|
|
716
|
+
...(this.#options.localAddresses === undefined ? {} : { localAddresses: this.#options.localAddresses }),
|
|
686
717
|
...(this.#options.network === undefined ? {} : { network: this.#options.network }),
|
|
687
718
|
...(this.#keepsConfiguredCallbackIp() ? { keepConfiguredCallbackIp: true } : {}),
|
|
688
719
|
...(this.#options.now === undefined ? {} : { now: this.#options.now }),
|
|
689
720
|
...this.#options.interfaceManagerOptions,
|
|
690
721
|
});
|
|
691
722
|
this.#manager = manager;
|
|
692
|
-
if (
|
|
723
|
+
if (localLite) {
|
|
724
|
+
this.#notice('info', "this openccu-lite system: the interfaces are reached through its lite-rpc with the addon's own token, without callbacks (the direct connection is selectable in the settings)");
|
|
725
|
+
}
|
|
726
|
+
else if (liteProbe?.answer !== undefined) {
|
|
693
727
|
this.#notice('info', `${connection.host}: an openccu-lite system - the interfaces are reached through its lite-rpc with the API token, without callbacks`);
|
|
694
728
|
}
|
|
695
729
|
try {
|
|
@@ -756,6 +790,39 @@ export class Backend {
|
|
|
756
790
|
// B-70: counted from the start (or the reconnect of a save) when no page is open
|
|
757
791
|
this.#armIdleTimer();
|
|
758
792
|
}
|
|
793
|
+
/** Disconnected, or another connect started, while this one was waiting (read through a call, so an `await` cannot narrow it away). */
|
|
794
|
+
#superseded(seq) {
|
|
795
|
+
return this.#stopped || seq !== this.#connectSeq;
|
|
796
|
+
}
|
|
797
|
+
/** Task 107: the addon's own API token on openccu-lite, or `undefined` everywhere else. */
|
|
798
|
+
async #readAddonToken() {
|
|
799
|
+
const found = await nodeAuth({ addon: this.#options.addonId ?? ADDON_ID }, this.#options.addonTokenDir === undefined ? {} : { addonTokenDir: this.#options.addonTokenDir }).resolve('start');
|
|
800
|
+
const token = found.token?.trim() ?? '';
|
|
801
|
+
return token === '' ? undefined : token;
|
|
802
|
+
}
|
|
803
|
+
/**
|
|
804
|
+
* Task 107: the one-time move of a `local` profile to lite-rpc, on the first connect on
|
|
805
|
+
* openccu-lite that found the addon's token. A profile that was never moved - every one of an
|
|
806
|
+
* earlier version, which connected directly, and a fresh one - gets `localRpc: 'lite'` and the
|
|
807
|
+
* marker; a profile that carries the marker is left exactly as it is, whatever it says, so a
|
|
808
|
+
* `direct` the user chose afterwards survives every restart and update.
|
|
809
|
+
*/
|
|
810
|
+
async #migrateLocalRpc() {
|
|
811
|
+
const connection = this.#config.connection;
|
|
812
|
+
if (connection.connectionMigrated === 1) {
|
|
813
|
+
return;
|
|
814
|
+
}
|
|
815
|
+
const moved = connection.localRpc === undefined;
|
|
816
|
+
const config = this.#withHostFacts(await this.#config.setConnection({
|
|
817
|
+
...connection,
|
|
818
|
+
...(moved ? { localRpc: 'lite' } : {}),
|
|
819
|
+
connectionMigrated: 1,
|
|
820
|
+
}));
|
|
821
|
+
this.events.emit('config.changed', config);
|
|
822
|
+
if (moved) {
|
|
823
|
+
this.#notice('info', 'connection: moved to lite-rpc, the default on openccu-lite - once; the direct connection with callbacks stays selectable in the settings and is never changed again');
|
|
824
|
+
}
|
|
825
|
+
}
|
|
759
826
|
/**
|
|
760
827
|
* B-62: whether the connection's own host is an openccu-lite system - decided from what exists,
|
|
761
828
|
* openccu-lite's own rule (D-40): `GET /api/meta/v1/version` on the host itself answers
|
|
@@ -1167,6 +1234,9 @@ export class Backend {
|
|
|
1167
1234
|
...(ports === undefined ? {} : { callbackDefaultPorts: { xmlrpc: ports.xmlrpc, binrpc: ports.binrpc } }),
|
|
1168
1235
|
...(pins === undefined ? {} : { callbackPinned: { ...pins } }),
|
|
1169
1236
|
...(publish ? { publishCallbackPorts: true } : {}),
|
|
1237
|
+
// task 107: the addon's token was found, so the host is an openccu-lite system and the
|
|
1238
|
+
// settings dialog may offer lite-rpc or the direct connection
|
|
1239
|
+
...(this.#addonToken === undefined ? {} : { liteSystem: true }),
|
|
1170
1240
|
// B-70: only a host that goes idle offers the time; the default of an unpinned host is
|
|
1171
1241
|
// D-31's default (never, since B-95), whatever it was started with, so "the default" means one thing
|
|
1172
1242
|
...(idle === undefined
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* have - is caught here rather than at the first `init` call, where the error would arrive as a
|
|
7
7
|
* socket timeout twenty seconds later.
|
|
8
8
|
*/
|
|
9
|
-
import { DEFAULT_INTERFACES, INTERFACE_NAMES, META_PROVIDERS, isKnownInterface, resolveInterface, resolveUserDefinedInterface, validateUserDefinedInterface, } from '@homematic-manager/core';
|
|
9
|
+
import { DEFAULT_INTERFACES, INTERFACE_NAMES, LOCAL_RPC_CHOICES, META_PROVIDERS, isKnownInterface, resolveInterface, resolveUserDefinedInterface, validateUserDefinedInterface, } from '@homematic-manager/core';
|
|
10
10
|
/**
|
|
11
11
|
* Minimum pause between two writes to one interface.
|
|
12
12
|
*
|
|
@@ -85,6 +85,12 @@ export function normaliseConnection(input) {
|
|
|
85
85
|
const metaProvider = META_PROVIDERS.find((candidate) => candidate === raw.metaProvider);
|
|
86
86
|
const metaToken = stringOr(raw.metaToken, '').trim();
|
|
87
87
|
const metaUrl = stringOr(raw.metaUrl, '').trim();
|
|
88
|
+
// Task 107: the addon's way to the interfaces on openccu-lite, and the marker that the
|
|
89
|
+
// one-time move to lite-rpc has run. A value that is neither choice is dropped (the backend
|
|
90
|
+
// then treats the profile as never migrated, which is the safe reading); the marker is kept
|
|
91
|
+
// only as the `1` this version writes.
|
|
92
|
+
const localRpc = LOCAL_RPC_CHOICES.find((candidate) => candidate === raw.localRpc);
|
|
93
|
+
const connectionMigrated = raw.connectionMigrated === 1 ? 1 : undefined;
|
|
88
94
|
const connection = {
|
|
89
95
|
host: stringOr(raw.host, defaults.host).trim(),
|
|
90
96
|
interfaces: interfaces.length > 0 ? [...new Set(interfaces)] : defaults.interfaces,
|
|
@@ -92,6 +98,8 @@ export function normaliseConnection(input) {
|
|
|
92
98
|
extraInterfaces,
|
|
93
99
|
tls: typeof raw.tls === 'boolean' ? raw.tls : defaults.tls,
|
|
94
100
|
...(raw.local === true ? { local: true } : {}),
|
|
101
|
+
...(localRpc === undefined ? {} : { localRpc }),
|
|
102
|
+
...(connectionMigrated === undefined ? {} : { connectionMigrated }),
|
|
95
103
|
rega: typeof raw.rega === 'boolean' ? raw.rega : defaults.rega,
|
|
96
104
|
callback: {
|
|
97
105
|
ip: stringOr(callback['ip'], defaults.callback.ip).trim(),
|
|
@@ -32,6 +32,23 @@ export interface ConnectionConfig {
|
|
|
32
32
|
* and no CCU authentication. What the addon of task 13 sets; `local` wins over `tls`.
|
|
33
33
|
*/
|
|
34
34
|
local?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Task 107: how the addon on an openccu-lite system (`local`) reaches the interface processes.
|
|
37
|
+
*
|
|
38
|
+
* `lite` (the default) goes through the system's lite-rpc with the addon's own API token - one
|
|
39
|
+
* subscriber at the daemons for every client, the events replayed after a break, nothing
|
|
40
|
+
* registered with `init`; `direct` keeps the CCU way, XML-RPC/BIN-RPC on the processes' own
|
|
41
|
+
* ports with callback servers, for whoever wants it (CUxD, say, which lite-rpc does not carry).
|
|
42
|
+
* Read only on a system that minted the addon's token; a CCU connects directly whatever it says.
|
|
43
|
+
*/
|
|
44
|
+
localRpc?: LocalRpcChoice;
|
|
45
|
+
/**
|
|
46
|
+
* Task 107: the one-time move to lite-rpc has run (`1`). A profile that connected directly to
|
|
47
|
+
* the interfaces is moved to `lite` once, at the first start on openccu-lite that finds the
|
|
48
|
+
* addon's token; from then on the choice is the user's, and a later version never moves it
|
|
49
|
+
* again - so `direct` chosen afterwards stays `direct` across restarts and updates.
|
|
50
|
+
*/
|
|
51
|
+
connectionMigrated?: number;
|
|
35
52
|
auth?: {
|
|
36
53
|
user: string;
|
|
37
54
|
password: string;
|
|
@@ -260,6 +277,12 @@ export interface AppConfig {
|
|
|
260
277
|
defaultMs: number;
|
|
261
278
|
pinnedMs?: number;
|
|
262
279
|
};
|
|
280
|
+
/**
|
|
281
|
+
* Task 107: the host runs as the addon on an openccu-lite system that minted its API token, so
|
|
282
|
+
* the settings dialog offers {@link ConnectionConfig.localRpc}. A property of the host, learnt at
|
|
283
|
+
* the connect; absent everywhere else, where the choice means nothing.
|
|
284
|
+
*/
|
|
285
|
+
liteSystem?: boolean;
|
|
263
286
|
}
|
|
264
287
|
/**
|
|
265
288
|
* B-53 (#162, #165): why the automatic callback address is the one it is.
|
|
@@ -496,6 +519,10 @@ export type NameMap = Record<string, string>;
|
|
|
496
519
|
export type MetaProviderChoice = 'auto' | 'local' | 'occulite' | 'rega';
|
|
497
520
|
/** The values of {@link MetaProviderChoice} as a runtime list, for validation and a select. */
|
|
498
521
|
export declare const META_PROVIDERS: readonly MetaProviderChoice[];
|
|
522
|
+
/** Task 107: {@link ConnectionConfig.localRpc} - the addon's way to the interfaces on openccu-lite. */
|
|
523
|
+
export type LocalRpcChoice = 'lite' | 'direct';
|
|
524
|
+
/** The values of {@link LocalRpcChoice} as a runtime list, for validation and a select. */
|
|
525
|
+
export declare const LOCAL_RPC_CHOICES: readonly LocalRpcChoice[];
|
|
499
526
|
/**
|
|
500
527
|
* D-40: which store the names, rooms and functions come from, and whether it can be written.
|
|
501
528
|
*
|
|
@@ -23,6 +23,8 @@ export function callbackPinOption(field) {
|
|
|
23
23
|
}
|
|
24
24
|
/** The values of {@link MetaProviderChoice} as a runtime list, for validation and a select. */
|
|
25
25
|
export const META_PROVIDERS = Object.freeze(['auto', 'local', 'occulite', 'rega']);
|
|
26
|
+
/** The values of {@link LocalRpcChoice} as a runtime list, for validation and a select. */
|
|
27
|
+
export const LOCAL_RPC_CHOICES = Object.freeze(['lite', 'direct']);
|
|
26
28
|
export const RPC_ORIGINS = Object.freeze(['console', 'ui', 'background']);
|
|
27
29
|
/**
|
|
28
30
|
* Every event of {@link ApiEvents} as a runtime value, because a type has none.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "homematic-manager",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0",
|
|
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.4.0"
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"@homematic-manager/backend": "3.
|
|
71
|
-
"@homematic-manager/core": "3.
|
|
70
|
+
"@homematic-manager/backend": "3.4.0",
|
|
71
|
+
"@homematic-manager/core": "3.4.0",
|
|
72
72
|
"binrpc": "^4.2.0",
|
|
73
73
|
"homematic-rega": "^2.0.0",
|
|
74
74
|
"homematic-xmlrpc": "^2.0.0",
|