@camstack/addon-provider-homematic 1.2.191 → 1.2.193
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/CHANGELOG.md +13 -0
- package/README.md +8 -0
- package/dist/.bundle-modules.json +7 -4
- package/dist/_stub.js +1168 -1012
- package/dist/{_virtual_mf-localSharedImportMap___mfe_internal__addon_provider_homematic_page-BxV9YeD6.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_provider_homematic_page-Da2xbO9l.mjs} +4 -4
- package/dist/_virtual_mf___mfe_internal__addon_provider_homematic_page__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-CqBgrgbo.mjs +26 -0
- package/dist/addon-provider-homematic.css +1 -1
- package/dist/addon.js +2005 -827
- package/dist/addon.mjs +2006 -828
- package/dist/{hostInit-CVYnx4wT.mjs → hostInit-DAlzBsEA.mjs} +3 -3
- package/dist/index.mjs +1 -1
- package/dist/remoteEntry.js +1 -1
- package/dist/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__addon_provider_homematic_page__remoteEntry_js-DtvMyC4I.mjs → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__addon_provider_homematic_page__remoteEntry_js-BvA2vFCp.mjs} +1 -1
- package/i18n/en.json +5 -1
- package/i18n/it.json +5 -1
- package/package.json +3 -3
- package/dist/_virtual_mf___mfe_internal__addon_provider_homematic_page__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-DsJZKFzR.mjs +0 -26
package/dist/addon.js
CHANGED
|
@@ -8,7 +8,7 @@ let crypto$1 = require("crypto");
|
|
|
8
8
|
let fs_promises = require("fs/promises");
|
|
9
9
|
let path = require("path");
|
|
10
10
|
let node_os = require("node:os");
|
|
11
|
-
//#region ../types/dist/event-category-
|
|
11
|
+
//#region ../types/dist/event-category-Dv-Gcv1f.mjs
|
|
12
12
|
var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
13
13
|
EventCategory["SystemBoot"] = "system.boot";
|
|
14
14
|
EventCategory["SystemAddonsReady"] = "system.addons-ready";
|
|
@@ -449,6 +449,15 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
|
449
449
|
*/
|
|
450
450
|
EventCategory["DeviceStateChanged"] = "device.state-changed";
|
|
451
451
|
/**
|
|
452
|
+
* A device COMMAND (a vocabulary action, D920/D983) settled in the hub's
|
|
453
|
+
* transition audit (D1022): confirmed, already in place, unconfirmed or
|
|
454
|
+
* failed. Never a device's own change. Payload: `DeviceCommandSettledEvent`
|
|
455
|
+
* (`{deviceId, action, outcome, actor, at}`, no arguments). It feeds
|
|
456
|
+
* the Notification Center `device-command` kind. Telemetry (D8): losing one
|
|
457
|
+
* costs a notification, never state; the audit row is the record.
|
|
458
|
+
*/
|
|
459
|
+
EventCategory["DeviceCommandSettled"] = "device.command-settled";
|
|
460
|
+
/**
|
|
452
461
|
* The NATIVE shadow of a cap a composition has claimed fields of moved
|
|
453
462
|
* (D663). Payload: `{ deviceId, capName, native }` — what the provider
|
|
454
463
|
* wrote, BEFORE the owned fields are overlaid. Owner-only (D224): it is for
|
|
@@ -811,7 +820,7 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
|
811
820
|
return EventCategory;
|
|
812
821
|
}({});
|
|
813
822
|
//#endregion
|
|
814
|
-
//#region ../types/dist/composed-stable-id-
|
|
823
|
+
//#region ../types/dist/composed-stable-id-iddnCQ51.mjs
|
|
815
824
|
/**
|
|
816
825
|
import { errMsg } from '@camstack/types'
|
|
817
826
|
* Extract a human-readable message from an unknown error value.
|
|
@@ -1153,6 +1162,11 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
|
|
|
1153
1162
|
* with the switch's on/off only. Speed or oscillation appear only when the
|
|
1154
1163
|
* device also has a fan cap (D1033). */
|
|
1155
1164
|
DeviceRole["SwitchFan"] = "switch-fan";
|
|
1165
|
+
/** A relay driving an on/off-only lamp: drawn as a light (bulb and glow, no
|
|
1166
|
+
* slider), presented to the exports as a light with power only. Not a
|
|
1167
|
+
* `light` type: the provider owns the type, and a light implies brightness
|
|
1168
|
+
* or colour this relay lacks. */
|
|
1169
|
+
DeviceRole["SwitchLight"] = "switch-light";
|
|
1156
1170
|
/** Air conditioner / split unit: cooling, fan speed, louvres. */
|
|
1157
1171
|
DeviceRole["ClimateAc"] = "climate-ac";
|
|
1158
1172
|
/** Room thermostat: a setpoint and a room temperature. The default. */
|
|
@@ -6053,7 +6067,7 @@ var ZodIssueCode = {
|
|
|
6053
6067
|
var ZodFirstPartyTypeKind;
|
|
6054
6068
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
6055
6069
|
//#endregion
|
|
6056
|
-
//#region ../types/dist/sleep-
|
|
6070
|
+
//#region ../types/dist/sleep-BvVGLl30.mjs
|
|
6057
6071
|
/**
|
|
6058
6072
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
6059
6073
|
* window to float samples (D455).
|
|
@@ -6736,6 +6750,13 @@ async function runAddonMigrations(host, migrations, logger, options = {}) {
|
|
|
6736
6750
|
else skipped.push(id);
|
|
6737
6751
|
};
|
|
6738
6752
|
const selected = options.only === void 0 ? null : new Set(options.only);
|
|
6753
|
+
const deferred = /* @__PURE__ */ new Set();
|
|
6754
|
+
const deferredBy = (reason) => {
|
|
6755
|
+
if (selected === null || reason === null) return null;
|
|
6756
|
+
const dep = /^dependency-(?:pending|blocked):(.+)$/.exec(reason)?.[1];
|
|
6757
|
+
if (dep === void 0 || !byId.has(dep)) return null;
|
|
6758
|
+
return !selected.has(dep) || deferred.has(dep) ? dep : null;
|
|
6759
|
+
};
|
|
6739
6760
|
for (const step of declaration.steps) {
|
|
6740
6761
|
if (selected !== null && !selected.has(step.id)) continue;
|
|
6741
6762
|
const bound = byId.get(step.id);
|
|
@@ -6747,6 +6768,19 @@ async function runAddonMigrations(host, migrations, logger, options = {}) {
|
|
|
6747
6768
|
try {
|
|
6748
6769
|
const gate = await host.startMigration({ id: step.id });
|
|
6749
6770
|
if (!gate.proceed) {
|
|
6771
|
+
const waitsFor = deferredBy(gate.reason);
|
|
6772
|
+
if (waitsFor !== null) {
|
|
6773
|
+
log.info("migration deferred: its predecessor runs in another phase of this owner", {
|
|
6774
|
+
tags,
|
|
6775
|
+
meta: {
|
|
6776
|
+
waitsFor,
|
|
6777
|
+
reason: gate.reason
|
|
6778
|
+
}
|
|
6779
|
+
});
|
|
6780
|
+
deferred.add(step.id);
|
|
6781
|
+
skipped.push(step.id);
|
|
6782
|
+
continue;
|
|
6783
|
+
}
|
|
6750
6784
|
log.warn("migration not run", {
|
|
6751
6785
|
tags,
|
|
6752
6786
|
meta: {
|
|
@@ -10224,6 +10258,13 @@ var DeviceTransitionSchema = object({
|
|
|
10224
10258
|
actor: TransitionActorSchema,
|
|
10225
10259
|
command: TransitionCommandSchema.optional()
|
|
10226
10260
|
});
|
|
10261
|
+
object({
|
|
10262
|
+
deviceId: number$1().int(),
|
|
10263
|
+
action: string(),
|
|
10264
|
+
outcome: TransitionOutcomeSchema,
|
|
10265
|
+
actor: TransitionActorSchema,
|
|
10266
|
+
at: number$1()
|
|
10267
|
+
});
|
|
10227
10268
|
var READING_QUANTITIES = [
|
|
10228
10269
|
"temperature",
|
|
10229
10270
|
"pressure",
|
|
@@ -10767,6 +10808,13 @@ var ACTUATOR_CAP_VOCABULARY = {
|
|
|
10767
10808
|
},
|
|
10768
10809
|
state: { on: { icon: "lightbulb" } }
|
|
10769
10810
|
},
|
|
10811
|
+
[DeviceRole.SwitchLight]: {
|
|
10812
|
+
actions: {
|
|
10813
|
+
"switch.on": { icon: "lightbulb" },
|
|
10814
|
+
"switch.off": { icon: "lightbulb-off" }
|
|
10815
|
+
},
|
|
10816
|
+
state: { on: { icon: "lightbulb" } }
|
|
10817
|
+
},
|
|
10770
10818
|
[DeviceRole.Chime]: { actions: {
|
|
10771
10819
|
"switch.on": {
|
|
10772
10820
|
label: t("Enable chime", "Attiva il campanello"),
|
|
@@ -12247,7 +12295,10 @@ var ACTUATOR_CAP_VOCABULARY = {
|
|
|
12247
12295
|
"ir-transmitter": {
|
|
12248
12296
|
scope: "device",
|
|
12249
12297
|
noun: t("IR / RF transmitter", "Trasmettitore IR / RF"),
|
|
12250
|
-
notOperatorFacing: {
|
|
12298
|
+
notOperatorFacing: {
|
|
12299
|
+
send: "a raw pulse train is not something an operator composes in an automation; the remote that owns the command table sends it",
|
|
12300
|
+
learn: "an interactive capture the operator starts from the source dialog and answers by pressing a physical remote; no automation can supply the signal"
|
|
12301
|
+
}
|
|
12251
12302
|
},
|
|
12252
12303
|
control: {
|
|
12253
12304
|
scope: "device",
|
|
@@ -15168,6 +15219,32 @@ var CAP_VOCABULARY_BY_NAME = {
|
|
|
15168
15219
|
...SYSTEM_CAP_VOCABULARY
|
|
15169
15220
|
};
|
|
15170
15221
|
/**
|
|
15222
|
+
* Vocabulary actions by id (D983). An action step names a vocabulary action
|
|
15223
|
+
* (`cover.open`), never a raw cap method; this is the one lookup that turns the
|
|
15224
|
+
* id into its cap, method and effect — and a persisted legacy `cap` + `method`
|
|
15225
|
+
* pair back into the action id when exactly one action matches.
|
|
15226
|
+
*/
|
|
15227
|
+
function buildIndex() {
|
|
15228
|
+
const byId = /* @__PURE__ */ new Map();
|
|
15229
|
+
for (const [cap, entry] of Object.entries(CAP_VOCABULARY_BY_NAME)) {
|
|
15230
|
+
if (entry.scope !== "device") continue;
|
|
15231
|
+
for (const action of entry.actions ?? []) byId.set(action.id, {
|
|
15232
|
+
cap,
|
|
15233
|
+
action
|
|
15234
|
+
});
|
|
15235
|
+
}
|
|
15236
|
+
return byId;
|
|
15237
|
+
}
|
|
15238
|
+
var index;
|
|
15239
|
+
function actionIndex() {
|
|
15240
|
+
index ??= buildIndex();
|
|
15241
|
+
return index;
|
|
15242
|
+
}
|
|
15243
|
+
/** The vocabulary action with this id, or `undefined`. */
|
|
15244
|
+
function findVocabAction(actionId) {
|
|
15245
|
+
return actionIndex().get(actionId);
|
|
15246
|
+
}
|
|
15247
|
+
/**
|
|
15171
15248
|
* `addon-pages-source` — collection cap exposing per-provider raw page
|
|
15172
15249
|
* declarations. Every addon that contributes a UI page registers a
|
|
15173
15250
|
* provider here. The hub-side singleton aggregator (`addon-pages` cap,
|
|
@@ -17475,7 +17552,7 @@ Object.freeze({
|
|
|
17475
17552
|
}
|
|
17476
17553
|
});
|
|
17477
17554
|
//#endregion
|
|
17478
|
-
//#region ../types/dist/implemented-methods-
|
|
17555
|
+
//#region ../types/dist/implemented-methods-CSTk6zYK.mjs
|
|
17479
17556
|
/**
|
|
17480
17557
|
* The ffmpeg build every CamStack node downloads, per platform and arch.
|
|
17481
17558
|
*
|
|
@@ -17529,6 +17606,30 @@ function portable(target) {
|
|
|
17529
17606
|
}
|
|
17530
17607
|
portable("linux64"), portable("linuxarm64"), portable("macarm64"), portable("mac64"), `${BASE}${FFMPEG_RELEASE}`;
|
|
17531
17608
|
/**
|
|
17609
|
+
* A device's KIND is its type plus its role (D1033): the type is the set of
|
|
17610
|
+
* controls it has, the role says which thing it is among the devices that
|
|
17611
|
+
* share those controls. A plug-in heater is a `switch` with role
|
|
17612
|
+
* `switch-heater`; an air conditioner and a radiator valve are both `climate`,
|
|
17613
|
+
* told apart by their `climate-*` role.
|
|
17614
|
+
*/
|
|
17615
|
+
/**
|
|
17616
|
+
* Type values a persisted row may still carry after the type was retired, and
|
|
17617
|
+
* the type each one is read as. The row is rewritten by the next registration
|
|
17618
|
+
* of the device (its provider stamps the live type), so this is a read alias,
|
|
17619
|
+
* not a migration.
|
|
17620
|
+
*
|
|
17621
|
+
* `heater` is deliberately absent: the only heaters were composed devices the
|
|
17622
|
+
* operator deletes. Such a row stays an unknown type, which every reader
|
|
17623
|
+
* treats as a generic device.
|
|
17624
|
+
*/
|
|
17625
|
+
var RETIRED_DEVICE_TYPES = { thermostat: DeviceType.Climate };
|
|
17626
|
+
/** The live type a stored `type` value stands for (itself unless retired). */
|
|
17627
|
+
function canonicalStoredDeviceType(stored) {
|
|
17628
|
+
return RETIRED_DEVICE_TYPES[stored] ?? stored;
|
|
17629
|
+
}
|
|
17630
|
+
preprocess((value) => typeof value === "string" ? canonicalStoredDeviceType(value) : value, _enum(DeviceType));
|
|
17631
|
+
DeviceRole.ClimateThermostat, DeviceRole.ClimateAc, DeviceRole.ClimateRadiator, DeviceRole.ClimateFloor, DeviceRole.ClimateHeater, DeviceRole.ClimateHeatPumpCircuit;
|
|
17632
|
+
/**
|
|
17532
17633
|
* THE table "which boolean of this device type counts as HIGH", and the
|
|
17533
17634
|
* pure evaluator of its EDGE.
|
|
17534
17635
|
*
|
|
@@ -23379,7 +23480,7 @@ var DeviceTokenScopeSchema = object({
|
|
|
23379
23480
|
function migrateLegacyTokenScope(raw) {
|
|
23380
23481
|
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
|
|
23381
23482
|
if (Reflect.get(raw, "type") !== "device") return raw;
|
|
23382
|
-
if (Reflect.get(raw, "selector") !== void 0) return raw;
|
|
23483
|
+
if (Reflect.get(raw, "selector") !== void 0) return canonicalSelectorTypes(raw);
|
|
23383
23484
|
const targets = Reflect.get(raw, "targets");
|
|
23384
23485
|
if (!Array.isArray(targets)) return raw;
|
|
23385
23486
|
return {
|
|
@@ -23391,6 +23492,27 @@ function migrateLegacyTokenScope(raw) {
|
|
|
23391
23492
|
access: Reflect.get(raw, "access")
|
|
23392
23493
|
};
|
|
23393
23494
|
}
|
|
23495
|
+
/**
|
|
23496
|
+
* A stored `types` selector may name a type D1033 retired (`thermostat`). The
|
|
23497
|
+
* grant is read back through this same preprocess, so the retired name is
|
|
23498
|
+
* rewritten to its canonical type here and {@link DeviceSelectorSchema} itself
|
|
23499
|
+
* stays a strict enum on the wire.
|
|
23500
|
+
*/
|
|
23501
|
+
function canonicalSelectorTypes(raw) {
|
|
23502
|
+
const selector = Reflect.get(raw, "selector");
|
|
23503
|
+
if (selector === null || typeof selector !== "object") return raw;
|
|
23504
|
+
if (Reflect.get(selector, "kind") !== "types") return raw;
|
|
23505
|
+
const types = Reflect.get(selector, "types");
|
|
23506
|
+
if (!Array.isArray(types)) return raw;
|
|
23507
|
+
const canonical = types.map((t) => typeof t === "string" ? canonicalStoredDeviceType(t) : t);
|
|
23508
|
+
return {
|
|
23509
|
+
...raw,
|
|
23510
|
+
selector: {
|
|
23511
|
+
...selector,
|
|
23512
|
+
types: canonical
|
|
23513
|
+
}
|
|
23514
|
+
};
|
|
23515
|
+
}
|
|
23394
23516
|
var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
|
|
23395
23517
|
object({
|
|
23396
23518
|
type: literal("category"),
|
|
@@ -44082,6 +44204,59 @@ function macroOnly(macro) {
|
|
|
44082
44204
|
};
|
|
44083
44205
|
}
|
|
44084
44206
|
}
|
|
44207
|
+
var EventVocabularyKindSchema = _enum([
|
|
44208
|
+
"press",
|
|
44209
|
+
"long-press",
|
|
44210
|
+
"long-press-start",
|
|
44211
|
+
"release",
|
|
44212
|
+
"repeat",
|
|
44213
|
+
"double-press",
|
|
44214
|
+
"other"
|
|
44215
|
+
]);
|
|
44216
|
+
/** The part of the device an event comes from: a button, a channel. */
|
|
44217
|
+
var EventVocabularySourceSchema = object({
|
|
44218
|
+
id: string().min(1),
|
|
44219
|
+
label: string().min(1)
|
|
44220
|
+
});
|
|
44221
|
+
/** One scalar field of an event's `data`, by dotted path. */
|
|
44222
|
+
var EventVocabularyFieldSchema = object({
|
|
44223
|
+
path: string().min(1),
|
|
44224
|
+
kind: _enum([
|
|
44225
|
+
"string",
|
|
44226
|
+
"number",
|
|
44227
|
+
"boolean",
|
|
44228
|
+
"enum"
|
|
44229
|
+
]),
|
|
44230
|
+
enumValues: array(string()).optional(),
|
|
44231
|
+
label: string().min(1).optional()
|
|
44232
|
+
});
|
|
44233
|
+
var EventVocabularyEntrySchema = object({
|
|
44234
|
+
/** The native token, verbatim. */
|
|
44235
|
+
id: string().min(1),
|
|
44236
|
+
source: EventVocabularySourceSchema.optional(),
|
|
44237
|
+
label: string().min(1),
|
|
44238
|
+
description: string().optional(),
|
|
44239
|
+
kind: EventVocabularyKindSchema.optional(),
|
|
44240
|
+
payload: array(EventVocabularyFieldSchema).optional()
|
|
44241
|
+
});
|
|
44242
|
+
/**
|
|
44243
|
+
* The vocabulary of a source that declares tokens and nothing else: one
|
|
44244
|
+
* entry per token, labelled with the token itself.
|
|
44245
|
+
*/
|
|
44246
|
+
function plainEventVocabulary(eventTypes) {
|
|
44247
|
+
return [...new Set(eventTypes)].filter((eventType) => eventType !== "").map((eventType) => ({
|
|
44248
|
+
id: eventType,
|
|
44249
|
+
label: eventType
|
|
44250
|
+
}));
|
|
44251
|
+
}
|
|
44252
|
+
/** The native tokens of a vocabulary, each once, in declaration order. */
|
|
44253
|
+
function eventTypesOfVocabulary(vocabulary) {
|
|
44254
|
+
return [...new Set(vocabulary.map((entry) => entry.id))];
|
|
44255
|
+
}
|
|
44256
|
+
/** The entry a fire belongs to: same token, same source (or both without one). */
|
|
44257
|
+
function findVocabularyEntry(vocabulary, eventType, sourceId) {
|
|
44258
|
+
return vocabulary.find((entry) => entry.id === eventType && entry.source?.id === sourceId);
|
|
44259
|
+
}
|
|
44085
44260
|
Math.PI / 180;
|
|
44086
44261
|
/**
|
|
44087
44262
|
* WHEN something happens, as data (D983) — the one time vocabulary of the
|
|
@@ -44289,6 +44464,33 @@ var ScheduleLeafSchema = object({
|
|
|
44289
44464
|
/** @deprecated legacy cron — new schedules use `at`. */
|
|
44290
44465
|
cron: string().min(1).max(120).optional()
|
|
44291
44466
|
}).refine((leaf) => leaf.at === void 0 !== (leaf.cron === void 0), { message: "a schedule names exactly one of `at` (a time spec) and `cron` (legacy)" }).refine((leaf) => leaf.days === void 0 || leaf.at !== void 0, { message: "`days` goes with `at`; a cron expression carries its own days" });
|
|
44467
|
+
/**
|
|
44468
|
+
* One payload predicate of a `device-fired` row: the value at `path` inside
|
|
44469
|
+
* the fire's `data` (dotted) equals `equals`. Compared strictly, no coercion.
|
|
44470
|
+
*/
|
|
44471
|
+
var DeviceFiredMatchSchema = object({
|
|
44472
|
+
path: string().min(1).max(120),
|
|
44473
|
+
equals: union([
|
|
44474
|
+
string(),
|
|
44475
|
+
number$1(),
|
|
44476
|
+
boolean()
|
|
44477
|
+
])
|
|
44478
|
+
});
|
|
44479
|
+
/**
|
|
44480
|
+
* "fires": one device of the `event-emitter` capability reported an event
|
|
44481
|
+
* (D1045). Every list is an OR, the lists together an AND; an absent list does
|
|
44482
|
+
* not narrow. `eventIds` are the device's own tokens, `sourceIds` the parts of
|
|
44483
|
+
* the device (a button), `kinds` the shared press kinds of its vocabulary.
|
|
44484
|
+
*/
|
|
44485
|
+
var DeviceFiredLeafSchema = object({
|
|
44486
|
+
kind: literal("device-fired"),
|
|
44487
|
+
...eventLeafId,
|
|
44488
|
+
deviceId: number$1().int().nonnegative(),
|
|
44489
|
+
eventIds: array(string().min(1)).min(1).max(64).optional(),
|
|
44490
|
+
sourceIds: array(string().min(1)).min(1).max(64).optional(),
|
|
44491
|
+
kinds: array(EventVocabularyKindSchema).min(1).optional(),
|
|
44492
|
+
match: array(DeviceFiredMatchSchema).min(1).max(8).optional()
|
|
44493
|
+
});
|
|
44292
44494
|
var ManualLeafSchema = object({
|
|
44293
44495
|
kind: literal("manual"),
|
|
44294
44496
|
...eventLeafId
|
|
@@ -44430,6 +44632,7 @@ var AutomationWhenSchema = lazy(() => discriminatedUnion("kind", [
|
|
|
44430
44632
|
}),
|
|
44431
44633
|
DeviceBecomesLeafSchema,
|
|
44432
44634
|
DeviceEventLeafSchema,
|
|
44635
|
+
DeviceFiredLeafSchema,
|
|
44433
44636
|
ScheduleLeafSchema,
|
|
44434
44637
|
ManualLeafSchema,
|
|
44435
44638
|
IntervalLeafSchema,
|
|
@@ -44444,6 +44647,7 @@ var AutomationWhenSchema = lazy(() => discriminatedUnion("kind", [
|
|
|
44444
44647
|
var EVENT_KINDS = new Set([
|
|
44445
44648
|
"device-becomes",
|
|
44446
44649
|
"device-event",
|
|
44650
|
+
"device-fired",
|
|
44447
44651
|
"schedule",
|
|
44448
44652
|
"manual",
|
|
44449
44653
|
"interval",
|
|
@@ -44524,6 +44728,7 @@ function hasEmptyContainer(node) {
|
|
|
44524
44728
|
var LEAF_WORDS = {
|
|
44525
44729
|
"device-becomes": "a device value that becomes",
|
|
44526
44730
|
"device-event": "a device event",
|
|
44731
|
+
"device-fired": "a device firing an event",
|
|
44527
44732
|
schedule: "a schedule",
|
|
44528
44733
|
manual: "a manual run",
|
|
44529
44734
|
interval: "an interval",
|
|
@@ -44773,21 +44978,23 @@ function convertLegacyWhen(half) {
|
|
|
44773
44978
|
* (instants) and state leaves (durations). It replaces the flat trigger list
|
|
44774
44979
|
* plus the separate condition tree; the firing rule is in that file and in
|
|
44775
44980
|
* ADR "one tree".
|
|
44776
|
-
* - **Actions** — the `wait` and `
|
|
44981
|
+
* - **Actions** — the `wait` and device `command` steps, plus the `{kind:'code'}`
|
|
44777
44982
|
* fragment of §3.2.2. See {@link AutomationActionSchema}.
|
|
44778
44983
|
*
|
|
44779
44984
|
* A recipe stored in the old shape (`triggers` + `conditions`) still LOADS:
|
|
44780
44985
|
* {@link AutomationRecipeSchema} (the parse-anywhere schema) converts it on parse. Nothing writes it.
|
|
44781
44986
|
*/
|
|
44782
44987
|
/**
|
|
44783
|
-
* One action step: `wait`, or a `
|
|
44988
|
+
* One action step: `wait`, or a device `command`.
|
|
44784
44989
|
*
|
|
44785
|
-
* A
|
|
44786
|
-
* `{ $var }` resolved from the run's
|
|
44787
|
-
*
|
|
44788
|
-
*
|
|
44789
|
-
*
|
|
44790
|
-
*
|
|
44990
|
+
* A command step names a VOCABULARY action (`cover.open`) and who it acts on
|
|
44991
|
+
* (D983: `devices`, a `domain`, or a `{ $var }` resolved from the run's
|
|
44992
|
+
* variables). It never names a cap method: the step runner turns the action
|
|
44993
|
+
* id into its cap + method through the vocabulary index when the step runs
|
|
44994
|
+
* (`vocabCall`), the one place that mapping happens. The step runner
|
|
44995
|
+
* (`runSteps`) owns the device-scope check, the stop-at-first-failure and the
|
|
44996
|
+
* variable substitution, once, for every caller — automations, Actions, and
|
|
44997
|
+
* the notification centre, which runs only Actions (planning#473).
|
|
44791
44998
|
*/
|
|
44792
44999
|
/** The longest one `wait` step lasts. It is cut by a restart of the run and does not survive a hub restart. */
|
|
44793
45000
|
var WAIT_MAX_SECONDS = 3600;
|
|
@@ -44796,39 +45003,22 @@ var AutomationWaitStepSchema = object({
|
|
|
44796
45003
|
kind: literal("wait"),
|
|
44797
45004
|
seconds: number$1().min(0).max(WAIT_MAX_SECONDS, WAIT_TOO_LONG)
|
|
44798
45005
|
});
|
|
44799
|
-
/** The legacy `deviceId` of a cap step: still READ, never written (D983). */
|
|
44800
|
-
var LegacyStepDeviceSchema = union([
|
|
44801
|
-
number$1().int(),
|
|
44802
|
-
array(number$1().int()).min(1),
|
|
44803
|
-
object({ $var: string().min(1) })
|
|
44804
|
-
]);
|
|
44805
45006
|
/**
|
|
44806
|
-
* The fields of a
|
|
44807
|
-
*
|
|
44808
|
-
* device); a step is {@link AutomationCapStepSchema}.
|
|
45007
|
+
* The fields of a command step, before the vocabulary check. A step is
|
|
45008
|
+
* {@link AutomationCommandStepSchema}.
|
|
44809
45009
|
*/
|
|
44810
|
-
var
|
|
44811
|
-
kind: literal("
|
|
44812
|
-
/**
|
|
44813
|
-
|
|
44814
|
-
|
|
44815
|
-
|
|
44816
|
-
* cap + method match exactly one vocabulary action.
|
|
44817
|
-
*/
|
|
44818
|
-
actionId: string().min(1).optional(),
|
|
44819
|
-
/** WHO the step acts on. The only shape that is written. */
|
|
44820
|
-
target: ActionTargetSchema.optional(),
|
|
45010
|
+
var AutomationCommandStepBaseSchema = object({
|
|
45011
|
+
kind: literal("command"),
|
|
45012
|
+
/** WHO the step acts on. */
|
|
45013
|
+
target: ActionTargetSchema,
|
|
45014
|
+
/** The vocabulary action this step performs (`cover.open`). */
|
|
45015
|
+
actionId: string().min(1),
|
|
44821
45016
|
/**
|
|
44822
|
-
*
|
|
44823
|
-
*
|
|
44824
|
-
*
|
|
45017
|
+
* The values of the action's OPEN args (`position`, `presetId`); the args
|
|
45018
|
+
* the vocabulary bakes into the action are added when the step runs. Values
|
|
45019
|
+
* may carry `{{vars.x}}` slots, or be exactly `{ $var: 'name' }`, which
|
|
45020
|
+
* SUBSTITUTE and do not evaluate (§3.2.3).
|
|
44825
45021
|
*/
|
|
44826
|
-
deviceId: LegacyStepDeviceSchema.optional(),
|
|
44827
|
-
cap: string().min(1),
|
|
44828
|
-
method: string().min(1),
|
|
44829
|
-
/** Values may carry `{{vars.x}}` slots, or be exactly `{ $var: 'name' }`, which
|
|
44830
|
-
* SUBSTITUTE and do not evaluate (§3.2.3). Anything beyond substitution is
|
|
44831
|
-
* the expression leaf. */
|
|
44832
45022
|
args: record(string(), unknown()).optional(),
|
|
44833
45023
|
/**
|
|
44834
45024
|
* The unit the person picked per arg (display only). `args` always hold the
|
|
@@ -44837,18 +45027,20 @@ var AutomationCapStepBaseSchema = object({
|
|
|
44837
45027
|
*/
|
|
44838
45028
|
argUnits: record(string(), string().min(1)).optional()
|
|
44839
45029
|
});
|
|
45030
|
+
/** The vocabulary check every command step passes: the action exists. */
|
|
45031
|
+
function refineKnownAction(step, ctx) {
|
|
45032
|
+
if (findVocabAction(step.actionId) === void 0) ctx.addIssue({
|
|
45033
|
+
code: "custom",
|
|
45034
|
+
message: `"${step.actionId}" is not a vocabulary action id`,
|
|
45035
|
+
path: ["actionId"]
|
|
45036
|
+
});
|
|
45037
|
+
}
|
|
44840
45038
|
/**
|
|
44841
|
-
* The steps an internal Action may contain:
|
|
45039
|
+
* The steps an internal Action may contain: command and wait, and nothing that can
|
|
44842
45040
|
* call back into an Action — so an Action can never reach itself (no cycles).
|
|
44843
45041
|
* This is the LEAF shape: no condition of its own.
|
|
44844
45042
|
*/
|
|
44845
|
-
var LeafActionStepSchema = discriminatedUnion("kind", [AutomationWaitStepSchema,
|
|
44846
|
-
message: "a cap step needs a target",
|
|
44847
|
-
path: ["target"]
|
|
44848
|
-
}).refine((step) => step.target?.kind !== "domain" || step.actionId !== void 0, {
|
|
44849
|
-
message: "a domain target needs the vocabulary action it applies to (actionId)",
|
|
44850
|
-
path: ["actionId"]
|
|
44851
|
-
})]);
|
|
45043
|
+
var LeafActionStepSchema = discriminatedUnion("kind", [AutomationWaitStepSchema, AutomationCommandStepBaseSchema.superRefine(refineKnownAction)]);
|
|
44852
45044
|
/**
|
|
44853
45045
|
* The optional guard of a step (#472): `if` is the ONE `when` tree (D980), read
|
|
44854
45046
|
* on the state mirror when the step is reached; `else` runs when it is false.
|
|
@@ -44869,13 +45061,7 @@ var GuardedWaitStepSchema = AutomationWaitStepSchema.extend(stepGuardShape).refi
|
|
|
44869
45061
|
* same two step kinds an automation runs, minus a guard that reads the
|
|
44870
45062
|
* automation's trigger, which such a list does not have.
|
|
44871
45063
|
*/
|
|
44872
|
-
var ActionStepSchema = discriminatedUnion("kind", [GuardedWaitStepSchema,
|
|
44873
|
-
message: "a cap step needs a target",
|
|
44874
|
-
path: ["target"]
|
|
44875
|
-
}).refine((step) => step.target?.kind !== "domain" || step.actionId !== void 0, {
|
|
44876
|
-
message: "a domain target needs the vocabulary action it applies to (actionId)",
|
|
44877
|
-
path: ["actionId"]
|
|
44878
|
-
}).refine((step) => step.else === void 0 || step.if !== void 0, elseNeedsIf)]).superRefine((step, ctx) => {
|
|
45064
|
+
var ActionStepSchema = discriminatedUnion("kind", [GuardedWaitStepSchema, AutomationCommandStepBaseSchema.extend(stepGuardShape).superRefine(refineKnownAction).refine((step) => step.else === void 0 || step.if !== void 0, elseNeedsIf)]).superRefine((step, ctx) => {
|
|
44879
45065
|
if (step.if !== void 0 && hasTriggeredByLeaves(step.if)) ctx.addIssue({
|
|
44880
45066
|
code: "custom",
|
|
44881
45067
|
message: TRIGGERED_BY_NEEDS_AUTOMATION,
|
|
@@ -44890,17 +45076,11 @@ var ActionStepSchema = discriminatedUnion("kind", [GuardedWaitStepSchema, Automa
|
|
|
44890
45076
|
var continueOnErrorShape = {
|
|
44891
45077
|
/** A failure of this step is traced `failed-continued` and the next step runs. */
|
|
44892
45078
|
continueOnError: literal(true).optional() };
|
|
44893
|
-
/** An automation's
|
|
44894
|
-
var
|
|
45079
|
+
/** An automation's command step: the shared guarded command step, plus `continueOnError`. */
|
|
45080
|
+
var AutomationGuardedCommandStepSchema = AutomationCommandStepBaseSchema.extend({
|
|
44895
45081
|
...stepGuardShape,
|
|
44896
45082
|
...continueOnErrorShape
|
|
44897
|
-
}).refine((step) => step.
|
|
44898
|
-
message: "a cap step needs a target",
|
|
44899
|
-
path: ["target"]
|
|
44900
|
-
}).refine((step) => step.target?.kind !== "domain" || step.actionId !== void 0, {
|
|
44901
|
-
message: "a domain target needs the vocabulary action it applies to (actionId)",
|
|
44902
|
-
path: ["actionId"]
|
|
44903
|
-
}).refine((step) => step.else === void 0 || step.if !== void 0, elseNeedsIf);
|
|
45083
|
+
}).superRefine(refineKnownAction).refine((step) => step.else === void 0 || step.if !== void 0, elseNeedsIf);
|
|
44904
45084
|
/** End the run here, on purpose. `reason` may carry `{{vars.x}}` slots. */
|
|
44905
45085
|
var AutomationStopStepSchema = object({
|
|
44906
45086
|
kind: literal("stop"),
|
|
@@ -44980,13 +45160,7 @@ function nestTooDeep(issue) {
|
|
|
44980
45160
|
}
|
|
44981
45161
|
var plainStepSchemas = [
|
|
44982
45162
|
AutomationWaitStepSchema.strict(),
|
|
44983
|
-
|
|
44984
|
-
message: "a cap step needs a target",
|
|
44985
|
-
path: ["target"]
|
|
44986
|
-
}).refine((step) => step.target?.kind !== "domain" || step.actionId !== void 0, {
|
|
44987
|
-
message: "a domain target needs the vocabulary action it applies to (actionId)",
|
|
44988
|
-
path: ["actionId"]
|
|
44989
|
-
}),
|
|
45163
|
+
AutomationCommandStepBaseSchema.extend(continueOnErrorShape).strict().superRefine(refineKnownAction),
|
|
44990
45164
|
AutomationStopStepSchema.omit({ if: true }).strict(),
|
|
44991
45165
|
AutomationSetStepSchema.omit({ if: true }).strict(),
|
|
44992
45166
|
AutomationRunActionStepSchema.strict()
|
|
@@ -44997,7 +45171,7 @@ var plainStepSchemas = [
|
|
|
44997
45171
|
*/
|
|
44998
45172
|
var AutomationBranchStepSchema = discriminatedUnion("kind", plainStepSchemas, { error: nestTooDeep });
|
|
44999
45173
|
/** A step that can run beside others: it writes no variable and does not end the run. */
|
|
45000
|
-
var AutomationParallelMemberSchema = AutomationBranchStepSchema.refine((step) => step.kind === "
|
|
45174
|
+
var AutomationParallelMemberSchema = AutomationBranchStepSchema.refine((step) => step.kind === "command" || step.kind === "action" || step.kind === "wait", "a parallel holds device commands, actions and waits only: a set or a stop beside other steps has no order");
|
|
45001
45175
|
/**
|
|
45002
45176
|
* Several steps at once (#500): all are started together and all are awaited.
|
|
45003
45177
|
* A failure fails the run once the others finished, as in a sequence; a member
|
|
@@ -45077,7 +45251,7 @@ var AutomationBodyStepSchema = discriminatedUnion("kind", [
|
|
|
45077
45251
|
var AutomationRepeatStepSchema = repeatSchemaOf(AutomationBodyStepSchema);
|
|
45078
45252
|
var AutomationActionSchema = discriminatedUnion("kind", [
|
|
45079
45253
|
GuardedWaitStepSchema,
|
|
45080
|
-
|
|
45254
|
+
AutomationGuardedCommandStepSchema,
|
|
45081
45255
|
AutomationStopStepSchema,
|
|
45082
45256
|
AutomationSetStepSchema,
|
|
45083
45257
|
chooseSchemaOf(AutomationBodyStepSchema),
|
|
@@ -45148,38 +45322,6 @@ function convertLegacyRecipe(legacy) {
|
|
|
45148
45322
|
};
|
|
45149
45323
|
}
|
|
45150
45324
|
var AutomationRecipeSchema = union([CurrentAutomationRecipeSchema, LegacyAutomationRecipeSchema.transform(convertLegacyRecipe)]);
|
|
45151
|
-
var DETECTION_DESCRIPTIONS = {
|
|
45152
|
-
deviceId: "the camera that saw it",
|
|
45153
|
-
className: "what it saw",
|
|
45154
|
-
trackId: "the track",
|
|
45155
|
-
score: "how sure the detector was",
|
|
45156
|
-
label: "the label it matched (a name, a plate), empty when none"
|
|
45157
|
-
};
|
|
45158
|
-
var STATIONARY_DESCRIPTIONS = {
|
|
45159
|
-
deviceId: "the camera that saw it",
|
|
45160
|
-
className: "what it saw",
|
|
45161
|
-
zones: "the zones it is in",
|
|
45162
|
-
phase: "appeared or departed",
|
|
45163
|
-
entryId: "the stopped object"
|
|
45164
|
-
};
|
|
45165
|
-
var BECOMES_DESCRIPTIONS = {
|
|
45166
|
-
deviceId: "the device that changed",
|
|
45167
|
-
from: "the value before the change, empty when it is not known",
|
|
45168
|
-
to: "the value it changed to"
|
|
45169
|
-
};
|
|
45170
|
-
function describe$1(descriptions) {
|
|
45171
|
-
return Object.entries(descriptions).map(([name, description]) => ({
|
|
45172
|
-
name,
|
|
45173
|
-
description
|
|
45174
|
-
}));
|
|
45175
|
-
}
|
|
45176
|
-
describe$1(DETECTION_DESCRIPTIONS);
|
|
45177
|
-
describe$1(STATIONARY_DESCRIPTIONS);
|
|
45178
|
-
describe$1(BECOMES_DESCRIPTIONS).map((v) => v.name === "deviceId" ? {
|
|
45179
|
-
...v,
|
|
45180
|
-
hintKey: "becomesDeviceId"
|
|
45181
|
-
} : v);
|
|
45182
|
-
new Set(Object.values(COCO_TO_MACRO.mapping));
|
|
45183
45325
|
/**
|
|
45184
45326
|
* Schedulers (D983) — an entity that performs actions over the day.
|
|
45185
45327
|
*
|
|
@@ -45438,6 +45580,7 @@ var AutomationConditionTraceNodeSchema = object({
|
|
|
45438
45580
|
"triggered-by",
|
|
45439
45581
|
"device-becomes",
|
|
45440
45582
|
"device-event",
|
|
45583
|
+
"device-fired",
|
|
45441
45584
|
"schedule",
|
|
45442
45585
|
"interval",
|
|
45443
45586
|
"manual",
|
|
@@ -45577,6 +45720,110 @@ var AutomationStateDocSchema = object({
|
|
|
45577
45720
|
lastRunStartedAt: number$1().nullable(),
|
|
45578
45721
|
traces: array(AutomationRunTraceSchema)
|
|
45579
45722
|
});
|
|
45723
|
+
var DETECTION_DESCRIPTIONS = {
|
|
45724
|
+
deviceId: "the camera that saw it",
|
|
45725
|
+
className: "what it saw",
|
|
45726
|
+
trackId: "the track",
|
|
45727
|
+
score: "how sure the detector was",
|
|
45728
|
+
label: "the label it matched (a name, a plate), empty when none"
|
|
45729
|
+
};
|
|
45730
|
+
var STATIONARY_DESCRIPTIONS = {
|
|
45731
|
+
deviceId: "the camera that saw it",
|
|
45732
|
+
className: "what it saw",
|
|
45733
|
+
zones: "the zones it is in",
|
|
45734
|
+
phase: "appeared or departed",
|
|
45735
|
+
entryId: "the stopped object"
|
|
45736
|
+
};
|
|
45737
|
+
var BECOMES_DESCRIPTIONS = {
|
|
45738
|
+
deviceId: "the device that changed",
|
|
45739
|
+
from: "the value before the change, empty when it is not known",
|
|
45740
|
+
to: "the value it changed to"
|
|
45741
|
+
};
|
|
45742
|
+
/**
|
|
45743
|
+
* A fire's payload is offered too, as `data.<path>` (`{{vars.data.channel}}`):
|
|
45744
|
+
* those names depend on the device, so they are not in this list.
|
|
45745
|
+
*/
|
|
45746
|
+
var FIRED_DESCRIPTIONS = {
|
|
45747
|
+
deviceId: "the device that fired",
|
|
45748
|
+
eventType: "the event, as the device names it",
|
|
45749
|
+
sourceId: "the part of the device that fired (a button), empty when it names none",
|
|
45750
|
+
eventKind: "the kind of press (press, long-press …), empty when the device declares none"
|
|
45751
|
+
};
|
|
45752
|
+
function describe$1(descriptions) {
|
|
45753
|
+
return Object.entries(descriptions).map(([name, description]) => ({
|
|
45754
|
+
name,
|
|
45755
|
+
description
|
|
45756
|
+
}));
|
|
45757
|
+
}
|
|
45758
|
+
describe$1(DETECTION_DESCRIPTIONS);
|
|
45759
|
+
describe$1(STATIONARY_DESCRIPTIONS);
|
|
45760
|
+
describe$1(FIRED_DESCRIPTIONS).map((v) => v.name === "deviceId" ? {
|
|
45761
|
+
...v,
|
|
45762
|
+
hintKey: "firedDeviceId"
|
|
45763
|
+
} : v);
|
|
45764
|
+
describe$1(BECOMES_DESCRIPTIONS).map((v) => v.name === "deviceId" ? {
|
|
45765
|
+
...v,
|
|
45766
|
+
hintKey: "becomesDeviceId"
|
|
45767
|
+
} : v);
|
|
45768
|
+
new Set(Object.values(COCO_TO_MACRO.mapping));
|
|
45769
|
+
/**
|
|
45770
|
+
* Generic stateless event emitter. Installed on a `DeviceType.EventEmitter`
|
|
45771
|
+
* device. Carries the device's EXACT declared event vocabulary verbatim
|
|
45772
|
+
* (NO normalization). Two shapes:
|
|
45773
|
+
* - structured source (HA `event.*` entity) → `vocabulary` is the fixed
|
|
45774
|
+
* declared set (e.g. press_short, press_long, …).
|
|
45775
|
+
* - generic/legacy source (HA bus events, e.g. zha_event) → `vocabulary`
|
|
45776
|
+
* is [] (open) and `lastEvent.data` carries the complex payload.
|
|
45777
|
+
* `vocabulary` (D1044) names each event for a person and types it for a
|
|
45778
|
+
* rule; `eventTypes` is its list of native tokens, kept for older readers.
|
|
45779
|
+
* A fire names the part of the device it came from in `sourceId` when the
|
|
45780
|
+
* vocabulary declares sources (a remote's buttons).
|
|
45781
|
+
* `seq` is monotonic so two identical events still produce distinct slice writes.
|
|
45782
|
+
*/
|
|
45783
|
+
var EventFireSchema = object({
|
|
45784
|
+
deviceId: number$1(),
|
|
45785
|
+
eventType: string(),
|
|
45786
|
+
sourceId: string().optional(),
|
|
45787
|
+
data: record(string(), unknown()).nullable(),
|
|
45788
|
+
timestamp: number$1().meta(readingMeta("none")),
|
|
45789
|
+
seq: number$1().meta(readingMeta("count"))
|
|
45790
|
+
});
|
|
45791
|
+
var EventEmitterStatusSchema = object({
|
|
45792
|
+
eventTypes: array(string()),
|
|
45793
|
+
/**
|
|
45794
|
+
* Required of a provider by the type. A status written before the field
|
|
45795
|
+
* existed still parses, as an empty vocabulary: read it through
|
|
45796
|
+
* `readEventVocabulary`, which then answers with the plain tokens.
|
|
45797
|
+
*/
|
|
45798
|
+
vocabulary: array(EventVocabularyEntrySchema).default([]),
|
|
45799
|
+
lastEvent: EventFireSchema.nullable(),
|
|
45800
|
+
eventCountSinceStart: number$1().meta(readingMeta("count"))
|
|
45801
|
+
});
|
|
45802
|
+
var eventEmitterCapability = {
|
|
45803
|
+
name: "event-emitter",
|
|
45804
|
+
scope: "device",
|
|
45805
|
+
deviceNative: true,
|
|
45806
|
+
mode: "singleton",
|
|
45807
|
+
deviceTypes: [DeviceType.EventEmitter],
|
|
45808
|
+
methods: {},
|
|
45809
|
+
events: { onEvent: { data: EventFireSchema } },
|
|
45810
|
+
status: {
|
|
45811
|
+
schema: EventEmitterStatusSchema,
|
|
45812
|
+
kind: "push"
|
|
45813
|
+
},
|
|
45814
|
+
runtimeState: EventEmitterStatusSchema,
|
|
45815
|
+
/**
|
|
45816
|
+
* Runtime-state durability: **session** — `eventCountSinceStart` names its own scope.
|
|
45817
|
+
*
|
|
45818
|
+
* See `RuntimeStateDurability`. Enforced by
|
|
45819
|
+
* `scripts/check-runtime-state-durability.ts`.
|
|
45820
|
+
*/
|
|
45821
|
+
durability: "session",
|
|
45822
|
+
/**
|
|
45823
|
+
* History (D850): none — `eventCountSinceStart` resets with the addon; events live in ledgers.
|
|
45824
|
+
*/
|
|
45825
|
+
history: "none"
|
|
45826
|
+
};
|
|
45580
45827
|
/**
|
|
45581
45828
|
* Actions — named, runnable things an operator (or an automation) can start,
|
|
45582
45829
|
* declared as LIST ENTRIES, never as devices.
|
|
@@ -45756,6 +46003,177 @@ var UnitWarningSchema = object({
|
|
|
45756
46003
|
assumedUnit: string(),
|
|
45757
46004
|
message: string()
|
|
45758
46005
|
});
|
|
46006
|
+
/**
|
|
46007
|
+
* `device-export` — collection cap for addons that export camstack
|
|
46008
|
+
* devices to external ecosystems (HomeAssistant via MQTT discovery,
|
|
46009
|
+
* HomeKit/HAP, Alexa Smart Home, …).
|
|
46010
|
+
*
|
|
46011
|
+
* No `ecosystem` enum — the addon id identifies the export target.
|
|
46012
|
+
* Each addon owns its mapping logic in its own settings UI. The cap
|
|
46013
|
+
* exposes only the COMMON surface: link state, supported device
|
|
46014
|
+
* kinds (so the UI can filter the device picker), and per-device
|
|
46015
|
+
* expose/unexpose.
|
|
46016
|
+
*
|
|
46017
|
+
* INSTANCES. One export addon can serve several independent targets (a
|
|
46018
|
+
* HomeKit bridge, a Home Assistant broker). `listInstances` names them.
|
|
46019
|
+
* `instanceId` on a READ is optional: absent = the whole addon (linked if any
|
|
46020
|
+
* enabled instance is, `exposedDeviceCount` = distinct devices, `setup` = the
|
|
46021
|
+
* default instance's); present = that instance; an id the provider does not
|
|
46022
|
+
* serve is refused with `ExportInstanceUnknownError` (`export-instance-unknown`),
|
|
46023
|
+
* never answered empty. `instanceId` on a WRITE is REQUIRED: a membership
|
|
46024
|
+
* change always names the target it changes. A single-instance provider
|
|
46025
|
+
* accepts an absent id on a read or its own id, and refuses any other.
|
|
46026
|
+
*/
|
|
46027
|
+
/** Which instance of an export addon a call addresses. Absent on a read = the whole addon. */
|
|
46028
|
+
var InstanceIdSchema$1 = string().min(1);
|
|
46029
|
+
var InstancePinSchema = object({ instanceId: InstanceIdSchema$1.optional() });
|
|
46030
|
+
/** One independent export target of an addon. */
|
|
46031
|
+
var ExportInstanceSchema = object({
|
|
46032
|
+
instanceId: InstanceIdSchema$1,
|
|
46033
|
+
name: string(),
|
|
46034
|
+
enabled: boolean(),
|
|
46035
|
+
kind: string().optional(),
|
|
46036
|
+
/**
|
|
46037
|
+
* What this instance's platform accepts as a device name, in one operator-facing sentence
|
|
46038
|
+
* (D1049). The derived "Name on <instance>" field shows it; absent = the field says nothing
|
|
46039
|
+
* about the rule.
|
|
46040
|
+
*/
|
|
46041
|
+
nameRule: string().optional()
|
|
46042
|
+
});
|
|
46043
|
+
var LinkStateSchema = _enum([
|
|
46044
|
+
"unlinked",
|
|
46045
|
+
"linked",
|
|
46046
|
+
"error"
|
|
46047
|
+
]);
|
|
46048
|
+
/**
|
|
46049
|
+
* A single label/value row surfaced in the export panel's "Setup"
|
|
46050
|
+
* section. Rendered with a copy-to-clipboard button. `secret: true`
|
|
46051
|
+
* rows are masked by default with a reveal toggle (client ids,
|
|
46052
|
+
* secrets, …).
|
|
46053
|
+
*/
|
|
46054
|
+
var ExportSetupFieldSchema = object({
|
|
46055
|
+
label: string(),
|
|
46056
|
+
value: string(),
|
|
46057
|
+
/** Mask the value by default + render a reveal toggle (client id, secrets). */
|
|
46058
|
+
secret: boolean().optional()
|
|
46059
|
+
});
|
|
46060
|
+
/**
|
|
46061
|
+
* Generic, addon-agnostic pairing/account block. Any export addon can
|
|
46062
|
+
* surface a scannable QR, a set of copyable label/value rows, and a
|
|
46063
|
+
* free-form operator note — the `DeviceExportPanel` renders whatever
|
|
46064
|
+
* the provider supplies and skips the section entirely when `setup`
|
|
46065
|
+
* is unset.
|
|
46066
|
+
*/
|
|
46067
|
+
var ExportSetupSchema = object({
|
|
46068
|
+
/** A string to render as a scannable QR — HAP `X-HM://…` URI, a pairing URL, etc. Omitted when there's nothing to scan. */
|
|
46069
|
+
qr: string().optional(),
|
|
46070
|
+
/** Label/value rows shown with a copy button (HAP setup code, OAuth URLs, client id, linked-account count, …). */
|
|
46071
|
+
fields: array(ExportSetupFieldSchema).readonly().optional(),
|
|
46072
|
+
/** Free-form operator instructions rendered above the fields. */
|
|
46073
|
+
note: string().optional()
|
|
46074
|
+
});
|
|
46075
|
+
var DeviceExportStatusSchema = object({
|
|
46076
|
+
linkState: LinkStateSchema,
|
|
46077
|
+
exposedDeviceCount: number$1(),
|
|
46078
|
+
error: string().optional(),
|
|
46079
|
+
/**
|
|
46080
|
+
* Optional pairing/account info the panel renders in a generic
|
|
46081
|
+
* "Setup" section. Addon-agnostic — the addon id identifies the
|
|
46082
|
+
* export target, never an `ecosystem` key here.
|
|
46083
|
+
*/
|
|
46084
|
+
setup: ExportSetupSchema.optional()
|
|
46085
|
+
});
|
|
46086
|
+
var DeviceKindSchema = string();
|
|
46087
|
+
/**
|
|
46088
|
+
* EXPOSED NAME. What one instance calls a device on its platform, when it should not be the
|
|
46089
|
+
* device's own name. The exporter owns it: it is stored per instance in the exporter's per-device
|
|
46090
|
+
* store (D865), validated by the exporter against its platform's naming rules, and never reaches
|
|
46091
|
+
* the exported id — a rename updates the SAME device on the platform, never a second one.
|
|
46092
|
+
* Blank or `null` = the device's own name. A name the platform would refuse is refused with
|
|
46093
|
+
* `ExportNameRefusedError` (`export-name-refused`), whose message says why.
|
|
46094
|
+
*/
|
|
46095
|
+
var ExposedDeviceSchema = object({
|
|
46096
|
+
deviceId: string(),
|
|
46097
|
+
exposedAs: string().optional(),
|
|
46098
|
+
/** The operator's name for this device on this instance; absent = the device's own name. */
|
|
46099
|
+
exposedName: string().optional(),
|
|
46100
|
+
capabilities: array(string()).optional()
|
|
46101
|
+
});
|
|
46102
|
+
var ExposeInputSchema = object({
|
|
46103
|
+
instanceId: InstanceIdSchema$1,
|
|
46104
|
+
deviceId: string(),
|
|
46105
|
+
capabilities: array(string()).optional(),
|
|
46106
|
+
/** Set the exposed name in the same call; absent = leave it as it is, blank/null = clear it. */
|
|
46107
|
+
exposedName: string().nullable().optional()
|
|
46108
|
+
});
|
|
46109
|
+
var SetExposedNameInputSchema = object({
|
|
46110
|
+
instanceId: InstanceIdSchema$1,
|
|
46111
|
+
deviceId: string(),
|
|
46112
|
+
/** Blank or null = the device's own name. */
|
|
46113
|
+
name: string().nullable(),
|
|
46114
|
+
/**
|
|
46115
|
+
* Validate only: refuse exactly as a real call would, write nothing. A caller saving several
|
|
46116
|
+
* names at once checks every one first, so one refusal writes none (D1049).
|
|
46117
|
+
*/
|
|
46118
|
+
dryRun: boolean().optional()
|
|
46119
|
+
});
|
|
46120
|
+
var UnexposeInputSchema = object({
|
|
46121
|
+
instanceId: InstanceIdSchema$1,
|
|
46122
|
+
deviceId: string()
|
|
46123
|
+
});
|
|
46124
|
+
/**
|
|
46125
|
+
* What an exporter may expose besides devices (D968). An action and a
|
|
46126
|
+
* notification target are LIST ENTRIES, never devices (D954): they enter an
|
|
46127
|
+
* exporter's own selection, not the device registry.
|
|
46128
|
+
*/
|
|
46129
|
+
var ExportEntityKindSchema = _enum([
|
|
46130
|
+
"device",
|
|
46131
|
+
"action",
|
|
46132
|
+
"notifier"
|
|
46133
|
+
]);
|
|
46134
|
+
var ExportEntityRefSchema = discriminatedUnion("kind", [
|
|
46135
|
+
object({
|
|
46136
|
+
kind: literal("device"),
|
|
46137
|
+
deviceId: string()
|
|
46138
|
+
}),
|
|
46139
|
+
object({
|
|
46140
|
+
kind: literal("action"),
|
|
46141
|
+
actionId: string().min(1)
|
|
46142
|
+
}),
|
|
46143
|
+
object({
|
|
46144
|
+
kind: literal("notifier"),
|
|
46145
|
+
targetId: string().min(1)
|
|
46146
|
+
})
|
|
46147
|
+
]);
|
|
46148
|
+
var ExposedEntitySchema = object({
|
|
46149
|
+
entity: ExportEntityRefSchema,
|
|
46150
|
+
exposedAs: string().optional()
|
|
46151
|
+
});
|
|
46152
|
+
var ExposeEntityInputSchema = object({
|
|
46153
|
+
instanceId: InstanceIdSchema$1,
|
|
46154
|
+
entity: ExportEntityRefSchema
|
|
46155
|
+
});
|
|
46156
|
+
var UnexposeEntityInputSchema = object({
|
|
46157
|
+
instanceId: InstanceIdSchema$1,
|
|
46158
|
+
entity: ExportEntityRefSchema
|
|
46159
|
+
});
|
|
46160
|
+
method(InstancePinSchema, DeviceExportStatusSchema), method(_void(), array(ExportInstanceSchema)), method(InstancePinSchema, array(DeviceKindSchema)), method(InstancePinSchema, array(ExposedDeviceSchema)), method(ExposeInputSchema, _void(), {
|
|
46161
|
+
kind: "mutation",
|
|
46162
|
+
auth: "admin"
|
|
46163
|
+
}), method(UnexposeInputSchema, _void(), {
|
|
46164
|
+
kind: "mutation",
|
|
46165
|
+
auth: "admin"
|
|
46166
|
+
}), method(SetExposedNameInputSchema, _void(), {
|
|
46167
|
+
kind: "mutation",
|
|
46168
|
+
auth: "admin"
|
|
46169
|
+
}), optionalMethod(_void(), array(ExportEntityKindSchema)), optionalMethod(InstancePinSchema, array(ExposedEntitySchema)), optionalMethod(ExposeEntityInputSchema, _void(), {
|
|
46170
|
+
kind: "mutation",
|
|
46171
|
+
auth: "admin"
|
|
46172
|
+
}), optionalMethod(UnexposeEntityInputSchema, _void(), {
|
|
46173
|
+
kind: "mutation",
|
|
46174
|
+
auth: "admin"
|
|
46175
|
+
});
|
|
46176
|
+
record(string(), string());
|
|
45759
46177
|
_enum([
|
|
45760
46178
|
"automation",
|
|
45761
46179
|
"action",
|
|
@@ -50959,11 +51377,13 @@ var IrCodecError = class extends Error {
|
|
|
50959
51377
|
this.code = code;
|
|
50960
51378
|
}
|
|
50961
51379
|
};
|
|
51380
|
+
/** Maximum number of mark/space entries one pulse train may carry. */
|
|
51381
|
+
var IR_TIMINGS_MAX = 1024;
|
|
50962
51382
|
/**
|
|
50963
51383
|
* A pulse train in signed microseconds: mark (+) first, then space (-), strictly
|
|
50964
51384
|
* alternating, no zeros, 2..1024 entries.
|
|
50965
51385
|
*/
|
|
50966
|
-
var IrTimingsSchema = array(number$1().int()).min(2).max(
|
|
51386
|
+
var IrTimingsSchema = array(number$1().int()).min(2).max(IR_TIMINGS_MAX).superRefine((timings, ctx) => {
|
|
50967
51387
|
timings.forEach((value, index) => {
|
|
50968
51388
|
const expectMark = index % 2 === 0;
|
|
50969
51389
|
if (value === 0 || value > 0 !== expectMark) ctx.addIssue({
|
|
@@ -51010,15 +51430,186 @@ function decodePronto(code) {
|
|
|
51010
51430
|
carrierHz: Math.round(1e6 / unitUs)
|
|
51011
51431
|
};
|
|
51012
51432
|
}
|
|
51013
|
-
/**
|
|
51014
|
-
|
|
51015
|
-
|
|
51016
|
-
|
|
51017
|
-
|
|
51018
|
-
|
|
51019
|
-
|
|
51020
|
-
|
|
51021
|
-
|
|
51433
|
+
/**
|
|
51434
|
+
* FastLZ level 1: a byte-oriented LZ77 stream. A control byte below 32 starts a
|
|
51435
|
+
* literal run of `ctrl + 1` bytes; otherwise it is a back-reference whose length
|
|
51436
|
+
* is `ctrl >> 5` (extended by one byte when 7) and whose distance is split
|
|
51437
|
+
* between the low 5 bits and the next byte.
|
|
51438
|
+
*/
|
|
51439
|
+
var MAX_DISTANCE = 8192;
|
|
51440
|
+
var MAX_LITERAL_RUN = 32;
|
|
51441
|
+
var MIN_MATCH = 3;
|
|
51442
|
+
var MAX_MATCH = 264;
|
|
51443
|
+
/**
|
|
51444
|
+
* Most bytes a decoded IR code may hold: two bytes per timing. A level-1 stream
|
|
51445
|
+
* can expand ~130x, so the decoder checks this bound before every write.
|
|
51446
|
+
*/
|
|
51447
|
+
var IR_DECOMPRESSED_MAX = IR_TIMINGS_MAX * 2;
|
|
51448
|
+
function fastlzDecompress(input) {
|
|
51449
|
+
const out = [];
|
|
51450
|
+
let ip = 0;
|
|
51451
|
+
const room = (count) => {
|
|
51452
|
+
if (out.length + count > IR_DECOMPRESSED_MAX) throw new IrCodecError("tuya-malformed", "decompressed code is larger than any IR train");
|
|
51453
|
+
};
|
|
51454
|
+
const next = () => {
|
|
51455
|
+
const byte = input[ip++];
|
|
51456
|
+
if (byte === void 0) throw new IrCodecError("tuya-malformed", "compressed stream is truncated");
|
|
51457
|
+
return byte;
|
|
51458
|
+
};
|
|
51459
|
+
while (ip < input.length) {
|
|
51460
|
+
const ctrl = next();
|
|
51461
|
+
if (ctrl < 32) {
|
|
51462
|
+
room(ctrl + 1);
|
|
51463
|
+
for (let i = 0; i <= ctrl; i++) out.push(next());
|
|
51464
|
+
continue;
|
|
51465
|
+
}
|
|
51466
|
+
let len = (ctrl >> 5) - 1;
|
|
51467
|
+
if (len === 6) len += next();
|
|
51468
|
+
const distance = ((ctrl & 31) << 8) + next() + 1;
|
|
51469
|
+
const start = out.length - distance;
|
|
51470
|
+
if (start < 0) throw new IrCodecError("tuya-malformed", "back-reference points before the stream");
|
|
51471
|
+
room(len + 3);
|
|
51472
|
+
for (let i = 0; i < len + 3; i++) {
|
|
51473
|
+
const byte = out[start + i];
|
|
51474
|
+
if (byte === void 0) throw new IrCodecError("tuya-malformed", "back-reference is invalid");
|
|
51475
|
+
out.push(byte);
|
|
51476
|
+
}
|
|
51477
|
+
}
|
|
51478
|
+
return Uint8Array.from(out);
|
|
51479
|
+
}
|
|
51480
|
+
function fastlzCompress(input) {
|
|
51481
|
+
const out = [];
|
|
51482
|
+
const lastSeen = /* @__PURE__ */ new Map();
|
|
51483
|
+
let literalStart = 0;
|
|
51484
|
+
const flushLiterals = (end) => {
|
|
51485
|
+
for (let from = literalStart; from < end; from += MAX_LITERAL_RUN) {
|
|
51486
|
+
const to = Math.min(from + MAX_LITERAL_RUN, end);
|
|
51487
|
+
out.push(to - from - 1);
|
|
51488
|
+
for (let i = from; i < to; i++) out.push(input[i] ?? 0);
|
|
51489
|
+
}
|
|
51490
|
+
};
|
|
51491
|
+
let pos = 0;
|
|
51492
|
+
while (pos < input.length) {
|
|
51493
|
+
let matchLen = 0;
|
|
51494
|
+
let matchDistance = 0;
|
|
51495
|
+
if (pos + MIN_MATCH <= input.length) {
|
|
51496
|
+
const key = (input[pos] ?? 0) << 16 | (input[pos + 1] ?? 0) << 8 | (input[pos + 2] ?? 0);
|
|
51497
|
+
const candidate = lastSeen.get(key);
|
|
51498
|
+
lastSeen.set(key, pos);
|
|
51499
|
+
if (candidate !== void 0 && pos - candidate <= MAX_DISTANCE) {
|
|
51500
|
+
let len = 0;
|
|
51501
|
+
while (pos + len < input.length && len < MAX_MATCH && input[candidate + len] === input[pos + len]) len++;
|
|
51502
|
+
if (len >= MIN_MATCH) {
|
|
51503
|
+
matchLen = len;
|
|
51504
|
+
matchDistance = pos - candidate - 1;
|
|
51505
|
+
}
|
|
51506
|
+
}
|
|
51507
|
+
}
|
|
51508
|
+
if (matchLen === 0) {
|
|
51509
|
+
pos++;
|
|
51510
|
+
continue;
|
|
51511
|
+
}
|
|
51512
|
+
flushLiterals(pos);
|
|
51513
|
+
const enc = matchLen - 2;
|
|
51514
|
+
if (enc < 7) out.push(enc << 5 | matchDistance >> 8);
|
|
51515
|
+
else out.push(224 | matchDistance >> 8, enc - 7);
|
|
51516
|
+
out.push(matchDistance & 255);
|
|
51517
|
+
pos += matchLen;
|
|
51518
|
+
literalStart = pos;
|
|
51519
|
+
}
|
|
51520
|
+
flushLiterals(input.length);
|
|
51521
|
+
return Uint8Array.from(out);
|
|
51522
|
+
}
|
|
51523
|
+
var ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
51524
|
+
var MAX_DURATION_US = 65535;
|
|
51525
|
+
function toBase64(bytes) {
|
|
51526
|
+
let out = "";
|
|
51527
|
+
for (let i = 0; i < bytes.length; i += 3) {
|
|
51528
|
+
const a = bytes[i] ?? 0;
|
|
51529
|
+
const b = bytes[i + 1] ?? 0;
|
|
51530
|
+
const c = bytes[i + 2] ?? 0;
|
|
51531
|
+
const word = a << 16 | b << 8 | c;
|
|
51532
|
+
out += ALPHABET[word >> 18 & 63];
|
|
51533
|
+
out += ALPHABET[word >> 12 & 63];
|
|
51534
|
+
out += i + 1 < bytes.length ? ALPHABET[word >> 6 & 63] : "=";
|
|
51535
|
+
out += i + 2 < bytes.length ? ALPHABET[word & 63] : "=";
|
|
51536
|
+
}
|
|
51537
|
+
return out;
|
|
51538
|
+
}
|
|
51539
|
+
function fromBase64(text) {
|
|
51540
|
+
const clean = text.trim().replace(/=+$/, "");
|
|
51541
|
+
if (clean.length === 0 || clean.length % 4 === 1) throw new IrCodecError("tuya-malformed", "not a base64 string");
|
|
51542
|
+
const out = [];
|
|
51543
|
+
let bits = 0;
|
|
51544
|
+
let acc = 0;
|
|
51545
|
+
for (const ch of clean) {
|
|
51546
|
+
const value = ALPHABET.indexOf(ch);
|
|
51547
|
+
if (value < 0) throw new IrCodecError("tuya-malformed", "not a base64 string");
|
|
51548
|
+
acc = acc << 6 | value;
|
|
51549
|
+
bits += 6;
|
|
51550
|
+
if (bits >= 8) {
|
|
51551
|
+
bits -= 8;
|
|
51552
|
+
out.push(acc >> bits & 255);
|
|
51553
|
+
}
|
|
51554
|
+
}
|
|
51555
|
+
return Uint8Array.from(out);
|
|
51556
|
+
}
|
|
51557
|
+
/** Signed pulse train to a Tuya IR code: base64(FastLZ(uint16 LE durations)). */
|
|
51558
|
+
function encodeTuya(timings) {
|
|
51559
|
+
const bytes = new Uint8Array(timings.length * 2);
|
|
51560
|
+
timings.forEach((value, index) => {
|
|
51561
|
+
const duration = Math.abs(value);
|
|
51562
|
+
if (duration === 0 || duration > MAX_DURATION_US) throw new IrCodecError("invalid-timings", `timing ${index} does not fit 16 bits`);
|
|
51563
|
+
bytes[index * 2] = duration & 255;
|
|
51564
|
+
bytes[index * 2 + 1] = duration >> 8;
|
|
51565
|
+
});
|
|
51566
|
+
return toBase64(fastlzCompress(bytes));
|
|
51567
|
+
}
|
|
51568
|
+
/** A Tuya IR code to a signed pulse train (mark first). Throws `IrCodecError`. */
|
|
51569
|
+
function decodeTuya(code) {
|
|
51570
|
+
const bytes = fastlzDecompress(fromBase64(code));
|
|
51571
|
+
if (bytes.length === 0 || bytes.length % 2 !== 0) throw new IrCodecError("tuya-malformed", "payload is not a list of 16-bit durations");
|
|
51572
|
+
const timings = [];
|
|
51573
|
+
for (let i = 0; i < bytes.length; i += 2) {
|
|
51574
|
+
const duration = (bytes[i] ?? 0) | (bytes[i + 1] ?? 0) << 8;
|
|
51575
|
+
timings.push(i / 2 % 2 === 0 ? duration : -duration);
|
|
51576
|
+
}
|
|
51577
|
+
const checked = IrTimingsSchema.safeParse(timings);
|
|
51578
|
+
if (!checked.success) throw new IrCodecError("tuya-malformed", checked.error.message);
|
|
51579
|
+
return checked.data;
|
|
51580
|
+
}
|
|
51581
|
+
/** Device-native IR code formats a transmitter can replay verbatim. */
|
|
51582
|
+
var IrNativeFormatSchema = _enum(["tuya"]);
|
|
51583
|
+
/**
|
|
51584
|
+
* Longest native code accepted: base64 of the worst-case compressed stream
|
|
51585
|
+
* (every decoded byte as a literal, plus one control byte per 32), with margin.
|
|
51586
|
+
*/
|
|
51587
|
+
var IR_NATIVE_CODE_MAX_CHARS = Math.ceil((IR_DECOMPRESSED_MAX + Math.ceil(IR_DECOMPRESSED_MAX / 32)) / 3) * 4 + 256;
|
|
51588
|
+
var IrNativeCodeSchema = object({
|
|
51589
|
+
format: IrNativeFormatSchema,
|
|
51590
|
+
code: string().min(1).max(IR_NATIVE_CODE_MAX_CHARS)
|
|
51591
|
+
});
|
|
51592
|
+
var IR_NATIVE_CODECS = { tuya: {
|
|
51593
|
+
encode: encodeTuya,
|
|
51594
|
+
decode: decodeTuya
|
|
51595
|
+
} };
|
|
51596
|
+
/** What a remote command stores: a raw pulse train, a learned Pronto code, or a device-native code. */
|
|
51597
|
+
var IrPayloadSchema = discriminatedUnion("kind", [
|
|
51598
|
+
object({
|
|
51599
|
+
kind: literal("raw"),
|
|
51600
|
+
timings: array(number$1().int()),
|
|
51601
|
+
settings: TransmitSettingsSchema.optional()
|
|
51602
|
+
}),
|
|
51603
|
+
object({
|
|
51604
|
+
kind: literal("pronto"),
|
|
51605
|
+
code: string()
|
|
51606
|
+
}),
|
|
51607
|
+
object({
|
|
51608
|
+
kind: literal("native"),
|
|
51609
|
+
format: IrNativeFormatSchema,
|
|
51610
|
+
code: string()
|
|
51611
|
+
})
|
|
51612
|
+
]);
|
|
51022
51613
|
/** Resolve a payload to what `ir-transmitter.send` takes. Throws `IrCodecError`. */
|
|
51023
51614
|
function toTimings(payload) {
|
|
51024
51615
|
if (payload.kind === "pronto") {
|
|
@@ -51028,6 +51619,10 @@ function toTimings(payload) {
|
|
|
51028
51619
|
settings: { carrierHz: decoded.carrierHz }
|
|
51029
51620
|
};
|
|
51030
51621
|
}
|
|
51622
|
+
if (payload.kind === "native") return {
|
|
51623
|
+
timings: IR_NATIVE_CODECS[payload.format].decode(payload.code),
|
|
51624
|
+
settings: {}
|
|
51625
|
+
};
|
|
51031
51626
|
const checked = IrTimingsSchema.safeParse(payload.timings);
|
|
51032
51627
|
if (!checked.success) throw new IrCodecError("invalid-timings", checked.error.message);
|
|
51033
51628
|
return {
|
|
@@ -51899,8 +52494,8 @@ function actuator(input) {
|
|
|
51899
52494
|
};
|
|
51900
52495
|
}
|
|
51901
52496
|
new Map(GROUP_TEMPLATES.map((template) => [template.id, template]));
|
|
51902
|
-
DeviceFeature.LightColorRgb, DeviceFeature.LightColorHsv, DeviceFeature.LightColorMired;
|
|
51903
52497
|
DeviceType.Camera;
|
|
52498
|
+
DeviceFeature.LightColorRgb, DeviceFeature.LightColorHsv, DeviceFeature.LightColorMired;
|
|
51904
52499
|
var PowerSourceRefusalReasonSchema = _enum([
|
|
51905
52500
|
"no-power-source",
|
|
51906
52501
|
"switch-missing",
|
|
@@ -53360,144 +53955,6 @@ method(object({
|
|
|
53360
53955
|
kind: "mutation",
|
|
53361
53956
|
auth: "admin"
|
|
53362
53957
|
});
|
|
53363
|
-
/**
|
|
53364
|
-
* `device-export` — collection cap for addons that export camstack
|
|
53365
|
-
* devices to external ecosystems (HomeAssistant via MQTT discovery,
|
|
53366
|
-
* HomeKit/HAP, Alexa Smart Home, …).
|
|
53367
|
-
*
|
|
53368
|
-
* No `ecosystem` enum — the addon id identifies the export target.
|
|
53369
|
-
* Each addon owns its mapping logic in its own settings UI. The cap
|
|
53370
|
-
* exposes only the COMMON surface: link state, supported device
|
|
53371
|
-
* kinds (so the UI can filter the device picker), and per-device
|
|
53372
|
-
* expose/unexpose.
|
|
53373
|
-
*
|
|
53374
|
-
* INSTANCES. One export addon can serve several independent targets (a
|
|
53375
|
-
* HomeKit bridge, a Home Assistant broker). `listInstances` names them.
|
|
53376
|
-
* `instanceId` on a READ is optional: absent = the whole addon (linked if any
|
|
53377
|
-
* enabled instance is, `exposedDeviceCount` = distinct devices, `setup` = the
|
|
53378
|
-
* default instance's); present = that instance; an id the provider does not
|
|
53379
|
-
* serve is refused with `ExportInstanceUnknownError` (`export-instance-unknown`),
|
|
53380
|
-
* never answered empty. `instanceId` on a WRITE is REQUIRED: a membership
|
|
53381
|
-
* change always names the target it changes. A single-instance provider
|
|
53382
|
-
* accepts an absent id on a read or its own id, and refuses any other.
|
|
53383
|
-
*/
|
|
53384
|
-
/** Which instance of an export addon a call addresses. Absent on a read = the whole addon. */
|
|
53385
|
-
var InstanceIdSchema$1 = string().min(1);
|
|
53386
|
-
var InstancePinSchema = object({ instanceId: InstanceIdSchema$1.optional() });
|
|
53387
|
-
/** One independent export target of an addon. */
|
|
53388
|
-
var ExportInstanceSchema = object({
|
|
53389
|
-
instanceId: InstanceIdSchema$1,
|
|
53390
|
-
name: string(),
|
|
53391
|
-
enabled: boolean(),
|
|
53392
|
-
kind: string().optional()
|
|
53393
|
-
});
|
|
53394
|
-
var LinkStateSchema = _enum([
|
|
53395
|
-
"unlinked",
|
|
53396
|
-
"linked",
|
|
53397
|
-
"error"
|
|
53398
|
-
]);
|
|
53399
|
-
/**
|
|
53400
|
-
* A single label/value row surfaced in the export panel's "Setup"
|
|
53401
|
-
* section. Rendered with a copy-to-clipboard button. `secret: true`
|
|
53402
|
-
* rows are masked by default with a reveal toggle (client ids,
|
|
53403
|
-
* secrets, …).
|
|
53404
|
-
*/
|
|
53405
|
-
var ExportSetupFieldSchema = object({
|
|
53406
|
-
label: string(),
|
|
53407
|
-
value: string(),
|
|
53408
|
-
/** Mask the value by default + render a reveal toggle (client id, secrets). */
|
|
53409
|
-
secret: boolean().optional()
|
|
53410
|
-
});
|
|
53411
|
-
/**
|
|
53412
|
-
* Generic, addon-agnostic pairing/account block. Any export addon can
|
|
53413
|
-
* surface a scannable QR, a set of copyable label/value rows, and a
|
|
53414
|
-
* free-form operator note — the `DeviceExportPanel` renders whatever
|
|
53415
|
-
* the provider supplies and skips the section entirely when `setup`
|
|
53416
|
-
* is unset.
|
|
53417
|
-
*/
|
|
53418
|
-
var ExportSetupSchema = object({
|
|
53419
|
-
/** A string to render as a scannable QR — HAP `X-HM://…` URI, a pairing URL, etc. Omitted when there's nothing to scan. */
|
|
53420
|
-
qr: string().optional(),
|
|
53421
|
-
/** Label/value rows shown with a copy button (HAP setup code, OAuth URLs, client id, linked-account count, …). */
|
|
53422
|
-
fields: array(ExportSetupFieldSchema).readonly().optional(),
|
|
53423
|
-
/** Free-form operator instructions rendered above the fields. */
|
|
53424
|
-
note: string().optional()
|
|
53425
|
-
});
|
|
53426
|
-
var DeviceExportStatusSchema = object({
|
|
53427
|
-
linkState: LinkStateSchema,
|
|
53428
|
-
exposedDeviceCount: number$1(),
|
|
53429
|
-
error: string().optional(),
|
|
53430
|
-
/**
|
|
53431
|
-
* Optional pairing/account info the panel renders in a generic
|
|
53432
|
-
* "Setup" section. Addon-agnostic — the addon id identifies the
|
|
53433
|
-
* export target, never an `ecosystem` key here.
|
|
53434
|
-
*/
|
|
53435
|
-
setup: ExportSetupSchema.optional()
|
|
53436
|
-
});
|
|
53437
|
-
var DeviceKindSchema = string();
|
|
53438
|
-
var ExposedDeviceSchema = object({
|
|
53439
|
-
deviceId: string(),
|
|
53440
|
-
exposedAs: string().optional(),
|
|
53441
|
-
capabilities: array(string()).optional()
|
|
53442
|
-
});
|
|
53443
|
-
var ExposeInputSchema = object({
|
|
53444
|
-
instanceId: InstanceIdSchema$1,
|
|
53445
|
-
deviceId: string(),
|
|
53446
|
-
capabilities: array(string()).optional()
|
|
53447
|
-
});
|
|
53448
|
-
var UnexposeInputSchema = object({
|
|
53449
|
-
instanceId: InstanceIdSchema$1,
|
|
53450
|
-
deviceId: string()
|
|
53451
|
-
});
|
|
53452
|
-
/**
|
|
53453
|
-
* What an exporter may expose besides devices (D968). An action and a
|
|
53454
|
-
* notification target are LIST ENTRIES, never devices (D954): they enter an
|
|
53455
|
-
* exporter's own selection, not the device registry.
|
|
53456
|
-
*/
|
|
53457
|
-
var ExportEntityKindSchema = _enum([
|
|
53458
|
-
"device",
|
|
53459
|
-
"action",
|
|
53460
|
-
"notifier"
|
|
53461
|
-
]);
|
|
53462
|
-
var ExportEntityRefSchema = discriminatedUnion("kind", [
|
|
53463
|
-
object({
|
|
53464
|
-
kind: literal("device"),
|
|
53465
|
-
deviceId: string()
|
|
53466
|
-
}),
|
|
53467
|
-
object({
|
|
53468
|
-
kind: literal("action"),
|
|
53469
|
-
actionId: string().min(1)
|
|
53470
|
-
}),
|
|
53471
|
-
object({
|
|
53472
|
-
kind: literal("notifier"),
|
|
53473
|
-
targetId: string().min(1)
|
|
53474
|
-
})
|
|
53475
|
-
]);
|
|
53476
|
-
var ExposedEntitySchema = object({
|
|
53477
|
-
entity: ExportEntityRefSchema,
|
|
53478
|
-
exposedAs: string().optional()
|
|
53479
|
-
});
|
|
53480
|
-
var ExposeEntityInputSchema = object({
|
|
53481
|
-
instanceId: InstanceIdSchema$1,
|
|
53482
|
-
entity: ExportEntityRefSchema
|
|
53483
|
-
});
|
|
53484
|
-
var UnexposeEntityInputSchema = object({
|
|
53485
|
-
instanceId: InstanceIdSchema$1,
|
|
53486
|
-
entity: ExportEntityRefSchema
|
|
53487
|
-
});
|
|
53488
|
-
method(InstancePinSchema, DeviceExportStatusSchema), method(_void(), array(ExportInstanceSchema)), method(InstancePinSchema, array(DeviceKindSchema)), method(InstancePinSchema, array(ExposedDeviceSchema)), method(ExposeInputSchema, _void(), {
|
|
53489
|
-
kind: "mutation",
|
|
53490
|
-
auth: "admin"
|
|
53491
|
-
}), method(UnexposeInputSchema, _void(), {
|
|
53492
|
-
kind: "mutation",
|
|
53493
|
-
auth: "admin"
|
|
53494
|
-
}), optionalMethod(_void(), array(ExportEntityKindSchema)), optionalMethod(InstancePinSchema, array(ExposedEntitySchema)), optionalMethod(ExposeEntityInputSchema, _void(), {
|
|
53495
|
-
kind: "mutation",
|
|
53496
|
-
auth: "admin"
|
|
53497
|
-
}), optionalMethod(UnexposeEntityInputSchema, _void(), {
|
|
53498
|
-
kind: "mutation",
|
|
53499
|
-
auth: "admin"
|
|
53500
|
-
});
|
|
53501
53958
|
var DeviceAliasSchema = string().max(64).regex(/^[a-z][a-z0-9_]*$/);
|
|
53502
53959
|
var DeviceTemplateSchema = string().min(1).max(4096);
|
|
53503
53960
|
/** One value a caller hands the renderer for `thisDevice`. */
|
|
@@ -56667,117 +57124,6 @@ var enumSensorCapability = {
|
|
|
56667
57124
|
* whether persisting is worth a SQLite commit. */
|
|
56668
57125
|
volatileStateFields: ["lastFetchedAt", "timestamp"]
|
|
56669
57126
|
};
|
|
56670
|
-
var EventVocabularyKindSchema = _enum([
|
|
56671
|
-
"press",
|
|
56672
|
-
"long-press",
|
|
56673
|
-
"long-press-start",
|
|
56674
|
-
"release",
|
|
56675
|
-
"repeat",
|
|
56676
|
-
"double-press",
|
|
56677
|
-
"other"
|
|
56678
|
-
]);
|
|
56679
|
-
/** The part of the device an event comes from: a button, a channel. */
|
|
56680
|
-
var EventVocabularySourceSchema = object({
|
|
56681
|
-
id: string().min(1),
|
|
56682
|
-
label: string().min(1)
|
|
56683
|
-
});
|
|
56684
|
-
/** One scalar field of an event's `data`, by dotted path. */
|
|
56685
|
-
var EventVocabularyFieldSchema = object({
|
|
56686
|
-
path: string().min(1),
|
|
56687
|
-
kind: _enum([
|
|
56688
|
-
"string",
|
|
56689
|
-
"number",
|
|
56690
|
-
"boolean",
|
|
56691
|
-
"enum"
|
|
56692
|
-
]),
|
|
56693
|
-
enumValues: array(string()).optional(),
|
|
56694
|
-
label: string().min(1).optional()
|
|
56695
|
-
});
|
|
56696
|
-
var EventVocabularyEntrySchema = object({
|
|
56697
|
-
/** The native token, verbatim. */
|
|
56698
|
-
id: string().min(1),
|
|
56699
|
-
source: EventVocabularySourceSchema.optional(),
|
|
56700
|
-
label: string().min(1),
|
|
56701
|
-
description: string().optional(),
|
|
56702
|
-
kind: EventVocabularyKindSchema.optional(),
|
|
56703
|
-
payload: array(EventVocabularyFieldSchema).optional()
|
|
56704
|
-
});
|
|
56705
|
-
/**
|
|
56706
|
-
* The vocabulary of a source that declares tokens and nothing else: one
|
|
56707
|
-
* entry per token, labelled with the token itself.
|
|
56708
|
-
*/
|
|
56709
|
-
function plainEventVocabulary(eventTypes) {
|
|
56710
|
-
return [...new Set(eventTypes)].filter((eventType) => eventType !== "").map((eventType) => ({
|
|
56711
|
-
id: eventType,
|
|
56712
|
-
label: eventType
|
|
56713
|
-
}));
|
|
56714
|
-
}
|
|
56715
|
-
/** The native tokens of a vocabulary, each once, in declaration order. */
|
|
56716
|
-
function eventTypesOfVocabulary(vocabulary) {
|
|
56717
|
-
return [...new Set(vocabulary.map((entry) => entry.id))];
|
|
56718
|
-
}
|
|
56719
|
-
/** The entry a fire belongs to: same token, same source (or both without one). */
|
|
56720
|
-
function findVocabularyEntry(vocabulary, eventType, sourceId) {
|
|
56721
|
-
return vocabulary.find((entry) => entry.id === eventType && entry.source?.id === sourceId);
|
|
56722
|
-
}
|
|
56723
|
-
/**
|
|
56724
|
-
* Generic stateless event emitter. Installed on a `DeviceType.EventEmitter`
|
|
56725
|
-
* device. Carries the device's EXACT declared event vocabulary verbatim
|
|
56726
|
-
* (NO normalization). Two shapes:
|
|
56727
|
-
* - structured source (HA `event.*` entity) → `vocabulary` is the fixed
|
|
56728
|
-
* declared set (e.g. press_short, press_long, …).
|
|
56729
|
-
* - generic/legacy source (HA bus events, e.g. zha_event) → `vocabulary`
|
|
56730
|
-
* is [] (open) and `lastEvent.data` carries the complex payload.
|
|
56731
|
-
* `vocabulary` (D1044) names each event for a person and types it for a
|
|
56732
|
-
* rule; `eventTypes` is its list of native tokens, kept for older readers.
|
|
56733
|
-
* A fire names the part of the device it came from in `sourceId` when the
|
|
56734
|
-
* vocabulary declares sources (a remote's buttons).
|
|
56735
|
-
* `seq` is monotonic so two identical events still produce distinct slice writes.
|
|
56736
|
-
*/
|
|
56737
|
-
var EventFireSchema = object({
|
|
56738
|
-
deviceId: number$1(),
|
|
56739
|
-
eventType: string(),
|
|
56740
|
-
sourceId: string().optional(),
|
|
56741
|
-
data: record(string(), unknown()).nullable(),
|
|
56742
|
-
timestamp: number$1().meta(readingMeta("none")),
|
|
56743
|
-
seq: number$1().meta(readingMeta("count"))
|
|
56744
|
-
});
|
|
56745
|
-
var EventEmitterStatusSchema = object({
|
|
56746
|
-
eventTypes: array(string()),
|
|
56747
|
-
/**
|
|
56748
|
-
* Required of a provider by the type. A status written before the field
|
|
56749
|
-
* existed still parses, as an empty vocabulary: read it through
|
|
56750
|
-
* `readEventVocabulary`, which then answers with the plain tokens.
|
|
56751
|
-
*/
|
|
56752
|
-
vocabulary: array(EventVocabularyEntrySchema).default([]),
|
|
56753
|
-
lastEvent: EventFireSchema.nullable(),
|
|
56754
|
-
eventCountSinceStart: number$1().meta(readingMeta("count"))
|
|
56755
|
-
});
|
|
56756
|
-
var eventEmitterCapability = {
|
|
56757
|
-
name: "event-emitter",
|
|
56758
|
-
scope: "device",
|
|
56759
|
-
deviceNative: true,
|
|
56760
|
-
mode: "singleton",
|
|
56761
|
-
deviceTypes: [DeviceType.EventEmitter],
|
|
56762
|
-
methods: {},
|
|
56763
|
-
events: { onEvent: { data: EventFireSchema } },
|
|
56764
|
-
status: {
|
|
56765
|
-
schema: EventEmitterStatusSchema,
|
|
56766
|
-
kind: "push"
|
|
56767
|
-
},
|
|
56768
|
-
runtimeState: EventEmitterStatusSchema,
|
|
56769
|
-
/**
|
|
56770
|
-
* Runtime-state durability: **session** — `eventCountSinceStart` names its own scope.
|
|
56771
|
-
*
|
|
56772
|
-
* See `RuntimeStateDurability`. Enforced by
|
|
56773
|
-
* `scripts/check-runtime-state-durability.ts`.
|
|
56774
|
-
*/
|
|
56775
|
-
durability: "session",
|
|
56776
|
-
/**
|
|
56777
|
-
* History (D850): none — `eventCountSinceStart` resets with the addon; events live in ledgers.
|
|
56778
|
-
*/
|
|
56779
|
-
history: "none"
|
|
56780
|
-
};
|
|
56781
57127
|
var IdentitySchema = object({
|
|
56782
57128
|
id: string(),
|
|
56783
57129
|
name: string(),
|
|
@@ -58463,6 +58809,193 @@ var StateLookSchema = object({
|
|
|
58463
58809
|
background: _enum(HERO_BACKGROUNDS),
|
|
58464
58810
|
animation: HeroAnimationSchema
|
|
58465
58811
|
});
|
|
58812
|
+
/** A string in both languages, as the cap vocabulary writes it (D920): no `t()` in the model. */
|
|
58813
|
+
var HeroTextSchema = object({
|
|
58814
|
+
en: string(),
|
|
58815
|
+
it: string()
|
|
58816
|
+
});
|
|
58817
|
+
/**
|
|
58818
|
+
* What a device that has not reported says in place of its value: an empty "—",
|
|
58819
|
+
* never a word like "Unknown" and never a 0 (D393). The card stays its normal
|
|
58820
|
+
* self; only the value is empty.
|
|
58821
|
+
*/
|
|
58822
|
+
var NOT_REPORTED = {
|
|
58823
|
+
en: "—",
|
|
58824
|
+
it: "—"
|
|
58825
|
+
};
|
|
58826
|
+
/**
|
|
58827
|
+
* The ONE measurement a simple sensor shows (card wave, phase 1).
|
|
58828
|
+
*
|
|
58829
|
+
* A sensor that measures a single quantity (a temperature, a humidity, a power,
|
|
58830
|
+
* a contact, a text state) is drawn as that reading, once, big, inside a scene
|
|
58831
|
+
* whose motion says what the number means: heat rising when hot, flakes when
|
|
58832
|
+
* cold, a wire flowing at the speed of the power, a ring while a window is
|
|
58833
|
+
* open. Everything the card draws is decided here; a client only paints it.
|
|
58834
|
+
*/
|
|
58835
|
+
var HERO_MEASUREMENT_QUANTITIES = [
|
|
58836
|
+
"temperature",
|
|
58837
|
+
"humidity",
|
|
58838
|
+
"power",
|
|
58839
|
+
"contact",
|
|
58840
|
+
"text"
|
|
58841
|
+
];
|
|
58842
|
+
/** How a temperature reads to a person; drives the heat or the cold scene. */
|
|
58843
|
+
var HERO_MEASUREMENT_BANDS = [
|
|
58844
|
+
"hot",
|
|
58845
|
+
"mild",
|
|
58846
|
+
"cold"
|
|
58847
|
+
];
|
|
58848
|
+
/** `updated` = the value was last read then ("2 min ago"); `changed` = it has held since then ("for 12 min"). */
|
|
58849
|
+
var HERO_MEASUREMENT_SINCE_KINDS = ["updated", "changed"];
|
|
58850
|
+
var HeroMeasurementReadingSchema = object({
|
|
58851
|
+
value: number$1(),
|
|
58852
|
+
quantity: ReadingQuantitySchema
|
|
58853
|
+
});
|
|
58854
|
+
var HeroMeasurementSchema = object({
|
|
58855
|
+
quantity: _enum(HERO_MEASUREMENT_QUANTITIES),
|
|
58856
|
+
reading: HeroMeasurementReadingSchema.nullable(),
|
|
58857
|
+
icon: IconKeySchema.nullable(),
|
|
58858
|
+
value: HeroTextSchema,
|
|
58859
|
+
unit: string().nullable(),
|
|
58860
|
+
band: _enum(HERO_MEASUREMENT_BANDS).nullable(),
|
|
58861
|
+
level: number$1().min(0).max(1).nullable(),
|
|
58862
|
+
word: HeroTextSchema,
|
|
58863
|
+
tone: _enum(HERO_TONES),
|
|
58864
|
+
since: number$1().nullable(),
|
|
58865
|
+
sinceKind: _enum(HERO_MEASUREMENT_SINCE_KINDS),
|
|
58866
|
+
historyKey: string().nullable()
|
|
58867
|
+
});
|
|
58868
|
+
var same$2 = (text) => t(text, text);
|
|
58869
|
+
var clamp01$1 = (n) => Math.min(1, Math.max(0, n));
|
|
58870
|
+
var trimmed = (n, digits) => String(Number(n.toFixed(digits)));
|
|
58871
|
+
function temperatureBand(celsius) {
|
|
58872
|
+
if (celsius < 12) return "cold";
|
|
58873
|
+
if (celsius > 28) return "hot";
|
|
58874
|
+
return "mild";
|
|
58875
|
+
}
|
|
58876
|
+
var BAND_WORD = {
|
|
58877
|
+
hot: t("Hot", "Caldo"),
|
|
58878
|
+
mild: t("Normal", "Normale"),
|
|
58879
|
+
cold: t("Cold", "Freddo")
|
|
58880
|
+
};
|
|
58881
|
+
var BAND_TONE = {
|
|
58882
|
+
hot: "warning",
|
|
58883
|
+
mild: "muted",
|
|
58884
|
+
cold: "info"
|
|
58885
|
+
};
|
|
58886
|
+
function temperatureMeasurement(celsius, since) {
|
|
58887
|
+
const band = temperatureBand(celsius);
|
|
58888
|
+
return {
|
|
58889
|
+
quantity: "temperature",
|
|
58890
|
+
reading: {
|
|
58891
|
+
value: celsius,
|
|
58892
|
+
quantity: "temperature"
|
|
58893
|
+
},
|
|
58894
|
+
icon: "thermometer",
|
|
58895
|
+
value: same$2(trimmed(celsius, 1)),
|
|
58896
|
+
unit: "°C",
|
|
58897
|
+
band,
|
|
58898
|
+
level: null,
|
|
58899
|
+
word: BAND_WORD[band],
|
|
58900
|
+
tone: BAND_TONE[band],
|
|
58901
|
+
since,
|
|
58902
|
+
sinceKind: "updated",
|
|
58903
|
+
historyKey: "cap:temperature-sensor.temperature"
|
|
58904
|
+
};
|
|
58905
|
+
}
|
|
58906
|
+
function humidityMeasurement(percent, since) {
|
|
58907
|
+
const dry = percent < 30;
|
|
58908
|
+
const humid = percent > 70;
|
|
58909
|
+
return {
|
|
58910
|
+
quantity: "humidity",
|
|
58911
|
+
reading: {
|
|
58912
|
+
value: percent,
|
|
58913
|
+
quantity: "humidity"
|
|
58914
|
+
},
|
|
58915
|
+
icon: "droplets",
|
|
58916
|
+
value: same$2(String(Math.round(percent))),
|
|
58917
|
+
unit: "%",
|
|
58918
|
+
band: null,
|
|
58919
|
+
level: clamp01$1(percent / 100),
|
|
58920
|
+
word: dry ? t("Dry", "Secco") : humid ? t("Humid", "Umido") : t("Normal", "Normale"),
|
|
58921
|
+
tone: dry || humid ? "warning" : "info",
|
|
58922
|
+
since,
|
|
58923
|
+
sinceKind: "updated",
|
|
58924
|
+
historyKey: "cap:humidity-sensor.humidity"
|
|
58925
|
+
};
|
|
58926
|
+
}
|
|
58927
|
+
function textMeasurement(text, since) {
|
|
58928
|
+
return {
|
|
58929
|
+
quantity: "text",
|
|
58930
|
+
reading: null,
|
|
58931
|
+
icon: null,
|
|
58932
|
+
value: same$2(text),
|
|
58933
|
+
unit: null,
|
|
58934
|
+
band: null,
|
|
58935
|
+
level: null,
|
|
58936
|
+
word: t("Changed", "Cambiato"),
|
|
58937
|
+
tone: "muted",
|
|
58938
|
+
since,
|
|
58939
|
+
sinceKind: "updated",
|
|
58940
|
+
historyKey: null
|
|
58941
|
+
};
|
|
58942
|
+
}
|
|
58943
|
+
/** What each quantity draws beside its value, reported or not. */
|
|
58944
|
+
var QUANTITY_FACE = {
|
|
58945
|
+
temperature: {
|
|
58946
|
+
icon: "thermometer",
|
|
58947
|
+
unit: "°C",
|
|
58948
|
+
sinceKind: "updated",
|
|
58949
|
+
historyKey: "cap:temperature-sensor.temperature"
|
|
58950
|
+
},
|
|
58951
|
+
humidity: {
|
|
58952
|
+
icon: "droplets",
|
|
58953
|
+
unit: "%",
|
|
58954
|
+
sinceKind: "updated",
|
|
58955
|
+
historyKey: "cap:humidity-sensor.humidity"
|
|
58956
|
+
},
|
|
58957
|
+
power: {
|
|
58958
|
+
icon: "zap",
|
|
58959
|
+
unit: "W",
|
|
58960
|
+
sinceKind: "updated",
|
|
58961
|
+
historyKey: "cap:power-meter.power"
|
|
58962
|
+
},
|
|
58963
|
+
contact: {
|
|
58964
|
+
icon: null,
|
|
58965
|
+
unit: null,
|
|
58966
|
+
sinceKind: "changed",
|
|
58967
|
+
historyKey: null
|
|
58968
|
+
},
|
|
58969
|
+
text: {
|
|
58970
|
+
icon: null,
|
|
58971
|
+
unit: null,
|
|
58972
|
+
sinceKind: "updated",
|
|
58973
|
+
historyKey: null
|
|
58974
|
+
}
|
|
58975
|
+
};
|
|
58976
|
+
/**
|
|
58977
|
+
* The measurement of a sensor that has not reported yet: its normal card with
|
|
58978
|
+
* an empty "—" value and its unit — never a placeholder, never a 0 (D393). The
|
|
58979
|
+
* reading is `null` (nothing to format), the scene does not move, and nothing
|
|
58980
|
+
* claims a moment.
|
|
58981
|
+
*/
|
|
58982
|
+
function emptyMeasurement(quantity) {
|
|
58983
|
+
const face = QUANTITY_FACE[quantity];
|
|
58984
|
+
return {
|
|
58985
|
+
quantity,
|
|
58986
|
+
reading: null,
|
|
58987
|
+
icon: face.icon,
|
|
58988
|
+
value: NOT_REPORTED,
|
|
58989
|
+
unit: face.unit,
|
|
58990
|
+
band: null,
|
|
58991
|
+
level: null,
|
|
58992
|
+
word: NOT_REPORTED,
|
|
58993
|
+
tone: "muted",
|
|
58994
|
+
since: null,
|
|
58995
|
+
sinceKind: face.sinceKind,
|
|
58996
|
+
historyKey: face.historyKey
|
|
58997
|
+
};
|
|
58998
|
+
}
|
|
58466
58999
|
/** The scene as the model carries it. `null` = the device did not say (never a guess). */
|
|
58467
59000
|
var HeroSceneSchema = object({
|
|
58468
59001
|
id: _enum([
|
|
@@ -58513,12 +59046,7 @@ var HeroSceneSchema = object({
|
|
|
58513
59046
|
level: number$1().min(0).max(1).nullable()
|
|
58514
59047
|
});
|
|
58515
59048
|
DeviceType.Camera, DeviceType.Hub, DeviceType.Light, DeviceType.Siren, DeviceType.Switch, DeviceType.Sensor, DeviceType.Climate, DeviceType.Button, DeviceType.EventEmitter, DeviceType.Update, DeviceType.Generic, DeviceType.Notifier, DeviceType.Script, DeviceType.Automation, DeviceType.Lock, DeviceType.Cover, DeviceType.Valve, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.HeatPump, DeviceType.Fan, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Control, DeviceType.Presence, DeviceType.Weather, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder, DeviceType.PetFountain, DeviceType.Dishwasher, DeviceType.Washer, DeviceType.Dryer, DeviceType.Gateway;
|
|
58516
|
-
DeviceRole.Siren, DeviceRole.Floodlight, DeviceRole.Spotlight, DeviceRole.PirSensor, DeviceRole.Chime, DeviceRole.Autotrack, DeviceRole.Nightvision, DeviceRole.PrivacyMask, DeviceRole.Doorbell, DeviceRole.CoverBlind, DeviceRole.CoverShutter, DeviceRole.CoverAwning, DeviceRole.CoverCurtain, DeviceRole.CoverGarage, DeviceRole.CoverGate, DeviceRole.CoverDoor, DeviceRole.CoverWindow, DeviceRole.BinaryHelper, DeviceRole.Outlet, DeviceRole.SwitchHeater, DeviceRole.SwitchFan, DeviceRole.ClimateAc, DeviceRole.ClimateThermostat, DeviceRole.ClimateFloor, DeviceRole.ClimateRadiator, DeviceRole.ClimateHeater, DeviceRole.ClimateHeatPumpCircuit, DeviceRole.MotionSensor, DeviceRole.ContactSensor, DeviceRole.LeakSensor, DeviceRole.SmokeSensor, DeviceRole.COSensor, DeviceRole.GasSensor, DeviceRole.TamperSensor, DeviceRole.VibrationSensor, DeviceRole.ConnectivitySensor, DeviceRole.SoundSensor, DeviceRole.BinarySensor, DeviceRole.TemperatureSensor, DeviceRole.HumiditySensor, DeviceRole.AmbientLightSensor, DeviceRole.PressureSensor, DeviceRole.WindSensor, DeviceRole.RainSensor, DeviceRole.UvSensor, DeviceRole.SolarRadiationSensor, DeviceRole.SoilMoistureSensor, DeviceRole.PowerSensor, DeviceRole.EnergySensor, DeviceRole.VoltageSensor, DeviceRole.CurrentSensor, DeviceRole.AirQualitySensor, DeviceRole.BatterySensor, DeviceRole.NumericSensor, DeviceRole.EnumSensor, DeviceRole.DateTimeSensor, DeviceRole.GenericSensor, DeviceRole.NumericControl, DeviceRole.SelectControl, DeviceRole.TextControl, DeviceRole.DateTimeControl, DeviceRole.MobilePushNotifier, DeviceRole.MessagingNotifier, DeviceRole.EmailNotifier, DeviceRole.GenericNotifier, DeviceRole.IrTransmitter;
|
|
58517
|
-
/** A string in both languages, as the cap vocabulary writes it (D920): no `t()` in the model. */
|
|
58518
|
-
var HeroTextSchema = object({
|
|
58519
|
-
en: string(),
|
|
58520
|
-
it: string()
|
|
58521
|
-
});
|
|
59049
|
+
DeviceRole.Siren, DeviceRole.Floodlight, DeviceRole.Spotlight, DeviceRole.PirSensor, DeviceRole.Chime, DeviceRole.Autotrack, DeviceRole.Nightvision, DeviceRole.PrivacyMask, DeviceRole.Doorbell, DeviceRole.CoverBlind, DeviceRole.CoverShutter, DeviceRole.CoverAwning, DeviceRole.CoverCurtain, DeviceRole.CoverGarage, DeviceRole.CoverGate, DeviceRole.CoverDoor, DeviceRole.CoverWindow, DeviceRole.BinaryHelper, DeviceRole.Outlet, DeviceRole.SwitchHeater, DeviceRole.SwitchFan, DeviceRole.SwitchLight, DeviceRole.ClimateAc, DeviceRole.ClimateThermostat, DeviceRole.ClimateFloor, DeviceRole.ClimateRadiator, DeviceRole.ClimateHeater, DeviceRole.ClimateHeatPumpCircuit, DeviceRole.MotionSensor, DeviceRole.ContactSensor, DeviceRole.LeakSensor, DeviceRole.SmokeSensor, DeviceRole.COSensor, DeviceRole.GasSensor, DeviceRole.TamperSensor, DeviceRole.VibrationSensor, DeviceRole.ConnectivitySensor, DeviceRole.SoundSensor, DeviceRole.BinarySensor, DeviceRole.TemperatureSensor, DeviceRole.HumiditySensor, DeviceRole.AmbientLightSensor, DeviceRole.PressureSensor, DeviceRole.WindSensor, DeviceRole.RainSensor, DeviceRole.UvSensor, DeviceRole.SolarRadiationSensor, DeviceRole.SoilMoistureSensor, DeviceRole.PowerSensor, DeviceRole.EnergySensor, DeviceRole.VoltageSensor, DeviceRole.CurrentSensor, DeviceRole.AirQualitySensor, DeviceRole.BatterySensor, DeviceRole.NumericSensor, DeviceRole.EnumSensor, DeviceRole.DateTimeSensor, DeviceRole.GenericSensor, DeviceRole.NumericControl, DeviceRole.SelectControl, DeviceRole.TextControl, DeviceRole.DateTimeControl, DeviceRole.MobilePushNotifier, DeviceRole.MessagingNotifier, DeviceRole.EmailNotifier, DeviceRole.GenericNotifier, DeviceRole.IrTransmitter;
|
|
58522
59050
|
var HeroRowIdSchema = _enum([
|
|
58523
59051
|
"progress",
|
|
58524
59052
|
"run-for",
|
|
@@ -58624,6 +59152,25 @@ var HeroControlSchema = discriminatedUnion("kind", [
|
|
|
58624
59152
|
optionLabels: record(string(), HeroTextSchema).optional(),
|
|
58625
59153
|
call: HeroCallSchema,
|
|
58626
59154
|
valueArg: string()
|
|
59155
|
+
}),
|
|
59156
|
+
object({
|
|
59157
|
+
kind: literal("number"),
|
|
59158
|
+
id: string(),
|
|
59159
|
+
label: HeroTextSchema,
|
|
59160
|
+
value: number$1().nullable(),
|
|
59161
|
+
/** `null` = any number; the device rounds what it does not accept. */
|
|
59162
|
+
step: number$1().nullable(),
|
|
59163
|
+
unit: string(),
|
|
59164
|
+
call: HeroCallSchema,
|
|
59165
|
+
valueArg: string()
|
|
59166
|
+
}),
|
|
59167
|
+
object({
|
|
59168
|
+
kind: literal("text"),
|
|
59169
|
+
id: string(),
|
|
59170
|
+
label: HeroTextSchema,
|
|
59171
|
+
value: string().nullable(),
|
|
59172
|
+
call: HeroCallSchema,
|
|
59173
|
+
valueArg: string()
|
|
58627
59174
|
})
|
|
58628
59175
|
]);
|
|
58629
59176
|
/** Declared by its interface: a `z.infer` of one more icon union pushes the cap's inferred type past what the compiler can print. */
|
|
@@ -58825,6 +59372,11 @@ var HeroModelSchema = object({
|
|
|
58825
59372
|
timedRun: HeroTimedRunSlotSchema.nullable(),
|
|
58826
59373
|
powerSupply: HeroPowerSupplySlotSchema.nullable(),
|
|
58827
59374
|
rows: array(HeroRowSchema),
|
|
59375
|
+
/**
|
|
59376
|
+
* The ONE measurement of a simple sensor, drawn once inside the scene in place of
|
|
59377
|
+
* the caption, tiles and value chips. Absent = the card draws as before.
|
|
59378
|
+
*/
|
|
59379
|
+
measurement: HeroMeasurementSchema.optional(),
|
|
58828
59380
|
/** Ids of parts that actuate the device, hidden from a session that may not act on it. */
|
|
58829
59381
|
gated: array(string()),
|
|
58830
59382
|
provenance: array(HeroProvenanceSchema)
|
|
@@ -58896,8 +59448,23 @@ var HeroRowModelSchema = object({
|
|
|
58896
59448
|
* the call. Absent or empty = `primary` alone.
|
|
58897
59449
|
*/
|
|
58898
59450
|
extras: array(HeroControlSchema).max(2).optional(),
|
|
58899
|
-
trailing: HeroFactSchema.nullable()
|
|
59451
|
+
trailing: HeroFactSchema.nullable(),
|
|
59452
|
+
/**
|
|
59453
|
+
* The simple sensor's one reading (the hero's `measurement`): the row draws its value
|
|
59454
|
+
* at the right, the unit small, the quantity's icon in the mini-scene. Absent = an
|
|
59455
|
+
* older server or a device that is not a simple sensor: draw `trailing`.
|
|
59456
|
+
*/
|
|
59457
|
+
measurement: HeroMeasurementSchema.optional()
|
|
58900
59458
|
});
|
|
59459
|
+
new Set([
|
|
59460
|
+
"temperature",
|
|
59461
|
+
"humidity",
|
|
59462
|
+
"pressure",
|
|
59463
|
+
"illuminance",
|
|
59464
|
+
"reading",
|
|
59465
|
+
"air-quality",
|
|
59466
|
+
"valve"
|
|
59467
|
+
]);
|
|
58901
59468
|
DeviceType.Climate;
|
|
58902
59469
|
DeviceType.Climate, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.MediaPlayer;
|
|
58903
59470
|
/**
|
|
@@ -59353,6 +59920,12 @@ var IntegrationLiteSchema = object({
|
|
|
59353
59920
|
var AvailableIntegrationTypeSchema = object({
|
|
59354
59921
|
addonId: string(),
|
|
59355
59922
|
name: string(),
|
|
59923
|
+
/**
|
|
59924
|
+
* Product name a new integration is prefilled from (`<label> - Home`).
|
|
59925
|
+
* Absent: the client uses `name`. Set when the catalog title is not the
|
|
59926
|
+
* product (Bosch SHC, MQTT).
|
|
59927
|
+
*/
|
|
59928
|
+
providerLabel: string().optional(),
|
|
59356
59929
|
description: string(),
|
|
59357
59930
|
iconUrl: string().nullable(),
|
|
59358
59931
|
color: string(),
|
|
@@ -59980,13 +60553,32 @@ var IrSendResultSchema = object({
|
|
|
59980
60553
|
var IrTransmitterInfoSchema = object({
|
|
59981
60554
|
media: array(IrMediumSchema),
|
|
59982
60555
|
settable: array(TransmitSettingKeySchema),
|
|
59983
|
-
maxTimings: number$1().int().positive()
|
|
60556
|
+
maxTimings: number$1().int().positive(),
|
|
60557
|
+
/** The transmitter can learn a code (`learn`). */
|
|
60558
|
+
learn: boolean().default(false),
|
|
60559
|
+
/** Native code formats the transmitter replays verbatim (`send.native`). */
|
|
60560
|
+
formats: array(IrNativeFormatSchema).default([])
|
|
60561
|
+
});
|
|
60562
|
+
var IR_LEARN_TIMEOUT_DEFAULT_MS = 2e4;
|
|
60563
|
+
var IR_LEARN_TIMEOUT_MAX_MS = 6e4;
|
|
60564
|
+
var IrLearnResultSchema = object({
|
|
60565
|
+
/** The code in the device's own format, when it reports one. */
|
|
60566
|
+
native: IrNativeCodeSchema.nullable(),
|
|
60567
|
+
timings: IrTimingsSchema,
|
|
60568
|
+
carrierHz: number$1().int().positive().nullable()
|
|
59984
60569
|
});
|
|
59985
60570
|
DeviceType.Generic, method(object({
|
|
59986
60571
|
deviceId: number$1().int().nonnegative(),
|
|
59987
|
-
timings: IrTimingsSchema,
|
|
60572
|
+
timings: IrTimingsSchema.optional(),
|
|
60573
|
+
native: IrNativeCodeSchema.optional(),
|
|
59988
60574
|
settings: TransmitSettingsSchema.optional()
|
|
59989
|
-
}), IrSendResultSchema, {
|
|
60575
|
+
}).refine((input) => input.timings === void 0 !== (input.native === void 0), { message: "send takes exactly one of timings or native" }), IrSendResultSchema, {
|
|
60576
|
+
kind: "mutation",
|
|
60577
|
+
auth: "protected"
|
|
60578
|
+
}), method(object({
|
|
60579
|
+
deviceId: number$1().int().nonnegative(),
|
|
60580
|
+
timeoutMs: number$1().int().positive().max(IR_LEARN_TIMEOUT_MAX_MS).default(IR_LEARN_TIMEOUT_DEFAULT_MS)
|
|
60581
|
+
}), IrLearnResultSchema, {
|
|
59990
60582
|
kind: "mutation",
|
|
59991
60583
|
auth: "protected"
|
|
59992
60584
|
}), method(object({ deviceId: number$1().int().nonnegative() }), IrTransmitterInfoSchema, {
|
|
@@ -69772,6 +70364,7 @@ var NcSystemEventKindSchema = _enum([
|
|
|
69772
70364
|
"recording-degraded",
|
|
69773
70365
|
"device-attention-required",
|
|
69774
70366
|
"device-attention-resolved",
|
|
70367
|
+
"device-command",
|
|
69775
70368
|
"storage-location-low",
|
|
69776
70369
|
"storage-location-critical",
|
|
69777
70370
|
"storage-location-ok",
|
|
@@ -69834,11 +70427,6 @@ var NC_ALARM_SYSTEM_EVENT_KINDS = [
|
|
|
69834
70427
|
"alarm-sensor-bypass",
|
|
69835
70428
|
"alarm-disarmed"
|
|
69836
70429
|
];
|
|
69837
|
-
/**
|
|
69838
|
-
* One coherent system-event condition. `kinds` is the required opt-in safety
|
|
69839
|
-
* gate; the remaining lists are optional narrowing filters relevant to the
|
|
69840
|
-
* selected kinds.
|
|
69841
|
-
*/
|
|
69842
70430
|
var NcSystemEventConditionSchema = object({
|
|
69843
70431
|
kinds: array(NcSystemEventKindSchema).min(1),
|
|
69844
70432
|
deviceIds: array(number$1().int()).min(1).optional(),
|
|
@@ -69870,6 +70458,28 @@ var NcSystemEventConditionSchema = object({
|
|
|
69870
70458
|
nodeIds: array(string().min(1)).min(1).optional(),
|
|
69871
70459
|
packageNames: array(string().min(1)).min(1).optional(),
|
|
69872
70460
|
/**
|
|
70461
|
+
* `device-command` only: the vocabulary ACTION IDS (D983, `powerSource.forceRestart`)
|
|
70462
|
+
* this rule speaks about - the same dictionary the automation action blocks
|
|
70463
|
+
* pick from. The hub refuses an id the action index does not know.
|
|
70464
|
+
*/
|
|
70465
|
+
commandActions: array(string().min(1)).min(1).optional(),
|
|
70466
|
+
/** `device-command` only: how the command settled. A device's own change is not a command. */
|
|
70467
|
+
commandOutcomes: array(_enum([
|
|
70468
|
+
"confirmed",
|
|
70469
|
+
"already",
|
|
70470
|
+
"unconfirmed",
|
|
70471
|
+
"failed"
|
|
70472
|
+
])).min(1).optional(),
|
|
70473
|
+
/** `device-command` only: who asked (`user`, `addon`, `action`, `scheduler`, `composition`, `node`). */
|
|
70474
|
+
commandActorKinds: array(_enum([
|
|
70475
|
+
"user",
|
|
70476
|
+
"addon",
|
|
70477
|
+
"action",
|
|
70478
|
+
"scheduler",
|
|
70479
|
+
"composition",
|
|
70480
|
+
"node"
|
|
70481
|
+
])).min(1).optional(),
|
|
70482
|
+
/**
|
|
69873
70483
|
* At or below this remaining-life %, a consumable is LOW for THIS rule
|
|
69874
70484
|
* (D642). Absent = {@link NC_CONSUMABLE_LOW_PERCENT_DEFAULT}; at most
|
|
69875
70485
|
* {@link NC_CONSUMABLE_LOW_PERCENT_MAX}, so every episode can recover. Scoped to the
|
|
@@ -70850,6 +71460,13 @@ var NcRuleInputSchema = object({
|
|
|
70850
71460
|
*/
|
|
70851
71461
|
groupingSec: number$1().int().min(5).max(60).optional(),
|
|
70852
71462
|
/**
|
|
71463
|
+
* Hold deliveries of this rule to one target and, when two or more arrive
|
|
71464
|
+
* before the window ends, send them as one summary. Absent = the kind's
|
|
71465
|
+
* default (`groupWithinSecOf`): 5 s for a system-event rule, 0 for every
|
|
71466
|
+
* other kind. `0` sends each delivery as it does today.
|
|
71467
|
+
*/
|
|
71468
|
+
groupWithinSec: number$1().int().min(0).max(300).optional(),
|
|
71469
|
+
/**
|
|
70853
71470
|
* ASK ME TO CONFIRM DETECTIONS (#243): a DETECTION notification of this rule
|
|
70854
71471
|
* carries "Correct" / "Wrong" buttons (and, where the channel has room, a
|
|
70855
71472
|
* "Wrong, it is a <class>" choice). A tap marks the track for retraining, the
|
|
@@ -71286,7 +71903,12 @@ var NcHistoryEntrySchema = object({
|
|
|
71286
71903
|
* Assistant export) must render as "no image right now", never as a
|
|
71287
71904
|
* broken link.
|
|
71288
71905
|
*/
|
|
71289
|
-
artifactIds: array(string().min(1)).optional()
|
|
71906
|
+
artifactIds: array(string().min(1)).optional(),
|
|
71907
|
+
/**
|
|
71908
|
+
* When this row was folded into a group-window summary, the outbox id of
|
|
71909
|
+
* that one notification. Absent on a row that was sent as itself.
|
|
71910
|
+
*/
|
|
71911
|
+
groupedInto: string().min(1).optional()
|
|
71290
71912
|
});
|
|
71291
71913
|
/**
|
|
71292
71914
|
* Query filter for `getHistory` (spec §4.2). Every field is a narrowing
|
|
@@ -77359,10 +77981,15 @@ getStatus: method(object({ deviceId: number$1() }), RecordingSignalStatusSchema)
|
|
|
77359
77981
|
*/
|
|
77360
77982
|
history: "none"
|
|
77361
77983
|
};
|
|
77362
|
-
var RemoteBindingSchema = object({ action:
|
|
77363
|
-
|
|
77364
|
-
|
|
77365
|
-
|
|
77984
|
+
var RemoteBindingSchema = object({ action: object({
|
|
77985
|
+
kind: literal("cap"),
|
|
77986
|
+
deviceId: number$1().int().nonnegative(),
|
|
77987
|
+
cap: string().min(1),
|
|
77988
|
+
method: string().min(1),
|
|
77989
|
+
args: record(string(), unknown()).optional(),
|
|
77990
|
+
/** The unit the person picked per arg (display only); `args` always hold the cap's own unit. */
|
|
77991
|
+
argUnits: record(string(), string().min(1)).optional()
|
|
77992
|
+
}) });
|
|
77366
77993
|
var RemoteCustomButtonSchema = object({
|
|
77367
77994
|
/** The slug after `custom:` in the role. */
|
|
77368
77995
|
key: string().refine(isRemoteCustomKey, { message: "a lowercase slug" }),
|
|
@@ -78352,7 +78979,7 @@ var sceneMonitorCapability = {
|
|
|
78352
78979
|
* instead of failing silently weeks later.
|
|
78353
78980
|
*
|
|
78354
78981
|
* Reachable from three surfaces on this one mutation: the scene card, a
|
|
78355
|
-
* notification button (an `onTrigger` sequence with a `kind:'
|
|
78982
|
+
* notification button (an `onTrigger` sequence with a `kind:'command'` step —
|
|
78356
78983
|
* no new Notification-Center code at all), and tRPC for scripts.
|
|
78357
78984
|
*/
|
|
78358
78985
|
resetScene: method(object({
|
|
@@ -85331,8 +85958,6 @@ var BaseDeviceProvider = class extends BaseAddon {
|
|
|
85331
85958
|
}
|
|
85332
85959
|
};
|
|
85333
85960
|
DeviceType.HeatPump;
|
|
85334
|
-
DeviceType.Climate;
|
|
85335
|
-
DeviceRole.ClimateThermostat, DeviceRole.ClimateAc, DeviceRole.ClimateRadiator, DeviceRole.ClimateFloor, DeviceRole.ClimateHeater, DeviceRole.ClimateHeatPumpCircuit;
|
|
85336
85961
|
DeviceType.Cover, DeviceType.Valve, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.HeatPump, DeviceType.Camera, DeviceType.Hub, DeviceType.Switch, DeviceType.Siren, DeviceType.Light, DeviceType.Fan, DeviceType.Sensor, DeviceType.Climate, DeviceType.Button, DeviceType.EventEmitter, DeviceType.Update, DeviceType.Generic, DeviceType.Notifier, DeviceType.Script, DeviceType.Automation, DeviceType.Lock, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Control, DeviceType.Presence, DeviceType.Weather, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder, DeviceType.PetFountain, DeviceType.Dishwasher, DeviceType.Washer, DeviceType.Dryer, DeviceType.Gateway;
|
|
85337
85962
|
new Set(Object.values(DeviceType));
|
|
85338
85963
|
/** Parses the raw slice with the cap's own schema; `undefined` when it does not parse. */
|
|
@@ -85345,6 +85970,13 @@ function contribution(cap, schema, build) {
|
|
|
85345
85970
|
}
|
|
85346
85971
|
};
|
|
85347
85972
|
}
|
|
85973
|
+
/** The fragment, carrying the cap's single measurement when it has one. */
|
|
85974
|
+
function measured(fragment, measurement) {
|
|
85975
|
+
return measurement === void 0 ? fragment : {
|
|
85976
|
+
...fragment,
|
|
85977
|
+
measurement
|
|
85978
|
+
};
|
|
85979
|
+
}
|
|
85348
85980
|
function action(id, label, icon, cap, method, args = {}, emphasis = "normal", confirm = null) {
|
|
85349
85981
|
return {
|
|
85350
85982
|
id,
|
|
@@ -85464,7 +86096,7 @@ var lockContribution = contribution("lock-control", LockControlStatusSchema, (sl
|
|
|
85464
86096
|
const state = slice?.state ?? null;
|
|
85465
86097
|
const words = state === null ? null : LOCK_WORDS[state];
|
|
85466
86098
|
const since = slice === void 0 ? null : elapsedText(slice.lastChangedAt, ctx.now);
|
|
85467
|
-
const title = words?.title ??
|
|
86099
|
+
const title = words?.title ?? NOT_REPORTED;
|
|
85468
86100
|
return {
|
|
85469
86101
|
reading: reading("lock-control", words?.state ?? "unknown", false, words?.title),
|
|
85470
86102
|
rows: [row$1("lock", state === "locked" || state === "locking" ? "lock" : "lock-open", joinText([title, since]), lockControls(state, ctx.features.includes(DeviceFeature.LockOpen)))],
|
|
@@ -85556,7 +86188,7 @@ var ACCESS_FAMILY_CONTRIBUTIONS = {
|
|
|
85556
86188
|
const modes = slice === void 0 ? ALARM_MODES : slice.availableModes;
|
|
85557
86189
|
return {
|
|
85558
86190
|
reading: reading("alarm-panel", words?.state ?? "unknown", false, words?.title),
|
|
85559
|
-
rows: [row$1("alarm", state === "triggered" ? "shield-alert" : state === "disarmed" ? "shield-off" : "shield-check", joinText([words?.title ??
|
|
86191
|
+
rows: [row$1("alarm", state === "triggered" ? "shield-alert" : state === "disarmed" ? "shield-off" : "shield-check", joinText([words?.title ?? NOT_REPORTED, since]), alarmControls(state, modes, slice?.requiresCode ?? false))],
|
|
85560
86192
|
...since === null || words === null ? {} : { facts: [fact("since", "clock", since, state === "triggered" ? "danger" : "muted")] },
|
|
85561
86193
|
...words === null ? {} : { tiles: {
|
|
85562
86194
|
left: [{
|
|
@@ -85587,7 +86219,7 @@ var ACCESS_FAMILY_CONTRIBUTIONS = {
|
|
|
85587
86219
|
return {
|
|
85588
86220
|
reading: reading("automation-control", state, false, title),
|
|
85589
86221
|
rows: [row$1("automation", "workflow", joinText([
|
|
85590
|
-
title ??
|
|
86222
|
+
title ?? NOT_REPORTED,
|
|
85591
86223
|
last === null ? null : t(`Ran ${last.en}`, `Eseguita ${last.it}`),
|
|
85592
86224
|
slice?.lastError == null ? null : t(slice.lastError, slice.lastError)
|
|
85593
86225
|
]), [asAction(run), toggle])],
|
|
@@ -85603,7 +86235,7 @@ var ACCESS_FAMILY_CONTRIBUTIONS = {
|
|
|
85603
86235
|
return {
|
|
85604
86236
|
reading: reading("script-runner", state, false, title),
|
|
85605
86237
|
rows: [row$1("script", "scroll-text", joinText([
|
|
85606
|
-
title ??
|
|
86238
|
+
title ?? NOT_REPORTED,
|
|
85607
86239
|
last === null ? null : t(`Ran ${last.en}`, `Eseguito ${last.it}`),
|
|
85608
86240
|
slice?.lastError == null ? null : t(slice.lastError, slice.lastError)
|
|
85609
86241
|
]), [asAction(control)])],
|
|
@@ -85612,7 +86244,7 @@ var ACCESS_FAMILY_CONTRIBUTIONS = {
|
|
|
85612
86244
|
}),
|
|
85613
86245
|
"do-not-disturb": contribution("do-not-disturb", DoNotDisturbStatusSchema, (slice) => {
|
|
85614
86246
|
const on = slice?.enabled ?? null;
|
|
85615
|
-
return { rows: [row$1("do-not-disturb", "bell-off", on === null ?
|
|
86247
|
+
return { rows: [row$1("do-not-disturb", "bell-off", on === null ? NOT_REPORTED : on ? t("Do not disturb on", "Non disturbare attivo") : t("Do not disturb off", "Non disturbare spento"), [{
|
|
85616
86248
|
kind: "toggle",
|
|
85617
86249
|
id: "do-not-disturb.toggle",
|
|
85618
86250
|
label: t("Do not disturb", "Non disturbare"),
|
|
@@ -85630,7 +86262,7 @@ var ACCESS_FAMILY_CONTRIBUTIONS = {
|
|
|
85630
86262
|
* is absent from the facts, never a zero (D393).
|
|
85631
86263
|
*/
|
|
85632
86264
|
var has$3 = (ctx, f) => ctx.features.includes(f);
|
|
85633
|
-
var unknownText =
|
|
86265
|
+
var unknownText = NOT_REPORTED;
|
|
85634
86266
|
var pct$2 = (n) => t(`${Math.round(n)}%`, `${Math.round(n)}%`);
|
|
85635
86267
|
var unit = (n) => Math.min(1, Math.max(0, n / 100));
|
|
85636
86268
|
/** Battery as a fact, unless the device is also bound to the `battery` cap (it already says so). */
|
|
@@ -86619,10 +87251,26 @@ var controlContribution = contribution("control", ControlStatusSchema, (slice, c
|
|
|
86619
87251
|
};
|
|
86620
87252
|
});
|
|
86621
87253
|
var CONTROL_LABEL = t("Value", "Valore");
|
|
86622
|
-
/**
|
|
87254
|
+
/**
|
|
87255
|
+
* A number with known bounds is a slider, one without a number field, a choice a picker,
|
|
87256
|
+
* free text a text field; a date stays read-only.
|
|
87257
|
+
*/
|
|
86623
87258
|
function controlRows(slice) {
|
|
86624
87259
|
if (slice.kind === "numeric" && typeof slice.value === "number") {
|
|
86625
|
-
if (slice.min === void 0 || slice.max === void 0) return [
|
|
87260
|
+
if (slice.min === void 0 || slice.max === void 0) return [row$1("control", "sliders-horizontal", null, [{
|
|
87261
|
+
kind: "number",
|
|
87262
|
+
id: "control.value",
|
|
87263
|
+
label: CONTROL_LABEL,
|
|
87264
|
+
value: slice.value,
|
|
87265
|
+
step: slice.step ?? null,
|
|
87266
|
+
unit: "",
|
|
87267
|
+
call: {
|
|
87268
|
+
cap: "control",
|
|
87269
|
+
method: "setValue",
|
|
87270
|
+
args: { control: { kind: "numeric" } }
|
|
87271
|
+
},
|
|
87272
|
+
valueArg: "control.value"
|
|
87273
|
+
}])];
|
|
86626
87274
|
return [row$1("control", "sliders-horizontal", null, [{
|
|
86627
87275
|
kind: "slider",
|
|
86628
87276
|
id: "control.value",
|
|
@@ -86653,6 +87301,18 @@ function controlRows(slice) {
|
|
|
86653
87301
|
},
|
|
86654
87302
|
valueArg: "control.value"
|
|
86655
87303
|
}])];
|
|
87304
|
+
if (slice.kind === "text") return [row$1("control", "sliders-horizontal", null, [{
|
|
87305
|
+
kind: "text",
|
|
87306
|
+
id: "control.value",
|
|
87307
|
+
label: CONTROL_LABEL,
|
|
87308
|
+
value: typeof slice.value === "string" ? slice.value : null,
|
|
87309
|
+
call: {
|
|
87310
|
+
cap: "control",
|
|
87311
|
+
method: "setValue",
|
|
87312
|
+
args: { control: { kind: "text" } }
|
|
87313
|
+
},
|
|
87314
|
+
valueArg: "control.value"
|
|
87315
|
+
}])];
|
|
86656
87316
|
return [];
|
|
86657
87317
|
}
|
|
86658
87318
|
var SENSORS_FAMILY_CONTRIBUTIONS = {
|
|
@@ -87008,15 +87668,15 @@ function sensorFragment(value, id, icon, en, it, text) {
|
|
|
87008
87668
|
tiles: { right: [tile$1(en, it, text)] }
|
|
87009
87669
|
};
|
|
87010
87670
|
}
|
|
87011
|
-
var temperatureContribution = contribution("temperature-sensor", TemperatureSensorStatusSchema, (slice) => sensorFragment(slice?.temperature ?? null, "temperature", "thermometer", "Temperature", "Temperatura", formatDegrees(slice?.temperature ?? 0)));
|
|
87012
|
-
var humidityContribution = contribution("humidity-sensor", HumiditySensorStatusSchema, (slice) => sensorFragment(slice?.humidity ?? null, "humidity", "droplets", "Humidity", "Umidità", `${Math.round(slice?.humidity ?? 0)}%`));
|
|
87671
|
+
var temperatureContribution = contribution("temperature-sensor", TemperatureSensorStatusSchema, (slice) => measured(sensorFragment(slice?.temperature ?? null, "temperature", "thermometer", "Temperature", "Temperatura", formatDegrees(slice?.temperature ?? 0)), slice?.temperature == null ? emptyMeasurement("temperature") : temperatureMeasurement(slice.temperature, slice.lastFetchedAt)));
|
|
87672
|
+
var humidityContribution = contribution("humidity-sensor", HumiditySensorStatusSchema, (slice) => measured(sensorFragment(slice?.humidity ?? null, "humidity", "droplets", "Humidity", "Umidità", `${Math.round(slice?.humidity ?? 0)}%`), slice?.humidity == null ? emptyMeasurement("humidity") : humidityMeasurement(slice.humidity, slice.lastFetchedAt)));
|
|
87013
87673
|
var pressureContribution = contribution("pressure-sensor", PressureSensorStatusSchema, (slice) => sensorFragment(slice?.pressure ?? null, "pressure", "gauge", "Pressure", "Pressione", `${Math.round(slice?.pressure ?? 0)} hPa`));
|
|
87014
87674
|
var illuminanceContribution = contribution("ambient-light-sensor", AmbientLightSensorStatusSchema, (slice) => sensorFragment(slice?.illuminance ?? null, "illuminance", "sun", "Light", "Luce", `${Math.round(slice?.illuminance ?? 0)} lx`));
|
|
87015
87675
|
var numericContribution = contribution("numeric-sensor", NumericSensorStatusSchema, (slice) => sensorFragment(slice?.value ?? null, "reading", "gauge", "Value", "Valore", String(Number((slice?.value ?? 0).toFixed(2)))));
|
|
87016
87676
|
var enumContribution = contribution("enum-sensor", EnumSensorStatusSchema, (slice) => {
|
|
87017
|
-
if (slice === void 0 || slice.value === "") return { reading: reading("sensor", "unknown") };
|
|
87677
|
+
if (slice === void 0 || slice.value === "") return measured({ reading: reading("sensor", "unknown") }, emptyMeasurement("text"));
|
|
87018
87678
|
if (slice.timestamp === true) return { reading: reading("sensor", "on") };
|
|
87019
|
-
return sensorFragment(slice.value, "reading", "gauge", "State", "Stato", slice.value);
|
|
87679
|
+
return measured(sensorFragment(slice.value, "reading", "gauge", "State", "Stato", slice.value), textMeasurement(slice.value, slice.lastFetchedAt));
|
|
87020
87680
|
});
|
|
87021
87681
|
/** Index bands: the headline of an air-quality sensor is a word, not a number. */
|
|
87022
87682
|
function airQualityWord(aqi) {
|
|
@@ -87138,7 +87798,7 @@ function circuitControl(circuit) {
|
|
|
87138
87798
|
return picker(`heat-pump.${circuit.id}.mode`, t("Mode", "Modalità"), circuit.operationMode, method, args);
|
|
87139
87799
|
}
|
|
87140
87800
|
/** A circuit with no reading is still a row: it shows that nothing is known, not nothing. */
|
|
87141
|
-
var UNKNOWN_STATUS =
|
|
87801
|
+
var UNKNOWN_STATUS = NOT_REPORTED;
|
|
87142
87802
|
function circuitRow(circuit) {
|
|
87143
87803
|
const control = circuitControl(circuit);
|
|
87144
87804
|
const status = thermalStatusText(circuit.targetTemp, circuit.currentTemp) ?? UNKNOWN_STATUS;
|
|
@@ -87362,9 +88022,8 @@ function look(icon, tone, background, animation) {
|
|
|
87362
88022
|
animation
|
|
87363
88023
|
};
|
|
87364
88024
|
}
|
|
87365
|
-
/**
|
|
88025
|
+
/** Unreachable: identical for every look. */
|
|
87366
88026
|
var OFFLINE = look("wifi-off", "muted", "plain", "none");
|
|
87367
|
-
var UNKNOWN = look("circle-question-mark", "muted", "plain", "none");
|
|
87368
88027
|
var ALERT = look("triangle-alert", "danger", "alert-wash", "pulse");
|
|
87369
88028
|
function lookOf(spec) {
|
|
87370
88029
|
const at = (s) => look(spec.icon, s[0], s[1], s[2]);
|
|
@@ -87376,7 +88035,7 @@ function lookOf(spec) {
|
|
|
87376
88035
|
standby: at(spec.standby),
|
|
87377
88036
|
alert: spec.alert ?? ALERT,
|
|
87378
88037
|
offline: OFFLINE,
|
|
87379
|
-
unknown:
|
|
88038
|
+
unknown: look(spec.icon, "muted", "plain", "none")
|
|
87380
88039
|
};
|
|
87381
88040
|
}
|
|
87382
88041
|
var MUTED = [
|
|
@@ -87985,7 +88644,7 @@ lookOf({
|
|
|
87985
88644
|
});
|
|
87986
88645
|
DeviceType.Climate;
|
|
87987
88646
|
DeviceType.Camera, DeviceType.Hub, DeviceType.Light, DeviceType.Siren, DeviceType.Switch, DeviceType.Sensor, DeviceType.Climate, DeviceType.Button, DeviceType.EventEmitter, DeviceType.Update, DeviceType.Generic, DeviceType.Notifier, DeviceType.Script, DeviceType.Automation, DeviceType.Lock, DeviceType.Cover, DeviceType.Valve, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.HeatPump, DeviceType.Fan, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Control, DeviceType.Presence, DeviceType.Weather, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder, DeviceType.PetFountain, DeviceType.Dishwasher, DeviceType.Washer, DeviceType.Dryer, DeviceType.Gateway;
|
|
87988
|
-
DeviceRole.Siren, DeviceRole.Floodlight, DeviceRole.Spotlight, DeviceRole.PirSensor, DeviceRole.Chime, DeviceRole.Autotrack, DeviceRole.Nightvision, DeviceRole.PrivacyMask, DeviceRole.Doorbell, DeviceRole.CoverBlind, DeviceRole.CoverShutter, DeviceRole.CoverAwning, DeviceRole.CoverCurtain, DeviceRole.CoverGarage, DeviceRole.CoverGate, DeviceRole.CoverDoor, DeviceRole.CoverWindow, DeviceRole.BinaryHelper, DeviceRole.Outlet, DeviceRole.SwitchHeater, DeviceRole.SwitchFan, DeviceRole.ClimateAc, DeviceRole.ClimateThermostat, DeviceRole.ClimateFloor, DeviceRole.ClimateRadiator, DeviceRole.ClimateHeater, DeviceRole.ClimateHeatPumpCircuit, DeviceRole.MotionSensor, DeviceRole.ContactSensor, DeviceRole.LeakSensor, DeviceRole.SmokeSensor, DeviceRole.COSensor, DeviceRole.GasSensor, DeviceRole.TamperSensor, DeviceRole.VibrationSensor, DeviceRole.ConnectivitySensor, DeviceRole.SoundSensor, DeviceRole.BinarySensor, DeviceRole.TemperatureSensor, DeviceRole.HumiditySensor, DeviceRole.AmbientLightSensor, DeviceRole.PressureSensor, DeviceRole.WindSensor, DeviceRole.RainSensor, DeviceRole.UvSensor, DeviceRole.SolarRadiationSensor, DeviceRole.SoilMoistureSensor, DeviceRole.PowerSensor, DeviceRole.EnergySensor, DeviceRole.VoltageSensor, DeviceRole.CurrentSensor, DeviceRole.AirQualitySensor, DeviceRole.BatterySensor, DeviceRole.NumericSensor, DeviceRole.EnumSensor, DeviceRole.DateTimeSensor, DeviceRole.GenericSensor, DeviceRole.NumericControl, DeviceRole.SelectControl, DeviceRole.TextControl, DeviceRole.DateTimeControl, DeviceRole.MobilePushNotifier, DeviceRole.MessagingNotifier, DeviceRole.EmailNotifier, DeviceRole.GenericNotifier, DeviceRole.IrTransmitter;
|
|
88647
|
+
DeviceRole.Siren, DeviceRole.Floodlight, DeviceRole.Spotlight, DeviceRole.PirSensor, DeviceRole.Chime, DeviceRole.Autotrack, DeviceRole.Nightvision, DeviceRole.PrivacyMask, DeviceRole.Doorbell, DeviceRole.CoverBlind, DeviceRole.CoverShutter, DeviceRole.CoverAwning, DeviceRole.CoverCurtain, DeviceRole.CoverGarage, DeviceRole.CoverGate, DeviceRole.CoverDoor, DeviceRole.CoverWindow, DeviceRole.BinaryHelper, DeviceRole.Outlet, DeviceRole.SwitchHeater, DeviceRole.SwitchFan, DeviceRole.SwitchLight, DeviceRole.ClimateAc, DeviceRole.ClimateThermostat, DeviceRole.ClimateFloor, DeviceRole.ClimateRadiator, DeviceRole.ClimateHeater, DeviceRole.ClimateHeatPumpCircuit, DeviceRole.MotionSensor, DeviceRole.ContactSensor, DeviceRole.LeakSensor, DeviceRole.SmokeSensor, DeviceRole.COSensor, DeviceRole.GasSensor, DeviceRole.TamperSensor, DeviceRole.VibrationSensor, DeviceRole.ConnectivitySensor, DeviceRole.SoundSensor, DeviceRole.BinarySensor, DeviceRole.TemperatureSensor, DeviceRole.HumiditySensor, DeviceRole.AmbientLightSensor, DeviceRole.PressureSensor, DeviceRole.WindSensor, DeviceRole.RainSensor, DeviceRole.UvSensor, DeviceRole.SolarRadiationSensor, DeviceRole.SoilMoistureSensor, DeviceRole.PowerSensor, DeviceRole.EnergySensor, DeviceRole.VoltageSensor, DeviceRole.CurrentSensor, DeviceRole.AirQualitySensor, DeviceRole.BatterySensor, DeviceRole.NumericSensor, DeviceRole.EnumSensor, DeviceRole.DateTimeSensor, DeviceRole.GenericSensor, DeviceRole.NumericControl, DeviceRole.SelectControl, DeviceRole.TextControl, DeviceRole.DateTimeControl, DeviceRole.MobilePushNotifier, DeviceRole.MessagingNotifier, DeviceRole.EmailNotifier, DeviceRole.GenericNotifier, DeviceRole.IrTransmitter;
|
|
87989
88648
|
Object.freeze({
|
|
87990
88649
|
"accessories.getStatus": {
|
|
87991
88650
|
capName: "accessories",
|
|
@@ -89912,6 +90571,13 @@ Object.freeze({
|
|
|
89912
90571
|
access: "view",
|
|
89913
90572
|
role: "admin"
|
|
89914
90573
|
},
|
|
90574
|
+
"deviceExport.setExposedName": {
|
|
90575
|
+
capName: "device-export",
|
|
90576
|
+
capScope: "system",
|
|
90577
|
+
addonId: null,
|
|
90578
|
+
access: "create",
|
|
90579
|
+
role: "admin"
|
|
90580
|
+
},
|
|
89915
90581
|
"deviceExport.unexposeDevice": {
|
|
89916
90582
|
capName: "device-export",
|
|
89917
90583
|
capScope: "system",
|
|
@@ -91851,6 +92517,13 @@ Object.freeze({
|
|
|
91851
92517
|
access: "view",
|
|
91852
92518
|
role: "viewer"
|
|
91853
92519
|
},
|
|
92520
|
+
"irTransmitter.learn": {
|
|
92521
|
+
capName: "ir-transmitter",
|
|
92522
|
+
capScope: "device",
|
|
92523
|
+
addonId: null,
|
|
92524
|
+
access: "create",
|
|
92525
|
+
role: "viewer"
|
|
92526
|
+
},
|
|
91854
92527
|
"irTransmitter.send": {
|
|
91855
92528
|
capName: "ir-transmitter",
|
|
91856
92529
|
capScope: "device",
|
|
@@ -98369,48 +99042,6 @@ Object.freeze({
|
|
|
98369
99042
|
role: "admin"
|
|
98370
99043
|
}
|
|
98371
99044
|
});
|
|
98372
|
-
/**
|
|
98373
|
-
* "Do" actions an operator can pick for a device — presentation-free.
|
|
98374
|
-
*
|
|
98375
|
-
* The wire shape stays `{ cap, method, args }`. Since D920 this module no
|
|
98376
|
-
* longer HOLDS a catalogue: {@link DEVICE_DO_ACTIONS} is a projection of the
|
|
98377
|
-
* cap vocabulary (`cap-vocabulary/`), the one cap-keyed map of every action
|
|
98378
|
-
* and trigger — so a picker built on this module and one built on
|
|
98379
|
-
* `actionsForDevice` (the vocabulary resolver) can never disagree about what
|
|
98380
|
-
* a device can do. Ids, baked args and the matching of saved steps are the
|
|
98381
|
-
* vocabulary's; labels here are its English labels.
|
|
98382
|
-
*
|
|
98383
|
-
* Shared by the admin NC Sequences / rule Do editor and Automations; the
|
|
98384
|
-
* viewer can reuse the same catalogue once its step editor catches up.
|
|
98385
|
-
*/
|
|
98386
|
-
function openArgKind(offer) {
|
|
98387
|
-
if (offer.kind === "number") return "number";
|
|
98388
|
-
if (offer.kind === "dynamic" && offer.valueKind === "number") return "number";
|
|
98389
|
-
if (offer.kind === "enum" && offer.values.every((v) => typeof v.value === "number")) return "number";
|
|
98390
|
-
return "string";
|
|
98391
|
-
}
|
|
98392
|
-
function projectOpenArg(arg) {
|
|
98393
|
-
return {
|
|
98394
|
-
key: arg.key,
|
|
98395
|
-
label: arg.label.en,
|
|
98396
|
-
kind: openArgKind(arg.offer),
|
|
98397
|
-
offer: arg.offer,
|
|
98398
|
-
...arg.optional === true ? { optional: true } : {}
|
|
98399
|
-
};
|
|
98400
|
-
}
|
|
98401
|
-
function projectAction(cap, action) {
|
|
98402
|
-
const open = action.openArgs ?? [];
|
|
98403
|
-
return {
|
|
98404
|
-
id: action.id,
|
|
98405
|
-
label: action.label.en,
|
|
98406
|
-
cap,
|
|
98407
|
-
method: action.method,
|
|
98408
|
-
args: action.args ?? {},
|
|
98409
|
-
...open.length > 0 ? { openArgs: open.map(projectOpenArg) } : {}
|
|
98410
|
-
};
|
|
98411
|
-
}
|
|
98412
|
-
Object.entries(CAP_VOCABULARY_BY_NAME).flatMap(([cap, entry]) => entry.scope === "device" ? (entry.actions ?? []).map((a) => projectAction(cap, a)) : []);
|
|
98413
|
-
DeviceType.Camera, DeviceType.Hub, DeviceType.Light, DeviceType.Siren, DeviceType.Switch, DeviceType.Sensor, DeviceType.Climate, DeviceType.Button, DeviceType.EventEmitter, DeviceType.Update, DeviceType.Generic, DeviceType.Notifier, DeviceType.Script, DeviceType.Automation, DeviceType.Lock, DeviceType.Cover, DeviceType.Valve, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.HeatPump, DeviceType.Fan, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Control, DeviceType.Presence, DeviceType.Weather, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder, DeviceType.PetFountain, DeviceType.Dishwasher, DeviceType.Washer, DeviceType.Dryer, DeviceType.Gateway;
|
|
98414
99045
|
DeviceFeature.BatteryOperated;
|
|
98415
99046
|
function bound(cap, methods = [], authority = "reported") {
|
|
98416
99047
|
return {
|
|
@@ -98469,6 +99100,10 @@ function offered(received) {
|
|
|
98469
99100
|
};
|
|
98470
99101
|
}
|
|
98471
99102
|
offered(HA_AS), withheld(HOMEKIT_REASON), withheld(ALEXA_REASON), withheld(GOOGLE_REASON), withheld(MATTER_REASON);
|
|
99103
|
+
DeviceType.Camera, DeviceType.Hub, DeviceType.Light, DeviceType.Siren, DeviceType.Switch, DeviceType.Sensor, DeviceType.Climate, DeviceType.HeatPump, DeviceType.Button, DeviceType.EventEmitter, DeviceType.Update, DeviceType.Generic, DeviceType.Notifier, DeviceType.Script, DeviceType.Automation, DeviceType.Lock, DeviceType.Cover, DeviceType.Valve, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.Fan, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Control, DeviceType.Presence, DeviceType.Weather, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder, DeviceType.PetFountain, DeviceType.Dishwasher, DeviceType.Washer, DeviceType.Dryer, DeviceType.Gateway;
|
|
99104
|
+
DeviceRole.Siren, DeviceRole.Floodlight, DeviceRole.Spotlight, DeviceRole.PirSensor, DeviceRole.Chime, DeviceRole.Autotrack, DeviceRole.Nightvision, DeviceRole.PrivacyMask, DeviceRole.Doorbell, DeviceRole.CoverBlind, DeviceRole.CoverShutter, DeviceRole.CoverAwning, DeviceRole.CoverCurtain, DeviceRole.CoverGarage, DeviceRole.CoverGate, DeviceRole.CoverDoor, DeviceRole.CoverWindow, DeviceRole.BinaryHelper, DeviceRole.Outlet, DeviceRole.SwitchHeater, DeviceRole.SwitchFan, DeviceRole.SwitchLight, DeviceRole.ClimateAc, DeviceRole.ClimateThermostat, DeviceRole.ClimateFloor, DeviceRole.ClimateRadiator, DeviceRole.ClimateHeater, DeviceRole.ClimateHeatPumpCircuit, DeviceRole.MotionSensor, DeviceRole.ContactSensor, DeviceRole.LeakSensor, DeviceRole.SmokeSensor, DeviceRole.COSensor, DeviceRole.GasSensor, DeviceRole.TamperSensor, DeviceRole.VibrationSensor, DeviceRole.ConnectivitySensor, DeviceRole.SoundSensor, DeviceRole.BinarySensor, DeviceRole.TemperatureSensor, DeviceRole.HumiditySensor, DeviceRole.AmbientLightSensor, DeviceRole.PressureSensor, DeviceRole.WindSensor, DeviceRole.RainSensor, DeviceRole.UvSensor, DeviceRole.SolarRadiationSensor, DeviceRole.SoilMoistureSensor, DeviceRole.PowerSensor, DeviceRole.EnergySensor, DeviceRole.VoltageSensor, DeviceRole.CurrentSensor, DeviceRole.AirQualitySensor, DeviceRole.BatterySensor, DeviceRole.NumericSensor, DeviceRole.EnumSensor, DeviceRole.DateTimeSensor, DeviceRole.GenericSensor, DeviceRole.NumericControl, DeviceRole.SelectControl, DeviceRole.TextControl, DeviceRole.DateTimeControl, DeviceRole.MobilePushNotifier, DeviceRole.MessagingNotifier, DeviceRole.EmailNotifier, DeviceRole.GenericNotifier, DeviceRole.IrTransmitter;
|
|
99105
|
+
new Set(Object.values(DeviceType));
|
|
99106
|
+
new Set(Object.values(DeviceRole));
|
|
98472
99107
|
var PowerSwitchRefusedError = class extends Error {
|
|
98473
99108
|
reason;
|
|
98474
99109
|
constructor(reason, message) {
|
|
@@ -99845,6 +100480,11 @@ Object.freeze({
|
|
|
99845
100480
|
form: "single",
|
|
99846
100481
|
optional: false
|
|
99847
100482
|
}],
|
|
100483
|
+
"irTransmitter.learn": [{
|
|
100484
|
+
name: "deviceId",
|
|
100485
|
+
form: "single",
|
|
100486
|
+
optional: false
|
|
100487
|
+
}],
|
|
99848
100488
|
"irTransmitter.send": [{
|
|
99849
100489
|
name: "deviceId",
|
|
99850
100490
|
form: "single",
|
|
@@ -101784,7 +102424,10 @@ var NC_SYSTEM_EVENT_FILTER_KEYS = [
|
|
|
101784
102424
|
"deviceTypes",
|
|
101785
102425
|
"nodeIds",
|
|
101786
102426
|
"packageNames",
|
|
101787
|
-
"consumableLowPercent"
|
|
102427
|
+
"consumableLowPercent",
|
|
102428
|
+
"commandActions",
|
|
102429
|
+
"commandOutcomes",
|
|
102430
|
+
"commandActorKinds"
|
|
101788
102431
|
];
|
|
101789
102432
|
new Map(Object.entries({
|
|
101790
102433
|
"device-online": "device-events",
|
|
@@ -101807,6 +102450,7 @@ new Map(Object.entries({
|
|
|
101807
102450
|
"recording-degraded": "device-events",
|
|
101808
102451
|
"device-attention-required": "device-events",
|
|
101809
102452
|
"device-attention-resolved": "device-events",
|
|
102453
|
+
"device-command": "device-events",
|
|
101810
102454
|
"node-online": "system",
|
|
101811
102455
|
"node-offline": "system",
|
|
101812
102456
|
"node-restarting": "system",
|
|
@@ -101907,6 +102551,12 @@ var NC_SYSTEM_EVENT_KIND_GROUP_SPECS = [
|
|
|
101907
102551
|
label: "Needs attention",
|
|
101908
102552
|
kinds: ["device-attention-required", "device-attention-resolved"]
|
|
101909
102553
|
},
|
|
102554
|
+
{
|
|
102555
|
+
id: "device-command",
|
|
102556
|
+
family: "device-events",
|
|
102557
|
+
label: "Commands given to devices",
|
|
102558
|
+
kinds: ["device-command"]
|
|
102559
|
+
},
|
|
101910
102560
|
{
|
|
101911
102561
|
id: "nodes",
|
|
101912
102562
|
family: "system",
|
|
@@ -101984,6 +102634,15 @@ function systemEventKindsOfFamily(family) {
|
|
|
101984
102634
|
return NC_SYSTEM_EVENT_KIND_GROUP_SPECS.filter((g) => g.family === family).flatMap((g) => g.kinds);
|
|
101985
102635
|
}
|
|
101986
102636
|
NC_AUDIO_DEFAULTS.hitPercent, NC_AUDIO_DEFAULTS.samplingSeconds;
|
|
102637
|
+
new Set([
|
|
102638
|
+
"alarm.trigger",
|
|
102639
|
+
"alarm.disarm",
|
|
102640
|
+
"alarm.arm.home",
|
|
102641
|
+
"alarm.arm.away",
|
|
102642
|
+
"alarm.arm.night",
|
|
102643
|
+
"alarm.arm.vacation",
|
|
102644
|
+
"alarm.arm.custom_bypass"
|
|
102645
|
+
]);
|
|
101987
102646
|
/**
|
|
101988
102647
|
* WHICH WAY A BOOLEAN SENSOR MOVED — read off the one slice a sensor event
|
|
101989
102648
|
* persists (D640 "a sensor rule fires on the raise, the clear, or both").
|
|
@@ -102179,6 +102838,7 @@ var DEVICE_EVENTS = [
|
|
|
102179
102838
|
"recording-healthy",
|
|
102180
102839
|
"recording-degraded",
|
|
102181
102840
|
...DEVICE_ATTENTION,
|
|
102841
|
+
"device-command",
|
|
102182
102842
|
...ALARM
|
|
102183
102843
|
];
|
|
102184
102844
|
/** Every kind a summary may speak about — the two summarisable families. */
|
|
@@ -102332,6 +102992,9 @@ var STATE_SUMMARY_VARS = [
|
|
|
102332
102992
|
[...RULE_BODY_ONLY],
|
|
102333
102993
|
[...RULE_TEXT],
|
|
102334
102994
|
([...RULE_TEXT], [...DEVICE_EVENTS]),
|
|
102995
|
+
[...RULE_TEXT],
|
|
102996
|
+
[...RULE_TEXT],
|
|
102997
|
+
([...RULE_TEXT], [...DEVICE_EVENTS]),
|
|
102335
102998
|
([...RULE_TEXT], [...COMBINED_ALARM]),
|
|
102336
102999
|
([...RULE_TEXT], [...COMBINED_ALARM]),
|
|
102337
103000
|
([...RULE_TEXT], [...DEVICE_EVENTS]),
|
|
@@ -103184,6 +103847,38 @@ function bestLocationMatch(externalName, existing, threshold = .8) {
|
|
|
103184
103847
|
return best;
|
|
103185
103848
|
}
|
|
103186
103849
|
/**
|
|
103850
|
+
* Names chosen when an integration or a Gateway device is created.
|
|
103851
|
+
* A stored name is never rewritten from these helpers.
|
|
103852
|
+
*/
|
|
103853
|
+
var HOME_SUFFIX = "Home";
|
|
103854
|
+
function collapse(value) {
|
|
103855
|
+
return value.trim().replace(/\s+/g, " ");
|
|
103856
|
+
}
|
|
103857
|
+
/** "KLF-200" → "KLF200". A hyphen between words ("Home Hub") stays. */
|
|
103858
|
+
function compactModelToken(value) {
|
|
103859
|
+
return value.replace(/([A-Za-z])-(\d)/g, "$1$2");
|
|
103860
|
+
}
|
|
103861
|
+
/** Prefill for a new integration: "<provider> - Home". The operator can edit it. */
|
|
103862
|
+
function defaultIntegrationName(providerLabel) {
|
|
103863
|
+
const label = collapse(providerLabel);
|
|
103864
|
+
if (label.length === 0) return HOME_SUFFIX;
|
|
103865
|
+
return `${label} - ${HOME_SUFFIX}`;
|
|
103866
|
+
}
|
|
103867
|
+
/**
|
|
103868
|
+
* A Gateway device: "<Brand> <Model>". An unknown model is the brand alone
|
|
103869
|
+
* (the caller passes the brand-level fallback it already has, e.g. "Velux KLF-200").
|
|
103870
|
+
*/
|
|
103871
|
+
function gatewayDeviceName(brand, model) {
|
|
103872
|
+
const brandPart = compactModelToken(collapse(brand));
|
|
103873
|
+
const raw = collapse(model ?? "");
|
|
103874
|
+
if (raw.length === 0) return brandPart;
|
|
103875
|
+
const modelPart = compactModelToken(raw);
|
|
103876
|
+
const prefix = `${brandPart.toLowerCase()} `;
|
|
103877
|
+
if (modelPart.toLowerCase() === brandPart.toLowerCase()) return brandPart;
|
|
103878
|
+
if (modelPart.toLowerCase().startsWith(prefix)) return modelPart;
|
|
103879
|
+
return `${brandPart} ${modelPart}`;
|
|
103880
|
+
}
|
|
103881
|
+
/**
|
|
103187
103882
|
* Closes the gap D49 leaves: an integration deleted while its provider was down never emits an
|
|
103188
103883
|
* event the provider sees. An integration id absent from an ANSWERED list is only a suspect; its
|
|
103189
103884
|
* devices go (through the provider's own removeDevices) when a SECOND answered read, at least
|
|
@@ -103368,6 +104063,284 @@ var HomematicReconciler = class {
|
|
|
103368
104063
|
}
|
|
103369
104064
|
};
|
|
103370
104065
|
//#endregion
|
|
104066
|
+
//#region src/homematic-mapping.ts
|
|
104067
|
+
/**
|
|
104068
|
+
* Map a single Homematic channel to its CamStack triplet. The channel
|
|
104069
|
+
* `TYPE` is the discriminator. Only the controllable / primary channel
|
|
104070
|
+
* types map; status-only `*_TRANSMITTER` mirrors and the various key /
|
|
104071
|
+
* remote / week-profile channels return `null` (their datapoints are
|
|
104072
|
+
* still decoded into the owning cap's slice via the device's
|
|
104073
|
+
* `valueChanged` handler, keyed by parameter name).
|
|
104074
|
+
*/
|
|
104075
|
+
function mapHmChannel(channelType) {
|
|
104076
|
+
if (!channelType) return null;
|
|
104077
|
+
switch (channelType.toUpperCase()) {
|
|
104078
|
+
case "SWITCH_VIRTUAL_RECEIVER": return {
|
|
104079
|
+
deviceType: DeviceType.Switch,
|
|
104080
|
+
role: null,
|
|
104081
|
+
capabilities: ["switch"]
|
|
104082
|
+
};
|
|
104083
|
+
case "SHUTTER_VIRTUAL_RECEIVER": return {
|
|
104084
|
+
deviceType: DeviceType.Cover,
|
|
104085
|
+
role: null,
|
|
104086
|
+
capabilities: ["cover"]
|
|
104087
|
+
};
|
|
104088
|
+
case "HEATING_CLIMATECONTROL_TRANSCEIVER": return {
|
|
104089
|
+
deviceType: DeviceType.Climate,
|
|
104090
|
+
role: null,
|
|
104091
|
+
capabilities: [
|
|
104092
|
+
"climate-control",
|
|
104093
|
+
"temperature-sensor",
|
|
104094
|
+
"humidity-sensor"
|
|
104095
|
+
]
|
|
104096
|
+
};
|
|
104097
|
+
case "MOTIONDETECTOR_TRANSCEIVER": return {
|
|
104098
|
+
deviceType: DeviceType.Sensor,
|
|
104099
|
+
role: DeviceRole.MotionSensor,
|
|
104100
|
+
capabilities: ["motion", "ambient-light-sensor"]
|
|
104101
|
+
};
|
|
104102
|
+
case "DOOR_LOCK_STATE_TRANSMITTER": return {
|
|
104103
|
+
deviceType: DeviceType.Lock,
|
|
104104
|
+
role: null,
|
|
104105
|
+
capabilities: ["lock-control"]
|
|
104106
|
+
};
|
|
104107
|
+
case "ENERGIE_METER_TRANSMITTER": return {
|
|
104108
|
+
deviceType: DeviceType.Sensor,
|
|
104109
|
+
role: DeviceRole.PowerSensor,
|
|
104110
|
+
capabilities: ["power-meter"]
|
|
104111
|
+
};
|
|
104112
|
+
case "KEY_TRANSCEIVER":
|
|
104113
|
+
case "KEY_TRANSMITTER":
|
|
104114
|
+
case "VIRTUAL_KEY":
|
|
104115
|
+
case "KEY": return {
|
|
104116
|
+
deviceType: DeviceType.EventEmitter,
|
|
104117
|
+
role: null,
|
|
104118
|
+
capabilities: ["event-emitter"]
|
|
104119
|
+
};
|
|
104120
|
+
default: return null;
|
|
104121
|
+
}
|
|
104122
|
+
}
|
|
104123
|
+
/**
|
|
104124
|
+
* Best-effort parent DeviceType for a whole Homematic device, derived
|
|
104125
|
+
* from the union of its channel mappings. Actuators win over sensors so
|
|
104126
|
+
* a switch + energy-meter device (HmIP-BSM) reports as a Switch, not a
|
|
104127
|
+
* Sensor, and a thermostat with a humidity sensor reports as a
|
|
104128
|
+
* Climate device (D1033). A remote/wall-switch is primarily an EventEmitter: it is
|
|
104129
|
+
* ranked above Sensor so its battery / maintenance sensor channels don't
|
|
104130
|
+
* win the parent type. Returns `DeviceType.Generic` when no channel maps.
|
|
104131
|
+
*/
|
|
104132
|
+
var PARENT_TYPE_PRIORITY = [
|
|
104133
|
+
DeviceType.Climate,
|
|
104134
|
+
DeviceType.Lock,
|
|
104135
|
+
DeviceType.Cover,
|
|
104136
|
+
DeviceType.Light,
|
|
104137
|
+
DeviceType.Switch,
|
|
104138
|
+
DeviceType.EventEmitter,
|
|
104139
|
+
DeviceType.Sensor
|
|
104140
|
+
];
|
|
104141
|
+
function inferHmDeviceType(device) {
|
|
104142
|
+
const present = /* @__PURE__ */ new Set();
|
|
104143
|
+
for (const channel of device.channels) {
|
|
104144
|
+
const mapping = mapHmChannel(channel.type);
|
|
104145
|
+
if (mapping) present.add(mapping.deviceType);
|
|
104146
|
+
}
|
|
104147
|
+
for (const dt of PARENT_TYPE_PRIORITY) if (present.has(dt)) return dt;
|
|
104148
|
+
return DeviceType.Generic;
|
|
104149
|
+
}
|
|
104150
|
+
function mapHmDeviceChannels(device) {
|
|
104151
|
+
const out = [];
|
|
104152
|
+
for (const channel of device.channels) {
|
|
104153
|
+
const mapping = mapHmChannel(channel.type);
|
|
104154
|
+
if (mapping) out.push({
|
|
104155
|
+
channel,
|
|
104156
|
+
mapping
|
|
104157
|
+
});
|
|
104158
|
+
}
|
|
104159
|
+
return out;
|
|
104160
|
+
}
|
|
104161
|
+
//#endregion
|
|
104162
|
+
//#region src/devices/hm-cold-start.ts
|
|
104163
|
+
/**
|
|
104164
|
+
* Shared cold-start defaults + the key-channel press vocabulary helpers,
|
|
104165
|
+
* extracted from the (legacy) flat `homematic-device.ts` so the Container +
|
|
104166
|
+
* accessory-child classes reuse the SAME seeds and decoders without
|
|
104167
|
+
* duplicating them. Pure: no `BaseDevice` / facade dependency.
|
|
104168
|
+
*/
|
|
104169
|
+
/**
|
|
104170
|
+
* Cold-start defaults so reads never miss a slice before the first push.
|
|
104171
|
+
* `lastChangedAt: 0` marks each as a PLACEHOLDER — the value is a guess, and
|
|
104172
|
+
* consumers read it as unknown. A replayed CCU value is stamped
|
|
104173
|
+
* `HM_SEEDED_CHANGED_AT` instead (`hm-change-stamp.ts`).
|
|
104174
|
+
*/
|
|
104175
|
+
var COLD_SWITCH = {
|
|
104176
|
+
on: false,
|
|
104177
|
+
lastChangedAt: 0
|
|
104178
|
+
};
|
|
104179
|
+
var COLD_COVER = {
|
|
104180
|
+
state: "closed",
|
|
104181
|
+
position: null,
|
|
104182
|
+
tiltPosition: null,
|
|
104183
|
+
lastChangedAt: 0
|
|
104184
|
+
};
|
|
104185
|
+
var COLD_LOCK = {
|
|
104186
|
+
state: "unlocked",
|
|
104187
|
+
lastChangedAt: 0
|
|
104188
|
+
};
|
|
104189
|
+
var COLD_MOTION = {
|
|
104190
|
+
detected: false,
|
|
104191
|
+
lastDetectedAt: null,
|
|
104192
|
+
autoClearAfterMs: null
|
|
104193
|
+
};
|
|
104194
|
+
/**
|
|
104195
|
+
* The motion seed a constructor writes OVER the slice hydrated from the
|
|
104196
|
+
* persisted runtime state. The level is a placeholder (`false`) until the
|
|
104197
|
+
* CCU says otherwise, but a stored rise is a fact: `lastDetectedAt: null`
|
|
104198
|
+
* means "never detected" (`motion.cap.ts`), and a restart must not turn
|
|
104199
|
+
* "fired an hour ago" into that.
|
|
104200
|
+
*/
|
|
104201
|
+
function coldMotionKeepingRise(stored) {
|
|
104202
|
+
const rise = stored?.lastDetectedAt;
|
|
104203
|
+
return {
|
|
104204
|
+
...COLD_MOTION,
|
|
104205
|
+
lastDetectedAt: typeof rise === "number" && Number.isFinite(rise) && rise > 0 ? rise : null
|
|
104206
|
+
};
|
|
104207
|
+
}
|
|
104208
|
+
var COLD_CLIMATE = {
|
|
104209
|
+
mode: "auto",
|
|
104210
|
+
availableModes: [...[
|
|
104211
|
+
"off",
|
|
104212
|
+
"heat",
|
|
104213
|
+
"auto"
|
|
104214
|
+
]],
|
|
104215
|
+
fanMode: "",
|
|
104216
|
+
availableFanModes: [],
|
|
104217
|
+
preset: "",
|
|
104218
|
+
availablePresets: ["boost"],
|
|
104219
|
+
target: null,
|
|
104220
|
+
targetHigh: null,
|
|
104221
|
+
targetLow: null,
|
|
104222
|
+
targetHumidity: null,
|
|
104223
|
+
currentTemp: null,
|
|
104224
|
+
currentHumidity: null,
|
|
104225
|
+
swingVertical: null,
|
|
104226
|
+
swingHorizontal: null,
|
|
104227
|
+
lastFetchedAt: 0
|
|
104228
|
+
};
|
|
104229
|
+
/**
|
|
104230
|
+
* The standard HmIP key-channel datapoint vocabulary, used VERBATIM (NO
|
|
104231
|
+
* normalization) as the `event-emitter` event types — the native uppercase
|
|
104232
|
+
* tokens a `KEY_TRANSCEIVER` / `KEY_TRANSMITTER` / `VIRTUAL_KEY` / `KEY`
|
|
104233
|
+
* channel emits on the facade `valueChanged` stream.
|
|
104234
|
+
*/
|
|
104235
|
+
var HM_KEY_PRESS_DATAPOINTS = [
|
|
104236
|
+
"PRESS_SHORT",
|
|
104237
|
+
"PRESS_LONG",
|
|
104238
|
+
"PRESS_LONG_START",
|
|
104239
|
+
"PRESS_LONG_RELEASE",
|
|
104240
|
+
"PRESS_CONT"
|
|
104241
|
+
];
|
|
104242
|
+
/** Set form for O(1) fire-detection membership tests. */
|
|
104243
|
+
var HM_KEY_PRESS_SET = new Set(HM_KEY_PRESS_DATAPOINTS);
|
|
104244
|
+
/** Cold-start event-emitter slice; vocabulary supplied per-device. */
|
|
104245
|
+
function coldEventEmitter(vocabulary) {
|
|
104246
|
+
return {
|
|
104247
|
+
eventTypes: eventTypesOfVocabulary(vocabulary),
|
|
104248
|
+
vocabulary: [...vocabulary],
|
|
104249
|
+
lastEvent: null,
|
|
104250
|
+
eventCountSinceStart: 0
|
|
104251
|
+
};
|
|
104252
|
+
}
|
|
104253
|
+
/**
|
|
104254
|
+
* Collect the union of native `PRESS_*` datapoints a device's key channels
|
|
104255
|
+
* support, VERBATIM. Falls back to the standard HmIP key vocabulary when no
|
|
104256
|
+
* datapoints were enumerated, so the cap always advertises a non-empty set.
|
|
104257
|
+
*/
|
|
104258
|
+
function keyEventVocabulary(keyChannels) {
|
|
104259
|
+
const found = /* @__PURE__ */ new Set();
|
|
104260
|
+
for (const channel of keyChannels) for (const dp of channel.dataPoints ?? []) if (HM_KEY_PRESS_SET.has(dp.parameter)) found.add(dp.parameter);
|
|
104261
|
+
if (found.size === 0) return HM_KEY_PRESS_DATAPOINTS;
|
|
104262
|
+
return HM_KEY_PRESS_DATAPOINTS.filter((dp) => found.has(dp));
|
|
104263
|
+
}
|
|
104264
|
+
/**
|
|
104265
|
+
* The CamStack cap names that are ACTUATORS — driven by the library's typed
|
|
104266
|
+
* custom entities (correct channel), NOT by the raw mapped channels. The
|
|
104267
|
+
* raw-channel sensor/event loop skips these so they are not double-registered.
|
|
104268
|
+
*/
|
|
104269
|
+
var ACTUATOR_CAP_NAMES = new Set([
|
|
104270
|
+
"switch",
|
|
104271
|
+
"cover",
|
|
104272
|
+
"light",
|
|
104273
|
+
"lock-control",
|
|
104274
|
+
"climate-control"
|
|
104275
|
+
]);
|
|
104276
|
+
/** Parse the numeric channel index suffix (`:N`) from a channel address.
|
|
104277
|
+
* Null when absent. Kept as a string for the event payload, mirroring the
|
|
104278
|
+
* CCU's `device:index` addressing. */
|
|
104279
|
+
function channelIndexFromAddress(channelAddress) {
|
|
104280
|
+
const idx = channelAddress.lastIndexOf(":");
|
|
104281
|
+
if (idx === -1) return null;
|
|
104282
|
+
const suffix = channelAddress.slice(idx + 1);
|
|
104283
|
+
return suffix.length > 0 ? suffix : null;
|
|
104284
|
+
}
|
|
104285
|
+
//#endregion
|
|
104286
|
+
//#region src/devices/hm-key-vocabulary.ts
|
|
104287
|
+
var PRESS_MEANING = {
|
|
104288
|
+
PRESS_SHORT: {
|
|
104289
|
+
label: "Short press",
|
|
104290
|
+
kind: "press"
|
|
104291
|
+
},
|
|
104292
|
+
PRESS_LONG: {
|
|
104293
|
+
label: "Long press",
|
|
104294
|
+
kind: "long-press"
|
|
104295
|
+
},
|
|
104296
|
+
PRESS_LONG_START: {
|
|
104297
|
+
label: "Long press started",
|
|
104298
|
+
kind: "long-press-start"
|
|
104299
|
+
},
|
|
104300
|
+
PRESS_LONG_RELEASE: {
|
|
104301
|
+
label: "Long press released",
|
|
104302
|
+
kind: "release"
|
|
104303
|
+
},
|
|
104304
|
+
PRESS_CONT: {
|
|
104305
|
+
label: "Long press held",
|
|
104306
|
+
kind: "repeat"
|
|
104307
|
+
}
|
|
104308
|
+
};
|
|
104309
|
+
/** The channels of a device that are buttons, in channel order. */
|
|
104310
|
+
function hmKeyChannels(device) {
|
|
104311
|
+
return mapHmDeviceChannels(device).filter(({ mapping }) => mapping.capabilities.includes("event-emitter")).map(({ channel }) => channel);
|
|
104312
|
+
}
|
|
104313
|
+
/** The presses one key channel has; the standard set when it lists none. */
|
|
104314
|
+
function pressesOf(channel) {
|
|
104315
|
+
const listed = new Set((channel.dataPoints ?? []).map((dataPoint) => dataPoint.parameter).filter((parameter) => HM_KEY_PRESS_SET.has(parameter)));
|
|
104316
|
+
if (listed.size === 0) return HM_KEY_PRESS_DATAPOINTS;
|
|
104317
|
+
return HM_KEY_PRESS_DATAPOINTS.filter((parameter) => listed.has(parameter));
|
|
104318
|
+
}
|
|
104319
|
+
function entryOf(parameter, source) {
|
|
104320
|
+
const meaning = PRESS_MEANING[parameter];
|
|
104321
|
+
if (meaning === void 0) return {
|
|
104322
|
+
id: parameter,
|
|
104323
|
+
source,
|
|
104324
|
+
label: parameter
|
|
104325
|
+
};
|
|
104326
|
+
return {
|
|
104327
|
+
id: parameter,
|
|
104328
|
+
source,
|
|
104329
|
+
label: meaning.label,
|
|
104330
|
+
kind: meaning.kind
|
|
104331
|
+
};
|
|
104332
|
+
}
|
|
104333
|
+
function hmKeyVocabulary(device) {
|
|
104334
|
+
return hmKeyChannels(device).flatMap((channel, position) => {
|
|
104335
|
+
const index = channelIndexFromAddress(channel.address) ?? String(channel.index);
|
|
104336
|
+
const source = {
|
|
104337
|
+
id: index,
|
|
104338
|
+
label: `Button ${position + 1} (channel ${index})`
|
|
104339
|
+
};
|
|
104340
|
+
return pressesOf(channel).map((parameter) => entryOf(parameter, source));
|
|
104341
|
+
});
|
|
104342
|
+
}
|
|
104343
|
+
//#endregion
|
|
103371
104344
|
//#region src/ccu/ccu-facade.ts
|
|
103372
104345
|
function errorText(err) {
|
|
103373
104346
|
return err instanceof Error ? err.message : String(err);
|
|
@@ -103383,6 +104356,144 @@ function requireConfirmed(confirmed) {
|
|
|
103383
104356
|
if (confirmed !== true) throw new Error("A CCU write needs the operator confirmation (confirmed: true)");
|
|
103384
104357
|
}
|
|
103385
104358
|
//#endregion
|
|
104359
|
+
//#region src/ccu/hm-channel-links.ts
|
|
104360
|
+
/**
|
|
104361
|
+
* The slice of nodehomematic the button-event actions need. Specs hand in a
|
|
104362
|
+
* fake. The installed 0.5.1 build has none of these methods: the adapter
|
|
104363
|
+
* feature-checks and answers `unsupported` instead of calling them.
|
|
104364
|
+
*
|
|
104365
|
+
* What 0.6 must provide, on the facade object:
|
|
104366
|
+
* - `getChannelLinkState(address) → { central: boolean; links: { sender, receiver, name }[] }`
|
|
104367
|
+
* - `createCentralLink(address)` idempotent
|
|
104368
|
+
* - `removeCentralLink(address)` idempotent, throwing a typed error on failure
|
|
104369
|
+
* - `name: string | null` on devices and channels (read separately, not here)
|
|
104370
|
+
*/
|
|
104371
|
+
var ChannelLinkSchema = object({
|
|
104372
|
+
sender: string(),
|
|
104373
|
+
receiver: string(),
|
|
104374
|
+
name: string()
|
|
104375
|
+
});
|
|
104376
|
+
var ChannelLinkStateSchema = object({
|
|
104377
|
+
central: boolean(),
|
|
104378
|
+
links: array(ChannelLinkSchema)
|
|
104379
|
+
});
|
|
104380
|
+
var GET_CHANNEL_LINK_STATE = "getChannelLinkState";
|
|
104381
|
+
var CREATE_CENTRAL_LINK = "createCentralLink";
|
|
104382
|
+
var REMOVE_CENTRAL_LINK = "removeCentralLink";
|
|
104383
|
+
/** A method the installed library actually has, bound to its facade. */
|
|
104384
|
+
function lookup$1(target, name) {
|
|
104385
|
+
const value = Reflect.get(target, name);
|
|
104386
|
+
if (typeof value !== "function") return null;
|
|
104387
|
+
const fn = (...args) => Reflect.apply(value, target, [...args]);
|
|
104388
|
+
return fn;
|
|
104389
|
+
}
|
|
104390
|
+
function errorMessage$1(err) {
|
|
104391
|
+
return err instanceof Error ? err.message : String(err);
|
|
104392
|
+
}
|
|
104393
|
+
async function write(target, name, address) {
|
|
104394
|
+
const fn = lookup$1(target, name);
|
|
104395
|
+
if (fn === null) return { kind: "unsupported" };
|
|
104396
|
+
try {
|
|
104397
|
+
await fn(address);
|
|
104398
|
+
return { kind: "ok" };
|
|
104399
|
+
} catch (err) {
|
|
104400
|
+
return {
|
|
104401
|
+
kind: "error",
|
|
104402
|
+
message: errorMessage$1(err)
|
|
104403
|
+
};
|
|
104404
|
+
}
|
|
104405
|
+
}
|
|
104406
|
+
/** Adapt a live facade. Missing methods are `unsupported`, never a cast. */
|
|
104407
|
+
function channelLinkPort(target) {
|
|
104408
|
+
return {
|
|
104409
|
+
async getChannelLinkState(address) {
|
|
104410
|
+
const fn = lookup$1(target, GET_CHANNEL_LINK_STATE);
|
|
104411
|
+
if (fn === null) return { kind: "unsupported" };
|
|
104412
|
+
try {
|
|
104413
|
+
const parsed = ChannelLinkStateSchema.safeParse(await fn(address));
|
|
104414
|
+
if (!parsed.success) return {
|
|
104415
|
+
kind: "error",
|
|
104416
|
+
message: "Channel link state did not match the expected shape"
|
|
104417
|
+
};
|
|
104418
|
+
return {
|
|
104419
|
+
kind: "ok",
|
|
104420
|
+
state: parsed.data
|
|
104421
|
+
};
|
|
104422
|
+
} catch (err) {
|
|
104423
|
+
return {
|
|
104424
|
+
kind: "error",
|
|
104425
|
+
message: errorMessage$1(err)
|
|
104426
|
+
};
|
|
104427
|
+
}
|
|
104428
|
+
},
|
|
104429
|
+
createCentralLink: (address) => write(target, CREATE_CENTRAL_LINK, address),
|
|
104430
|
+
removeCentralLink: (address) => write(target, REMOVE_CENTRAL_LINK, address)
|
|
104431
|
+
};
|
|
104432
|
+
}
|
|
104433
|
+
/**
|
|
104434
|
+
* A CCU name on a device or channel (`name: string | null` in nodehomematic
|
|
104435
|
+
* 0.6). 0.5.1 omits the field: that is "no name", not a failure.
|
|
104436
|
+
*/
|
|
104437
|
+
function readHmName(value) {
|
|
104438
|
+
if (!("name" in value)) return null;
|
|
104439
|
+
const raw = Reflect.get(value, "name");
|
|
104440
|
+
if (typeof raw !== "string") return null;
|
|
104441
|
+
const trimmed = raw.trim();
|
|
104442
|
+
return trimmed.length > 0 ? trimmed : null;
|
|
104443
|
+
}
|
|
104444
|
+
//#endregion
|
|
104445
|
+
//#region src/ccu/ccu-button-events.ts
|
|
104446
|
+
var UNSUPPORTED = "This CCU library cannot read or change central links yet";
|
|
104447
|
+
function centralOf(read) {
|
|
104448
|
+
if (read.kind === "unsupported") return "unsupported";
|
|
104449
|
+
if (read.kind === "error") return "unknown";
|
|
104450
|
+
return read.state.central ? "on" : "off";
|
|
104451
|
+
}
|
|
104452
|
+
async function keyChannelRow(port, channel) {
|
|
104453
|
+
const read = await port.getChannelLinkState(channel.address);
|
|
104454
|
+
return {
|
|
104455
|
+
address: channel.address,
|
|
104456
|
+
index: channelIndexFromAddress(channel.address) ?? String(channel.index),
|
|
104457
|
+
name: readHmName(channel),
|
|
104458
|
+
central: centralOf(read)
|
|
104459
|
+
};
|
|
104460
|
+
}
|
|
104461
|
+
/** Key-channel central-link rows for adopted devices. Direct links are not touched. */
|
|
104462
|
+
async function keyChannelsForDevice(deps, integrationId, device, adopted) {
|
|
104463
|
+
if (!adopted.has(device.address)) return [];
|
|
104464
|
+
const keys = hmKeyChannels(device);
|
|
104465
|
+
if (keys.length === 0) return [];
|
|
104466
|
+
const port = deps.channelLinks(integrationId);
|
|
104467
|
+
if (port === null) return [];
|
|
104468
|
+
return Promise.all(keys.map((channel) => keyChannelRow(port, channel)));
|
|
104469
|
+
}
|
|
104470
|
+
function withKeyChannels(row, keyChannels) {
|
|
104471
|
+
return {
|
|
104472
|
+
...row,
|
|
104473
|
+
keyChannels: [...keyChannels]
|
|
104474
|
+
};
|
|
104475
|
+
}
|
|
104476
|
+
/** Enable or disable the central link of one key channel. Other links stay. */
|
|
104477
|
+
function buildButtonEventHandlers(deps) {
|
|
104478
|
+
return { setButtonEvents: async (input) => {
|
|
104479
|
+
requireConfirmed(input.confirmed);
|
|
104480
|
+
requireFacade(deps, input.integrationId);
|
|
104481
|
+
const port = deps.channelLinks(input.integrationId);
|
|
104482
|
+
if (port === null) throw new Error(UNSUPPORTED);
|
|
104483
|
+
const result = input.enabled ? await port.createCentralLink(input.address) : await port.removeCentralLink(input.address);
|
|
104484
|
+
if (result.kind === "unsupported") throw new Error(UNSUPPORTED);
|
|
104485
|
+
if (result.kind === "error") {
|
|
104486
|
+
deps.logger.warn("Homematic central link change failed", { meta: {
|
|
104487
|
+
integrationId: input.integrationId,
|
|
104488
|
+
address: input.address,
|
|
104489
|
+
error: result.message
|
|
104490
|
+
} });
|
|
104491
|
+
throw new Error(result.message);
|
|
104492
|
+
}
|
|
104493
|
+
return { ok: true };
|
|
104494
|
+
} };
|
|
104495
|
+
}
|
|
104496
|
+
//#endregion
|
|
103386
104497
|
//#region src/ccu/ccu-device-rows.ts
|
|
103387
104498
|
/** `RSSI_*` reports this when the device has no signal reading. */
|
|
103388
104499
|
var RSSI_UNKNOWN = 65535;
|
|
@@ -103429,7 +104540,8 @@ function toCcuDeviceRow(device) {
|
|
|
103429
104540
|
lowBattery: asBool$1(readParam(maintenance, ["LOW_BAT", "LOWBAT"])),
|
|
103430
104541
|
unreach: asBool$1(readParam(maintenance, ["UNREACH", "STICKY_UNREACH"])),
|
|
103431
104542
|
configPending: asBool$1(readParam(maintenance, ["CONFIG_PENDING"])),
|
|
103432
|
-
sabotage: asBool$1(readParam(maintenance, ["SABOTAGE", "ERROR_SABOTAGE"]))
|
|
104543
|
+
sabotage: asBool$1(readParam(maintenance, ["SABOTAGE", "ERROR_SABOTAGE"])),
|
|
104544
|
+
keyChannels: []
|
|
103433
104545
|
};
|
|
103434
104546
|
}
|
|
103435
104547
|
//#endregion
|
|
@@ -103437,7 +104549,12 @@ function toCcuDeviceRow(device) {
|
|
|
103437
104549
|
/** The CCU device list: every device the CCU knows, with its radio and maintenance health. */
|
|
103438
104550
|
function buildCcuDevicesHandlers(deps) {
|
|
103439
104551
|
return { listCcuDevices: async (input) => {
|
|
103440
|
-
|
|
104552
|
+
const facade = requireFacade(deps, input.integrationId);
|
|
104553
|
+
const adopted = await deps.adoptedAddresses(input.integrationId);
|
|
104554
|
+
return { devices: await Promise.all(facade.devices().map(async (device) => {
|
|
104555
|
+
const links = await keyChannelsForDevice(deps, input.integrationId, device, adopted);
|
|
104556
|
+
return withKeyChannels(toCcuDeviceRow(device), links);
|
|
104557
|
+
})) };
|
|
103441
104558
|
} };
|
|
103442
104559
|
}
|
|
103443
104560
|
//#endregion
|
|
@@ -103582,6 +104699,24 @@ var AcknowledgeInputSchema = IntegrationRefSchema.extend({
|
|
|
103582
104699
|
confirmed: ConfirmedSchema
|
|
103583
104700
|
});
|
|
103584
104701
|
var OkResultSchema = object({ ok: literal(true) });
|
|
104702
|
+
var SetButtonEventsInputSchema = IntegrationRefSchema.extend({
|
|
104703
|
+
/** Key-channel address, e.g. `00315F298E5093:1`. */
|
|
104704
|
+
address: string().min(1),
|
|
104705
|
+
enabled: boolean(),
|
|
104706
|
+
confirmed: ConfirmedSchema
|
|
104707
|
+
});
|
|
104708
|
+
/** One key channel's central-link state. `unknown` is a read that failed. */
|
|
104709
|
+
var KeyChannelLinkSchema = object({
|
|
104710
|
+
address: string(),
|
|
104711
|
+
index: string(),
|
|
104712
|
+
name: string().nullable(),
|
|
104713
|
+
central: _enum([
|
|
104714
|
+
"on",
|
|
104715
|
+
"off",
|
|
104716
|
+
"unsupported",
|
|
104717
|
+
"unknown"
|
|
104718
|
+
])
|
|
104719
|
+
});
|
|
103585
104720
|
var CcuDevicesResultSchema = object({ devices: array(object({
|
|
103586
104721
|
address: string(),
|
|
103587
104722
|
type: string(),
|
|
@@ -103602,7 +104737,12 @@ var CcuDevicesResultSchema = object({ devices: array(object({
|
|
|
103602
104737
|
lowBattery: boolean().nullable(),
|
|
103603
104738
|
unreach: boolean().nullable(),
|
|
103604
104739
|
configPending: boolean().nullable(),
|
|
103605
|
-
sabotage: boolean().nullable()
|
|
104740
|
+
sabotage: boolean().nullable(),
|
|
104741
|
+
/**
|
|
104742
|
+
* Key channels of an ADOPTED device, and whether the CCU sends their presses
|
|
104743
|
+
* (a central link). Empty for a device that is not adopted or has no keys.
|
|
104744
|
+
*/
|
|
104745
|
+
keyChannels: array(KeyChannelLinkSchema).default([])
|
|
103606
104746
|
})) });
|
|
103607
104747
|
/** The group types the CCU can create (nodehomematic `HmGroupCreate.type`). */
|
|
103608
104748
|
var HEATING_GROUP_TYPES = ["hmip.heating.group", "HomeMatic.heating"];
|
|
@@ -127308,6 +128448,10 @@ var homematicActions = defineCustomActions({
|
|
|
127308
128448
|
acknowledgeServiceMessage: customAction(AcknowledgeInputSchema, OkResultSchema, {
|
|
127309
128449
|
kind: "mutation",
|
|
127310
128450
|
auth: "admin"
|
|
128451
|
+
}),
|
|
128452
|
+
setButtonEvents: customAction(SetButtonEventsInputSchema, OkResultSchema, {
|
|
128453
|
+
kind: "mutation",
|
|
128454
|
+
auth: "admin"
|
|
127311
128455
|
})
|
|
127312
128456
|
});
|
|
127313
128457
|
//#endregion
|
|
@@ -127355,7 +128499,7 @@ function inferCallbackHost(ccuHost) {
|
|
|
127355
128499
|
var homematicConfigSchema = object({
|
|
127356
128500
|
host: string().min(1).describe("CCU3 / RaspberryMatic host name or IP address"),
|
|
127357
128501
|
enableHmipRf: boolean().default(true).describe("Enable Homematic IP (HmIP-RF)"),
|
|
127358
|
-
enableBidcosRf: boolean().default(false).describe("Enable Homematic (BidCos-RF)"),
|
|
128502
|
+
enableBidcosRf: boolean().default(false).describe("Enable Homematic (BidCos-RF). HM-RCV-50, RPI-RF-MOD and classic BidCos devices appear only with this on"),
|
|
127359
128503
|
enableGroups: boolean().default(true).describe("Enable groups (heating groups / VirtualDevices)"),
|
|
127360
128504
|
enableBidcosWired: boolean().default(false).describe("Enable BidCos-Wired (HM-Wired)"),
|
|
127361
128505
|
username: string().default("Admin").describe("WebUI username (optional — enables names / rooms / sysvars)"),
|
|
@@ -127501,6 +128645,8 @@ function buildConnectionFormSchema() {
|
|
|
127501
128645
|
key: "enableBidcosRf",
|
|
127502
128646
|
label: "Enable Homematic (BidCos-RF)",
|
|
127503
128647
|
labelKey: "provider-homematic:connection.s_interfaces.enableBidcosRf.label",
|
|
128648
|
+
description: "HM-RCV-50, RPI-RF-MOD and classic BidCos devices appear only with this on.",
|
|
128649
|
+
descriptionKey: "provider-homematic:connection.s_interfaces.enableBidcosRf.description",
|
|
127504
128650
|
default: false
|
|
127505
128651
|
},
|
|
127506
128652
|
{
|
|
@@ -127770,81 +128916,6 @@ var HOMEMATIC_ROWS_TO_RECORD_MIGRATION = {
|
|
|
127770
128916
|
})
|
|
127771
128917
|
};
|
|
127772
128918
|
//#endregion
|
|
127773
|
-
//#region src/homematic-facade-resolver.ts
|
|
127774
|
-
/**
|
|
127775
|
-
* Per-integration registry that device classes use to reach the live
|
|
127776
|
-
* `Homematic` facade (and the session state) of their CCU.
|
|
127777
|
-
*
|
|
127778
|
-
* The kernel constructs device classes through the `deviceClasses` map with
|
|
127779
|
-
* only a `DeviceContext` — it cannot thread the facade in as a constructor
|
|
127780
|
-
* arg. The connection lives on the INTEGRATION, so the CCU box and every device
|
|
127781
|
-
* adopted from it resolve the same session by `integrationId`. A device
|
|
127782
|
-
* persisted without an `integrationId` cannot be attributed to a CCU and
|
|
127783
|
-
* resolves nothing.
|
|
127784
|
-
*/
|
|
127785
|
-
var HmFacadeResolver = class {
|
|
127786
|
-
#facades = /* @__PURE__ */ new Map();
|
|
127787
|
-
#sessions = /* @__PURE__ */ new Map();
|
|
127788
|
-
/** Per-integration state-change fan-out (connect, disconnect, error). */
|
|
127789
|
-
#snapshotSubs = /* @__PURE__ */ new Map();
|
|
127790
|
-
/** Publish or remove the facade for an integration id. `null` removes the entry. */
|
|
127791
|
-
set(integrationId, facade) {
|
|
127792
|
-
if (facade === null) {
|
|
127793
|
-
this.#facades.delete(integrationId);
|
|
127794
|
-
return;
|
|
127795
|
-
}
|
|
127796
|
-
this.#facades.set(integrationId, facade);
|
|
127797
|
-
}
|
|
127798
|
-
/** The live facade for an integration id, or null when unknown / absent / not running. */
|
|
127799
|
-
get(integrationId) {
|
|
127800
|
-
if (integrationId === void 0 || integrationId === null) return null;
|
|
127801
|
-
return this.#facades.get(integrationId) ?? null;
|
|
127802
|
-
}
|
|
127803
|
-
/** Publish or remove the session (state + connection) for an integration id. */
|
|
127804
|
-
setSession(integrationId, session) {
|
|
127805
|
-
if (session === null) {
|
|
127806
|
-
this.#sessions.delete(integrationId);
|
|
127807
|
-
return;
|
|
127808
|
-
}
|
|
127809
|
-
this.#sessions.set(integrationId, session);
|
|
127810
|
-
}
|
|
127811
|
-
/** The session of an integration, or null when it is not registered. */
|
|
127812
|
-
getSession(integrationId) {
|
|
127813
|
-
if (integrationId === void 0 || integrationId === null) return null;
|
|
127814
|
-
return this.#sessions.get(integrationId) ?? null;
|
|
127815
|
-
}
|
|
127816
|
-
/** Subscribe a device to the state changes of one integration. Returns an unsubscribe fn. */
|
|
127817
|
-
onSnapshot(integrationId, cb) {
|
|
127818
|
-
let set = this.#snapshotSubs.get(integrationId);
|
|
127819
|
-
if (!set) {
|
|
127820
|
-
set = /* @__PURE__ */ new Set();
|
|
127821
|
-
this.#snapshotSubs.set(integrationId, set);
|
|
127822
|
-
}
|
|
127823
|
-
set.add(cb);
|
|
127824
|
-
return () => {
|
|
127825
|
-
const current = this.#snapshotSubs.get(integrationId);
|
|
127826
|
-
current?.delete(cb);
|
|
127827
|
-
if (current && current.size === 0) this.#snapshotSubs.delete(integrationId);
|
|
127828
|
-
};
|
|
127829
|
-
}
|
|
127830
|
-
/** Fan one state change out to every subscribed device of an integration. */
|
|
127831
|
-
emitSnapshot(integrationId) {
|
|
127832
|
-
const set = this.#snapshotSubs.get(integrationId);
|
|
127833
|
-
if (!set) return;
|
|
127834
|
-
for (const cb of [...set]) try {
|
|
127835
|
-
cb();
|
|
127836
|
-
} catch {}
|
|
127837
|
-
}
|
|
127838
|
-
/** Remove everything (called on full shutdown). */
|
|
127839
|
-
clear() {
|
|
127840
|
-
this.#facades.clear();
|
|
127841
|
-
this.#sessions.clear();
|
|
127842
|
-
this.#snapshotSubs.clear();
|
|
127843
|
-
}
|
|
127844
|
-
};
|
|
127845
|
-
/** The single in-process resolver shared between the integration and its devices. */
|
|
127846
|
-
var homematicFacades = new HmFacadeResolver();
|
|
127847
|
-
//#endregion
|
|
127848
128919
|
//#region src/homematic-diagnostics-mapping.ts
|
|
127849
128920
|
var MAINTENANCE_CHANNEL_TYPE$1 = "MAINTENANCE";
|
|
127850
128921
|
/** Reachability parameters that drive the Container's `online`, not a child. */
|
|
@@ -127975,226 +129046,6 @@ function readReachability(device) {
|
|
|
127975
129046
|
return null;
|
|
127976
129047
|
}
|
|
127977
129048
|
//#endregion
|
|
127978
|
-
//#region src/homematic-mapping.ts
|
|
127979
|
-
/**
|
|
127980
|
-
* Map a single Homematic channel to its CamStack triplet. The channel
|
|
127981
|
-
* `TYPE` is the discriminator. Only the controllable / primary channel
|
|
127982
|
-
* types map; status-only `*_TRANSMITTER` mirrors and the various key /
|
|
127983
|
-
* remote / week-profile channels return `null` (their datapoints are
|
|
127984
|
-
* still decoded into the owning cap's slice via the device's
|
|
127985
|
-
* `valueChanged` handler, keyed by parameter name).
|
|
127986
|
-
*/
|
|
127987
|
-
function mapHmChannel(channelType) {
|
|
127988
|
-
if (!channelType) return null;
|
|
127989
|
-
switch (channelType.toUpperCase()) {
|
|
127990
|
-
case "SWITCH_VIRTUAL_RECEIVER": return {
|
|
127991
|
-
deviceType: DeviceType.Switch,
|
|
127992
|
-
role: null,
|
|
127993
|
-
capabilities: ["switch"]
|
|
127994
|
-
};
|
|
127995
|
-
case "SHUTTER_VIRTUAL_RECEIVER": return {
|
|
127996
|
-
deviceType: DeviceType.Cover,
|
|
127997
|
-
role: null,
|
|
127998
|
-
capabilities: ["cover"]
|
|
127999
|
-
};
|
|
128000
|
-
case "HEATING_CLIMATECONTROL_TRANSCEIVER": return {
|
|
128001
|
-
deviceType: DeviceType.Climate,
|
|
128002
|
-
role: null,
|
|
128003
|
-
capabilities: [
|
|
128004
|
-
"climate-control",
|
|
128005
|
-
"temperature-sensor",
|
|
128006
|
-
"humidity-sensor"
|
|
128007
|
-
]
|
|
128008
|
-
};
|
|
128009
|
-
case "MOTIONDETECTOR_TRANSCEIVER": return {
|
|
128010
|
-
deviceType: DeviceType.Sensor,
|
|
128011
|
-
role: DeviceRole.MotionSensor,
|
|
128012
|
-
capabilities: ["motion", "ambient-light-sensor"]
|
|
128013
|
-
};
|
|
128014
|
-
case "DOOR_LOCK_STATE_TRANSMITTER": return {
|
|
128015
|
-
deviceType: DeviceType.Lock,
|
|
128016
|
-
role: null,
|
|
128017
|
-
capabilities: ["lock-control"]
|
|
128018
|
-
};
|
|
128019
|
-
case "ENERGIE_METER_TRANSMITTER": return {
|
|
128020
|
-
deviceType: DeviceType.Sensor,
|
|
128021
|
-
role: DeviceRole.PowerSensor,
|
|
128022
|
-
capabilities: ["power-meter"]
|
|
128023
|
-
};
|
|
128024
|
-
case "KEY_TRANSCEIVER":
|
|
128025
|
-
case "KEY_TRANSMITTER":
|
|
128026
|
-
case "VIRTUAL_KEY":
|
|
128027
|
-
case "KEY": return {
|
|
128028
|
-
deviceType: DeviceType.EventEmitter,
|
|
128029
|
-
role: null,
|
|
128030
|
-
capabilities: ["event-emitter"]
|
|
128031
|
-
};
|
|
128032
|
-
default: return null;
|
|
128033
|
-
}
|
|
128034
|
-
}
|
|
128035
|
-
/**
|
|
128036
|
-
* Best-effort parent DeviceType for a whole Homematic device, derived
|
|
128037
|
-
* from the union of its channel mappings. Actuators win over sensors so
|
|
128038
|
-
* a switch + energy-meter device (HmIP-BSM) reports as a Switch, not a
|
|
128039
|
-
* Sensor, and a thermostat with a humidity sensor reports as a
|
|
128040
|
-
* Climate device (D1033). A remote/wall-switch is primarily an EventEmitter: it is
|
|
128041
|
-
* ranked above Sensor so its battery / maintenance sensor channels don't
|
|
128042
|
-
* win the parent type. Returns `DeviceType.Generic` when no channel maps.
|
|
128043
|
-
*/
|
|
128044
|
-
var PARENT_TYPE_PRIORITY = [
|
|
128045
|
-
DeviceType.Climate,
|
|
128046
|
-
DeviceType.Lock,
|
|
128047
|
-
DeviceType.Cover,
|
|
128048
|
-
DeviceType.Light,
|
|
128049
|
-
DeviceType.Switch,
|
|
128050
|
-
DeviceType.EventEmitter,
|
|
128051
|
-
DeviceType.Sensor
|
|
128052
|
-
];
|
|
128053
|
-
function inferHmDeviceType(device) {
|
|
128054
|
-
const present = /* @__PURE__ */ new Set();
|
|
128055
|
-
for (const channel of device.channels) {
|
|
128056
|
-
const mapping = mapHmChannel(channel.type);
|
|
128057
|
-
if (mapping) present.add(mapping.deviceType);
|
|
128058
|
-
}
|
|
128059
|
-
for (const dt of PARENT_TYPE_PRIORITY) if (present.has(dt)) return dt;
|
|
128060
|
-
return DeviceType.Generic;
|
|
128061
|
-
}
|
|
128062
|
-
function mapHmDeviceChannels(device) {
|
|
128063
|
-
const out = [];
|
|
128064
|
-
for (const channel of device.channels) {
|
|
128065
|
-
const mapping = mapHmChannel(channel.type);
|
|
128066
|
-
if (mapping) out.push({
|
|
128067
|
-
channel,
|
|
128068
|
-
mapping
|
|
128069
|
-
});
|
|
128070
|
-
}
|
|
128071
|
-
return out;
|
|
128072
|
-
}
|
|
128073
|
-
//#endregion
|
|
128074
|
-
//#region src/devices/hm-cold-start.ts
|
|
128075
|
-
/**
|
|
128076
|
-
* Shared cold-start defaults + the key-channel press vocabulary helpers,
|
|
128077
|
-
* extracted from the (legacy) flat `homematic-device.ts` so the Container +
|
|
128078
|
-
* accessory-child classes reuse the SAME seeds and decoders without
|
|
128079
|
-
* duplicating them. Pure: no `BaseDevice` / facade dependency.
|
|
128080
|
-
*/
|
|
128081
|
-
/**
|
|
128082
|
-
* Cold-start defaults so reads never miss a slice before the first push.
|
|
128083
|
-
* `lastChangedAt: 0` marks each as a PLACEHOLDER — the value is a guess, and
|
|
128084
|
-
* consumers read it as unknown. A replayed CCU value is stamped
|
|
128085
|
-
* `HM_SEEDED_CHANGED_AT` instead (`hm-change-stamp.ts`).
|
|
128086
|
-
*/
|
|
128087
|
-
var COLD_SWITCH = {
|
|
128088
|
-
on: false,
|
|
128089
|
-
lastChangedAt: 0
|
|
128090
|
-
};
|
|
128091
|
-
var COLD_COVER = {
|
|
128092
|
-
state: "closed",
|
|
128093
|
-
position: null,
|
|
128094
|
-
tiltPosition: null,
|
|
128095
|
-
lastChangedAt: 0
|
|
128096
|
-
};
|
|
128097
|
-
var COLD_LOCK = {
|
|
128098
|
-
state: "unlocked",
|
|
128099
|
-
lastChangedAt: 0
|
|
128100
|
-
};
|
|
128101
|
-
var COLD_MOTION = {
|
|
128102
|
-
detected: false,
|
|
128103
|
-
lastDetectedAt: null,
|
|
128104
|
-
autoClearAfterMs: null
|
|
128105
|
-
};
|
|
128106
|
-
/**
|
|
128107
|
-
* The motion seed a constructor writes OVER the slice hydrated from the
|
|
128108
|
-
* persisted runtime state. The level is a placeholder (`false`) until the
|
|
128109
|
-
* CCU says otherwise, but a stored rise is a fact: `lastDetectedAt: null`
|
|
128110
|
-
* means "never detected" (`motion.cap.ts`), and a restart must not turn
|
|
128111
|
-
* "fired an hour ago" into that.
|
|
128112
|
-
*/
|
|
128113
|
-
function coldMotionKeepingRise(stored) {
|
|
128114
|
-
const rise = stored?.lastDetectedAt;
|
|
128115
|
-
return {
|
|
128116
|
-
...COLD_MOTION,
|
|
128117
|
-
lastDetectedAt: typeof rise === "number" && Number.isFinite(rise) && rise > 0 ? rise : null
|
|
128118
|
-
};
|
|
128119
|
-
}
|
|
128120
|
-
var COLD_CLIMATE = {
|
|
128121
|
-
mode: "auto",
|
|
128122
|
-
availableModes: [...[
|
|
128123
|
-
"off",
|
|
128124
|
-
"heat",
|
|
128125
|
-
"auto"
|
|
128126
|
-
]],
|
|
128127
|
-
fanMode: "",
|
|
128128
|
-
availableFanModes: [],
|
|
128129
|
-
preset: "",
|
|
128130
|
-
availablePresets: ["boost"],
|
|
128131
|
-
target: null,
|
|
128132
|
-
targetHigh: null,
|
|
128133
|
-
targetLow: null,
|
|
128134
|
-
targetHumidity: null,
|
|
128135
|
-
currentTemp: null,
|
|
128136
|
-
currentHumidity: null,
|
|
128137
|
-
swingVertical: null,
|
|
128138
|
-
swingHorizontal: null,
|
|
128139
|
-
lastFetchedAt: 0
|
|
128140
|
-
};
|
|
128141
|
-
/**
|
|
128142
|
-
* The standard HmIP key-channel datapoint vocabulary, used VERBATIM (NO
|
|
128143
|
-
* normalization) as the `event-emitter` event types — the native uppercase
|
|
128144
|
-
* tokens a `KEY_TRANSCEIVER` / `KEY_TRANSMITTER` / `VIRTUAL_KEY` / `KEY`
|
|
128145
|
-
* channel emits on the facade `valueChanged` stream.
|
|
128146
|
-
*/
|
|
128147
|
-
var HM_KEY_PRESS_DATAPOINTS = [
|
|
128148
|
-
"PRESS_SHORT",
|
|
128149
|
-
"PRESS_LONG",
|
|
128150
|
-
"PRESS_LONG_START",
|
|
128151
|
-
"PRESS_LONG_RELEASE",
|
|
128152
|
-
"PRESS_CONT"
|
|
128153
|
-
];
|
|
128154
|
-
/** Set form for O(1) fire-detection membership tests. */
|
|
128155
|
-
var HM_KEY_PRESS_SET = new Set(HM_KEY_PRESS_DATAPOINTS);
|
|
128156
|
-
/** Cold-start event-emitter slice; vocabulary supplied per-device. */
|
|
128157
|
-
function coldEventEmitter(vocabulary) {
|
|
128158
|
-
return {
|
|
128159
|
-
eventTypes: eventTypesOfVocabulary(vocabulary),
|
|
128160
|
-
vocabulary: [...vocabulary],
|
|
128161
|
-
lastEvent: null,
|
|
128162
|
-
eventCountSinceStart: 0
|
|
128163
|
-
};
|
|
128164
|
-
}
|
|
128165
|
-
/**
|
|
128166
|
-
* Collect the union of native `PRESS_*` datapoints a device's key channels
|
|
128167
|
-
* support, VERBATIM. Falls back to the standard HmIP key vocabulary when no
|
|
128168
|
-
* datapoints were enumerated, so the cap always advertises a non-empty set.
|
|
128169
|
-
*/
|
|
128170
|
-
function keyEventVocabulary(keyChannels) {
|
|
128171
|
-
const found = /* @__PURE__ */ new Set();
|
|
128172
|
-
for (const channel of keyChannels) for (const dp of channel.dataPoints ?? []) if (HM_KEY_PRESS_SET.has(dp.parameter)) found.add(dp.parameter);
|
|
128173
|
-
if (found.size === 0) return HM_KEY_PRESS_DATAPOINTS;
|
|
128174
|
-
return HM_KEY_PRESS_DATAPOINTS.filter((dp) => found.has(dp));
|
|
128175
|
-
}
|
|
128176
|
-
/**
|
|
128177
|
-
* The CamStack cap names that are ACTUATORS — driven by the library's typed
|
|
128178
|
-
* custom entities (correct channel), NOT by the raw mapped channels. The
|
|
128179
|
-
* raw-channel sensor/event loop skips these so they are not double-registered.
|
|
128180
|
-
*/
|
|
128181
|
-
var ACTUATOR_CAP_NAMES = new Set([
|
|
128182
|
-
"switch",
|
|
128183
|
-
"cover",
|
|
128184
|
-
"light",
|
|
128185
|
-
"lock-control",
|
|
128186
|
-
"climate-control"
|
|
128187
|
-
]);
|
|
128188
|
-
/** Parse the numeric channel index suffix (`:N`) from a channel address.
|
|
128189
|
-
* Null when absent. Kept as a string for the event payload, mirroring the
|
|
128190
|
-
* CCU's `device:index` addressing. */
|
|
128191
|
-
function channelIndexFromAddress(channelAddress) {
|
|
128192
|
-
const idx = channelAddress.lastIndexOf(":");
|
|
128193
|
-
if (idx === -1) return null;
|
|
128194
|
-
const suffix = channelAddress.slice(idx + 1);
|
|
128195
|
-
return suffix.length > 0 ? suffix : null;
|
|
128196
|
-
}
|
|
128197
|
-
//#endregion
|
|
128198
129049
|
//#region src/devices/hm-entity-spec.ts
|
|
128199
129050
|
var MAINTENANCE_CHANNEL_TYPE = "MAINTENANCE";
|
|
128200
129051
|
/**
|
|
@@ -128373,6 +129224,113 @@ function deriveHmEntitySpecs(device, customEntities) {
|
|
|
128373
129224
|
];
|
|
128374
129225
|
}
|
|
128375
129226
|
//#endregion
|
|
129227
|
+
//#region src/devices/hm-primary-child.ts
|
|
129228
|
+
var ACT_PREFIX = "act-";
|
|
129229
|
+
function channelIndex(key) {
|
|
129230
|
+
const suffix = channelIndexFromAddress(key.slice(4));
|
|
129231
|
+
if (suffix === null) return Number.MAX_SAFE_INTEGER;
|
|
129232
|
+
const parsed = Number(suffix);
|
|
129233
|
+
return Number.isFinite(parsed) ? parsed : Number.MAX_SAFE_INTEGER;
|
|
129234
|
+
}
|
|
129235
|
+
/**
|
|
129236
|
+
* Which child a Homematic container stands for.
|
|
129237
|
+
*
|
|
129238
|
+
* A device with relay channels stands for the first relay (lowest channel
|
|
129239
|
+
* index), so a two-relay switch is not left to the namesake tie-break. A
|
|
129240
|
+
* key-only device (no actuator) stands for its event-emitter. Anything else
|
|
129241
|
+
* declares nothing and the shared heuristic decides.
|
|
129242
|
+
*/
|
|
129243
|
+
function hmPrimaryChildKeys(specs) {
|
|
129244
|
+
const first = specs.filter((spec) => spec.key.startsWith(ACT_PREFIX) && spec.config["kind"] === "switch").toSorted((a, b) => channelIndex(a.key) - channelIndex(b.key))[0];
|
|
129245
|
+
if (first !== void 0) return [first.key];
|
|
129246
|
+
if (specs.some((spec) => spec.key.startsWith(ACT_PREFIX))) return [];
|
|
129247
|
+
return specs.some((spec) => spec.key === "events") ? ["events"] : [];
|
|
129248
|
+
}
|
|
129249
|
+
/**
|
|
129250
|
+
* The preference to write, or null when the container already has one or
|
|
129251
|
+
* there is nothing to declare. An operator pick is a different column.
|
|
129252
|
+
*/
|
|
129253
|
+
function preferenceToStamp(stored, declared) {
|
|
129254
|
+
if (stored !== void 0 && stored.length > 0) return null;
|
|
129255
|
+
if (declared.length === 0) return null;
|
|
129256
|
+
return declared;
|
|
129257
|
+
}
|
|
129258
|
+
//#endregion
|
|
129259
|
+
//#region src/homematic-facade-resolver.ts
|
|
129260
|
+
/**
|
|
129261
|
+
* Per-integration registry that device classes use to reach the live
|
|
129262
|
+
* `Homematic` facade (and the session state) of their CCU.
|
|
129263
|
+
*
|
|
129264
|
+
* The kernel constructs device classes through the `deviceClasses` map with
|
|
129265
|
+
* only a `DeviceContext` — it cannot thread the facade in as a constructor
|
|
129266
|
+
* arg. The connection lives on the INTEGRATION, so the CCU box and every device
|
|
129267
|
+
* adopted from it resolve the same session by `integrationId`. A device
|
|
129268
|
+
* persisted without an `integrationId` cannot be attributed to a CCU and
|
|
129269
|
+
* resolves nothing.
|
|
129270
|
+
*/
|
|
129271
|
+
var HmFacadeResolver = class {
|
|
129272
|
+
#facades = /* @__PURE__ */ new Map();
|
|
129273
|
+
#sessions = /* @__PURE__ */ new Map();
|
|
129274
|
+
/** Per-integration state-change fan-out (connect, disconnect, error). */
|
|
129275
|
+
#snapshotSubs = /* @__PURE__ */ new Map();
|
|
129276
|
+
/** Publish or remove the facade for an integration id. `null` removes the entry. */
|
|
129277
|
+
set(integrationId, facade) {
|
|
129278
|
+
if (facade === null) {
|
|
129279
|
+
this.#facades.delete(integrationId);
|
|
129280
|
+
return;
|
|
129281
|
+
}
|
|
129282
|
+
this.#facades.set(integrationId, facade);
|
|
129283
|
+
}
|
|
129284
|
+
/** The live facade for an integration id, or null when unknown / absent / not running. */
|
|
129285
|
+
get(integrationId) {
|
|
129286
|
+
if (integrationId === void 0 || integrationId === null) return null;
|
|
129287
|
+
return this.#facades.get(integrationId) ?? null;
|
|
129288
|
+
}
|
|
129289
|
+
/** Publish or remove the session (state + connection) for an integration id. */
|
|
129290
|
+
setSession(integrationId, session) {
|
|
129291
|
+
if (session === null) {
|
|
129292
|
+
this.#sessions.delete(integrationId);
|
|
129293
|
+
return;
|
|
129294
|
+
}
|
|
129295
|
+
this.#sessions.set(integrationId, session);
|
|
129296
|
+
}
|
|
129297
|
+
/** The session of an integration, or null when it is not registered. */
|
|
129298
|
+
getSession(integrationId) {
|
|
129299
|
+
if (integrationId === void 0 || integrationId === null) return null;
|
|
129300
|
+
return this.#sessions.get(integrationId) ?? null;
|
|
129301
|
+
}
|
|
129302
|
+
/** Subscribe a device to the state changes of one integration. Returns an unsubscribe fn. */
|
|
129303
|
+
onSnapshot(integrationId, cb) {
|
|
129304
|
+
let set = this.#snapshotSubs.get(integrationId);
|
|
129305
|
+
if (!set) {
|
|
129306
|
+
set = /* @__PURE__ */ new Set();
|
|
129307
|
+
this.#snapshotSubs.set(integrationId, set);
|
|
129308
|
+
}
|
|
129309
|
+
set.add(cb);
|
|
129310
|
+
return () => {
|
|
129311
|
+
const current = this.#snapshotSubs.get(integrationId);
|
|
129312
|
+
current?.delete(cb);
|
|
129313
|
+
if (current && current.size === 0) this.#snapshotSubs.delete(integrationId);
|
|
129314
|
+
};
|
|
129315
|
+
}
|
|
129316
|
+
/** Fan one state change out to every subscribed device of an integration. */
|
|
129317
|
+
emitSnapshot(integrationId) {
|
|
129318
|
+
const set = this.#snapshotSubs.get(integrationId);
|
|
129319
|
+
if (!set) return;
|
|
129320
|
+
for (const cb of [...set]) try {
|
|
129321
|
+
cb();
|
|
129322
|
+
} catch {}
|
|
129323
|
+
}
|
|
129324
|
+
/** Remove everything (called on full shutdown). */
|
|
129325
|
+
clear() {
|
|
129326
|
+
this.#facades.clear();
|
|
129327
|
+
this.#sessions.clear();
|
|
129328
|
+
this.#snapshotSubs.clear();
|
|
129329
|
+
}
|
|
129330
|
+
};
|
|
129331
|
+
/** The single in-process resolver shared between the integration and its devices. */
|
|
129332
|
+
var homematicFacades = new HmFacadeResolver();
|
|
129333
|
+
//#endregion
|
|
128376
129334
|
//#region src/devices/hm-child-device.ts
|
|
128377
129335
|
/**
|
|
128378
129336
|
* Persisted config every Homematic accessory CHILD carries. `address` is the
|
|
@@ -129237,65 +130195,9 @@ var HmSensorDevice = class extends HmChildDevice {
|
|
|
129237
130195
|
}
|
|
129238
130196
|
};
|
|
129239
130197
|
//#endregion
|
|
129240
|
-
//#region src/devices/hm-key-vocabulary.ts
|
|
129241
|
-
var PRESS_MEANING = {
|
|
129242
|
-
PRESS_SHORT: {
|
|
129243
|
-
label: "Short press",
|
|
129244
|
-
kind: "press"
|
|
129245
|
-
},
|
|
129246
|
-
PRESS_LONG: {
|
|
129247
|
-
label: "Long press",
|
|
129248
|
-
kind: "long-press"
|
|
129249
|
-
},
|
|
129250
|
-
PRESS_LONG_START: {
|
|
129251
|
-
label: "Long press started",
|
|
129252
|
-
kind: "long-press-start"
|
|
129253
|
-
},
|
|
129254
|
-
PRESS_LONG_RELEASE: {
|
|
129255
|
-
label: "Long press released",
|
|
129256
|
-
kind: "release"
|
|
129257
|
-
},
|
|
129258
|
-
PRESS_CONT: {
|
|
129259
|
-
label: "Long press held",
|
|
129260
|
-
kind: "repeat"
|
|
129261
|
-
}
|
|
129262
|
-
};
|
|
129263
|
-
/** The channels of a device that are buttons, in channel order. */
|
|
129264
|
-
function hmKeyChannels(device) {
|
|
129265
|
-
return mapHmDeviceChannels(device).filter(({ mapping }) => mapping.capabilities.includes("event-emitter")).map(({ channel }) => channel);
|
|
129266
|
-
}
|
|
129267
|
-
/** The presses one key channel has; the standard set when it lists none. */
|
|
129268
|
-
function pressesOf(channel) {
|
|
129269
|
-
const listed = new Set((channel.dataPoints ?? []).map((dataPoint) => dataPoint.parameter).filter((parameter) => HM_KEY_PRESS_SET.has(parameter)));
|
|
129270
|
-
if (listed.size === 0) return HM_KEY_PRESS_DATAPOINTS;
|
|
129271
|
-
return HM_KEY_PRESS_DATAPOINTS.filter((parameter) => listed.has(parameter));
|
|
129272
|
-
}
|
|
129273
|
-
function entryOf(parameter, source) {
|
|
129274
|
-
const meaning = PRESS_MEANING[parameter];
|
|
129275
|
-
if (meaning === void 0) return {
|
|
129276
|
-
id: parameter,
|
|
129277
|
-
source,
|
|
129278
|
-
label: parameter
|
|
129279
|
-
};
|
|
129280
|
-
return {
|
|
129281
|
-
id: parameter,
|
|
129282
|
-
source,
|
|
129283
|
-
label: meaning.label,
|
|
129284
|
-
kind: meaning.kind
|
|
129285
|
-
};
|
|
129286
|
-
}
|
|
129287
|
-
function hmKeyVocabulary(device) {
|
|
129288
|
-
return hmKeyChannels(device).flatMap((channel, position) => {
|
|
129289
|
-
const index = channelIndexFromAddress(channel.address) ?? String(channel.index);
|
|
129290
|
-
const source = {
|
|
129291
|
-
id: index,
|
|
129292
|
-
label: `Button ${position + 1} (channel ${index})`
|
|
129293
|
-
};
|
|
129294
|
-
return pressesOf(channel).map((parameter) => entryOf(parameter, source));
|
|
129295
|
-
});
|
|
129296
|
-
}
|
|
129297
|
-
//#endregion
|
|
129298
130198
|
//#region src/devices/hm-event-emitter-device.ts
|
|
130199
|
+
/** Shown on the Buttons child when none of its key channels has a central link. */
|
|
130200
|
+
var BUTTON_EVENTS_HINT = "The CCU does not send these presses — enable button events on the CCU page";
|
|
129299
130201
|
/**
|
|
129300
130202
|
* Event-emitter child config: the persisted native press vocabulary for the
|
|
129301
130203
|
* device's key channels. Stored at adoption so the cap advertises the right
|
|
@@ -129317,6 +130219,10 @@ var HmEventEmitterDevice = class extends HmChildDevice {
|
|
|
129317
130219
|
#declared = null;
|
|
129318
130220
|
/** Fires already reported as outside the vocabulary, as `source:token`. */
|
|
129319
130221
|
#undeclaredLogged = /* @__PURE__ */ new Set();
|
|
130222
|
+
/** Key channels that have delivered a press since this process started. */
|
|
130223
|
+
#pressSeen = /* @__PURE__ */ new Set();
|
|
130224
|
+
/** True once we know every key channel lacks a central link. */
|
|
130225
|
+
#centralLinkMissing = false;
|
|
129320
130226
|
#eventSeq = 0;
|
|
129321
130227
|
#eventCount = 0;
|
|
129322
130228
|
/** Unsubscribe for the integration's state-change fan-out. */
|
|
@@ -129327,7 +130233,29 @@ var HmEventEmitterDevice = class extends HmChildDevice {
|
|
|
129327
130233
|
this.persistedEventTypes = persisted && persisted.length > 0 ? persisted : HM_KEY_PRESS_DATAPOINTS;
|
|
129328
130234
|
this.registerEventEmitterCap();
|
|
129329
130235
|
this.attachValueChangedListener((event) => this.decodeKeyPress(event));
|
|
129330
|
-
if (this.integrationId !== void 0) this.#snapshotUnsub = homematicFacades.onSnapshot(this.integrationId, () =>
|
|
130236
|
+
if (this.integrationId !== void 0) this.#snapshotUnsub = homematicFacades.onSnapshot(this.integrationId, () => {
|
|
130237
|
+
this.refreshDeclaredVocabulary();
|
|
130238
|
+
this.refreshCentralLinks();
|
|
130239
|
+
});
|
|
130240
|
+
this.refreshCentralLinks();
|
|
130241
|
+
}
|
|
130242
|
+
getSettingsUISchema() {
|
|
130243
|
+
if (!this.#centralLinkMissing) return { sections: [] };
|
|
130244
|
+
return { sections: [{
|
|
130245
|
+
id: "button-events",
|
|
130246
|
+
title: "Button events",
|
|
130247
|
+
titleKey: "provider-homematic:device.buttonEvents.title",
|
|
130248
|
+
columns: 1,
|
|
130249
|
+
fields: [{
|
|
130250
|
+
type: "info",
|
|
130251
|
+
key: "buttonEventsHint",
|
|
130252
|
+
label: "Button events",
|
|
130253
|
+
labelKey: "provider-homematic:device.buttonEvents.hint.label",
|
|
130254
|
+
content: BUTTON_EVENTS_HINT,
|
|
130255
|
+
contentKey: "provider-homematic:device.buttonEvents.hint.content",
|
|
130256
|
+
variant: "warning"
|
|
130257
|
+
}]
|
|
130258
|
+
}] };
|
|
129331
130259
|
}
|
|
129332
130260
|
/**
|
|
129333
130261
|
* Rewrite the slice with the buttons once the CCU's channel list carries
|
|
@@ -129335,12 +130263,62 @@ var HmEventEmitterDevice = class extends HmChildDevice {
|
|
|
129335
130263
|
*/
|
|
129336
130264
|
refreshDeclaredVocabulary() {
|
|
129337
130265
|
if (this.#declared !== null) return;
|
|
129338
|
-
|
|
130266
|
+
this.vocabulary();
|
|
129339
130267
|
if (this.#declared === null) return;
|
|
130268
|
+
const published = this.publishedVocabulary();
|
|
129340
130269
|
const current = this.runtimeState.getCapState("event-emitter");
|
|
129341
130270
|
this.runtimeState.setCapState("event-emitter", {
|
|
129342
|
-
eventTypes: eventTypesOfVocabulary(
|
|
129343
|
-
vocabulary: [...
|
|
130271
|
+
eventTypes: eventTypesOfVocabulary(published),
|
|
130272
|
+
vocabulary: [...published],
|
|
130273
|
+
lastEvent: current?.lastEvent ?? null,
|
|
130274
|
+
eventCountSinceStart: current?.eventCountSinceStart ?? 0
|
|
130275
|
+
});
|
|
130276
|
+
}
|
|
130277
|
+
/** The live vocabulary, plus the central-link hint when the CCU sends nothing. */
|
|
130278
|
+
publishedVocabulary() {
|
|
130279
|
+
const vocabulary = this.vocabulary();
|
|
130280
|
+
if (!this.#centralLinkMissing) return vocabulary;
|
|
130281
|
+
return vocabulary.map((entry) => ({
|
|
130282
|
+
...entry,
|
|
130283
|
+
description: BUTTON_EVENTS_HINT
|
|
130284
|
+
}));
|
|
130285
|
+
}
|
|
130286
|
+
/**
|
|
130287
|
+
* Ask the facade whether each key channel has a central link. A library
|
|
130288
|
+
* that cannot answer (`unsupported`) leaves the hint off: absence of the
|
|
130289
|
+
* method is not evidence the CCU is silent.
|
|
130290
|
+
*/
|
|
130291
|
+
async refreshCentralLinks() {
|
|
130292
|
+
const facade = this.integrationId === void 0 ? null : homematicFacades.get(this.integrationId);
|
|
130293
|
+
const device = this.resolveHmDevice();
|
|
130294
|
+
if (facade === null || device === null) return;
|
|
130295
|
+
const keys = hmKeyChannels(device);
|
|
130296
|
+
if (keys.length === 0) return;
|
|
130297
|
+
const port = channelLinkPort(facade);
|
|
130298
|
+
let missing = false;
|
|
130299
|
+
for (const channel of keys) {
|
|
130300
|
+
const read = await port.getChannelLinkState(channel.address);
|
|
130301
|
+
if (read.kind === "unsupported") return;
|
|
130302
|
+
if (read.kind === "error") {
|
|
130303
|
+
this.ctx.logger.warn("Homematic key channel link state could not be read", {
|
|
130304
|
+
tags: { deviceId: this.ctx.id },
|
|
130305
|
+
meta: {
|
|
130306
|
+
address: this.address,
|
|
130307
|
+
channel: channel.address,
|
|
130308
|
+
error: read.message
|
|
130309
|
+
}
|
|
130310
|
+
});
|
|
130311
|
+
return;
|
|
130312
|
+
}
|
|
130313
|
+
if (!read.state.central) missing = true;
|
|
130314
|
+
}
|
|
130315
|
+
if (missing === this.#centralLinkMissing) return;
|
|
130316
|
+
this.#centralLinkMissing = missing;
|
|
130317
|
+
const current = this.runtimeState.getCapState("event-emitter");
|
|
130318
|
+
const published = this.publishedVocabulary();
|
|
130319
|
+
this.runtimeState.setCapState("event-emitter", {
|
|
130320
|
+
eventTypes: eventTypesOfVocabulary(published),
|
|
130321
|
+
vocabulary: [...published],
|
|
129344
130322
|
lastEvent: current?.lastEvent ?? null,
|
|
129345
130323
|
eventCountSinceStart: current?.eventCountSinceStart ?? 0
|
|
129346
130324
|
});
|
|
@@ -129352,7 +130330,7 @@ var HmEventEmitterDevice = class extends HmChildDevice {
|
|
|
129352
130330
|
}
|
|
129353
130331
|
registerEventEmitterCap() {
|
|
129354
130332
|
this.ctx.registerNativeCap(eventEmitterCapability, { getStatus: async () => this.runtimeState.getCapState("event-emitter") ?? coldEventEmitter(this.vocabulary()) });
|
|
129355
|
-
this.runtimeState.setCapState("event-emitter", coldEventEmitter(this.
|
|
130333
|
+
this.runtimeState.setCapState("event-emitter", coldEventEmitter(this.publishedVocabulary()));
|
|
129356
130334
|
}
|
|
129357
130335
|
/**
|
|
129358
130336
|
* The buttons and their presses, read LIVE from the CCU's channel list.
|
|
@@ -129386,6 +130364,11 @@ var HmEventEmitterDevice = class extends HmChildDevice {
|
|
|
129386
130364
|
}
|
|
129387
130365
|
});
|
|
129388
130366
|
}
|
|
130367
|
+
keyChannelAddresses() {
|
|
130368
|
+
const device = this.resolveHmDevice();
|
|
130369
|
+
if (device === null) return /* @__PURE__ */ new Set();
|
|
130370
|
+
return new Set(hmKeyChannels(device).map((channel) => channel.address));
|
|
130371
|
+
}
|
|
129389
130372
|
/**
|
|
129390
130373
|
* Translate a key-channel `PRESS_*` datapoint into an `EventFire`: emit
|
|
129391
130374
|
* `EventCategory.EventEmitted` on the bus and write the `event-emitter`
|
|
@@ -129397,8 +130380,36 @@ var HmEventEmitterDevice = class extends HmChildDevice {
|
|
|
129397
130380
|
decodeKeyPress(event) {
|
|
129398
130381
|
const now = event.ts || Date.now();
|
|
129399
130382
|
const { parameter, value, channel } = event;
|
|
129400
|
-
|
|
129401
|
-
if (
|
|
130383
|
+
const isPress = HM_KEY_PRESS_SET.has(parameter);
|
|
130384
|
+
if (!(isPress || this.keyChannelAddresses().has(channel))) return;
|
|
130385
|
+
if (!(isPress && !(typeof value === "boolean" && value === false))) {
|
|
130386
|
+
this.ctx.logger.debug("Homematic key channel value changed but decoded to no press", {
|
|
130387
|
+
tags: { deviceId: this.ctx.id },
|
|
130388
|
+
meta: {
|
|
130389
|
+
channel,
|
|
130390
|
+
parameter,
|
|
130391
|
+
...isPress ? { press: parameter } : {}
|
|
130392
|
+
}
|
|
130393
|
+
});
|
|
130394
|
+
return;
|
|
130395
|
+
}
|
|
130396
|
+
this.ctx.logger.debug("Homematic key press received", {
|
|
130397
|
+
tags: { deviceId: this.ctx.id },
|
|
130398
|
+
meta: {
|
|
130399
|
+
channel,
|
|
130400
|
+
press: parameter
|
|
130401
|
+
}
|
|
130402
|
+
});
|
|
130403
|
+
if (!this.#pressSeen.has(channel)) {
|
|
130404
|
+
this.#pressSeen.add(channel);
|
|
130405
|
+
this.ctx.logger.info("Homematic key channel delivered its first press since start", {
|
|
130406
|
+
tags: { deviceId: this.ctx.id },
|
|
130407
|
+
meta: {
|
|
130408
|
+
channel,
|
|
130409
|
+
press: parameter
|
|
130410
|
+
}
|
|
130411
|
+
});
|
|
130412
|
+
}
|
|
129402
130413
|
const channelIndex = channelIndexFromAddress(channel);
|
|
129403
130414
|
const fire = {
|
|
129404
130415
|
deviceId: this.id,
|
|
@@ -129414,7 +130425,7 @@ var HmEventEmitterDevice = class extends HmChildDevice {
|
|
|
129414
130425
|
deviceId: this.id,
|
|
129415
130426
|
addonId: this.ctx.deviceMeta.addonId
|
|
129416
130427
|
}, fire));
|
|
129417
|
-
const vocabulary = this.
|
|
130428
|
+
const vocabulary = this.publishedVocabulary();
|
|
129418
130429
|
this.noteUndeclared(vocabulary, parameter, channelIndex);
|
|
129419
130430
|
const slice = {
|
|
129420
130431
|
eventTypes: eventTypesOfVocabulary(vocabulary),
|
|
@@ -129718,6 +130729,43 @@ var HmChildDispatcher = class {
|
|
|
129718
130729
|
/** The documented boundary-cast export used in the `deviceClasses` restore map. */
|
|
129719
130730
|
var hmChildDeviceClass = HmChildDispatcher;
|
|
129720
130731
|
//#endregion
|
|
130732
|
+
//#region src/devices/hm-child-name.ts
|
|
130733
|
+
/**
|
|
130734
|
+
* Display name of one actuator child.
|
|
130735
|
+
*
|
|
130736
|
+
* A single actuator keeps the container's name (the caller passes it). A
|
|
130737
|
+
* multi-actuator child uses the CCU channel name when the facade has one,
|
|
130738
|
+
* otherwise `"<container> ch<index>"`. Never the channel address.
|
|
130739
|
+
*/
|
|
130740
|
+
function multiActuatorChildName(input) {
|
|
130741
|
+
if (input.channelName !== null) return input.channelName;
|
|
130742
|
+
const index = input.channelIndex ?? "?";
|
|
130743
|
+
return `${input.containerName} ch${index}`;
|
|
130744
|
+
}
|
|
130745
|
+
/** The name this addon used to give a multi-actuator child: container + raw address. */
|
|
130746
|
+
function legacyActuatorName(containerName, channelAddress) {
|
|
130747
|
+
return `${containerName} ${channelAddress}`;
|
|
130748
|
+
}
|
|
130749
|
+
/**
|
|
130750
|
+
* Whether an already-adopted actuator may take the new auto name.
|
|
130751
|
+
*
|
|
130752
|
+
* An operator rename (`userNamed`, or a legacy row whose name is not one of
|
|
130753
|
+
* the auto forms) is left alone. A name that is still the generated address
|
|
130754
|
+
* form, the `ch<index>` form, or the stable-id placeholder is replaced.
|
|
130755
|
+
* `stampUserNamed` is true only when the row is already flagged user-named:
|
|
130756
|
+
* the device-manager refuses a system rename of those rows, and accessory
|
|
130757
|
+
* registration stamps the flag on every non-placeholder name.
|
|
130758
|
+
*/
|
|
130759
|
+
function actuatorNameWrite(input) {
|
|
130760
|
+
if (input.currentName === input.desiredName) return { kind: "keep" };
|
|
130761
|
+
if (!(input.currentName === input.legacyAutoName || input.currentName === input.fallbackAutoName || input.currentName === input.stableId) && (input.userNamed === true || input.userNamed === void 0)) return { kind: "keep" };
|
|
130762
|
+
return {
|
|
130763
|
+
kind: "rename",
|
|
130764
|
+
name: input.desiredName,
|
|
130765
|
+
stampUserNamed: input.userNamed === true
|
|
130766
|
+
};
|
|
130767
|
+
}
|
|
130768
|
+
//#endregion
|
|
129721
130769
|
//#region src/devices/hm-container-device.ts
|
|
129722
130770
|
/**
|
|
129723
130771
|
* Persisted config for a Homematic Container (the parent of one physical CCU
|
|
@@ -129750,6 +130798,8 @@ var HmContainerDevice = class HmContainerDevice extends BaseDevice {
|
|
|
129750
130798
|
integrationId;
|
|
129751
130799
|
/** Unsubscribe for the facade `valueChanged` reachability listener. */
|
|
129752
130800
|
valueChangedUnsub = null;
|
|
130801
|
+
/** Unsubscribe for the session fan-out that re-stamps names once the CCU answers. */
|
|
130802
|
+
reconcileUnsub = null;
|
|
129753
130803
|
constructor(ctx) {
|
|
129754
130804
|
const cfg = hmContainerSchema.parse(ctx.persistedConfig ?? {});
|
|
129755
130805
|
super(ctx, hmContainerSchema, { type: DeviceType.Container });
|
|
@@ -129796,7 +130846,16 @@ var HmContainerDevice = class HmContainerDevice extends BaseDevice {
|
|
|
129796
130846
|
if (this.online !== next) this.markOnline(next);
|
|
129797
130847
|
});
|
|
129798
130848
|
}
|
|
130849
|
+
async onActivate() {
|
|
130850
|
+
await super.onActivate();
|
|
130851
|
+
await this.reconcileDerived();
|
|
130852
|
+
this.reconcileUnsub = homematicFacades.onSnapshot(this.integrationId, () => {
|
|
130853
|
+
this.reconcileDerived();
|
|
130854
|
+
});
|
|
130855
|
+
}
|
|
129799
130856
|
async removeDevice() {
|
|
130857
|
+
this.reconcileUnsub?.();
|
|
130858
|
+
this.reconcileUnsub = null;
|
|
129800
130859
|
if (this.valueChangedUnsub) {
|
|
129801
130860
|
try {
|
|
129802
130861
|
this.valueChangedUnsub();
|
|
@@ -129833,11 +130892,96 @@ var HmContainerDevice = class HmContainerDevice extends BaseDevice {
|
|
|
129833
130892
|
const specs = deriveHmEntitySpecs(hmDevice, this.facade?.customEntities()?.filter((e) => e.device === this.address) ?? []);
|
|
129834
130893
|
const multipleActuators = specs.filter((s) => s.key.startsWith("act-")).map((s) => s.key).length > 1;
|
|
129835
130894
|
return specs.map((spec) => {
|
|
129836
|
-
if (!spec.key.startsWith("act-")) return this.childSpec(spec);
|
|
129837
|
-
|
|
129838
|
-
|
|
130895
|
+
if (!spec.key.startsWith("act-") || !multipleActuators) return this.childSpec(spec, spec.key.startsWith("act-") ? this.name : void 0);
|
|
130896
|
+
return this.childSpec(spec, this.actuatorName(hmDevice, spec));
|
|
130897
|
+
});
|
|
130898
|
+
}
|
|
130899
|
+
/** CCU channel name, else `"<container> ch<index>"`. Never the raw address. */
|
|
130900
|
+
actuatorName(hmDevice, spec) {
|
|
130901
|
+
const channelAddress = spec.key.slice(4);
|
|
130902
|
+
const channel = hmDevice.channels.find((candidate) => candidate.address === channelAddress);
|
|
130903
|
+
const index = channel !== void 0 ? String(channel.index) : channelIndexFromAddress(channelAddress);
|
|
130904
|
+
return multiActuatorChildName({
|
|
130905
|
+
containerName: this.name,
|
|
130906
|
+
channelName: channel === void 0 ? null : readHmName(channel),
|
|
130907
|
+
channelIndex: index
|
|
130908
|
+
});
|
|
130909
|
+
}
|
|
130910
|
+
async reconcileDerived() {
|
|
130911
|
+
const hmDevice = this.resolveHmDevice();
|
|
130912
|
+
if (hmDevice === null) return;
|
|
130913
|
+
try {
|
|
130914
|
+
await this.stampPrimaryPreference(hmDevice);
|
|
130915
|
+
await this.refreshActuatorNames(hmDevice);
|
|
130916
|
+
} catch (err) {
|
|
130917
|
+
this.ctx.logger.warn("HmContainerDevice: could not refresh derived child meta", {
|
|
130918
|
+
tags: { deviceId: this.id },
|
|
130919
|
+
meta: {
|
|
130920
|
+
address: this.address,
|
|
130921
|
+
error: errMsg(err)
|
|
130922
|
+
}
|
|
130923
|
+
});
|
|
130924
|
+
}
|
|
130925
|
+
}
|
|
130926
|
+
async stampPrimaryPreference(hmDevice) {
|
|
130927
|
+
const manager = this.ctx.api?.deviceManager;
|
|
130928
|
+
if (manager === void 0) return;
|
|
130929
|
+
const declared = hmPrimaryChildKeys(deriveHmEntitySpecs(hmDevice, this.facade?.customEntities()?.filter((entity) => entity.device === this.address) ?? []));
|
|
130930
|
+
const keys = preferenceToStamp(this.ctx.deviceMeta.primaryChildPreference, declared);
|
|
130931
|
+
if (keys === null) return;
|
|
130932
|
+
await manager.setPrimaryChildPreference.mutate({
|
|
130933
|
+
deviceId: this.id,
|
|
130934
|
+
primaryChildPreference: keys
|
|
130935
|
+
});
|
|
130936
|
+
this.ctx.logger.info("Homematic container stamped its primary child", {
|
|
130937
|
+
tags: { deviceId: this.id },
|
|
130938
|
+
meta: {
|
|
130939
|
+
address: this.address,
|
|
130940
|
+
primaryChildPreference: keys
|
|
130941
|
+
}
|
|
129839
130942
|
});
|
|
129840
130943
|
}
|
|
130944
|
+
async refreshActuatorNames(hmDevice) {
|
|
130945
|
+
const manager = this.ctx.api?.deviceManager;
|
|
130946
|
+
if (manager === void 0) return;
|
|
130947
|
+
const specs = deriveHmEntitySpecs(hmDevice, this.facade?.customEntities()?.filter((entity) => entity.device === this.address) ?? []).filter((spec) => spec.key.startsWith("act-"));
|
|
130948
|
+
if (specs.length < 2) return;
|
|
130949
|
+
const children = await manager.getChildren.query({ parentDeviceId: this.id });
|
|
130950
|
+
for (const spec of specs) {
|
|
130951
|
+
const child = children.find((candidate) => candidate.stableId.endsWith(`-${spec.key}`));
|
|
130952
|
+
if (child === void 0) continue;
|
|
130953
|
+
const meta = await manager.loadMeta.query({ deviceId: child.id });
|
|
130954
|
+
if (meta === null) continue;
|
|
130955
|
+
const channelAddress = spec.key.slice(4);
|
|
130956
|
+
const desired = this.actuatorName(hmDevice, spec);
|
|
130957
|
+
const decision = actuatorNameWrite({
|
|
130958
|
+
currentName: meta.name,
|
|
130959
|
+
userNamed: meta.userNamed,
|
|
130960
|
+
desiredName: desired,
|
|
130961
|
+
legacyAutoName: legacyActuatorName(this.name, channelAddress),
|
|
130962
|
+
fallbackAutoName: multiActuatorChildName({
|
|
130963
|
+
containerName: this.name,
|
|
130964
|
+
channelName: null,
|
|
130965
|
+
channelIndex: channelIndexFromAddress(channelAddress)
|
|
130966
|
+
}),
|
|
130967
|
+
stableId: child.stableId
|
|
130968
|
+
});
|
|
130969
|
+
if (decision.kind === "keep") continue;
|
|
130970
|
+
await manager.setName.mutate({
|
|
130971
|
+
deviceId: child.id,
|
|
130972
|
+
name: decision.name,
|
|
130973
|
+
...decision.stampUserNamed ? {} : { stampUserNamed: false }
|
|
130974
|
+
});
|
|
130975
|
+
this.ctx.logger.info("Homematic actuator child took its channel name", {
|
|
130976
|
+
tags: { deviceId: child.id },
|
|
130977
|
+
meta: {
|
|
130978
|
+
address: this.address,
|
|
130979
|
+
channel: channelAddress,
|
|
130980
|
+
name: decision.name
|
|
130981
|
+
}
|
|
130982
|
+
});
|
|
130983
|
+
}
|
|
130984
|
+
}
|
|
129841
130985
|
/** Wrap one {@link HmEntitySpec} into an accessory-child spec, stamping the
|
|
129842
130986
|
* CCU `address` + integration FK onto config and the container link
|
|
129843
130987
|
* + integration + type/role onto meta. */
|
|
@@ -130126,7 +131270,7 @@ function buildCcuGatewayCandidate(input) {
|
|
|
130126
131270
|
const adoptedId = input.adopted.get(nativeId) ?? null;
|
|
130127
131271
|
return {
|
|
130128
131272
|
childNativeId: nativeId,
|
|
130129
|
-
name:
|
|
131273
|
+
name: gatewayDeviceName("Homematic", "CCU3"),
|
|
130130
131274
|
type: DeviceType.Gateway,
|
|
130131
131275
|
status: input.online ? "online" : "offline",
|
|
130132
131276
|
metadata: {
|
|
@@ -130395,7 +131539,7 @@ function buildHmAdoptionProvider(deps) {
|
|
|
130395
131539
|
const { deviceId } = await adoptGateway({
|
|
130396
131540
|
integrationId,
|
|
130397
131541
|
nativeId,
|
|
130398
|
-
name: perCandidate?.[nativeId]?.name ??
|
|
131542
|
+
name: perCandidate?.[nativeId]?.name ?? gatewayDeviceName("Homematic", "CCU3")
|
|
130399
131543
|
});
|
|
130400
131544
|
adopted.push({
|
|
130401
131545
|
childNativeId: nativeId,
|
|
@@ -130598,7 +131742,7 @@ function homematicDiscoveryCandidates(proposals) {
|
|
|
130598
131742
|
return proposals.map((found) => ({
|
|
130599
131743
|
stableId: `homematic:${found.id}`,
|
|
130600
131744
|
type: DeviceType.Gateway,
|
|
130601
|
-
suggestedName:
|
|
131745
|
+
suggestedName: defaultIntegrationName("Homematic"),
|
|
130602
131746
|
prefilledConfig: { host: found.host },
|
|
130603
131747
|
setupIntegration: true
|
|
130604
131748
|
}));
|
|
@@ -131500,6 +132644,7 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
|
|
|
131500
132644
|
...buildCcuHeatingHandlers(this.ccuActionDeps()),
|
|
131501
132645
|
...buildCcuPairingHandlers(this.ccuActionDeps()),
|
|
131502
132646
|
...buildCcuConfigHandlers(this.ccuActionDeps()),
|
|
132647
|
+
...buildButtonEventHandlers(this.ccuActionDeps()),
|
|
131503
132648
|
discoverCcu: async () => {
|
|
131504
132649
|
const { candidates } = await this.ctx.api.deviceManager.discoverProvider.mutate({ addonId: this.ctx.id });
|
|
131505
132650
|
const hosts = candidates.map((candidate) => ({
|
|
@@ -131522,12 +132667,38 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
|
|
|
131522
132667
|
listPages: () => HOMEMATIC_PAGES
|
|
131523
132668
|
};
|
|
131524
132669
|
}
|
|
132670
|
+
/** The child a new container stands for, from the live CCU descriptor. */
|
|
132671
|
+
primaryChildPreference(integrationId, address) {
|
|
132672
|
+
const facade = homematicFacades.get(integrationId);
|
|
132673
|
+
if (facade === null) return [];
|
|
132674
|
+
const device = facade.devices().find((candidate) => candidate.address === address);
|
|
132675
|
+
if (device === void 0) return [];
|
|
132676
|
+
return hmPrimaryChildKeys(deriveHmEntitySpecs(device, facade.customEntities().filter((entity) => entity.device === address)));
|
|
132677
|
+
}
|
|
132678
|
+
/** A connected session's facade, or null while the integration is down. */
|
|
132679
|
+
connectedFacade(integrationId) {
|
|
132680
|
+
return this.clients?.sessions().some((session) => session.id === integrationId && session.status === "connected") === true ? homematicFacades.get(integrationId) : null;
|
|
132681
|
+
}
|
|
132682
|
+
/** CCU addresses adopted as containers from one integration. */
|
|
132683
|
+
async adoptedCcuAddresses(integrationId) {
|
|
132684
|
+
const reg = this.ctx.kernel.deviceRegistry;
|
|
132685
|
+
const devices = this.ctx.kernel.devices;
|
|
132686
|
+
const addresses = /* @__PURE__ */ new Set();
|
|
132687
|
+
if (!reg || !devices) return addresses;
|
|
132688
|
+
for (const device of reg.getAllForAddon(this.addonId)) {
|
|
132689
|
+
if (device.parentDeviceId !== null) continue;
|
|
132690
|
+
const config = await devices.loadConfig(device.id).catch(() => ({}));
|
|
132691
|
+
if (config["integrationId"] !== integrationId) continue;
|
|
132692
|
+
if (typeof config["hmEntityKey"] === "string") continue;
|
|
132693
|
+
const address = config["hmAddress"];
|
|
132694
|
+
if (typeof address === "string" && address.length > 0) addresses.add(address);
|
|
132695
|
+
}
|
|
132696
|
+
return addresses;
|
|
132697
|
+
}
|
|
131525
132698
|
/** What the CCU management actions reach: connected sessions only, never a half-started facade. */
|
|
131526
132699
|
ccuActionDeps() {
|
|
131527
132700
|
return {
|
|
131528
|
-
facade: (integrationId) =>
|
|
131529
|
-
return this.clients?.sessions().some((session) => session.id === integrationId && session.status === "connected") === true ? homematicFacades.get(integrationId) : null;
|
|
131530
|
-
},
|
|
132701
|
+
facade: (integrationId) => this.connectedFacade(integrationId),
|
|
131531
132702
|
integrations: () => {
|
|
131532
132703
|
const clients = this.clients;
|
|
131533
132704
|
if (clients === null) return [];
|
|
@@ -131538,7 +132709,12 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
|
|
|
131538
132709
|
connected: connectedIds.has(integrationId)
|
|
131539
132710
|
}));
|
|
131540
132711
|
},
|
|
131541
|
-
logger: this.ctx.logger
|
|
132712
|
+
logger: this.ctx.logger,
|
|
132713
|
+
adoptedAddresses: (integrationId) => this.adoptedCcuAddresses(integrationId),
|
|
132714
|
+
channelLinks: (integrationId) => {
|
|
132715
|
+
const facade = this.connectedFacade(integrationId);
|
|
132716
|
+
return facade === null ? null : channelLinkPort(facade);
|
|
132717
|
+
}
|
|
131542
132718
|
};
|
|
131543
132719
|
}
|
|
131544
132720
|
async onShutdown() {
|
|
@@ -131776,10 +132952,12 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
|
|
|
131776
132952
|
name
|
|
131777
132953
|
};
|
|
131778
132954
|
const stableId = this.generateStableId(DeviceType.Container, config);
|
|
132955
|
+
const primaryChildPreference = this.primaryChildPreference(integrationId, hmAddress);
|
|
131779
132956
|
const device = await devices.create(stableId, HmContainerDevice, config, null, {
|
|
131780
132957
|
type: DeviceType.Container,
|
|
131781
132958
|
name,
|
|
131782
|
-
integrationId
|
|
132959
|
+
integrationId,
|
|
132960
|
+
...primaryChildPreference.length > 0 ? { primaryChildPreference } : {}
|
|
131783
132961
|
});
|
|
131784
132962
|
const children = await devices.getChildren(device.id);
|
|
131785
132963
|
return {
|