@camstack/addon-provider-homematic 1.2.198 → 1.2.200
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 +14 -0
- package/dist/_stub.js +2 -2
- package/dist/{_virtual_mf-localSharedImportMap___mfe_internal__addon_provider_homematic_page-Dn1q938b.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_provider_homematic_page-qmc1Dkr5.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-DELdD34C.mjs +26 -0
- package/dist/addon-provider-homematic.css +1 -1
- package/dist/addon.js +1137 -443
- package/dist/addon.mjs +1137 -443
- package/dist/{hostInit-Bn44sNXl.mjs → hostInit-DD3ofn9q.mjs} +3 -3
- package/dist/remoteEntry.js +1 -1
- package/dist/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__addon_provider_homematic_page__remoteEntry_js-Lmec5QIi.mjs → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__addon_provider_homematic_page__remoteEntry_js-C1yOQF9B.mjs} +1 -1
- package/dist/widgets/_stub.js +1 -1
- package/dist/widgets/{_virtual_mf-localSharedImportMap___mfe_internal__addon_provider_homematic_widgets-CRu7ZKE2.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_provider_homematic_widgets-BIJK_-Yo.mjs} +2 -2
- package/dist/widgets/_virtual_mf___mfe_internal__addon_provider_homematic_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-CcB6r27y.mjs +26 -0
- package/dist/widgets/{hostInit-oD-DrYN6.mjs → hostInit-B6-zj1pa.mjs} +2 -2
- package/dist/widgets/remoteEntry.js +1 -1
- package/package.json +4 -4
- package/dist/_virtual_mf___mfe_internal__addon_provider_homematic_page__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-JVtI9IQh.mjs +0 -26
- package/dist/widgets/_virtual_mf___mfe_internal__addon_provider_homematic_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-BEMWyRfG.mjs +0 -26
package/dist/addon.js
CHANGED
|
@@ -820,7 +820,7 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
|
820
820
|
return EventCategory;
|
|
821
821
|
}({});
|
|
822
822
|
//#endregion
|
|
823
|
-
//#region ../types/dist/composed-stable-id-
|
|
823
|
+
//#region ../types/dist/composed-stable-id-COP6zOXx.mjs
|
|
824
824
|
/**
|
|
825
825
|
import { errMsg } from '@camstack/types'
|
|
826
826
|
* Extract a human-readable message from an unknown error value.
|
|
@@ -833,8 +833,6 @@ function errMsg(err) {
|
|
|
833
833
|
}
|
|
834
834
|
var DeviceType = /* @__PURE__ */ function(DeviceType) {
|
|
835
835
|
DeviceType["Camera"] = "camera";
|
|
836
|
-
/** Legacy stored value, read only by the hub-to-integration migrations; no live device carries it. */
|
|
837
|
-
DeviceType["Hub"] = "hub";
|
|
838
836
|
DeviceType["Light"] = "light";
|
|
839
837
|
DeviceType["Siren"] = "siren";
|
|
840
838
|
DeviceType["Switch"] = "switch";
|
|
@@ -6071,7 +6069,7 @@ var ZodIssueCode = {
|
|
|
6071
6069
|
var ZodFirstPartyTypeKind;
|
|
6072
6070
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
6073
6071
|
//#endregion
|
|
6074
|
-
//#region ../types/dist/sleep-
|
|
6072
|
+
//#region ../types/dist/sleep-B5XPl2YP.mjs
|
|
6075
6073
|
/**
|
|
6076
6074
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
6077
6075
|
* window to float samples (D455).
|
|
@@ -6734,7 +6732,8 @@ async function runAddonMigrations(host, migrations, logger, options = {}) {
|
|
|
6734
6732
|
try {
|
|
6735
6733
|
declaration = await host.declareOwner({
|
|
6736
6734
|
owner,
|
|
6737
|
-
metas: migrations.map((m) => m.meta)
|
|
6735
|
+
metas: migrations.map((m) => m.meta),
|
|
6736
|
+
...options.retired === void 0 ? {} : { retired: [...options.retired] }
|
|
6738
6737
|
});
|
|
6739
6738
|
} catch (err) {
|
|
6740
6739
|
log.error("the migration engine refused or could not take this addon catalogue — none ran", { meta: { error: errMsg(err) } });
|
|
@@ -8667,6 +8666,14 @@ var BaseAddon = class {
|
|
|
8667
8666
|
declareRegistrySwitch(spec) {
|
|
8668
8667
|
this.registrySwitchSpec = spec;
|
|
8669
8668
|
}
|
|
8669
|
+
/**
|
|
8670
|
+
* Ids this addon removed from its catalogue on purpose (`declareRetiredMigrations`): sent with
|
|
8671
|
+
* every declaration so the engine does not read their applied rows as a newer database.
|
|
8672
|
+
*/
|
|
8673
|
+
retiredMigrationIds = [];
|
|
8674
|
+
declareRetiredMigrations(ids) {
|
|
8675
|
+
this.retiredMigrationIds = ids;
|
|
8676
|
+
}
|
|
8670
8677
|
registrySwitchSpec = null;
|
|
8671
8678
|
registrySwitchBound() {
|
|
8672
8679
|
const spec = this.registrySwitchSpec;
|
|
@@ -8690,10 +8697,14 @@ var BaseAddon = class {
|
|
|
8690
8697
|
async runBound(declared, options) {
|
|
8691
8698
|
const added = this.registrySwitchBound();
|
|
8692
8699
|
const migrations = [...declared, ...added];
|
|
8693
|
-
const
|
|
8700
|
+
const widened = options?.only === void 0 || added.length === 0 ? options : {
|
|
8694
8701
|
...options,
|
|
8695
8702
|
only: [...options.only, ...added.map((m) => m.meta.id)]
|
|
8696
8703
|
};
|
|
8704
|
+
const phased = this.retiredMigrationIds.length === 0 ? widened ?? {} : {
|
|
8705
|
+
...widened,
|
|
8706
|
+
retired: this.retiredMigrationIds
|
|
8707
|
+
};
|
|
8697
8708
|
const api = this.ctx.api.migrations;
|
|
8698
8709
|
const report = await runAddonMigrations({
|
|
8699
8710
|
declareOwner: (input) => api.declareOwner.mutate(input),
|
|
@@ -21668,7 +21679,7 @@ Object.freeze({
|
|
|
21668
21679
|
}
|
|
21669
21680
|
});
|
|
21670
21681
|
//#endregion
|
|
21671
|
-
//#region ../types/dist/implemented-methods-
|
|
21682
|
+
//#region ../types/dist/implemented-methods-0xxMOekw.mjs
|
|
21672
21683
|
/**
|
|
21673
21684
|
* The ffmpeg build every CamStack node downloads, per platform and arch.
|
|
21674
21685
|
*
|
|
@@ -47961,69 +47972,6 @@ function eventTypesOfVocabulary(vocabulary) {
|
|
|
47961
47972
|
function findVocabularyEntry(vocabulary, eventType, sourceId) {
|
|
47962
47973
|
return vocabulary.find((entry) => entry.id === eventType && entry.source?.id === sourceId);
|
|
47963
47974
|
}
|
|
47964
|
-
/**
|
|
47965
|
-
* The link an automation made FROM a template carries (#527): which template,
|
|
47966
|
-
* the values the operator filled in, and — when the template has since changed
|
|
47967
|
-
* so that those values no longer fit — the problems that say why.
|
|
47968
|
-
*
|
|
47969
|
-
* It lives inside the recipe (`AutomationRecipe.template`), so the one row in
|
|
47970
|
-
* `core_blocks` stays the one artefact: there is no second store of instances
|
|
47971
|
-
* to drift from the blocks, and deleting the automation deletes the link.
|
|
47972
|
-
* "Convert to a free automation" is dropping this field.
|
|
47973
|
-
*
|
|
47974
|
-
* This file depends on nothing in `recipe.ts`, so the recipe can embed it and
|
|
47975
|
-
* the template engine (`template/automation-template.ts`) can import both.
|
|
47976
|
-
*/
|
|
47977
|
-
/** An `event` input's value: the same three narrowing lists a `device-fired` row takes. */
|
|
47978
|
-
var TemplateEventValueSchema = object({
|
|
47979
|
-
eventIds: array(string().min(1)).min(1).max(64).optional(),
|
|
47980
|
-
sourceIds: array(string().min(1)).min(1).max(64).optional(),
|
|
47981
|
-
kinds: array(EventVocabularyKindSchema).min(1).optional()
|
|
47982
|
-
}).refine((value) => value.eventIds !== void 0 || value.sourceIds !== void 0 || value.kinds !== void 0, { message: "an event names at least one event, part or kind" });
|
|
47983
|
-
/** An `action` input's value: a vocabulary action and its open args. */
|
|
47984
|
-
var TemplateActionValueSchema = object({
|
|
47985
|
-
actionId: string().min(1),
|
|
47986
|
-
args: record$1(string(), unknown()).optional()
|
|
47987
|
-
});
|
|
47988
|
-
/** The value of one non-group input. Which member is right is the input kind's to judge. */
|
|
47989
|
-
var TemplateScalarValueSchema = union([
|
|
47990
|
-
number$1(),
|
|
47991
|
-
string(),
|
|
47992
|
-
boolean(),
|
|
47993
|
-
array(number$1().int().nonnegative()),
|
|
47994
|
-
TemplateEventValueSchema,
|
|
47995
|
-
TemplateActionValueSchema
|
|
47996
|
-
]);
|
|
47997
|
-
var TemplateInputValueSchema = union([TemplateScalarValueSchema, array(record$1(string(), TemplateScalarValueSchema))]);
|
|
47998
|
-
/** Input key → value. */
|
|
47999
|
-
var TemplateInputValuesSchema = record$1(string(), TemplateInputValueSchema);
|
|
48000
|
-
var TemplateInstanceProblemSchema = object({
|
|
48001
|
-
code: _enum([
|
|
48002
|
-
"missing-input",
|
|
48003
|
-
"invalid-input",
|
|
48004
|
-
"invalid-recipe",
|
|
48005
|
-
"missing-template",
|
|
48006
|
-
"edited-by-hand"
|
|
48007
|
-
]),
|
|
48008
|
-
/** Dotted input address (`buttons.2.targets`); absent for a whole-recipe problem. */
|
|
48009
|
-
input: string().optional(),
|
|
48010
|
-
detail: string()
|
|
48011
|
-
});
|
|
48012
|
-
var AutomationTemplateLinkSchema = object({
|
|
48013
|
-
templateId: string().min(1),
|
|
48014
|
-
values: TemplateInputValuesSchema,
|
|
48015
|
-
/**
|
|
48016
|
-
* Fingerprint of the generated code with this literal blanked
|
|
48017
|
-
* (`instanceCodeHash`), stamped by `generateAutomationBlock`. Code that no
|
|
48018
|
-
* longer matches it was edited by hand, and is never regenerated over.
|
|
48019
|
-
*/
|
|
48020
|
-
codeHash: string().optional(),
|
|
48021
|
-
/**
|
|
48022
|
-
* Present when the last re-expansion refused these values. The automation
|
|
48023
|
-
* keeps running the body of its last good expansion; nothing is dropped.
|
|
48024
|
-
*/
|
|
48025
|
-
problems: array(TemplateInstanceProblemSchema).min(1).optional()
|
|
48026
|
-
});
|
|
48027
47975
|
var ExpressionBindingSourceSchema = union([
|
|
48028
47976
|
object({
|
|
48029
47977
|
kind: literal("field").optional(),
|
|
@@ -48059,6 +48007,58 @@ object({
|
|
|
48059
48007
|
path: ["expr"]
|
|
48060
48008
|
});
|
|
48061
48009
|
});
|
|
48010
|
+
Math.PI / 180;
|
|
48011
|
+
/**
|
|
48012
|
+
* WHEN something happens, as data (D983) — the one time vocabulary of the
|
|
48013
|
+
* scheduler and of an automation's schedule leaf. Three shapes, no cron:
|
|
48014
|
+
*
|
|
48015
|
+
* - `clock` — a wall-clock time every day (`07:30`), read in the site's zone;
|
|
48016
|
+
* - `sun` — a sun event (`sunrise`, `sunset`, `dawn`, `dusk`) plus or minus
|
|
48017
|
+
* up to twelve hours, from the site's coordinates;
|
|
48018
|
+
* - `date` — one local date and time (`2026-12-24T18:00`), once.
|
|
48019
|
+
*
|
|
48020
|
+
* A site is a place and its IANA zone ({@link TimeSite}). Every function here
|
|
48021
|
+
* is pure: the zone arithmetic uses `Intl`, no date library.
|
|
48022
|
+
*
|
|
48023
|
+
* Wall-clock honesty across a DST change: a local time that does not exist
|
|
48024
|
+
* (02:30 on the spring-forward day) happens at the first minute that does
|
|
48025
|
+
* (03:00); one that happens twice (02:30 on the fall-back day) happens at its
|
|
48026
|
+
* FIRST occurrence.
|
|
48027
|
+
*/
|
|
48028
|
+
var SunEventSchema = _enum([
|
|
48029
|
+
"sunrise",
|
|
48030
|
+
"sunset",
|
|
48031
|
+
"dawn",
|
|
48032
|
+
"dusk"
|
|
48033
|
+
]);
|
|
48034
|
+
var TimeSpecSchema = discriminatedUnion("kind", [
|
|
48035
|
+
object({
|
|
48036
|
+
kind: literal("clock"),
|
|
48037
|
+
hh: number$1().int().min(0).max(23),
|
|
48038
|
+
mm: number$1().int().min(0).max(59)
|
|
48039
|
+
}),
|
|
48040
|
+
object({
|
|
48041
|
+
kind: literal("sun"),
|
|
48042
|
+
event: SunEventSchema,
|
|
48043
|
+
/** Minutes after the event (negative: before). */
|
|
48044
|
+
offsetMin: number$1().int().min(-720).max(720)
|
|
48045
|
+
}),
|
|
48046
|
+
object({
|
|
48047
|
+
kind: literal("date"),
|
|
48048
|
+
/** `YYYY-MM-DDTHH:mm`, site-local. */
|
|
48049
|
+
local: string().regex(/^(\d{4}-\d{2}-\d{2})T([01]\d|2[0-3]):([0-5]\d)$/, "expected YYYY-MM-DDTHH:mm")
|
|
48050
|
+
})
|
|
48051
|
+
]);
|
|
48052
|
+
/** A day of the week as a schedule names it. */
|
|
48053
|
+
var WeekdayKeySchema = _enum([
|
|
48054
|
+
"mon",
|
|
48055
|
+
"tue",
|
|
48056
|
+
"wed",
|
|
48057
|
+
"thu",
|
|
48058
|
+
"fri",
|
|
48059
|
+
"sat",
|
|
48060
|
+
"sun"
|
|
48061
|
+
]);
|
|
48062
48062
|
/**
|
|
48063
48063
|
* Identity envelope for a device's upstream-system metadata.
|
|
48064
48064
|
*
|
|
@@ -48451,58 +48451,6 @@ function macroOnly(macro) {
|
|
|
48451
48451
|
};
|
|
48452
48452
|
}
|
|
48453
48453
|
}
|
|
48454
|
-
Math.PI / 180;
|
|
48455
|
-
/**
|
|
48456
|
-
* WHEN something happens, as data (D983) — the one time vocabulary of the
|
|
48457
|
-
* scheduler and of an automation's schedule leaf. Three shapes, no cron:
|
|
48458
|
-
*
|
|
48459
|
-
* - `clock` — a wall-clock time every day (`07:30`), read in the site's zone;
|
|
48460
|
-
* - `sun` — a sun event (`sunrise`, `sunset`, `dawn`, `dusk`) plus or minus
|
|
48461
|
-
* up to twelve hours, from the site's coordinates;
|
|
48462
|
-
* - `date` — one local date and time (`2026-12-24T18:00`), once.
|
|
48463
|
-
*
|
|
48464
|
-
* A site is a place and its IANA zone ({@link TimeSite}). Every function here
|
|
48465
|
-
* is pure: the zone arithmetic uses `Intl`, no date library.
|
|
48466
|
-
*
|
|
48467
|
-
* Wall-clock honesty across a DST change: a local time that does not exist
|
|
48468
|
-
* (02:30 on the spring-forward day) happens at the first minute that does
|
|
48469
|
-
* (03:00); one that happens twice (02:30 on the fall-back day) happens at its
|
|
48470
|
-
* FIRST occurrence.
|
|
48471
|
-
*/
|
|
48472
|
-
var SunEventSchema = _enum([
|
|
48473
|
-
"sunrise",
|
|
48474
|
-
"sunset",
|
|
48475
|
-
"dawn",
|
|
48476
|
-
"dusk"
|
|
48477
|
-
]);
|
|
48478
|
-
var TimeSpecSchema = discriminatedUnion("kind", [
|
|
48479
|
-
object({
|
|
48480
|
-
kind: literal("clock"),
|
|
48481
|
-
hh: number$1().int().min(0).max(23),
|
|
48482
|
-
mm: number$1().int().min(0).max(59)
|
|
48483
|
-
}),
|
|
48484
|
-
object({
|
|
48485
|
-
kind: literal("sun"),
|
|
48486
|
-
event: SunEventSchema,
|
|
48487
|
-
/** Minutes after the event (negative: before). */
|
|
48488
|
-
offsetMin: number$1().int().min(-720).max(720)
|
|
48489
|
-
}),
|
|
48490
|
-
object({
|
|
48491
|
-
kind: literal("date"),
|
|
48492
|
-
/** `YYYY-MM-DDTHH:mm`, site-local. */
|
|
48493
|
-
local: string().regex(/^(\d{4}-\d{2}-\d{2})T([01]\d|2[0-3]):([0-5]\d)$/, "expected YYYY-MM-DDTHH:mm")
|
|
48494
|
-
})
|
|
48495
|
-
]);
|
|
48496
|
-
/** A day of the week as a schedule names it. */
|
|
48497
|
-
var WeekdayKeySchema = _enum([
|
|
48498
|
-
"mon",
|
|
48499
|
-
"tue",
|
|
48500
|
-
"wed",
|
|
48501
|
-
"thu",
|
|
48502
|
-
"fri",
|
|
48503
|
-
"sat",
|
|
48504
|
-
"sun"
|
|
48505
|
-
]);
|
|
48506
48454
|
/**
|
|
48507
48455
|
* Hold semantics — "for N seconds" on a leaf of the `when` tree (#498).
|
|
48508
48456
|
*
|
|
@@ -48759,24 +48707,33 @@ var StationaryPresentLeafSchema = object({
|
|
|
48759
48707
|
* (`kind: 'date'`) is refused: only a clock time or a sun event makes a window
|
|
48760
48708
|
* that repeats every day.
|
|
48761
48709
|
*/
|
|
48762
|
-
var
|
|
48763
|
-
kind: literal("time-is"),
|
|
48710
|
+
var timeIsWindowShape = {
|
|
48764
48711
|
between: object({
|
|
48765
48712
|
from: TimeSpecSchema,
|
|
48766
48713
|
to: TimeSpecSchema
|
|
48767
48714
|
}).optional(),
|
|
48768
48715
|
days: array(WeekdayKeySchema).min(1).max(7).optional()
|
|
48769
|
-
}
|
|
48770
|
-
|
|
48716
|
+
};
|
|
48717
|
+
function timeIsWindowProblems(window, ctx) {
|
|
48718
|
+
if (window.between === void 0 && window.days === void 0) ctx.addIssue({
|
|
48771
48719
|
code: "custom",
|
|
48772
48720
|
message: "a time-is leaf needs a between window, days, or both"
|
|
48773
48721
|
});
|
|
48774
|
-
for (const end of ["from", "to"]) if (
|
|
48722
|
+
for (const end of ["from", "to"]) if (window.between?.[end].kind === "date") ctx.addIssue({
|
|
48775
48723
|
code: "custom",
|
|
48776
48724
|
message: "a one-date time cannot bound a daily window: use a clock time or a sun event",
|
|
48777
48725
|
path: ["between", end]
|
|
48778
48726
|
});
|
|
48779
|
-
}
|
|
48727
|
+
}
|
|
48728
|
+
/**
|
|
48729
|
+
* What a `time-is` leaf holds beside its kind, judged by the leaf's own rules.
|
|
48730
|
+
* A template's time-window input stores exactly this.
|
|
48731
|
+
*/
|
|
48732
|
+
var TimeIsWindowSchema = object(timeIsWindowShape).superRefine(timeIsWindowProblems);
|
|
48733
|
+
var TimeIsLeafSchema = object({
|
|
48734
|
+
kind: literal("time-is"),
|
|
48735
|
+
...timeIsWindowShape
|
|
48736
|
+
}).superRefine(timeIsWindowProblems);
|
|
48780
48737
|
/**
|
|
48781
48738
|
* True for the run that one of the named event leaves started. It reads the
|
|
48782
48739
|
* run, not a device: in the tree it is judged against the leaf that fired, in
|
|
@@ -48984,6 +48941,79 @@ function validateWhenTree(when) {
|
|
|
48984
48941
|
return null;
|
|
48985
48942
|
}
|
|
48986
48943
|
/**
|
|
48944
|
+
* The link an automation made FROM a template carries (#527): which template,
|
|
48945
|
+
* the values the operator filled in, and — when the template has since changed
|
|
48946
|
+
* so that those values no longer fit — the problems that say why.
|
|
48947
|
+
*
|
|
48948
|
+
* It lives inside the recipe (`AutomationRecipe.template`), so the one row in
|
|
48949
|
+
* `core_blocks` stays the one artefact: there is no second store of instances
|
|
48950
|
+
* to drift from the blocks, and deleting the automation deletes the link.
|
|
48951
|
+
* "Convert to a free automation" is dropping this field.
|
|
48952
|
+
*
|
|
48953
|
+
* This file depends on nothing in `recipe.ts`, so the recipe can embed it and
|
|
48954
|
+
* the template engine (`template/automation-template.ts`) can import both.
|
|
48955
|
+
*/
|
|
48956
|
+
/** An `event` input's value: the same three narrowing lists a `device-fired` row takes. */
|
|
48957
|
+
var TemplateEventValueSchema = object({
|
|
48958
|
+
eventIds: array(string().min(1)).min(1).max(64).optional(),
|
|
48959
|
+
sourceIds: array(string().min(1)).min(1).max(64).optional(),
|
|
48960
|
+
kinds: array(EventVocabularyKindSchema).min(1).optional()
|
|
48961
|
+
}).refine((value) => value.eventIds !== void 0 || value.sourceIds !== void 0 || value.kinds !== void 0, { message: "an event names at least one event, part or kind" });
|
|
48962
|
+
/** An `action` input's value: a vocabulary action and its open args. */
|
|
48963
|
+
var TemplateActionValueSchema = object({
|
|
48964
|
+
actionId: string().min(1),
|
|
48965
|
+
args: record$1(string(), unknown()).optional()
|
|
48966
|
+
});
|
|
48967
|
+
/**
|
|
48968
|
+
* A `time-window` input's value: what a `time-is` leaf holds beside its kind.
|
|
48969
|
+
* "No limit" is the input left without a value, never an empty object.
|
|
48970
|
+
*/
|
|
48971
|
+
var TemplateTimeWindowValueSchema = TimeIsWindowSchema;
|
|
48972
|
+
var TemplateEntriesValueSchema = array(record$1(string(), unknown()));
|
|
48973
|
+
/** The value of one non-group input. Which member is right is the input kind's to judge. */
|
|
48974
|
+
var TemplateScalarValueSchema = union([
|
|
48975
|
+
number$1(),
|
|
48976
|
+
string(),
|
|
48977
|
+
boolean(),
|
|
48978
|
+
array(number$1().int().nonnegative()),
|
|
48979
|
+
TemplateEventValueSchema,
|
|
48980
|
+
TemplateActionValueSchema,
|
|
48981
|
+
TemplateTimeWindowValueSchema,
|
|
48982
|
+
TemplateEntriesValueSchema
|
|
48983
|
+
]);
|
|
48984
|
+
/** What a group row holds under one key: a value, or the rows of a group it nests. */
|
|
48985
|
+
var TemplateRowValueSchema = union([TemplateScalarValueSchema, array(record$1(string(), TemplateScalarValueSchema))]);
|
|
48986
|
+
var TemplateInputValueSchema = union([TemplateScalarValueSchema, array(record$1(string(), TemplateRowValueSchema))]);
|
|
48987
|
+
/** Input key → value. */
|
|
48988
|
+
var TemplateInputValuesSchema = record$1(string(), TemplateInputValueSchema);
|
|
48989
|
+
var TemplateInstanceProblemSchema = object({
|
|
48990
|
+
code: _enum([
|
|
48991
|
+
"missing-input",
|
|
48992
|
+
"invalid-input",
|
|
48993
|
+
"invalid-recipe",
|
|
48994
|
+
"missing-template",
|
|
48995
|
+
"edited-by-hand"
|
|
48996
|
+
]),
|
|
48997
|
+
/** Dotted input address (`buttons.2.targets`, `buttons.0.commands.1.targets`); absent for a whole-recipe problem. */
|
|
48998
|
+
input: string().optional(),
|
|
48999
|
+
detail: string()
|
|
49000
|
+
});
|
|
49001
|
+
var AutomationTemplateLinkSchema = object({
|
|
49002
|
+
templateId: string().min(1),
|
|
49003
|
+
values: TemplateInputValuesSchema,
|
|
49004
|
+
/**
|
|
49005
|
+
* Fingerprint of the generated code with this literal blanked
|
|
49006
|
+
* (`instanceCodeHash`), stamped by `generateAutomationBlock`. Code that no
|
|
49007
|
+
* longer matches it was edited by hand, and is never regenerated over.
|
|
49008
|
+
*/
|
|
49009
|
+
codeHash: string().optional(),
|
|
49010
|
+
/**
|
|
49011
|
+
* Present when the last re-expansion refused these values. The automation
|
|
49012
|
+
* keeps running the body of its last good expansion; nothing is dropped.
|
|
49013
|
+
*/
|
|
49014
|
+
problems: array(TemplateInstanceProblemSchema).min(1).optional()
|
|
49015
|
+
});
|
|
49016
|
+
/**
|
|
48987
49017
|
* The recipe shape before the single `when` tree: a flat list of triggers
|
|
48988
49018
|
* (OR'd, each an instant) and an optional condition tree. Stored recipes —
|
|
48989
49019
|
* the `AUTOMATION_RECIPE` literal of every block saved so far, and whatever an
|
|
@@ -57522,7 +57552,7 @@ var mediaPlayerCapability = {
|
|
|
57522
57552
|
]
|
|
57523
57553
|
}
|
|
57524
57554
|
};
|
|
57525
|
-
DeviceType.Camera, DeviceType.Sensor, DeviceType.Button, DeviceType.Switch, DeviceType.PetFeeder, DeviceType.Container, DeviceType.Climate, DeviceType.EventEmitter, DeviceType.Camera, DeviceType.
|
|
57555
|
+
DeviceType.Camera, DeviceType.Sensor, DeviceType.Button, DeviceType.Switch, DeviceType.PetFeeder, DeviceType.Container, DeviceType.Climate, DeviceType.EventEmitter, DeviceType.Camera, 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.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, DeviceType.HeatPump, DeviceType.EnergySystem, DeviceType.Camera, DeviceType.Fan, DeviceType.Fan, DeviceType.Fan, DeviceType.Fan, DeviceType.Fan, DeviceType.Fan, DeviceType.Fan, DeviceType.Fan, DeviceType.Fan, DeviceType.Fan, DeviceType.Lock, DeviceType.Camera, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Gateway, DeviceType.Camera, DeviceType.Sensor, DeviceType.MediaPlayer, DeviceType.Vacuum, DeviceType.Generic, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.PetFountain, DeviceType.Fan, DeviceType.Humidifier, DeviceType.Climate, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.MediaPlayer, DeviceType.WaterHeater, DeviceType.Humidifier, DeviceType.Fan, DeviceType.Climate, DeviceType.PetFeeder, DeviceType.MediaPlayer;
|
|
57526
57556
|
var NUMBER = {
|
|
57527
57557
|
kind: "fixed",
|
|
57528
57558
|
result: ["number"]
|
|
@@ -61849,7 +61879,7 @@ var TransitionsStatusSchema = object({
|
|
|
61849
61879
|
/** Refused rows since start, by reason. */
|
|
61850
61880
|
refused: record$1(string(), number$1())
|
|
61851
61881
|
});
|
|
61852
|
-
Object.values(DeviceType).filter((type) => type !== DeviceType.
|
|
61882
|
+
Object.values(DeviceType).filter((type) => type !== DeviceType.Container), method(object({
|
|
61853
61883
|
deviceId: number$1().int(),
|
|
61854
61884
|
capName: string().optional(),
|
|
61855
61885
|
actorKind: TransitionActorKindSchema.optional(),
|
|
@@ -65796,7 +65826,7 @@ var HeroSceneSchema = object({
|
|
|
65796
65826
|
/** 0..1: volume, cover position, cycle progress. */
|
|
65797
65827
|
level: number$1().min(0).max(1).nullable()
|
|
65798
65828
|
});
|
|
65799
|
-
DeviceType.Camera, DeviceType.
|
|
65829
|
+
DeviceType.Camera, 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.EnergySystem, 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;
|
|
65800
65830
|
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;
|
|
65801
65831
|
var HeroRowIdSchema = _enum([
|
|
65802
65832
|
"progress",
|
|
@@ -70552,7 +70582,9 @@ method(object({}), object({ entries: array(MigrationLedgerEntrySchema) }), { aut
|
|
|
70552
70582
|
auth: "admin"
|
|
70553
70583
|
}), method(object({
|
|
70554
70584
|
owner: string().min(1),
|
|
70555
|
-
metas: array(MigrationMetaSchema)
|
|
70585
|
+
metas: array(MigrationMetaSchema),
|
|
70586
|
+
/** Ids the owner deliberately removed: an applied row of one is fine, never "newer". */
|
|
70587
|
+
retired: array(string().min(1)).optional()
|
|
70556
70588
|
}), object({
|
|
70557
70589
|
bootId: string(),
|
|
70558
70590
|
snapshot: _enum([
|
|
@@ -86219,7 +86251,10 @@ object({
|
|
|
86219
86251
|
value: boolean(),
|
|
86220
86252
|
at: number$1()
|
|
86221
86253
|
}).nullable(),
|
|
86222
|
-
/**
|
|
86254
|
+
/**
|
|
86255
|
+
* Retired: a sent source is never a state (an infrared set cannot report its
|
|
86256
|
+
* input). Kept only so records written before parse; nothing writes or reads it.
|
|
86257
|
+
*/
|
|
86223
86258
|
source: object({
|
|
86224
86259
|
name: string(),
|
|
86225
86260
|
at: number$1()
|
|
@@ -89848,31 +89883,57 @@ var TemplateSelectOptionSchema = object({
|
|
|
89848
89883
|
value: string().min(1),
|
|
89849
89884
|
label: string().min(1).max(80)
|
|
89850
89885
|
});
|
|
89886
|
+
var SelectInputSchema = object({
|
|
89887
|
+
kind: literal("select"),
|
|
89888
|
+
...inputBase,
|
|
89889
|
+
options: array(TemplateSelectOptionSchema).min(1).max(50),
|
|
89890
|
+
default: string().optional()
|
|
89891
|
+
});
|
|
89892
|
+
var BooleanInputSchema = object({
|
|
89893
|
+
kind: literal("boolean"),
|
|
89894
|
+
...inputBase,
|
|
89895
|
+
default: boolean().optional()
|
|
89896
|
+
});
|
|
89897
|
+
/** A limit on when the automation may run; only a `gate` binding reads it. */
|
|
89898
|
+
var TimeWindowInputSchema = object({
|
|
89899
|
+
kind: literal("time-window"),
|
|
89900
|
+
...inputBase
|
|
89901
|
+
});
|
|
89851
89902
|
var TemplateScalarInputSchema = discriminatedUnion("kind", [
|
|
89903
|
+
object({
|
|
89904
|
+
kind: literal("entries"),
|
|
89905
|
+
...inputBase,
|
|
89906
|
+
entry: _enum(["trigger", "step"]),
|
|
89907
|
+
allow: array(string().min(1)).min(1).max(10),
|
|
89908
|
+
maxItems: number$1().int().min(1).max(20).optional()
|
|
89909
|
+
}),
|
|
89852
89910
|
DeviceInputSchema,
|
|
89853
89911
|
EventInputSchema,
|
|
89854
89912
|
ActionInputSchema$1,
|
|
89855
89913
|
NumberInputSchema,
|
|
89856
89914
|
DurationInputSchema,
|
|
89857
89915
|
TextInputSchema,
|
|
89858
|
-
|
|
89859
|
-
|
|
89860
|
-
|
|
89861
|
-
options: array(TemplateSelectOptionSchema).min(1).max(50),
|
|
89862
|
-
default: string().optional()
|
|
89863
|
-
}),
|
|
89864
|
-
object({
|
|
89865
|
-
kind: literal("boolean"),
|
|
89866
|
-
...inputBase,
|
|
89867
|
-
default: boolean().optional()
|
|
89868
|
-
})
|
|
89916
|
+
SelectInputSchema,
|
|
89917
|
+
BooleanInputSchema,
|
|
89918
|
+
TimeWindowInputSchema
|
|
89869
89919
|
]);
|
|
89870
|
-
var
|
|
89920
|
+
var groupBase = {
|
|
89871
89921
|
kind: literal("group"),
|
|
89872
89922
|
...inputBase,
|
|
89873
|
-
|
|
89923
|
+
/** What one row is, in the singular and lower case ("button"): "Add button". */
|
|
89924
|
+
rowLabel: string().min(1).max(40).optional(),
|
|
89874
89925
|
minRows: number$1().int().min(0).max(20).optional(),
|
|
89875
89926
|
maxRows: number$1().int().min(1).max(20).optional()
|
|
89927
|
+
};
|
|
89928
|
+
/** A group inside a group row: its rows hold values only, never another group. */
|
|
89929
|
+
var NestedGroupInputSchema = object({
|
|
89930
|
+
...groupBase,
|
|
89931
|
+
inputs: array(TemplateScalarInputSchema).min(1).max(10)
|
|
89932
|
+
});
|
|
89933
|
+
var TemplateRowInputSchema = discriminatedUnion("kind", [...TemplateScalarInputSchema.options, NestedGroupInputSchema]);
|
|
89934
|
+
var GroupInputSchema = object({
|
|
89935
|
+
...groupBase,
|
|
89936
|
+
inputs: array(TemplateRowInputSchema).min(1).max(10)
|
|
89876
89937
|
});
|
|
89877
89938
|
var TemplateInputSchema = discriminatedUnion("kind", [...TemplateScalarInputSchema.options, GroupInputSchema]);
|
|
89878
89939
|
var TemplatePathSchema = array(union([string().min(1), number$1().int().nonnegative()])).max(24);
|
|
@@ -89883,41 +89944,154 @@ var TemplateValueBindingSchema = object({
|
|
|
89883
89944
|
/** A device value written as a step target (`{ kind: 'devices', ids }`). */
|
|
89884
89945
|
as: literal("target").optional()
|
|
89885
89946
|
});
|
|
89886
|
-
var
|
|
89947
|
+
var TemplateRowIdBindingSchema = object({
|
|
89887
89948
|
kind: literal("row-id"),
|
|
89888
89949
|
path: TemplatePathSchema
|
|
89889
|
-
})
|
|
89890
|
-
|
|
89891
|
-
|
|
89950
|
+
});
|
|
89951
|
+
/**
|
|
89952
|
+
* Appends an `entries` input's elements, verbatim, to the list at `path`. In a
|
|
89953
|
+
* row's bindings `input` is the row's own entries input and `path` is from the
|
|
89954
|
+
* row's item; at the top level, with `in`, it appends the `input` entries of
|
|
89955
|
+
* EVERY row of the group `in` (all buttons' triggers into one `when`), and
|
|
89956
|
+
* without `in` it appends a top-level entries input.
|
|
89957
|
+
*/
|
|
89958
|
+
var TemplateEntriesBindingSchema = object({
|
|
89959
|
+
kind: literal("entries"),
|
|
89892
89960
|
input: inputKey,
|
|
89893
|
-
/** The list in the body the rows are appended to. */
|
|
89894
89961
|
path: TemplatePathSchema,
|
|
89895
|
-
|
|
89896
|
-
|
|
89897
|
-
|
|
89898
|
-
|
|
89899
|
-
|
|
89900
|
-
|
|
89901
|
-
|
|
89902
|
-
|
|
89903
|
-
|
|
89962
|
+
in: inputKey.optional()
|
|
89963
|
+
});
|
|
89964
|
+
/** What fills the item of a row that holds values only. */
|
|
89965
|
+
var TemplateLeafRowBindingSchema = discriminatedUnion("kind", [TemplateValueBindingSchema, TemplateRowIdBindingSchema]);
|
|
89966
|
+
var TemplateRowItemBindingSchema = discriminatedUnion("kind", [
|
|
89967
|
+
TemplateValueBindingSchema,
|
|
89968
|
+
TemplateEntriesBindingSchema,
|
|
89969
|
+
TemplateRowIdBindingSchema,
|
|
89970
|
+
object({
|
|
89971
|
+
kind: literal("row-ids"),
|
|
89972
|
+
/** The nested group whose rows are named. */
|
|
89973
|
+
input: inputKey,
|
|
89974
|
+
path: TemplatePathSchema
|
|
89975
|
+
}),
|
|
89976
|
+
object({
|
|
89977
|
+
kind: literal("rows"),
|
|
89978
|
+
/** The nested group, declared by the parent row's group. */
|
|
89979
|
+
input: inputKey,
|
|
89980
|
+
/** The list the nested rows are appended to, from the parent row's item. */
|
|
89981
|
+
path: TemplatePathSchema,
|
|
89982
|
+
item: unknown(),
|
|
89983
|
+
bindings: array(TemplateLeafRowBindingSchema).max(40)
|
|
89984
|
+
})
|
|
89985
|
+
]);
|
|
89986
|
+
var TemplateBindingSchema = discriminatedUnion("kind", [
|
|
89987
|
+
TemplateValueBindingSchema,
|
|
89988
|
+
TemplateEntriesBindingSchema,
|
|
89989
|
+
object({
|
|
89990
|
+
kind: literal("rows"),
|
|
89991
|
+
input: inputKey,
|
|
89992
|
+
/**
|
|
89993
|
+
* A group the rows of `input` hold: the binding then appends one item per
|
|
89994
|
+
* NESTED row of every row, and its bindings read the nested row.
|
|
89995
|
+
*/
|
|
89996
|
+
nested: inputKey.optional(),
|
|
89997
|
+
/** The list in the body the rows are appended to. */
|
|
89998
|
+
path: TemplatePathSchema,
|
|
89999
|
+
/** The JSON copied once per row. */
|
|
90000
|
+
item: unknown(),
|
|
90001
|
+
bindings: array(TemplateRowItemBindingSchema).max(40)
|
|
90002
|
+
}),
|
|
90003
|
+
object({
|
|
90004
|
+
kind: literal("gate"),
|
|
90005
|
+
/** A top-level `time-window` input. */
|
|
90006
|
+
input: inputKey,
|
|
90007
|
+
path: TemplatePathSchema
|
|
90008
|
+
})
|
|
90009
|
+
]);
|
|
90010
|
+
/** Twice-declared keys and event / action inputs that read no device beside them. */
|
|
90011
|
+
function levelProblems(inputs, path, inRow = false) {
|
|
90012
|
+
const issues = [];
|
|
90013
|
+
const seen = /* @__PURE__ */ new Set();
|
|
90014
|
+
for (const input of inputs) {
|
|
90015
|
+
if (seen.has(input.key)) issues.push({
|
|
89904
90016
|
message: `input "${input.key}" is declared twice`,
|
|
89905
|
-
path
|
|
90017
|
+
path
|
|
89906
90018
|
});
|
|
89907
|
-
|
|
89908
|
-
|
|
89909
|
-
|
|
89910
|
-
|
|
89911
|
-
if (scalar.deviceInput === void 0) continue;
|
|
89912
|
-
const device = siblings.find((s) => s.key === scalar.deviceInput);
|
|
89913
|
-
if (device === void 0 || device.kind !== "device") ctx.addIssue({
|
|
89914
|
-
code: "custom",
|
|
89915
|
-
message: `"${scalar.key}" reads the device input "${scalar.deviceInput}", which is not a device input beside it`,
|
|
89916
|
-
path: ["inputs", index]
|
|
89917
|
-
});
|
|
90019
|
+
seen.add(input.key);
|
|
90020
|
+
if (input.kind === "group") {
|
|
90021
|
+
issues.push(...levelProblems(input.inputs, path, true));
|
|
90022
|
+
continue;
|
|
89918
90023
|
}
|
|
90024
|
+
if (input.kind === "time-window" && inRow) issues.push({
|
|
90025
|
+
message: `time window "${input.key}" limits the whole automation: it is not a row input`,
|
|
90026
|
+
path
|
|
90027
|
+
});
|
|
90028
|
+
if (input.kind !== "event" && input.kind !== "action") continue;
|
|
90029
|
+
if (input.deviceInput === void 0) continue;
|
|
90030
|
+
const device = inputs.find((sibling) => sibling.key === input.deviceInput);
|
|
90031
|
+
if (device === void 0 || device.kind !== "device") issues.push({
|
|
90032
|
+
message: `"${input.key}" reads the device input "${input.deviceInput}", which is not a device input beside it`,
|
|
90033
|
+
path
|
|
90034
|
+
});
|
|
90035
|
+
}
|
|
90036
|
+
return issues;
|
|
90037
|
+
}
|
|
90038
|
+
function nestedGroupOf(group, key) {
|
|
90039
|
+
const found = group.inputs.find((input) => input.key === key);
|
|
90040
|
+
return found !== void 0 && found.kind === "group" ? found : void 0;
|
|
90041
|
+
}
|
|
90042
|
+
function leafBindingProblems(bindings, owner) {
|
|
90043
|
+
const issues = [];
|
|
90044
|
+
for (const row of bindings) {
|
|
90045
|
+
if (row.kind === "row-id") continue;
|
|
90046
|
+
if (row.kind === "value") {
|
|
90047
|
+
const input = owner.inputs.find((i) => i.key === row.input);
|
|
90048
|
+
if (input === void 0) issues.push(`row binding names "${row.input}", which group "${owner.key}" does not declare`);
|
|
90049
|
+
else if (input.kind === "group") issues.push(`group "${input.key}" is bound with rows, not a value`);
|
|
90050
|
+
else if (input.kind === "entries") issues.push(`entries "${input.key}" are bound with entries, not a value`);
|
|
90051
|
+
continue;
|
|
90052
|
+
}
|
|
90053
|
+
const nested = owner.inputs.find((i) => i.key === row.input);
|
|
90054
|
+
if (row.kind === "entries") {
|
|
90055
|
+
if (nested === void 0 || nested.kind !== "entries") issues.push(`"${row.input}" is not an entries input inside "${owner.key}"`);
|
|
90056
|
+
continue;
|
|
90057
|
+
}
|
|
90058
|
+
if (row.kind === "row-ids") {
|
|
90059
|
+
if (nested === void 0 || nested.kind !== "group" && nested.kind !== "entries") issues.push(`"${row.input}" is not a group or entries input inside "${owner.key}"`);
|
|
90060
|
+
continue;
|
|
90061
|
+
}
|
|
90062
|
+
if (nested === void 0 || nested.kind !== "group") {
|
|
90063
|
+
issues.push(`"${row.input}" is not a group inside "${owner.key}"`);
|
|
90064
|
+
continue;
|
|
90065
|
+
}
|
|
90066
|
+
issues.push(...leafBindingProblems(row.bindings, nested));
|
|
90067
|
+
}
|
|
90068
|
+
return issues;
|
|
90069
|
+
}
|
|
90070
|
+
function rowsBindingProblems(binding, group) {
|
|
90071
|
+
if (binding.nested === void 0) return leafBindingProblems(binding.bindings, group);
|
|
90072
|
+
const nested = nestedGroupOf(group, binding.nested);
|
|
90073
|
+
if (nested === void 0) return [`"${binding.nested}" is not a group inside "${group.key}"`];
|
|
90074
|
+
return leafBindingProblems(binding.bindings, nested);
|
|
90075
|
+
}
|
|
90076
|
+
function bindingProblems(payload, ctx) {
|
|
90077
|
+
const byKey = /* @__PURE__ */ new Map();
|
|
90078
|
+
for (const input of payload.inputs) byKey.set(input.key, input);
|
|
90079
|
+
for (const issue of levelProblems(payload.inputs, ["inputs"])) ctx.addIssue({
|
|
90080
|
+
code: "custom",
|
|
90081
|
+
message: issue.message,
|
|
90082
|
+
path: [...issue.path]
|
|
89919
90083
|
});
|
|
89920
90084
|
payload.bindings.forEach((binding, index) => {
|
|
90085
|
+
if (binding.kind === "entries" && binding.in !== void 0) {
|
|
90086
|
+
const group = byKey.get(binding.in);
|
|
90087
|
+
const entries = group !== void 0 && group.kind === "group" ? group.inputs.find((i) => i.key === binding.input) : void 0;
|
|
90088
|
+
if (entries === void 0 || entries.kind !== "entries") ctx.addIssue({
|
|
90089
|
+
code: "custom",
|
|
90090
|
+
message: `"${binding.input}" is not an entries input inside the group "${binding.in}"`,
|
|
90091
|
+
path: ["bindings", index]
|
|
90092
|
+
});
|
|
90093
|
+
return;
|
|
90094
|
+
}
|
|
89921
90095
|
const input = byKey.get(binding.input);
|
|
89922
90096
|
if (input === void 0) {
|
|
89923
90097
|
ctx.addIssue({
|
|
@@ -89932,6 +90106,18 @@ function bindingProblems(payload, ctx) {
|
|
|
89932
90106
|
message: `group "${input.key}" is bound with rows, not a value`,
|
|
89933
90107
|
path: ["bindings", index]
|
|
89934
90108
|
});
|
|
90109
|
+
if (binding.kind === "entries" !== (input.kind === "entries") && binding.kind !== "rows") {
|
|
90110
|
+
if (binding.kind === "entries" || binding.kind === "value") ctx.addIssue({
|
|
90111
|
+
code: "custom",
|
|
90112
|
+
message: binding.kind === "entries" ? `entries bindings read an entries input: "${input.key}" is ${input.kind}` : `entries "${input.key}" are bound with entries, not a value`,
|
|
90113
|
+
path: ["bindings", index]
|
|
90114
|
+
});
|
|
90115
|
+
}
|
|
90116
|
+
if (binding.kind === "gate" !== (input.kind === "time-window")) ctx.addIssue({
|
|
90117
|
+
code: "custom",
|
|
90118
|
+
message: `a gate reads a time window and a time window is bound with a gate: "${input.key}" is ${input.kind}`,
|
|
90119
|
+
path: ["bindings", index]
|
|
90120
|
+
});
|
|
89935
90121
|
if (binding.kind === "rows") {
|
|
89936
90122
|
if (input.kind !== "group") {
|
|
89937
90123
|
ctx.addIssue({
|
|
@@ -89941,9 +90127,9 @@ function bindingProblems(payload, ctx) {
|
|
|
89941
90127
|
});
|
|
89942
90128
|
return;
|
|
89943
90129
|
}
|
|
89944
|
-
for (const
|
|
90130
|
+
for (const message of rowsBindingProblems(binding, input)) ctx.addIssue({
|
|
89945
90131
|
code: "custom",
|
|
89946
|
-
message
|
|
90132
|
+
message,
|
|
89947
90133
|
path: ["bindings", index]
|
|
89948
90134
|
});
|
|
89949
90135
|
}
|
|
@@ -94999,7 +95185,7 @@ var BaseDeviceProvider = class extends BaseAddon {
|
|
|
94999
95185
|
}
|
|
95000
95186
|
};
|
|
95001
95187
|
DeviceType.HeatPump;
|
|
95002
|
-
DeviceType.Cover, DeviceType.Valve, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.HeatPump, DeviceType.EnergySystem, DeviceType.Camera, DeviceType.
|
|
95188
|
+
DeviceType.Cover, DeviceType.Valve, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.HeatPump, DeviceType.EnergySystem, DeviceType.Camera, 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;
|
|
95003
95189
|
new Set(Object.values(DeviceType));
|
|
95004
95190
|
/** Parses the raw slice with the cap's own schema; `undefined` when it does not parse. */
|
|
95005
95191
|
function contribution(cap, schema, build) {
|
|
@@ -97044,7 +97230,7 @@ var HEAT_PUMP_FAMILY_CONTRIBUTIONS = { "heat-pump-status": contribution("heat-pu
|
|
|
97044
97230
|
...Object.values(CLIMATE_FAMILY_CONTRIBUTIONS),
|
|
97045
97231
|
...Object.values(HEAT_PUMP_FAMILY_CONTRIBUTIONS)
|
|
97046
97232
|
];
|
|
97047
|
-
DeviceType.Camera, DeviceType.
|
|
97233
|
+
DeviceType.Camera, 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.EnergySystem, 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;
|
|
97048
97234
|
/**
|
|
97049
97235
|
* Who looks like what (D1023). One look per {@link DeviceType}, refined by a
|
|
97050
97236
|
* {@link DeviceRole} where the role changes how the device reads (a leak
|
|
@@ -97688,7 +97874,7 @@ lookOf({
|
|
|
97688
97874
|
standby: MUTED
|
|
97689
97875
|
});
|
|
97690
97876
|
DeviceType.Climate;
|
|
97691
|
-
DeviceType.Camera, DeviceType.
|
|
97877
|
+
DeviceType.Camera, 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.EnergySystem, 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;
|
|
97692
97878
|
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;
|
|
97693
97879
|
Object.freeze({
|
|
97694
97880
|
"accessories.getStatus": {
|
|
@@ -108159,7 +108345,7 @@ function offered(received) {
|
|
|
108159
108345
|
};
|
|
108160
108346
|
}
|
|
108161
108347
|
offered(HA_AS), withheld(HOMEKIT_REASON), withheld(ALEXA_REASON), withheld(GOOGLE_REASON), withheld(MATTER_REASON);
|
|
108162
|
-
DeviceType.Camera, DeviceType.
|
|
108348
|
+
DeviceType.Camera, DeviceType.Light, DeviceType.Siren, DeviceType.Switch, DeviceType.Sensor, DeviceType.Climate, DeviceType.HeatPump, DeviceType.EnergySystem, 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;
|
|
108163
108349
|
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;
|
|
108164
108350
|
new Set(Object.values(DeviceType));
|
|
108165
108351
|
new Set(Object.values(DeviceRole));
|
|
@@ -113712,6 +113898,17 @@ function buildCcuDeviceStateHandlers(deps) {
|
|
|
113712
113898
|
channels: device.channels.map(toChannelValues)
|
|
113713
113899
|
};
|
|
113714
113900
|
},
|
|
113901
|
+
/**
|
|
113902
|
+
* Read-only: why a key does not deliver presses. The library reads the
|
|
113903
|
+
* central link, direct links, VALUES/MASTER, the CCU's own data point
|
|
113904
|
+
* timestamps and the programs using the key, and when this client last
|
|
113905
|
+
* received each event — every section on its own (nodehomematic 0.8.0).
|
|
113906
|
+
*/
|
|
113907
|
+
diagnoseCcuKeyEvents: async (input) => {
|
|
113908
|
+
const facade = requireFacade(deps, input.integrationId);
|
|
113909
|
+
requireDevice(facade.devices(), input.address);
|
|
113910
|
+
return facade.diagnoseKeyEvents(input.address);
|
|
113911
|
+
},
|
|
113715
113912
|
setCcuValue: async (input) => {
|
|
113716
113913
|
requireConfirmed(input.confirmed);
|
|
113717
113914
|
const facade = requireFacade(deps, input.integrationId);
|
|
@@ -132281,7 +132478,7 @@ function serializeValue(value) {
|
|
|
132281
132478
|
if (value instanceof Date) return `<value><dateTime.iso8601>${formatDateTime(value)}</dateTime.iso8601></value>`;
|
|
132282
132479
|
if (value instanceof Uint8Array) return `<value><base64>${Buffer.from(value).toString("base64")}</base64></value>`;
|
|
132283
132480
|
if (Array.isArray(value)) return `<value><array><data>${value.map((item) => serializeValue(item)).join("")}</data></array></value>`;
|
|
132284
|
-
return `<value><struct>${Object.entries(value).map(([
|
|
132481
|
+
return `<value><struct>${Object.entries(value).map(([name2, member]) => `<member><name>${escapeXml(name2)}</name>${serializeValue(member)}</member>`).join("")}</struct></value>`;
|
|
132285
132482
|
}
|
|
132286
132483
|
function paramsBlock(params) {
|
|
132287
132484
|
if (params.length === 0) return "<params></params>";
|
|
@@ -132364,8 +132561,8 @@ function parseStruct(structChildren) {
|
|
|
132364
132561
|
const nameNodes = childrenOf(member, "name");
|
|
132365
132562
|
const valueNodes = childrenOf(member, "value");
|
|
132366
132563
|
if (nameNodes === void 0 || valueNodes === void 0) continue;
|
|
132367
|
-
const
|
|
132368
|
-
result[
|
|
132564
|
+
const name2 = textOf(nameNodes);
|
|
132565
|
+
result[name2] = parseValue(valueNodes);
|
|
132369
132566
|
}
|
|
132370
132567
|
return result;
|
|
132371
132568
|
}
|
|
@@ -132632,11 +132829,11 @@ var InterfaceClient = class {
|
|
|
132632
132829
|
* these four strings. Not retried: a second attempt after a lost answer
|
|
132633
132830
|
* could race the first.
|
|
132634
132831
|
*/
|
|
132635
|
-
async addLink(sender, receiver,
|
|
132832
|
+
async addLink(sender, receiver, name2, description) {
|
|
132636
132833
|
await this.callGuarded("addLink", [
|
|
132637
132834
|
sender,
|
|
132638
132835
|
receiver,
|
|
132639
|
-
|
|
132836
|
+
name2,
|
|
132640
132837
|
description
|
|
132641
132838
|
]);
|
|
132642
132839
|
}
|
|
@@ -133539,9 +133736,9 @@ function isRecord(value) {
|
|
|
133539
133736
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
133540
133737
|
}
|
|
133541
133738
|
function validName(raw, what) {
|
|
133542
|
-
const
|
|
133543
|
-
if (
|
|
133544
|
-
return
|
|
133739
|
+
const name2 = raw.trim();
|
|
133740
|
+
if (name2 === "" || name2.length > MAX_NAME || CONTROL_CHARS2.test(name2)) throw new ValidationError(`${what} name must be 1..${MAX_NAME} characters without control characters.`);
|
|
133741
|
+
return name2;
|
|
133545
133742
|
}
|
|
133546
133743
|
function validRoomId(id) {
|
|
133547
133744
|
if (!ROOM_ID.test(id)) throw new ValidationError(`Invalid room id "${id}".`);
|
|
@@ -133576,11 +133773,11 @@ var CcuTopology = class {
|
|
|
133576
133773
|
/** Rename a device, and with `renameChannels` every channel to `<name>:<index>`. */
|
|
133577
133774
|
async renameDevice(address, rawName, renameChannels) {
|
|
133578
133775
|
if (!DEVICE_ADDRESS.test(address)) throw new ValidationError(`Invalid device address "${address}".`);
|
|
133579
|
-
const
|
|
133776
|
+
const name2 = validName(rawName, "Device");
|
|
133580
133777
|
const label = "ReGa.runScript(renameDevice)";
|
|
133581
133778
|
const answer = okOf(await this.#rega(label, RENAME_DEVICE, {
|
|
133582
133779
|
address,
|
|
133583
|
-
name,
|
|
133780
|
+
name: name2,
|
|
133584
133781
|
channels: renameChannels ? "1" : "0"
|
|
133585
133782
|
}), label);
|
|
133586
133783
|
if (answer["ok"] !== true) throw new ValidationError(`Unknown device "${address}".`);
|
|
@@ -133602,11 +133799,11 @@ var CcuTopology = class {
|
|
|
133602
133799
|
/** Rename one channel; resolves with the name the CCU stored. */
|
|
133603
133800
|
async renameChannel(address, rawName) {
|
|
133604
133801
|
validChannelAddress(address);
|
|
133605
|
-
const
|
|
133802
|
+
const name2 = validName(rawName, "Channel");
|
|
133606
133803
|
const label = "ReGa.runScript(renameChannel)";
|
|
133607
133804
|
const answer = okOf(await this.#rega(label, RENAME_CHANNEL, {
|
|
133608
133805
|
address,
|
|
133609
|
-
name
|
|
133806
|
+
name: name2
|
|
133610
133807
|
}), label);
|
|
133611
133808
|
if (answer["ok"] !== true) throw new ValidationError(`Unknown channel "${address}".`);
|
|
133612
133809
|
return {
|
|
@@ -133625,10 +133822,10 @@ var CcuTopology = class {
|
|
|
133625
133822
|
}
|
|
133626
133823
|
/** Create an empty room; a room of the same name is a {@link ValidationError}. */
|
|
133627
133824
|
async createRoom(rawName) {
|
|
133628
|
-
const
|
|
133825
|
+
const name2 = validName(rawName, "Room");
|
|
133629
133826
|
const label = "ReGa.runScript(createRoom)";
|
|
133630
|
-
const answer = okOf(await this.#rega(label, CREATE_ROOM, { name }), label);
|
|
133631
|
-
if (answer["error"] === "exists") throw new ValidationError(`A room named "${
|
|
133827
|
+
const answer = okOf(await this.#rega(label, CREATE_ROOM, { name: name2 }), label);
|
|
133828
|
+
if (answer["error"] === "exists") throw new ValidationError(`A room named "${name2}" already exists.`);
|
|
133632
133829
|
const room = toRoom({
|
|
133633
133830
|
...answer,
|
|
133634
133831
|
channels: []
|
|
@@ -133638,11 +133835,11 @@ var CcuTopology = class {
|
|
|
133638
133835
|
}
|
|
133639
133836
|
/** Rename a room by id. */
|
|
133640
133837
|
async renameRoom(id, rawName) {
|
|
133641
|
-
const
|
|
133838
|
+
const name2 = validName(rawName, "Room");
|
|
133642
133839
|
const label = "ReGa.runScript(renameRoom)";
|
|
133643
133840
|
if (okOf(await this.#rega(label, RENAME_ROOM, {
|
|
133644
133841
|
id: validRoomId(id),
|
|
133645
|
-
name
|
|
133842
|
+
name: name2
|
|
133646
133843
|
}), label)["ok"] !== true) throw new ValidationError(`Unknown room "${id}".`);
|
|
133647
133844
|
}
|
|
133648
133845
|
/** Delete a room by id; an unerasable room is a {@link ValidationError}. */
|
|
@@ -133674,25 +133871,35 @@ var CcuTopology = class {
|
|
|
133674
133871
|
var DATAPOINT_NAME = /^[0-9A-Za-z_-]+\.[0-9A-Za-z_-]+:\d+\.PRESS_(?:SHORT|LONG)$/;
|
|
133675
133872
|
function checkedDatapoints(datapoints) {
|
|
133676
133873
|
if (datapoints.length === 0) throw new ValidationError("A key event program needs at least one data point.");
|
|
133677
|
-
for (const
|
|
133874
|
+
for (const name2 of datapoints) if (!DATAPOINT_NAME.test(name2)) throw new ValidationError(`Invalid key data point "${name2}".`);
|
|
133678
133875
|
return datapoints;
|
|
133679
133876
|
}
|
|
133680
133877
|
var FIND_PROGRAM = `string sName = "##name##";
|
|
133681
133878
|
object oPrograms = dom.GetObject(ID_PROGRAMS);
|
|
133682
133879
|
object oProg;
|
|
133683
133880
|
string sPid;
|
|
133881
|
+
string sIds = "";
|
|
133882
|
+
string sIdSep = "";
|
|
133883
|
+
integer iMatches = 0;
|
|
133684
133884
|
foreach(sPid, oPrograms.EnumUsedIDs()) {
|
|
133685
133885
|
object oCand = dom.GetObject(sPid);
|
|
133686
133886
|
if (oCand) {
|
|
133687
133887
|
if (oCand.Name() == sName) {
|
|
133688
133888
|
oProg = oCand;
|
|
133889
|
+
sIds = sIds # sIdSep # "\\"" # sPid # "\\"";
|
|
133890
|
+
sIdSep = ",";
|
|
133891
|
+
iMatches = iMatches + 1;
|
|
133689
133892
|
}
|
|
133690
133893
|
}
|
|
133691
133894
|
}`;
|
|
133895
|
+
var UNLESS_DUPLICATE = `if (iMatches > 1) {
|
|
133896
|
+
Write("{\\"error\\":\\"duplicate\\",\\"ids\\":[" # sIds # "]}");
|
|
133897
|
+
} else {`;
|
|
133692
133898
|
function buildEnsureKeyEventProgram(datapoints) {
|
|
133693
133899
|
const dps = checkedDatapoints(datapoints);
|
|
133694
133900
|
return `! nodehomematic:ensureKeyEventProgram
|
|
133695
133901
|
${FIND_PROGRAM}
|
|
133902
|
+
${UNLESS_DUPLICATE}
|
|
133696
133903
|
string sMissing = "";
|
|
133697
133904
|
string sMissSep = "";
|
|
133698
133905
|
${dps.map((dp, i) => `object oDp${i} = dom.GetObject("${dp}");
|
|
@@ -133740,18 +133947,22 @@ oSc.ConditionChannel(oDp${i}.Channel());`).join("\n")}
|
|
|
133740
133947
|
Write("false");
|
|
133741
133948
|
}
|
|
133742
133949
|
Write("}");
|
|
133950
|
+
}
|
|
133743
133951
|
}`;
|
|
133744
133952
|
}
|
|
133745
133953
|
var REMOVE_KEY_EVENT_PROGRAM = `! nodehomematic:removeKeyEventProgram
|
|
133746
133954
|
${FIND_PROGRAM}
|
|
133747
|
-
|
|
133748
|
-
|
|
133749
|
-
|
|
133750
|
-
}
|
|
133751
|
-
|
|
133955
|
+
${UNLESS_DUPLICATE}
|
|
133956
|
+
if (oProg) {
|
|
133957
|
+
dom.DeleteObject(oProg.ID());
|
|
133958
|
+
Write("{\\"removed\\":true}");
|
|
133959
|
+
} else {
|
|
133960
|
+
Write("{\\"removed\\":false}");
|
|
133961
|
+
}
|
|
133752
133962
|
}`;
|
|
133753
133963
|
var GET_KEY_EVENT_PROGRAM = `! nodehomematic:getKeyEventProgram
|
|
133754
133964
|
${FIND_PROGRAM}
|
|
133965
|
+
${UNLESS_DUPLICATE}
|
|
133755
133966
|
if (!oProg) {
|
|
133756
133967
|
Write("{\\"found\\":false}");
|
|
133757
133968
|
} else {
|
|
@@ -133777,7 +133988,32 @@ if (!oProg) {
|
|
|
133777
133988
|
}
|
|
133778
133989
|
}
|
|
133779
133990
|
Write("]}");
|
|
133991
|
+
}
|
|
133992
|
+
}`;
|
|
133993
|
+
var PROGRAM_ID = /^\d+$/;
|
|
133994
|
+
function buildDeleteProgram(programId) {
|
|
133995
|
+
if (!PROGRAM_ID.test(programId)) throw new ValidationError(`Invalid program id "${programId}".`);
|
|
133996
|
+
return `! nodehomematic:deleteProgram
|
|
133997
|
+
string sId = "${programId}";
|
|
133998
|
+
string sPid;
|
|
133999
|
+
boolean bProgram = false;
|
|
134000
|
+
foreach(sPid, dom.GetObject(ID_PROGRAMS).EnumUsedIDs()) {
|
|
134001
|
+
if (sPid == sId) {
|
|
134002
|
+
bProgram = true;
|
|
134003
|
+
}
|
|
134004
|
+
}
|
|
134005
|
+
if (bProgram) {
|
|
134006
|
+
object oProg = dom.GetObject(sId);
|
|
134007
|
+
if (oProg) {
|
|
134008
|
+
dom.DeleteObject(oProg.ID());
|
|
134009
|
+
Write("{\\"removed\\":true}");
|
|
134010
|
+
} else {
|
|
134011
|
+
Write("{\\"removed\\":false}");
|
|
134012
|
+
}
|
|
134013
|
+
} else {
|
|
134014
|
+
Write("{\\"removed\\":false}");
|
|
133780
134015
|
}`;
|
|
134016
|
+
}
|
|
133781
134017
|
var CHANNEL_ADDRESS2 = /^[0-9A-Za-z_-]+:\d+$/;
|
|
133782
134018
|
var CONTROL_CHARS3 = /[\u0000-\u001F\u007F]/;
|
|
133783
134019
|
var MAX_NAME2 = 128;
|
|
@@ -133789,13 +134025,19 @@ function record(raw, label) {
|
|
|
133789
134025
|
if (!isRecord2(raw)) throw new ClientError(`${label}: unexpected answer from the CCU.`);
|
|
133790
134026
|
return raw;
|
|
133791
134027
|
}
|
|
134028
|
+
function throwIfDuplicate(answer, name2) {
|
|
134029
|
+
if (answer["error"] !== "duplicate") return;
|
|
134030
|
+
const raw = answer["ids"];
|
|
134031
|
+
const ids = Array.isArray(raw) ? raw.filter((id) => typeof id === "string" && id !== "") : [];
|
|
134032
|
+
throw new ValidationError(`More than one program is named "${name2}" (ids ${ids.length > 0 ? ids.join(", ") : "?"}). deleteProgram(id) deletes one of them.`);
|
|
134033
|
+
}
|
|
133792
134034
|
function validName2(raw) {
|
|
133793
|
-
const
|
|
133794
|
-
if (
|
|
133795
|
-
return
|
|
134035
|
+
const name2 = raw.trim();
|
|
134036
|
+
if (name2 === "" || name2.length > MAX_NAME2 || CONTROL_CHARS3.test(name2)) throw new ValidationError(`Program name must be 1..${MAX_NAME2} characters without control characters.`);
|
|
134037
|
+
return name2;
|
|
133796
134038
|
}
|
|
133797
134039
|
function interfaceNameOf(interfaceId2) {
|
|
133798
|
-
const match = Object.values(Interface).find((
|
|
134040
|
+
const match = Object.values(Interface).find((name2) => interfaceId2.endsWith(`-${name2}`));
|
|
133799
134041
|
if (match === void 0) throw new ValidationError(`Cannot derive the CCU interface from "${interfaceId2}".`);
|
|
133800
134042
|
return match;
|
|
133801
134043
|
}
|
|
@@ -133810,7 +134052,7 @@ var CcuKeyPrograms = class {
|
|
|
133810
134052
|
* channels live on (`HmIP-RF`).
|
|
133811
134053
|
*/
|
|
133812
134054
|
async ensure(interfaceName, input) {
|
|
133813
|
-
const
|
|
134055
|
+
const name2 = validName2(input.name);
|
|
133814
134056
|
const parameters = input.parameters ?? DEFAULT_PARAMETERS;
|
|
133815
134057
|
if (parameters.length === 0) throw new ValidationError("At least one key parameter is needed.");
|
|
133816
134058
|
const datapoints = input.channelAddresses.flatMap((address) => {
|
|
@@ -133818,7 +134060,8 @@ var CcuKeyPrograms = class {
|
|
|
133818
134060
|
return parameters.map((param) => `${interfaceName}.${address}.${param}`);
|
|
133819
134061
|
});
|
|
133820
134062
|
const label = "ReGa.runScript(ensureKeyEventProgram)";
|
|
133821
|
-
const answer = record(await this.#rega(label, buildEnsureKeyEventProgram(datapoints), { name }), label);
|
|
134063
|
+
const answer = record(await this.#rega(label, buildEnsureKeyEventProgram(datapoints), { name: name2 }), label);
|
|
134064
|
+
throwIfDuplicate(answer, name2);
|
|
133822
134065
|
if (answer["error"] === "datapoint") throw new ValidationError(`The CCU has no such key data point: ${Array.isArray(answer["missing"]) ? answer["missing"].join(", ") : "?"}.`);
|
|
133823
134066
|
const programId = answer["programId"];
|
|
133824
134067
|
const created = answer["created"];
|
|
@@ -133828,19 +134071,32 @@ var CcuKeyPrograms = class {
|
|
|
133828
134071
|
created
|
|
133829
134072
|
};
|
|
133830
134073
|
}
|
|
134074
|
+
/**
|
|
134075
|
+
* Delete the program `programId` (digits only). `removed: false` when the id
|
|
134076
|
+
* is missing or is not a program; nothing is deleted in that case.
|
|
134077
|
+
*/
|
|
134078
|
+
async delete(programId) {
|
|
134079
|
+
const script = buildDeleteProgram(programId);
|
|
134080
|
+
const label = "ReGa.runScript(deleteProgram)";
|
|
134081
|
+
const answer = record(await this.#rega(label, script), label);
|
|
134082
|
+
if (typeof answer["removed"] !== "boolean") throw new ClientError(`${label}: unexpected answer from the CCU.`);
|
|
134083
|
+
return { removed: answer["removed"] };
|
|
134084
|
+
}
|
|
133831
134085
|
/** Delete the program by name; `removed: false` when it does not exist. */
|
|
133832
134086
|
async remove(rawName) {
|
|
133833
|
-
const
|
|
134087
|
+
const name2 = validName2(rawName);
|
|
133834
134088
|
const label = "ReGa.runScript(removeKeyEventProgram)";
|
|
133835
|
-
const answer = record(await this.#rega(label, REMOVE_KEY_EVENT_PROGRAM, { name }), label);
|
|
134089
|
+
const answer = record(await this.#rega(label, REMOVE_KEY_EVENT_PROGRAM, { name: name2 }), label);
|
|
134090
|
+
throwIfDuplicate(answer, name2);
|
|
133836
134091
|
if (typeof answer["removed"] !== "boolean") throw new ClientError(`${label}: unexpected answer from the CCU.`);
|
|
133837
134092
|
return { removed: answer["removed"] };
|
|
133838
134093
|
}
|
|
133839
134094
|
/** The program and the channels it listens to, or `null` when absent. */
|
|
133840
134095
|
async get(rawName) {
|
|
133841
|
-
const
|
|
134096
|
+
const name2 = validName2(rawName);
|
|
133842
134097
|
const label = "ReGa.runScript(getKeyEventProgram)";
|
|
133843
|
-
const answer = record(await this.#rega(label, GET_KEY_EVENT_PROGRAM, { name }), label);
|
|
134098
|
+
const answer = record(await this.#rega(label, GET_KEY_EVENT_PROGRAM, { name: name2 }), label);
|
|
134099
|
+
throwIfDuplicate(answer, name2);
|
|
133844
134100
|
if (answer["found"] !== true) return null;
|
|
133845
134101
|
const programId = answer["programId"];
|
|
133846
134102
|
if (typeof programId !== "string" || programId === "") throw new ClientError(`${label}: the CCU did not return the program id.`);
|
|
@@ -133857,21 +134113,231 @@ var CcuKeyPrograms = class {
|
|
|
133857
134113
|
};
|
|
133858
134114
|
}
|
|
133859
134115
|
};
|
|
134116
|
+
var CHANNEL_ADDRESS3 = /^([0-9A-Za-z_-]+):\d+$/;
|
|
134117
|
+
var INTERFACE_NAME = /^[0-9A-Za-z_-]+$/;
|
|
134118
|
+
var KEY_DIAGNOSIS_PARAMETERS = [
|
|
134119
|
+
"PRESS_SHORT",
|
|
134120
|
+
"PRESS_LONG",
|
|
134121
|
+
"PRESS_LONG_RELEASE"
|
|
134122
|
+
];
|
|
134123
|
+
function keyDatapointName(interfaceName, channelAddress2, parameter) {
|
|
134124
|
+
return `${interfaceName}.${channelAddress2}.${parameter}`;
|
|
134125
|
+
}
|
|
134126
|
+
function checkedInput(interfaceName, channelAddresses) {
|
|
134127
|
+
if (!INTERFACE_NAME.test(interfaceName)) throw new ValidationError(`Invalid interface name "${interfaceName}".`);
|
|
134128
|
+
for (const address of channelAddresses) if (!CHANNEL_ADDRESS3.test(address)) throw new ValidationError(`Invalid channel address "${address}".`);
|
|
134129
|
+
return channelAddresses;
|
|
134130
|
+
}
|
|
134131
|
+
function channelBlock(interfaceName, address, i) {
|
|
134132
|
+
return `Write(sSep);
|
|
134133
|
+
sSep = ",";
|
|
134134
|
+
Write("{\\"address\\":\\"${address}\\",");
|
|
134135
|
+
if (sChId${i} == "") {
|
|
134136
|
+
Write("\\"found\\":false,");
|
|
134137
|
+
} else {
|
|
134138
|
+
object oChn${i} = dom.GetObject(sChId${i});
|
|
134139
|
+
Write("\\"found\\":true,\\"id\\":\\"" # oChn${i}.ID() # "\\",\\"name\\":\\"" # oChn${i}.Name().UriEncode() # "\\",\\"visible\\":\\"" # oChn${i}.Visible() # "\\",\\"enabled\\":\\"" # "" # "\\",\\"readyConfig\\":\\"" # oChn${i}.ReadyConfig() # "\\",\\"lastActionSeconds\\":\\"" # oChn${i}.LastDPActionTimeSeconds() # "\\",");
|
|
134140
|
+
}
|
|
134141
|
+
Write("\\"datapoints\\":[");
|
|
134142
|
+
sDpSep = "";
|
|
134143
|
+
${KEY_DIAGNOSIS_PARAMETERS.map((parameter) => {
|
|
134144
|
+
const name2 = keyDatapointName(interfaceName, address, parameter);
|
|
134145
|
+
return `oDp = dom.GetObject("${name2}");
|
|
134146
|
+
Write(sDpSep);
|
|
134147
|
+
sDpSep = ",";
|
|
134148
|
+
Write("{\\"name\\":\\"${name2}\\"");
|
|
134149
|
+
if (oDp) {
|
|
134150
|
+
Write(",\\"exists\\":true,\\"id\\":\\"" # oDp.ID() # "\\",\\"value\\":\\"" # ("" # oDp.Value()).UriEncode() # "\\",\\"timestampSeconds\\":\\"" # oDp.TimestampSeconds() # "\\",\\"lastTimestampSeconds\\":\\"" # "" # "\\"}");
|
|
134151
|
+
} else {
|
|
134152
|
+
Write(",\\"exists\\":false}");
|
|
134153
|
+
}`;
|
|
134154
|
+
}).join("\n")}
|
|
134155
|
+
Write("]}");`;
|
|
134156
|
+
}
|
|
134157
|
+
function buildDiagnoseKeyEvents(interfaceName, channelAddresses) {
|
|
134158
|
+
const addresses = checkedInput(interfaceName, channelAddresses);
|
|
134159
|
+
const lookups = addresses.map((_a, i) => `string sChId${i} = "";`).join("\n");
|
|
134160
|
+
const matches = addresses.map((address, i) => `if (oTmp.Address() == "${address}") {
|
|
134161
|
+
sChId${i} = sId;
|
|
134162
|
+
}`).join("\n ");
|
|
134163
|
+
return `! nodehomematic:diagnoseKeyEvents
|
|
134164
|
+
string sId;
|
|
134165
|
+
string sSep = "";
|
|
134166
|
+
string sDpSep = "";
|
|
134167
|
+
string sTargets = "|";
|
|
134168
|
+
object oDp;
|
|
134169
|
+
${lookups}
|
|
134170
|
+
${addresses.flatMap((address) => KEY_DIAGNOSIS_PARAMETERS.map((parameter) => `sTargets = sTargets # "${keyDatapointName(interfaceName, address, parameter)}|";`)).join("\n")}
|
|
134171
|
+
foreach(sId, dom.GetObject(ID_CHANNELS).EnumUsedIDs()) {
|
|
134172
|
+
object oTmp = dom.GetObject(sId);
|
|
134173
|
+
if (oTmp) {
|
|
134174
|
+
${matches}
|
|
134175
|
+
}
|
|
134176
|
+
}
|
|
134177
|
+
Write("{\\"channels\\":[");
|
|
134178
|
+
${addresses.map((address, i) => channelBlock(interfaceName, address, i)).join("\n")}
|
|
134179
|
+
Write("],\\"programs\\":[");
|
|
134180
|
+
string sPrgId;
|
|
134181
|
+
string sPSep = "";
|
|
134182
|
+
foreach(sPrgId, dom.GetObject(ID_PROGRAMS).EnumUsedIDs()) {
|
|
134183
|
+
object oPrg = dom.GetObject(sPrgId);
|
|
134184
|
+
if (oPrg) {
|
|
134185
|
+
string sRefs = "";
|
|
134186
|
+
string sRSep = "";
|
|
134187
|
+
object oRule = oPrg.Rule();
|
|
134188
|
+
if (oRule) {
|
|
134189
|
+
integer iC = 0;
|
|
134190
|
+
integer iCn = oRule.RuleConditions().Count();
|
|
134191
|
+
while (iC < iCn) {
|
|
134192
|
+
object oCnd = oRule.RuleCondition(iC);
|
|
134193
|
+
if (oCnd) {
|
|
134194
|
+
integer iN = oCnd.CndSingleCount();
|
|
134195
|
+
integer iI = 0;
|
|
134196
|
+
while (iI < iN) {
|
|
134197
|
+
object oSc = oCnd.CndSingleCondition(iI);
|
|
134198
|
+
object oLeft = dom.GetObject(oSc.LeftVal());
|
|
134199
|
+
if (oLeft) {
|
|
134200
|
+
string sLn = oLeft.Name();
|
|
134201
|
+
if (sTargets.Find("|" # sLn # "|") != -1) {
|
|
134202
|
+
sRefs = sRefs # sRSep # "\\"" # sLn # "\\"";
|
|
134203
|
+
sRSep = ",";
|
|
134204
|
+
}
|
|
134205
|
+
}
|
|
134206
|
+
iI = iI + 1;
|
|
134207
|
+
}
|
|
134208
|
+
}
|
|
134209
|
+
iC = iC + 1;
|
|
134210
|
+
}
|
|
134211
|
+
}
|
|
134212
|
+
if (sRefs != "") {
|
|
134213
|
+
Write(sPSep);
|
|
134214
|
+
sPSep = ",";
|
|
134215
|
+
Write("{\\"id\\":\\"" # oPrg.ID() # "\\",\\"name\\":\\"" # oPrg.Name().UriEncode() # "\\",\\"active\\":\\"" # oPrg.Active() # "\\",\\"internal\\":\\"" # "" # "\\",\\"lastExecuteSeconds\\":\\"" # oPrg.ProgramLastExecuteTimeSeconds() # "\\",\\"datapoints\\":[" # sRefs # "]}");
|
|
134216
|
+
}
|
|
134217
|
+
}
|
|
134218
|
+
}
|
|
134219
|
+
Write("]}");`;
|
|
134220
|
+
}
|
|
134221
|
+
function isRecord3(value) {
|
|
134222
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
134223
|
+
}
|
|
134224
|
+
function records(value) {
|
|
134225
|
+
return Array.isArray(value) ? value.filter(isRecord3) : [];
|
|
134226
|
+
}
|
|
134227
|
+
function str(entry, key) {
|
|
134228
|
+
const value = entry[key];
|
|
134229
|
+
return typeof value === "string" && value !== "" ? value : null;
|
|
134230
|
+
}
|
|
134231
|
+
function name(entry, key) {
|
|
134232
|
+
const value = str(entry, key);
|
|
134233
|
+
return value === null ? null : decodeRegaName(value);
|
|
134234
|
+
}
|
|
134235
|
+
function bool(entry, key) {
|
|
134236
|
+
const value = str(entry, key);
|
|
134237
|
+
if (value === "true" || value === "1") return true;
|
|
134238
|
+
if (value === "false" || value === "0") return false;
|
|
134239
|
+
return null;
|
|
134240
|
+
}
|
|
134241
|
+
function epochMs(entry, key) {
|
|
134242
|
+
const value = str(entry, key);
|
|
134243
|
+
if (value === null) return null;
|
|
134244
|
+
const seconds = Number(value);
|
|
134245
|
+
return Number.isFinite(seconds) && seconds > 0 ? seconds * 1e3 : null;
|
|
134246
|
+
}
|
|
134247
|
+
function datapoint(entry) {
|
|
134248
|
+
const dpName = str(entry, "name");
|
|
134249
|
+
if (dpName === null) return null;
|
|
134250
|
+
if (entry["exists"] !== true) return {
|
|
134251
|
+
name: dpName,
|
|
134252
|
+
exists: false,
|
|
134253
|
+
id: null,
|
|
134254
|
+
value: null,
|
|
134255
|
+
timestamp: null,
|
|
134256
|
+
lastTimestamp: null
|
|
134257
|
+
};
|
|
134258
|
+
return {
|
|
134259
|
+
name: dpName,
|
|
134260
|
+
exists: true,
|
|
134261
|
+
id: str(entry, "id"),
|
|
134262
|
+
value: name(entry, "value"),
|
|
134263
|
+
timestamp: epochMs(entry, "timestampSeconds"),
|
|
134264
|
+
lastTimestamp: epochMs(entry, "lastTimestampSeconds")
|
|
134265
|
+
};
|
|
134266
|
+
}
|
|
134267
|
+
function channel(entry) {
|
|
134268
|
+
const address = str(entry, "address");
|
|
134269
|
+
if (address === null) return null;
|
|
134270
|
+
const datapoints = records(entry["datapoints"]).flatMap((dp) => {
|
|
134271
|
+
const parsed = datapoint(dp);
|
|
134272
|
+
return parsed === null ? [] : [parsed];
|
|
134273
|
+
});
|
|
134274
|
+
const found = entry["found"] === true;
|
|
134275
|
+
return {
|
|
134276
|
+
address,
|
|
134277
|
+
found,
|
|
134278
|
+
id: found ? str(entry, "id") : null,
|
|
134279
|
+
name: found ? name(entry, "name") : null,
|
|
134280
|
+
visible: found ? bool(entry, "visible") : null,
|
|
134281
|
+
enabled: found ? bool(entry, "enabled") : null,
|
|
134282
|
+
readyConfig: found ? bool(entry, "readyConfig") : null,
|
|
134283
|
+
lastActionAt: found ? epochMs(entry, "lastActionSeconds") : null,
|
|
134284
|
+
datapoints
|
|
134285
|
+
};
|
|
134286
|
+
}
|
|
134287
|
+
function program(entry) {
|
|
134288
|
+
const id = str(entry, "id");
|
|
134289
|
+
if (id === null) return null;
|
|
134290
|
+
const datapoints = Array.isArray(entry["datapoints"]) ? entry["datapoints"].filter((dp) => typeof dp === "string") : [];
|
|
134291
|
+
return {
|
|
134292
|
+
id,
|
|
134293
|
+
name: name(entry, "name") ?? "",
|
|
134294
|
+
active: bool(entry, "active"),
|
|
134295
|
+
internal: bool(entry, "internal"),
|
|
134296
|
+
lastExecutedAt: epochMs(entry, "lastExecuteSeconds"),
|
|
134297
|
+
datapoints
|
|
134298
|
+
};
|
|
134299
|
+
}
|
|
134300
|
+
var CcuKeyDiagnosis = class {
|
|
134301
|
+
#rega;
|
|
134302
|
+
constructor(rega) {
|
|
134303
|
+
this.#rega = rega;
|
|
134304
|
+
}
|
|
134305
|
+
/**
|
|
134306
|
+
* Read the ReGa channel objects, key data points and referencing programs
|
|
134307
|
+
* for `channelAddresses` on `interfaceName` (`HmIP-RF`). Writes nothing.
|
|
134308
|
+
*/
|
|
134309
|
+
async read(interfaceName, channelAddresses) {
|
|
134310
|
+
if (channelAddresses.length === 0) throw new ValidationError("The key diagnosis needs at least one channel.");
|
|
134311
|
+
const label = "ReGa.runScript(diagnoseKeyEvents)";
|
|
134312
|
+
const answer = await this.#rega(label, buildDiagnoseKeyEvents(interfaceName, channelAddresses));
|
|
134313
|
+
if (!isRecord3(answer)) throw new ClientError(`${label}: unexpected answer from the CCU.`);
|
|
134314
|
+
return {
|
|
134315
|
+
channels: records(answer["channels"]).flatMap((entry) => {
|
|
134316
|
+
const parsed = channel(entry);
|
|
134317
|
+
return parsed === null ? [] : [parsed];
|
|
134318
|
+
}),
|
|
134319
|
+
programs: records(answer["programs"]).flatMap((entry) => {
|
|
134320
|
+
const parsed = program(entry);
|
|
134321
|
+
return parsed === null ? [] : [parsed];
|
|
134322
|
+
})
|
|
134323
|
+
};
|
|
134324
|
+
}
|
|
134325
|
+
};
|
|
133860
134326
|
var GROUP_CREATE_PATH = "/pages/jpages/group/create";
|
|
133861
134327
|
var GROUP_SAVE_PATH = "/pages/jpages/group/save";
|
|
133862
134328
|
var GROUP_DELETE_PATH = "/pages/jpages/group/delete";
|
|
133863
134329
|
var DRAFT_GROUP_ID = /self\.groupId\s*=\s*(\d+)/;
|
|
133864
134330
|
var KNOWN_GROUP_TYPES = ["hmip.heating.group", "HomeMatic.heating"];
|
|
133865
|
-
var
|
|
134331
|
+
var CHANNEL_ADDRESS4 = /^[0-9A-Za-z_-]+:\d+$/;
|
|
133866
134332
|
var MAX_GROUP_NAME = 64;
|
|
133867
134333
|
var DEFAULT_INSTALL_SECONDS = 60;
|
|
133868
134334
|
var MAX_INSTALL_SECONDS = 3600;
|
|
133869
134335
|
var SERVICE_MESSAGE_ID = /^\d+$/;
|
|
133870
|
-
function
|
|
134336
|
+
function isRecord4(value) {
|
|
133871
134337
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
133872
134338
|
}
|
|
133873
134339
|
function asRecordArray(value) {
|
|
133874
|
-
return Array.isArray(value) ? value.filter(
|
|
134340
|
+
return Array.isArray(value) ? value.filter(isRecord4) : [];
|
|
133875
134341
|
}
|
|
133876
134342
|
function strOrNull(value) {
|
|
133877
134343
|
if (typeof value === "string") return value === "" ? null : value;
|
|
@@ -133884,9 +134350,9 @@ function numOrNull(value) {
|
|
|
133884
134350
|
return Number.isFinite(num) ? num : null;
|
|
133885
134351
|
}
|
|
133886
134352
|
var INTERFACES_BY_NAME = new Map(Object.values(Interface).map((iface) => [iface.toString(), iface]));
|
|
133887
|
-
function toInterface(
|
|
133888
|
-
const match = INTERFACES_BY_NAME.get(
|
|
133889
|
-
if (match === void 0) throw new ValidationError(`Unknown interface "${
|
|
134353
|
+
function toInterface(name2) {
|
|
134354
|
+
const match = INTERFACES_BY_NAME.get(name2);
|
|
134355
|
+
if (match === void 0) throw new ValidationError(`Unknown interface "${name2}".`);
|
|
133890
134356
|
return match;
|
|
133891
134357
|
}
|
|
133892
134358
|
function toGateway(info) {
|
|
@@ -133996,13 +134462,13 @@ var CcuManagement = class {
|
|
|
133996
134462
|
const address = strOrNull(entry["address"]);
|
|
133997
134463
|
const colon = address === null ? -1 : address.lastIndexOf(":");
|
|
133998
134464
|
const device = address === null ? null : colon === -1 ? address : address.slice(0, colon);
|
|
133999
|
-
const
|
|
134465
|
+
const channel2 = address === null || colon === -1 ? null : numOrNull(address.slice(colon + 1));
|
|
134000
134466
|
const seconds = numOrNull(entry["timestamp"]);
|
|
134001
134467
|
return [{
|
|
134002
134468
|
id,
|
|
134003
134469
|
name: decodedOrNull(entry["name"]),
|
|
134004
134470
|
address: device,
|
|
134005
|
-
channel,
|
|
134471
|
+
channel: channel2,
|
|
134006
134472
|
type: strOrNull(entry["type"]),
|
|
134007
134473
|
timestamp: seconds === null || seconds <= 0 ? null : seconds * 1e3,
|
|
134008
134474
|
acknowledgeable: entry["acknowledgeable"] === true
|
|
@@ -134013,7 +134479,7 @@ var CcuManagement = class {
|
|
|
134013
134479
|
async acknowledgeServiceMessage(id) {
|
|
134014
134480
|
if (!SERVICE_MESSAGE_ID.test(id)) throw new ValidationError(`Invalid service message id "${id}".`);
|
|
134015
134481
|
const raw = await this.rega("ReGa.runScript(acknowledgeServiceMessage)", ACKNOWLEDGE_SERVICE_MESSAGE, { id });
|
|
134016
|
-
if (!
|
|
134482
|
+
if (!isRecord4(raw) || raw["ok"] !== true) throw new ValidationError(`Unknown service message "${id}".`);
|
|
134017
134483
|
}
|
|
134018
134484
|
/** Version, product, serial and hostname; each `null` when unanswered. */
|
|
134019
134485
|
async ccuInfo() {
|
|
@@ -134023,8 +134489,8 @@ var CcuManagement = class {
|
|
|
134023
134489
|
this.rega("ReGa.runScript(ccuPlatform)", GET_CCU_PLATFORM)
|
|
134024
134490
|
]);
|
|
134025
134491
|
if (version.status === "rejected" && serial.status === "rejected" && platform.status === "rejected") throw version.reason instanceof CcuManagementError ? version.reason : new CcuManagementError(JsonRpcMethod.CCU_GET_VERSION, version.reason);
|
|
134026
|
-
const release = platform.status === "fulfilled" &&
|
|
134027
|
-
const hostname = platform.status === "fulfilled" &&
|
|
134492
|
+
const release = platform.status === "fulfilled" && isRecord4(platform.value) ? parseKeyValueLines(decodeRegaName(releaseText(platform.value))) : /* @__PURE__ */ new Map();
|
|
134493
|
+
const hostname = platform.status === "fulfilled" && isRecord4(platform.value) ? decodedOrNull(platform.value["host"]) : null;
|
|
134028
134494
|
const product = strOrNull(release.get("PRODUCT"));
|
|
134029
134495
|
return {
|
|
134030
134496
|
version: version.status === "fulfilled" ? strOrNull(version.value) : null,
|
|
@@ -134050,7 +134516,7 @@ var CcuManagement = class {
|
|
|
134050
134516
|
} catch (err) {
|
|
134051
134517
|
throw new CcuManagementError(JsonRpcMethod.CCU_GET_HEATING_GROUP_LIST, err);
|
|
134052
134518
|
}
|
|
134053
|
-
if (!
|
|
134519
|
+
if (!isRecord4(parsed)) return [];
|
|
134054
134520
|
return Object.keys(parsed).sort().flatMap((key) => asRecordArray(parsed[key])).flatMap((entry) => {
|
|
134055
134521
|
const group = toGroup(entry);
|
|
134056
134522
|
return group === null ? [] : [group];
|
|
@@ -134058,7 +134524,7 @@ var CcuManagement = class {
|
|
|
134058
134524
|
}
|
|
134059
134525
|
/** Create a group; resolves with the group as read back from the CCU. */
|
|
134060
134526
|
async createGroup(input) {
|
|
134061
|
-
const
|
|
134527
|
+
const name2 = validateGroupName(input.name);
|
|
134062
134528
|
const members = validateMembers(input.members);
|
|
134063
134529
|
const before = await this.groups();
|
|
134064
134530
|
this.validateType(input.type, before);
|
|
@@ -134069,16 +134535,16 @@ var CcuManagement = class {
|
|
|
134069
134535
|
const draftId = Number(draft[1]);
|
|
134070
134536
|
const id = numOrNull(await this.saveGroup(webUi, sid, {
|
|
134071
134537
|
groupId: draftId,
|
|
134072
|
-
groupName: jsEscape(
|
|
134538
|
+
groupName: jsEscape(name2),
|
|
134073
134539
|
groupTypeId: input.type,
|
|
134074
134540
|
forbidSingleOperation: false,
|
|
134075
134541
|
assignedDevicesIds: members,
|
|
134076
134542
|
isNewGroup: true,
|
|
134077
|
-
groupDeviceName: `${
|
|
134543
|
+
groupDeviceName: `${name2} `
|
|
134078
134544
|
})) ?? draftId;
|
|
134079
134545
|
await this.flagMembers(members, "true");
|
|
134080
134546
|
return this.verifyPresent(id, {
|
|
134081
|
-
name,
|
|
134547
|
+
name: name2,
|
|
134082
134548
|
type: input.type,
|
|
134083
134549
|
members
|
|
134084
134550
|
});
|
|
@@ -134086,11 +134552,11 @@ var CcuManagement = class {
|
|
|
134086
134552
|
/** Change a group's name and/or member list; resolves with the group read back. */
|
|
134087
134553
|
async updateGroup(id, patch) {
|
|
134088
134554
|
if (patch.name === void 0 && patch.members === void 0) throw new ValidationError("updateGroup needs a name and/or members.");
|
|
134089
|
-
const
|
|
134555
|
+
const name2 = patch.name === void 0 ? void 0 : validateGroupName(patch.name);
|
|
134090
134556
|
const members = patch.members === void 0 ? void 0 : validateMembers(patch.members);
|
|
134091
134557
|
const current = await this.requireGroup(id);
|
|
134092
134558
|
const { webUi, sid } = await this.requireWebUi("group/save");
|
|
134093
|
-
const nextName =
|
|
134559
|
+
const nextName = name2 ?? current.name;
|
|
134094
134560
|
const nextMembers = members ?? current.members.map((m) => m.address);
|
|
134095
134561
|
await this.saveGroup(webUi, sid, {
|
|
134096
134562
|
groupId: id,
|
|
@@ -134176,6 +134642,10 @@ var CcuManagement = class {
|
|
|
134176
134642
|
keyPrograms() {
|
|
134177
134643
|
return new CcuKeyPrograms((label, script, params) => this.rega(label, script, params));
|
|
134178
134644
|
}
|
|
134645
|
+
/** The read-only key diagnosis (ReGa side), on this service's session. */
|
|
134646
|
+
keyDiagnosis() {
|
|
134647
|
+
return new CcuKeyDiagnosis((label, script, params) => this.rega(label, script, params));
|
|
134648
|
+
}
|
|
134179
134649
|
requireClient(interfaceName) {
|
|
134180
134650
|
const iface = toInterface(interfaceName);
|
|
134181
134651
|
const client = this.interfaceClient(iface);
|
|
@@ -134218,17 +134688,17 @@ var CcuManagement = class {
|
|
|
134218
134688
|
info: null
|
|
134219
134689
|
}));
|
|
134220
134690
|
return asRecordArray(await this.call(JsonRpcMethod.INTERFACE_LIST_INTERFACES)).flatMap((entry) => {
|
|
134221
|
-
const
|
|
134222
|
-
return
|
|
134223
|
-
name,
|
|
134691
|
+
const name2 = strOrNull(entry["name"]);
|
|
134692
|
+
return name2 === null ? [] : [{
|
|
134693
|
+
name: name2,
|
|
134224
134694
|
port: numOrNull(entry["port"]),
|
|
134225
134695
|
info: strOrNull(entry["info"])
|
|
134226
134696
|
}];
|
|
134227
134697
|
});
|
|
134228
134698
|
}
|
|
134229
|
-
async isPresent(
|
|
134699
|
+
async isPresent(name2) {
|
|
134230
134700
|
if (this.json === void 0) return null;
|
|
134231
|
-
const answer = await this.tryOrNull(() => this.call(JsonRpcMethod.INTERFACE_IS_PRESENT, { interface:
|
|
134701
|
+
const answer = await this.tryOrNull(() => this.call(JsonRpcMethod.INTERFACE_IS_PRESENT, { interface: name2 }));
|
|
134232
134702
|
if (typeof answer === "boolean") return answer;
|
|
134233
134703
|
if (answer === "true") return true;
|
|
134234
134704
|
if (answer === "false") return false;
|
|
@@ -134254,8 +134724,8 @@ var DEVICE_ADDRESS_SUFFIX = /\b(INT\d{7})\s*$/;
|
|
|
134254
134724
|
function toGroup(entry) {
|
|
134255
134725
|
const id = numOrNull(entry["id"]);
|
|
134256
134726
|
if (id === null) return null;
|
|
134257
|
-
const props =
|
|
134258
|
-
const groupType =
|
|
134727
|
+
const props = isRecord4(entry["groupProperties"]) ? entry["groupProperties"] : {};
|
|
134728
|
+
const groupType = isRecord4(entry["groupType"]) ? entry["groupType"] : {};
|
|
134259
134729
|
const deviceName = strOrNull(props["GROUP_DEVICE_NAME"]);
|
|
134260
134730
|
const deviceMatch = deviceName === null ? null : DEVICE_ADDRESS_SUFFIX.exec(deviceName);
|
|
134261
134731
|
const members = asRecordArray(entry["groupMembers"]).flatMap((m) => {
|
|
@@ -134263,7 +134733,7 @@ function toGroup(entry) {
|
|
|
134263
134733
|
if (address === null) return [];
|
|
134264
134734
|
return [{
|
|
134265
134735
|
address,
|
|
134266
|
-
type: (
|
|
134736
|
+
type: (isRecord4(m["memberType"]) ? strOrNull(m["memberType"]["id"]) : null) ?? ""
|
|
134267
134737
|
}];
|
|
134268
134738
|
});
|
|
134269
134739
|
return {
|
|
@@ -134280,12 +134750,12 @@ function virtualDeviceSerial(id) {
|
|
|
134280
134750
|
return `INT${String(id).padStart(7, "0")}`;
|
|
134281
134751
|
}
|
|
134282
134752
|
function validateGroupName(raw) {
|
|
134283
|
-
const
|
|
134284
|
-
if (
|
|
134285
|
-
return
|
|
134753
|
+
const name2 = raw.replace(/"/g, "'").trim();
|
|
134754
|
+
if (name2 === "" || name2.length > MAX_GROUP_NAME) throw new ValidationError(`Group name must be 1..${MAX_GROUP_NAME} characters.`);
|
|
134755
|
+
return name2;
|
|
134286
134756
|
}
|
|
134287
134757
|
function validateMembers(members) {
|
|
134288
|
-
for (const address of members) if (!
|
|
134758
|
+
for (const address of members) if (!CHANNEL_ADDRESS4.test(address)) throw new ValidationError(`Invalid member channel address "${address}".`);
|
|
134289
134759
|
return [...new Set(members)];
|
|
134290
134760
|
}
|
|
134291
134761
|
function checkWebUiResponse(path$5, text) {
|
|
@@ -134295,8 +134765,8 @@ function checkWebUiResponse(path$5, text) {
|
|
|
134295
134765
|
} catch {
|
|
134296
134766
|
throw new CcuManagementError(path$5, new ClientError("response was not JSON"));
|
|
134297
134767
|
}
|
|
134298
|
-
if (!
|
|
134299
|
-
const code =
|
|
134768
|
+
if (!isRecord4(parsed) || parsed["isSuccessful"] !== true) {
|
|
134769
|
+
const code = isRecord4(parsed) ? strOrNull(parsed["errorCode"]) : null;
|
|
134300
134770
|
throw new CcuManagementError(path$5, new ClientError(code === "42" ? "session expired (errorCode 42)" : `refused (errorCode ${code ?? "none"})`));
|
|
134301
134771
|
}
|
|
134302
134772
|
const content = parsed["content"];
|
|
@@ -134306,33 +134776,33 @@ var FAULT_METHOD_NOT_FOUND = -32601;
|
|
|
134306
134776
|
var FAULT_INTERNAL_ERROR = -32603;
|
|
134307
134777
|
var MethodNotFoundError = class extends BaseHomematicError {};
|
|
134308
134778
|
var InvalidParamsError = class extends BaseHomematicError {};
|
|
134309
|
-
function requireString(params, index,
|
|
134779
|
+
function requireString(params, index, name2) {
|
|
134310
134780
|
const value = params[index];
|
|
134311
|
-
if (typeof value !== "string") throw new InvalidParamsError(`expected string argument "${
|
|
134781
|
+
if (typeof value !== "string") throw new InvalidParamsError(`expected string argument "${name2}" at position ${index}`);
|
|
134312
134782
|
return value;
|
|
134313
134783
|
}
|
|
134314
|
-
function requireNumber(params, index,
|
|
134784
|
+
function requireNumber(params, index, name2) {
|
|
134315
134785
|
const value = params[index];
|
|
134316
|
-
if (typeof value !== "number" || Number.isNaN(value)) throw new InvalidParamsError(`expected number argument "${
|
|
134786
|
+
if (typeof value !== "number" || Number.isNaN(value)) throw new InvalidParamsError(`expected number argument "${name2}" at position ${index}`);
|
|
134317
134787
|
return value;
|
|
134318
134788
|
}
|
|
134319
|
-
function requireArg(params, index,
|
|
134320
|
-
if (index >= params.length) throw new InvalidParamsError(`missing required argument "${
|
|
134789
|
+
function requireArg(params, index, name2) {
|
|
134790
|
+
if (index >= params.length) throw new InvalidParamsError(`missing required argument "${name2}" at position ${index}`);
|
|
134321
134791
|
return params[index];
|
|
134322
134792
|
}
|
|
134323
|
-
function requireStringArray(params, index,
|
|
134324
|
-
const value = requireArg(params, index,
|
|
134325
|
-
if (!Array.isArray(value)) throw new InvalidParamsError(`expected array argument "${
|
|
134793
|
+
function requireStringArray(params, index, name2) {
|
|
134794
|
+
const value = requireArg(params, index, name2);
|
|
134795
|
+
if (!Array.isArray(value)) throw new InvalidParamsError(`expected array argument "${name2}" at position ${index}`);
|
|
134326
134796
|
return value.map((item, i) => {
|
|
134327
|
-
if (typeof item !== "string") throw new InvalidParamsError(`expected string at "${
|
|
134797
|
+
if (typeof item !== "string") throw new InvalidParamsError(`expected string at "${name2}"[${i}]`);
|
|
134328
134798
|
return item;
|
|
134329
134799
|
});
|
|
134330
134800
|
}
|
|
134331
|
-
function requireStructArray(params, index,
|
|
134332
|
-
const value = requireArg(params, index,
|
|
134333
|
-
if (!Array.isArray(value)) throw new InvalidParamsError(`expected array argument "${
|
|
134801
|
+
function requireStructArray(params, index, name2) {
|
|
134802
|
+
const value = requireArg(params, index, name2);
|
|
134803
|
+
if (!Array.isArray(value)) throw new InvalidParamsError(`expected array argument "${name2}" at position ${index}`);
|
|
134334
134804
|
return value.map((item, i) => {
|
|
134335
|
-
if (typeof item !== "object" || item === null || Array.isArray(item)) throw new InvalidParamsError(`expected struct at "${
|
|
134805
|
+
if (typeof item !== "object" || item === null || Array.isArray(item)) throw new InvalidParamsError(`expected struct at "${name2}"[${i}]`);
|
|
134336
134806
|
return item;
|
|
134337
134807
|
});
|
|
134338
134808
|
}
|
|
@@ -134652,7 +135122,7 @@ var DeviceRegistry = class {
|
|
|
134652
135122
|
const deviceAddress = channelAddress2.slice(0, lastColon);
|
|
134653
135123
|
const device = this.devices.get(deviceAddress);
|
|
134654
135124
|
if (device === void 0) return void 0;
|
|
134655
|
-
return device.channels.find((
|
|
135125
|
+
return device.channels.find((channel2) => channel2.address === channelAddress2);
|
|
134656
135126
|
}
|
|
134657
135127
|
/**
|
|
134658
135128
|
* Resolve the {@link ParameterSpec} addressed by a dpk: device → channel
|
|
@@ -134660,9 +135130,9 @@ var DeviceRegistry = class {
|
|
|
134660
135130
|
* `dpk.paramsetKey`. Returns `undefined` if any hop is missing.
|
|
134661
135131
|
*/
|
|
134662
135132
|
resolveParameter(dpk) {
|
|
134663
|
-
const
|
|
134664
|
-
if (
|
|
134665
|
-
const specs =
|
|
135133
|
+
const channel2 = this.getChannel(dpk.channelAddress);
|
|
135134
|
+
if (channel2 === void 0) return void 0;
|
|
135135
|
+
const specs = channel2.parameters.get(dpk.parameter);
|
|
134666
135136
|
if (specs === void 0) return void 0;
|
|
134667
135137
|
if (dpk.paramsetKey === "VALUES") return specs.VALUES;
|
|
134668
135138
|
if (dpk.paramsetKey === "MASTER") return specs.MASTER;
|
|
@@ -134939,23 +135409,23 @@ var FileStorageBackend = class {
|
|
|
134939
135409
|
this.dir = options.dir;
|
|
134940
135410
|
this.prefix = slug(options.centralName);
|
|
134941
135411
|
}
|
|
134942
|
-
fileFor(
|
|
134943
|
-
return (0, path.join)(this.dir, `${this.prefix}_${
|
|
135412
|
+
fileFor(name2) {
|
|
135413
|
+
return (0, path.join)(this.dir, `${this.prefix}_${name2}.json`);
|
|
134944
135414
|
}
|
|
134945
|
-
async load(
|
|
135415
|
+
async load(name2) {
|
|
134946
135416
|
try {
|
|
134947
|
-
return await (0, fs_promises.readFile)(this.fileFor(
|
|
135417
|
+
return await (0, fs_promises.readFile)(this.fileFor(name2), "utf-8");
|
|
134948
135418
|
} catch (err) {
|
|
134949
135419
|
if (isNotFound(err)) return null;
|
|
134950
135420
|
throw err;
|
|
134951
135421
|
}
|
|
134952
135422
|
}
|
|
134953
|
-
async save(
|
|
135423
|
+
async save(name2, content) {
|
|
134954
135424
|
await (0, fs_promises.mkdir)(this.dir, { recursive: true });
|
|
134955
|
-
await (0, fs_promises.writeFile)(this.fileFor(
|
|
135425
|
+
await (0, fs_promises.writeFile)(this.fileFor(name2), content, "utf-8");
|
|
134956
135426
|
}
|
|
134957
|
-
async remove(
|
|
134958
|
-
await (0, fs_promises.rm)(this.fileFor(
|
|
135427
|
+
async remove(name2) {
|
|
135428
|
+
await (0, fs_promises.rm)(this.fileFor(name2), { force: true });
|
|
134959
135429
|
}
|
|
134960
135430
|
};
|
|
134961
135431
|
function isNotFound(err) {
|
|
@@ -134963,15 +135433,15 @@ function isNotFound(err) {
|
|
|
134963
135433
|
}
|
|
134964
135434
|
var InMemoryStorageBackend = class {
|
|
134965
135435
|
store = /* @__PURE__ */ new Map();
|
|
134966
|
-
load(
|
|
134967
|
-
return Promise.resolve(this.store.get(
|
|
135436
|
+
load(name2) {
|
|
135437
|
+
return Promise.resolve(this.store.get(name2) ?? null);
|
|
134968
135438
|
}
|
|
134969
|
-
save(
|
|
134970
|
-
this.store.set(
|
|
135439
|
+
save(name2, content) {
|
|
135440
|
+
this.store.set(name2, content);
|
|
134971
135441
|
return Promise.resolve();
|
|
134972
135442
|
}
|
|
134973
|
-
remove(
|
|
134974
|
-
this.store.delete(
|
|
135443
|
+
remove(name2) {
|
|
135444
|
+
this.store.delete(name2);
|
|
134975
135445
|
return Promise.resolve();
|
|
134976
135446
|
}
|
|
134977
135447
|
};
|
|
@@ -135082,14 +135552,14 @@ function buildChannel(interfaceId2, channelAddress2, desc, paramsetCache, detail
|
|
|
135082
135552
|
if (paramset === void 0) continue;
|
|
135083
135553
|
for (const [parameter, data] of Object.entries(paramset)) mergeSpec(parameters, parameter, key, parameterSpecFromData(data));
|
|
135084
135554
|
}
|
|
135085
|
-
const
|
|
135555
|
+
const name2 = details?.nameByAddress.get(channelAddress2);
|
|
135086
135556
|
return {
|
|
135087
135557
|
address: channelAddress2,
|
|
135088
135558
|
index: channelIndexOf(channelAddress2),
|
|
135089
135559
|
parameters,
|
|
135090
135560
|
...desc?.TYPE !== void 0 ? { type: desc.TYPE } : {},
|
|
135091
135561
|
...desc?.DIRECTION !== void 0 ? { direction: desc.DIRECTION } : {},
|
|
135092
|
-
...
|
|
135562
|
+
...name2 !== void 0 ? { name: name2 } : {}
|
|
135093
135563
|
};
|
|
135094
135564
|
}
|
|
135095
135565
|
function mergeSpec(parameters, parameter, key, spec) {
|
|
@@ -135105,7 +135575,7 @@ function mergeSpec(parameters, parameter, key, spec) {
|
|
|
135105
135575
|
}
|
|
135106
135576
|
function buildDevice(interfaceId2, device, channels, details) {
|
|
135107
135577
|
const address = device.ADDRESS;
|
|
135108
|
-
const
|
|
135578
|
+
const name2 = details?.nameByAddress.get(address);
|
|
135109
135579
|
const rooms = details?.roomsByAddress.get(address);
|
|
135110
135580
|
const functions = details?.functionsByAddress.get(address);
|
|
135111
135581
|
const updatable = device.UPDATABLE ?? device.FIRMWARE_UPDATABLE;
|
|
@@ -135119,7 +135589,7 @@ function buildDevice(interfaceId2, device, channels, details) {
|
|
|
135119
135589
|
...device.AVAILABLE_FIRMWARE !== void 0 ? { availableFirmware: device.AVAILABLE_FIRMWARE } : {},
|
|
135120
135590
|
...updatable !== void 0 ? { updatable } : {},
|
|
135121
135591
|
...device.FIRMWARE_UPDATE_STATE !== void 0 ? { firmwareUpdateState: device.FIRMWARE_UPDATE_STATE } : {},
|
|
135122
|
-
...
|
|
135592
|
+
...name2 !== void 0 ? { name: name2 } : {},
|
|
135123
135593
|
...rooms !== void 0 && rooms.length > 0 ? { rooms } : {},
|
|
135124
135594
|
...functions !== void 0 && functions.length > 0 ? { functions } : {}
|
|
135125
135595
|
};
|
|
@@ -135153,10 +135623,10 @@ function parseDeviceDetail(item, nameByAddress, channelIdToAddress) {
|
|
|
135153
135623
|
const record2 = asRecord(item);
|
|
135154
135624
|
if (record2 === void 0) return;
|
|
135155
135625
|
const address = asString(record2.address);
|
|
135156
|
-
const
|
|
135157
|
-
if (address !== void 0 &&
|
|
135158
|
-
for (const
|
|
135159
|
-
const ch = asRecord(
|
|
135626
|
+
const name2 = asString(record2.name);
|
|
135627
|
+
if (address !== void 0 && name2 !== void 0) nameByAddress.set(address, name2);
|
|
135628
|
+
for (const channel2 of asArray(record2.channels)) {
|
|
135629
|
+
const ch = asRecord(channel2);
|
|
135160
135630
|
if (ch === void 0) continue;
|
|
135161
135631
|
const chAddress = asString(ch.address);
|
|
135162
135632
|
if (chAddress === void 0) continue;
|
|
@@ -135170,31 +135640,31 @@ function deviceAddressOf(channelAddress2) {
|
|
|
135170
135640
|
const colon = channelAddress2.lastIndexOf(":");
|
|
135171
135641
|
return colon === -1 ? channelAddress2 : channelAddress2.slice(0, colon);
|
|
135172
135642
|
}
|
|
135173
|
-
function addGroupName(into, address,
|
|
135643
|
+
function addGroupName(into, address, name2) {
|
|
135174
135644
|
const existing = into.get(address);
|
|
135175
|
-
if (existing === void 0) into.set(address, [
|
|
135176
|
-
else if (!existing.includes(
|
|
135645
|
+
if (existing === void 0) into.set(address, [name2]);
|
|
135646
|
+
else if (!existing.includes(name2)) existing.push(name2);
|
|
135177
135647
|
}
|
|
135178
135648
|
function parseGroup(item, channelIdToAddress, into) {
|
|
135179
135649
|
const record2 = asRecord(item);
|
|
135180
135650
|
if (record2 === void 0) return;
|
|
135181
|
-
const
|
|
135182
|
-
if (
|
|
135651
|
+
const name2 = asString(record2.name);
|
|
135652
|
+
if (name2 === void 0) return;
|
|
135183
135653
|
const idMembers = asArray(record2.channelIds);
|
|
135184
135654
|
for (const member of idMembers) {
|
|
135185
135655
|
const channelId = asString(member);
|
|
135186
135656
|
if (channelId === void 0) continue;
|
|
135187
135657
|
const channelAddress2 = channelIdToAddress.get(channelId);
|
|
135188
135658
|
if (channelAddress2 === void 0) continue;
|
|
135189
|
-
addGroupName(into, channelAddress2,
|
|
135190
|
-
addGroupName(into, deviceAddressOf(channelAddress2),
|
|
135659
|
+
addGroupName(into, channelAddress2, name2);
|
|
135660
|
+
addGroupName(into, deviceAddressOf(channelAddress2), name2);
|
|
135191
135661
|
}
|
|
135192
135662
|
const addressMembers = firstArray(record2.channelAddresses, record2.members);
|
|
135193
135663
|
for (const member of addressMembers) {
|
|
135194
135664
|
const channelAddress2 = asString(member);
|
|
135195
135665
|
if (channelAddress2 === void 0) continue;
|
|
135196
|
-
addGroupName(into, channelAddress2,
|
|
135197
|
-
addGroupName(into, deviceAddressOf(channelAddress2),
|
|
135666
|
+
addGroupName(into, channelAddress2, name2);
|
|
135667
|
+
addGroupName(into, deviceAddressOf(channelAddress2), name2);
|
|
135198
135668
|
}
|
|
135199
135669
|
}
|
|
135200
135670
|
function asArray(value) {
|
|
@@ -135249,7 +135719,7 @@ function parseSysVarValue(type, raw) {
|
|
|
135249
135719
|
}
|
|
135250
135720
|
}
|
|
135251
135721
|
var WRITABLE_MARKER = "HAHM";
|
|
135252
|
-
function
|
|
135722
|
+
function isRecord5(value) {
|
|
135253
135723
|
return value !== null && typeof value === "object";
|
|
135254
135724
|
}
|
|
135255
135725
|
function asString2(value) {
|
|
@@ -135270,7 +135740,7 @@ function asOptionalNumber(value) {
|
|
|
135270
135740
|
}
|
|
135271
135741
|
function asRecordArray2(value) {
|
|
135272
135742
|
if (!Array.isArray(value)) return [];
|
|
135273
|
-
return value.filter(
|
|
135743
|
+
return value.filter(isRecord5);
|
|
135274
135744
|
}
|
|
135275
135745
|
var HubFetcher = class {
|
|
135276
135746
|
client;
|
|
@@ -135294,9 +135764,9 @@ var HubFetcher = class {
|
|
|
135294
135764
|
return entries.map((entry) => this.toSystemVariable(entry, descriptions));
|
|
135295
135765
|
}
|
|
135296
135766
|
/** Read a single system variable's raw value by name. */
|
|
135297
|
-
async getSystemVariable(
|
|
135767
|
+
async getSystemVariable(name2) {
|
|
135298
135768
|
const sid = this.sid();
|
|
135299
|
-
const raw = await this.client.post(JsonRpcMethod.SYSVAR_GET_VALUE_BY_NAME, { name }, sidOpts(sid));
|
|
135769
|
+
const raw = await this.client.post(JsonRpcMethod.SYSVAR_GET_VALUE_BY_NAME, { name: name2 }, sidOpts(sid));
|
|
135300
135770
|
if (typeof raw === "string" || typeof raw === "number" || typeof raw === "boolean") return raw;
|
|
135301
135771
|
if (raw === null || raw === void 0) return null;
|
|
135302
135772
|
return asString2(raw);
|
|
@@ -135306,25 +135776,25 @@ var HubFetcher = class {
|
|
|
135306
135776
|
* `SysVar.setBool` (1/0), number → `SysVar.setFloat`, string → ReGa
|
|
135307
135777
|
* `SET_SYSTEM_VARIABLE`. A null value is rejected.
|
|
135308
135778
|
*/
|
|
135309
|
-
async setSystemVariable(
|
|
135779
|
+
async setSystemVariable(name2, value) {
|
|
135310
135780
|
const sid = this.sid();
|
|
135311
|
-
if (value === null) throw new ValidationError(`Cannot set system variable "${
|
|
135781
|
+
if (value === null) throw new ValidationError(`Cannot set system variable "${name2}" to null`);
|
|
135312
135782
|
if (typeof value === "boolean") {
|
|
135313
135783
|
await this.client.post(JsonRpcMethod.SYSVAR_SET_BOOL, {
|
|
135314
|
-
name,
|
|
135784
|
+
name: name2,
|
|
135315
135785
|
value: value ? 1 : 0
|
|
135316
135786
|
}, sidOpts(sid));
|
|
135317
135787
|
return;
|
|
135318
135788
|
}
|
|
135319
135789
|
if (typeof value === "number") {
|
|
135320
135790
|
await this.client.post(JsonRpcMethod.SYSVAR_SET_FLOAT, {
|
|
135321
|
-
name,
|
|
135791
|
+
name: name2,
|
|
135322
135792
|
value
|
|
135323
135793
|
}, sidOpts(sid));
|
|
135324
135794
|
return;
|
|
135325
135795
|
}
|
|
135326
135796
|
await runScript(this.client, sid, SET_SYSTEM_VARIABLE, {
|
|
135327
|
-
name,
|
|
135797
|
+
name: name2,
|
|
135328
135798
|
value
|
|
135329
135799
|
});
|
|
135330
135800
|
}
|
|
@@ -135363,8 +135833,8 @@ var HubFetcher = class {
|
|
|
135363
135833
|
const sid = this.sid();
|
|
135364
135834
|
const parsed = await runScript(this.client, sid, GET_ROOMS_FUNCTIONS);
|
|
135365
135835
|
return {
|
|
135366
|
-
rooms: toDecodedMap(
|
|
135367
|
-
functions: toDecodedMap(
|
|
135836
|
+
rooms: toDecodedMap(isRecord5(parsed) ? parsed.rooms : void 0),
|
|
135837
|
+
functions: toDecodedMap(isRecord5(parsed) ? parsed.functions : void 0)
|
|
135368
135838
|
};
|
|
135369
135839
|
}
|
|
135370
135840
|
/** Build the `SYSVAR_DESCRIPTIONS` map: sysvar id → description text. */
|
|
@@ -135410,7 +135880,7 @@ function sidOpts(sid) {
|
|
|
135410
135880
|
}
|
|
135411
135881
|
function toDecodedMap(value) {
|
|
135412
135882
|
const map = /* @__PURE__ */ new Map();
|
|
135413
|
-
if (!
|
|
135883
|
+
if (!isRecord5(value)) return map;
|
|
135414
135884
|
for (const [addr, names] of Object.entries(value)) if (Array.isArray(names)) map.set(addr, names.filter((n) => typeof n === "string").map((n) => decodeRegaName(n)));
|
|
135415
135885
|
return map;
|
|
135416
135886
|
}
|
|
@@ -135470,6 +135940,10 @@ var ConnectionStateTracker = class {
|
|
|
135470
135940
|
recordEvent(interfaceId2, at = this.now()) {
|
|
135471
135941
|
this.lastEventAt.set(interfaceId2, at);
|
|
135472
135942
|
}
|
|
135943
|
+
/** Time of the latest inbound event recorded for an interface, or `undefined`. */
|
|
135944
|
+
getLastEventAt(interfaceId2) {
|
|
135945
|
+
return this.lastEventAt.get(interfaceId2);
|
|
135946
|
+
}
|
|
135473
135947
|
/**
|
|
135474
135948
|
* True if the callback channel is considered alive: either no event has been
|
|
135475
135949
|
* recorded yet (we have no evidence of silence) or the elapsed time since the
|
|
@@ -135742,8 +136216,8 @@ var Scheduler = class {
|
|
|
135742
136216
|
this.timers.clear();
|
|
135743
136217
|
}
|
|
135744
136218
|
/** Suspend every job except the named one (keeps it running unchanged). */
|
|
135745
|
-
pauseAllExcept(
|
|
135746
|
-
for (const [jobName, timer] of this.timers) if (jobName !==
|
|
136219
|
+
pauseAllExcept(name2) {
|
|
136220
|
+
for (const [jobName, timer] of this.timers) if (jobName !== name2) {
|
|
135747
136221
|
clearInterval(timer);
|
|
135748
136222
|
this.timers.delete(jobName);
|
|
135749
136223
|
}
|
|
@@ -135846,7 +136320,8 @@ var CallbackRouter = class {
|
|
|
135846
136320
|
type: "valueReceived",
|
|
135847
136321
|
dpk,
|
|
135848
136322
|
value,
|
|
135849
|
-
receivedAt
|
|
136323
|
+
receivedAt,
|
|
136324
|
+
origin: "event"
|
|
135850
136325
|
});
|
|
135851
136326
|
}
|
|
135852
136327
|
async routeNewDevices(interfaceId2, descriptions) {
|
|
@@ -136060,6 +136535,20 @@ var CentralUnit = class {
|
|
|
136060
136535
|
async installFirmware(interfaceId2, deviceAddress) {
|
|
136061
136536
|
await this.clientFor(interfaceId2).installFirmware(deviceAddress);
|
|
136062
136537
|
}
|
|
136538
|
+
/**
|
|
136539
|
+
* What the connection tracker knows about one interface: its state, the time
|
|
136540
|
+
* of the latest inbound event of ANY kind (`ConnectionStateTracker.recordEvent`,
|
|
136541
|
+
* called by the callback router for every event), and whether the callback
|
|
136542
|
+
* channel is considered alive (`isCallbackAlive`: true until the silence
|
|
136543
|
+
* exceeds the warn interval, or before the first event). Read only.
|
|
136544
|
+
*/
|
|
136545
|
+
getConnectionInfo(interfaceId2) {
|
|
136546
|
+
return {
|
|
136547
|
+
state: this.connectionState.getState(interfaceId2),
|
|
136548
|
+
lastEventAt: this.connectionState.getLastEventAt(interfaceId2) ?? null,
|
|
136549
|
+
callbackAlive: this.connectionState.isCallbackAlive(interfaceId2)
|
|
136550
|
+
};
|
|
136551
|
+
}
|
|
136063
136552
|
/** XML-RPC `getLinks(channelAddress, flags)`, routed by interface id. */
|
|
136064
136553
|
async getLinks(interfaceId2, channelAddress2, flags) {
|
|
136065
136554
|
return this.clientFor(interfaceId2).getLinks(channelAddress2, flags);
|
|
@@ -136076,8 +136565,8 @@ var CentralUnit = class {
|
|
|
136076
136565
|
return this.clientFor(interfaceId2).reportValueUsage(channelAddress2, valueId, refCounter);
|
|
136077
136566
|
}
|
|
136078
136567
|
/** XML-RPC `addLink(sender, receiver, name, description)`, routed by interface id. */
|
|
136079
|
-
async addLink(interfaceId2, sender, receiver,
|
|
136080
|
-
await this.clientFor(interfaceId2).addLink(sender, receiver,
|
|
136568
|
+
async addLink(interfaceId2, sender, receiver, name2, description) {
|
|
136569
|
+
await this.clientFor(interfaceId2).addLink(sender, receiver, name2, description);
|
|
136081
136570
|
}
|
|
136082
136571
|
/** XML-RPC `removeLink(sender, receiver)`, routed by interface id. */
|
|
136083
136572
|
async removeLink(interfaceId2, sender, receiver) {
|
|
@@ -136302,17 +136791,17 @@ var CentralUnit = class {
|
|
|
136302
136791
|
const tasks = [];
|
|
136303
136792
|
for (const runtime of this.runtimes.values()) for (const node of this.registryStore.getAll()) {
|
|
136304
136793
|
if (node.interfaceId !== runtime.interfaceId) continue;
|
|
136305
|
-
for (const
|
|
136306
|
-
if (!this.channelHasValuesParams(
|
|
136307
|
-
tasks.push(() => this.seedChannel(runtime,
|
|
136794
|
+
for (const channel2 of node.channels) {
|
|
136795
|
+
if (!this.channelHasValuesParams(channel2)) continue;
|
|
136796
|
+
tasks.push(() => this.seedChannel(runtime, channel2.address));
|
|
136308
136797
|
}
|
|
136309
136798
|
}
|
|
136310
136799
|
const seeded = await runBounded(tasks, SEED_CONCURRENCY);
|
|
136311
136800
|
if (seeded > 0) this.logger.debug(`seeded ${seeded} initial value(s) from VALUES paramsets`);
|
|
136312
136801
|
}
|
|
136313
136802
|
/** True if the channel advertises at least one VALUES parameter. */
|
|
136314
|
-
channelHasValuesParams(
|
|
136315
|
-
for (const [, specs] of
|
|
136803
|
+
channelHasValuesParams(channel2) {
|
|
136804
|
+
for (const [, specs] of channel2.parameters) if (specs.VALUES !== void 0) return true;
|
|
136316
136805
|
return false;
|
|
136317
136806
|
}
|
|
136318
136807
|
/**
|
|
@@ -136332,7 +136821,8 @@ var CentralUnit = class {
|
|
|
136332
136821
|
type: "valueReceived",
|
|
136333
136822
|
dpk,
|
|
136334
136823
|
value: rawValue,
|
|
136335
|
-
receivedAt
|
|
136824
|
+
receivedAt,
|
|
136825
|
+
origin: "seed"
|
|
136336
136826
|
});
|
|
136337
136827
|
count += 1;
|
|
136338
136828
|
}
|
|
@@ -136490,13 +136980,13 @@ var CentralUnit = class {
|
|
|
136490
136980
|
if (runtime === void 0) return;
|
|
136491
136981
|
for (const node of this.registryStore.getAll()) {
|
|
136492
136982
|
if (node.interfaceId !== interfaceId2) continue;
|
|
136493
|
-
for (const
|
|
136494
|
-
const valuesParams =
|
|
136983
|
+
for (const channel2 of node.channels) {
|
|
136984
|
+
const valuesParams = channel2.parameters;
|
|
136495
136985
|
for (const [parameter, specs] of valuesParams) {
|
|
136496
136986
|
if (specs.VALUES === void 0 || !specs.VALUES.readable) continue;
|
|
136497
136987
|
try {
|
|
136498
|
-
const value = await runtime.client.getValue(
|
|
136499
|
-
const dpk = makeDpkValues(interfaceId2,
|
|
136988
|
+
const value = await runtime.client.getValue(channel2.address, parameter);
|
|
136989
|
+
const dpk = makeDpkValues(interfaceId2, channel2.address, parameter);
|
|
136500
136990
|
this.valueCache.add(dpk, value, this.now());
|
|
136501
136991
|
} catch {}
|
|
136502
136992
|
}
|
|
@@ -136791,22 +137281,22 @@ var ModelDevice = class {
|
|
|
136791
137281
|
function interfaceFamilyOf(interfaceId2) {
|
|
136792
137282
|
return interfaceId2.toLowerCase().includes("hmip") ? "HMIP" : "HM";
|
|
136793
137283
|
}
|
|
136794
|
-
function buildChannel2(
|
|
137284
|
+
function buildChannel2(channel2, interfaceId2, family) {
|
|
136795
137285
|
const dataPoints = [];
|
|
136796
|
-
for (const [parameter, specs] of
|
|
137286
|
+
for (const [parameter, specs] of channel2.parameters) {
|
|
136797
137287
|
const spec = specs.VALUES;
|
|
136798
137288
|
if (spec === void 0 || !spec.readable && !spec.hasEvents && !spec.writable) continue;
|
|
136799
137289
|
dataPoints.push(new GenericDataPoint({
|
|
136800
|
-
dpk: makeDpk(interfaceId2,
|
|
137290
|
+
dpk: makeDpk(interfaceId2, channel2.address, "VALUES", parameter),
|
|
136801
137291
|
spec,
|
|
136802
137292
|
interfaceFamily: family
|
|
136803
137293
|
}));
|
|
136804
137294
|
}
|
|
136805
137295
|
return new ModelChannel({
|
|
136806
|
-
address:
|
|
136807
|
-
index:
|
|
136808
|
-
...
|
|
136809
|
-
...
|
|
137296
|
+
address: channel2.address,
|
|
137297
|
+
index: channel2.index,
|
|
137298
|
+
...channel2.type !== void 0 ? { type: channel2.type } : {},
|
|
137299
|
+
...channel2.name !== void 0 ? { name: channel2.name } : {},
|
|
136810
137300
|
dataPoints
|
|
136811
137301
|
});
|
|
136812
137302
|
}
|
|
@@ -136850,11 +137340,11 @@ function parseChannelLinks(value) {
|
|
|
136850
137340
|
const sender = structString(entry, "SENDER");
|
|
136851
137341
|
const receiver = structString(entry, "RECEIVER");
|
|
136852
137342
|
if (sender === void 0 || receiver === void 0) continue;
|
|
136853
|
-
const
|
|
137343
|
+
const name2 = entry.NAME;
|
|
136854
137344
|
links.push({
|
|
136855
137345
|
sender,
|
|
136856
137346
|
receiver,
|
|
136857
|
-
name: typeof
|
|
137347
|
+
name: typeof name2 === "string" ? name2 : ""
|
|
136858
137348
|
});
|
|
136859
137349
|
}
|
|
136860
137350
|
return links;
|
|
@@ -136864,6 +137354,138 @@ function metadataHasCentralLink(value) {
|
|
|
136864
137354
|
const counter = value[REPORT_VALUE_USAGE_VALUE_ID];
|
|
136865
137355
|
return typeof counter === "number" && counter > 0;
|
|
136866
137356
|
}
|
|
137357
|
+
var KEY_CHANNEL_TYPES = /* @__PURE__ */ new Set([
|
|
137358
|
+
"KEY_TRANSCEIVER",
|
|
137359
|
+
"KEY",
|
|
137360
|
+
"VIRTUAL_KEY"
|
|
137361
|
+
]);
|
|
137362
|
+
function messageOf(err) {
|
|
137363
|
+
return err instanceof Error ? err.message : String(err);
|
|
137364
|
+
}
|
|
137365
|
+
async function section(read) {
|
|
137366
|
+
try {
|
|
137367
|
+
return {
|
|
137368
|
+
ok: true,
|
|
137369
|
+
data: await read()
|
|
137370
|
+
};
|
|
137371
|
+
} catch (err) {
|
|
137372
|
+
return {
|
|
137373
|
+
ok: false,
|
|
137374
|
+
error: messageOf(err)
|
|
137375
|
+
};
|
|
137376
|
+
}
|
|
137377
|
+
}
|
|
137378
|
+
function pressShortCount(metadata) {
|
|
137379
|
+
if (typeof metadata !== "object" || metadata === null || Array.isArray(metadata) || metadata instanceof Date || metadata instanceof Uint8Array) return null;
|
|
137380
|
+
const counter = metadata["PRESS_SHORT"];
|
|
137381
|
+
return typeof counter === "number" ? counter : null;
|
|
137382
|
+
}
|
|
137383
|
+
function isKeyChannel(source, device, channel2) {
|
|
137384
|
+
if (channel2.type !== void 0 && KEY_CHANNEL_TYPES.has(channel2.type)) return true;
|
|
137385
|
+
if (channel2.dataPoint("PRESS_SHORT") !== void 0) return true;
|
|
137386
|
+
const spec = source.getParamsetSpec(device.interfaceId, channel2.address, "VALUES");
|
|
137387
|
+
return spec !== void 0 && "PRESS_SHORT" in spec;
|
|
137388
|
+
}
|
|
137389
|
+
function clientState(channel2, address, withPress) {
|
|
137390
|
+
const known = new Map((channel2?.dataPoints ?? []).map((dp) => [dp.parameter, dp]));
|
|
137391
|
+
const press = withPress ? KEY_DIAGNOSIS_PARAMETERS : [];
|
|
137392
|
+
const rest = [...known.keys()].filter((parameter) => !press.includes(parameter));
|
|
137393
|
+
return {
|
|
137394
|
+
channelAddress: address,
|
|
137395
|
+
parameters: [...press, ...rest].map((parameter) => {
|
|
137396
|
+
const dp = known.get(parameter);
|
|
137397
|
+
return {
|
|
137398
|
+
parameter,
|
|
137399
|
+
known: dp !== void 0,
|
|
137400
|
+
lastEventAt: dp?.lastUpdatedAt ?? null,
|
|
137401
|
+
value: dp?.value ?? null
|
|
137402
|
+
};
|
|
137403
|
+
})
|
|
137404
|
+
};
|
|
137405
|
+
}
|
|
137406
|
+
async function readChannelXmlRpc(source, interfaceId2, address) {
|
|
137407
|
+
const [centralLink, directLinks, values, master] = await Promise.all([
|
|
137408
|
+
section(async () => {
|
|
137409
|
+
const metadata = await source.getMetadata(interfaceId2, address, REPORT_VALUE_USAGE_DATA);
|
|
137410
|
+
return {
|
|
137411
|
+
pressShortCount: pressShortCount(metadata),
|
|
137412
|
+
active: metadataHasCentralLink(metadata)
|
|
137413
|
+
};
|
|
137414
|
+
}),
|
|
137415
|
+
section(async () => parseChannelLinks(await source.getLinks(interfaceId2, address, GET_LINKS_FLAGS))),
|
|
137416
|
+
section(() => source.readParamset(interfaceId2, address, "VALUES")),
|
|
137417
|
+
section(() => source.readParamset(interfaceId2, address, "MASTER"))
|
|
137418
|
+
]);
|
|
137419
|
+
return {
|
|
137420
|
+
centralLink,
|
|
137421
|
+
directLinks,
|
|
137422
|
+
values,
|
|
137423
|
+
master
|
|
137424
|
+
};
|
|
137425
|
+
}
|
|
137426
|
+
async function readMaintenance(source, interfaceId2, address) {
|
|
137427
|
+
return section(async () => {
|
|
137428
|
+
const values = await source.readParamset(interfaceId2, address, "VALUES");
|
|
137429
|
+
return {
|
|
137430
|
+
channelAddress: address,
|
|
137431
|
+
configPending: values["CONFIG_PENDING"] ?? null,
|
|
137432
|
+
unreach: values["UNREACH"] ?? null,
|
|
137433
|
+
rssiDevice: values["RSSI_DEVICE"] ?? null,
|
|
137434
|
+
rssiPeer: values["RSSI_PEER"] ?? null,
|
|
137435
|
+
updatePending: values["UPDATE_PENDING"] ?? null
|
|
137436
|
+
};
|
|
137437
|
+
});
|
|
137438
|
+
}
|
|
137439
|
+
async function readRega(source, device, keyAddresses) {
|
|
137440
|
+
if (keyAddresses.length === 0) return {
|
|
137441
|
+
available: true,
|
|
137442
|
+
state: {
|
|
137443
|
+
channels: [],
|
|
137444
|
+
programs: []
|
|
137445
|
+
}
|
|
137446
|
+
};
|
|
137447
|
+
try {
|
|
137448
|
+
return {
|
|
137449
|
+
available: true,
|
|
137450
|
+
state: await source.readRega(interfaceNameOf(device.interfaceId), keyAddresses)
|
|
137451
|
+
};
|
|
137452
|
+
} catch (err) {
|
|
137453
|
+
return {
|
|
137454
|
+
available: false,
|
|
137455
|
+
reason: messageOf(err)
|
|
137456
|
+
};
|
|
137457
|
+
}
|
|
137458
|
+
}
|
|
137459
|
+
async function diagnoseKeyEvents(source, device) {
|
|
137460
|
+
const keyChannels = device.channels.filter((channel2) => isKeyChannel(source, device, channel2));
|
|
137461
|
+
const maintenanceAddress = `${device.address}:0`;
|
|
137462
|
+
const [maintenance, channels, rega] = await Promise.all([
|
|
137463
|
+
readMaintenance(source, device.interfaceId, maintenanceAddress),
|
|
137464
|
+
Promise.all(keyChannels.map(async (channel2) => ({
|
|
137465
|
+
address: channel2.address,
|
|
137466
|
+
type: channel2.type ?? null,
|
|
137467
|
+
xmlRpc: await readChannelXmlRpc(source, device.interfaceId, channel2.address),
|
|
137468
|
+
client: clientState(channel2, channel2.address, true)
|
|
137469
|
+
}))),
|
|
137470
|
+
readRega(source, device, keyChannels.map((channel2) => channel2.address))
|
|
137471
|
+
]);
|
|
137472
|
+
const info = source.getConnectionInfo(device.interfaceId);
|
|
137473
|
+
return {
|
|
137474
|
+
deviceAddress: device.address,
|
|
137475
|
+
interfaceId: device.interfaceId,
|
|
137476
|
+
takenAt: source.now(),
|
|
137477
|
+
maintenance,
|
|
137478
|
+
maintenanceClient: clientState(device.channel(maintenanceAddress), maintenanceAddress, false),
|
|
137479
|
+
channels,
|
|
137480
|
+
rega,
|
|
137481
|
+
interfaceClient: {
|
|
137482
|
+
interfaceId: device.interfaceId,
|
|
137483
|
+
state: String(info.state),
|
|
137484
|
+
lastEventAt: info.lastEventAt,
|
|
137485
|
+
callbackAlive: info.callbackAlive
|
|
137486
|
+
}
|
|
137487
|
+
};
|
|
137488
|
+
}
|
|
136867
137489
|
var SWITCH_LINK_SENDER_TYPE = "KEY_TRANSCEIVER";
|
|
136868
137490
|
var SWITCH_LINK_RECEIVER_TYPE = "SWITCH_VIRTUAL_RECEIVER";
|
|
136869
137491
|
var ACTION_TYPE = "PROFILE_ACTION_TYPE";
|
|
@@ -136989,12 +137611,12 @@ function parseLinks(value) {
|
|
|
136989
137611
|
const sender = nonEmptyString(entry["SENDER"]);
|
|
136990
137612
|
const receiver = nonEmptyString(entry["RECEIVER"]);
|
|
136991
137613
|
if (sender === void 0 || receiver === void 0) continue;
|
|
136992
|
-
const
|
|
137614
|
+
const name2 = entry["NAME"];
|
|
136993
137615
|
const description = entry["DESCRIPTION"];
|
|
136994
137616
|
links.push({
|
|
136995
137617
|
sender,
|
|
136996
137618
|
receiver,
|
|
136997
|
-
name: typeof
|
|
137619
|
+
name: typeof name2 === "string" ? name2 : "",
|
|
136998
137620
|
description: typeof description === "string" ? description : ""
|
|
136999
137621
|
});
|
|
137000
137622
|
}
|
|
@@ -137640,8 +138262,8 @@ var RfLockEntity = class extends CustomEntity {
|
|
|
137640
138262
|
await this.write("OPEN", true);
|
|
137641
138263
|
}
|
|
137642
138264
|
};
|
|
137643
|
-
function channelAddress(deviceAddress,
|
|
137644
|
-
return `${deviceAddress}:${
|
|
138265
|
+
function channelAddress(deviceAddress, channel2) {
|
|
138266
|
+
return `${deviceAddress}:${channel2}`;
|
|
137645
138267
|
}
|
|
137646
138268
|
function resolveFields(device, baseChannel, mappings, defaultOffset, target, readTarget) {
|
|
137647
138269
|
for (const mapping of mappings) {
|
|
@@ -137843,9 +138465,9 @@ var TypedEventEmitter = class {
|
|
|
137843
138465
|
};
|
|
137844
138466
|
var DEFAULT_CENTRAL_NAME = "nodehomematic";
|
|
137845
138467
|
var pendingTestInjectables;
|
|
137846
|
-
function toInterface2(
|
|
137847
|
-
const match = Object.values(Interface).includes(
|
|
137848
|
-
if (match === void 0) throw new ValidationError(`Unknown interface "${
|
|
138468
|
+
function toInterface2(name2) {
|
|
138469
|
+
const match = Object.values(Interface).includes(name2) ? name2 : void 0;
|
|
138470
|
+
if (match === void 0) throw new ValidationError(`Unknown interface "${name2}".`);
|
|
137849
138471
|
return match;
|
|
137850
138472
|
}
|
|
137851
138473
|
var CHANNEL_ADDRESS_PATTERN = /^[0-9A-Za-z_-]+:\d+$/;
|
|
@@ -138072,7 +138694,9 @@ var Homematic = class {
|
|
|
138072
138694
|
* CCU subscribes to the key data points (ReGa scripts and their eq-3/occu
|
|
138073
138695
|
* sources: `central/rega/key-event-program.ts`). All channels must be on one
|
|
138074
138696
|
* interface and the CCU must have their data points; a missing one is a
|
|
138075
|
-
* {@link ValidationError} naming it.
|
|
138697
|
+
* {@link ValidationError} naming it. Two programs with the same name are a
|
|
138698
|
+
* {@link ValidationError} listing their ids (`deleteProgram(id)` removes one).
|
|
138699
|
+
* Needs WebUI credentials.
|
|
138076
138700
|
*/
|
|
138077
138701
|
async ensureKeyEventProgram(input) {
|
|
138078
138702
|
if (input.channelAddresses.length === 0) throw new ValidationError("ensureKeyEventProgram needs at least one channel.");
|
|
@@ -138081,13 +138705,46 @@ var Homematic = class {
|
|
|
138081
138705
|
if (interfaces.size !== 1 || iface === void 0) throw new ValidationError("The key channels of one program must share an interface.");
|
|
138082
138706
|
return this.#requireManagement().keyPrograms().ensure(iface, input);
|
|
138083
138707
|
}
|
|
138084
|
-
/** Delete the key event program `name`; `removed: false` when it does not exist. Needs WebUI credentials. */
|
|
138085
|
-
async removeKeyEventProgram(
|
|
138086
|
-
return this.#requireManagement().keyPrograms().remove(
|
|
138708
|
+
/** Delete the key event program `name`; `removed: false` when it does not exist. A duplicate name is a {@link ValidationError}. Needs WebUI credentials. */
|
|
138709
|
+
async removeKeyEventProgram(name2) {
|
|
138710
|
+
return this.#requireManagement().keyPrograms().remove(name2);
|
|
138711
|
+
}
|
|
138712
|
+
/**
|
|
138713
|
+
* Delete one CCU program by its ReGa id (digits only). `removed: false` when
|
|
138714
|
+
* the id is missing or is not a program — nothing is deleted then. This is
|
|
138715
|
+
* the way out of two programs that share a name. Needs WebUI credentials.
|
|
138716
|
+
*/
|
|
138717
|
+
async deleteProgram(programId) {
|
|
138718
|
+
return this.#requireManagement().keyPrograms().delete(programId);
|
|
138719
|
+
}
|
|
138720
|
+
/** The key event program `name` and the channels it listens to, or `null`. A duplicate name is a {@link ValidationError}. Needs WebUI credentials. */
|
|
138721
|
+
async getKeyEventProgram(name2) {
|
|
138722
|
+
return this.#requireManagement().keyPrograms().get(name2);
|
|
138087
138723
|
}
|
|
138088
|
-
/**
|
|
138089
|
-
|
|
138090
|
-
|
|
138724
|
+
/**
|
|
138725
|
+
* Read-only diagnosis of "why does a key of this device not deliver
|
|
138726
|
+
* `PRESS_SHORT` to this client?": for the device's key channels it collects
|
|
138727
|
+
* the XML-RPC side (central link, direct links, VALUES, MASTER, and the
|
|
138728
|
+
* maintenance channel `:0`), the ReGa side (channel and key data point
|
|
138729
|
+
* objects with their last update, and the programs that reference them;
|
|
138730
|
+
* needs WebUI credentials, otherwise `rega.available` is `false`) and what
|
|
138731
|
+
* this client itself received. Each section fails on its own with
|
|
138732
|
+
* `{ ok: false, error }`. Sources and semantics: `key-event-diagnosis.ts`.
|
|
138733
|
+
* Throws {@link ValidationError} for an unknown device or before `start()`.
|
|
138734
|
+
*/
|
|
138735
|
+
async diagnoseKeyEvents(deviceAddress) {
|
|
138736
|
+
const management = this.#requireManagement();
|
|
138737
|
+
const device = this.#devicesByAddress.get(deviceAddress);
|
|
138738
|
+
if (device === void 0) throw new ValidationError(`Unknown device "${deviceAddress}".`);
|
|
138739
|
+
return diagnoseKeyEvents({
|
|
138740
|
+
getMetadata: (iface, address, dataId) => this.#central.getMetadata(iface, address, dataId),
|
|
138741
|
+
getLinks: (iface, address, flags) => this.#central.getLinks(iface, address, flags),
|
|
138742
|
+
readParamset: (iface, address, key) => this.#central.readParamset(iface, address, key),
|
|
138743
|
+
getParamsetSpec: (iface, address, key) => this.#central.getParamsetSpec(iface, address, key),
|
|
138744
|
+
getConnectionInfo: (iface) => this.#central.getConnectionInfo(iface),
|
|
138745
|
+
readRega: (iface, addresses) => management.keyDiagnosis().read(iface, addresses),
|
|
138746
|
+
now: () => Date.now()
|
|
138747
|
+
}, device);
|
|
138091
138748
|
}
|
|
138092
138749
|
/**
|
|
138093
138750
|
* Create a direct link from `sender` to `receiver` (XML-RPC
|
|
@@ -138097,11 +138754,11 @@ var Homematic = class {
|
|
|
138097
138754
|
* without a call and leaves the existing name and description unchanged.
|
|
138098
138755
|
* The sender must be a known channel; a fault is a {@link ClientError}.
|
|
138099
138756
|
*/
|
|
138100
|
-
async addLink(sender, receiver,
|
|
138757
|
+
async addLink(sender, receiver, name2 = "", description = "") {
|
|
138101
138758
|
const device = this.#requireKnownChannel(sender);
|
|
138102
138759
|
requireChannelAddress(receiver);
|
|
138103
138760
|
if (await this.#findLink(device.interfaceId, sender, receiver) !== void 0) return;
|
|
138104
|
-
await this.#central.addLink(device.interfaceId, sender, receiver,
|
|
138761
|
+
await this.#central.addLink(device.interfaceId, sender, receiver, name2, description);
|
|
138105
138762
|
}
|
|
138106
138763
|
/**
|
|
138107
138764
|
* Remove the direct link from `sender` to `receiver` (XML-RPC
|
|
@@ -138177,16 +138834,16 @@ var Homematic = class {
|
|
|
138177
138834
|
* Resolves with the names the CCU stored (it keeps names unique); `devices()`
|
|
138178
138835
|
* shows them from then on. Needs WebUI credentials.
|
|
138179
138836
|
*/
|
|
138180
|
-
async renameDevice(address,
|
|
138837
|
+
async renameDevice(address, name2, options) {
|
|
138181
138838
|
this.#requireKnownDevice(address);
|
|
138182
|
-
const result = await this.#requireTopology().renameDevice(address,
|
|
138839
|
+
const result = await this.#requireTopology().renameDevice(address, name2, options.renameChannels);
|
|
138183
138840
|
this.#rememberNames([result.device, ...result.channels]);
|
|
138184
138841
|
return result;
|
|
138185
138842
|
}
|
|
138186
138843
|
/** Rename one channel (as JSON-RPC `Channel.setName`); resolves with the stored name. Needs WebUI credentials. */
|
|
138187
|
-
async renameChannel(address,
|
|
138844
|
+
async renameChannel(address, name2) {
|
|
138188
138845
|
this.#requireKnownChannel(address);
|
|
138189
|
-
const result = await this.#requireTopology().renameChannel(address,
|
|
138846
|
+
const result = await this.#requireTopology().renameChannel(address, name2);
|
|
138190
138847
|
this.#rememberNames([result]);
|
|
138191
138848
|
return result;
|
|
138192
138849
|
}
|
|
@@ -138199,12 +138856,12 @@ var Homematic = class {
|
|
|
138199
138856
|
return this.#requireTopology().rooms();
|
|
138200
138857
|
}
|
|
138201
138858
|
/** Create an empty room (eq-3/occu `rega/esp/rooms.fn` `createRoomRetId`); a duplicate name is refused. Needs WebUI credentials. */
|
|
138202
|
-
async createRoom(
|
|
138203
|
-
return this.#requireTopology().createRoom(
|
|
138859
|
+
async createRoom(name2) {
|
|
138860
|
+
return this.#requireTopology().createRoom(name2);
|
|
138204
138861
|
}
|
|
138205
138862
|
/** Rename a room by its id (`rooms.fn` `changeRoomName`). Needs WebUI credentials. */
|
|
138206
|
-
async renameRoom(roomId,
|
|
138207
|
-
await this.#requireTopology().renameRoom(roomId,
|
|
138863
|
+
async renameRoom(roomId, name2) {
|
|
138864
|
+
await this.#requireTopology().renameRoom(roomId, name2);
|
|
138208
138865
|
}
|
|
138209
138866
|
/** Delete a room by its id (`rega/esp/system.fn` `DeleteObject`). Needs WebUI credentials. */
|
|
138210
138867
|
async deleteRoom(roomId) {
|
|
@@ -138358,20 +139015,20 @@ var Homematic = class {
|
|
|
138358
139015
|
return this.#sysvars.map(toHmSysVar);
|
|
138359
139016
|
}
|
|
138360
139017
|
/** Read a single system variable's current value by name. Throws if no hub. */
|
|
138361
|
-
async getSystemVariable(
|
|
138362
|
-
return this.#requireHub().getSystemVariable(
|
|
139018
|
+
async getSystemVariable(name2) {
|
|
139019
|
+
return this.#requireHub().getSystemVariable(name2);
|
|
138363
139020
|
}
|
|
138364
139021
|
/**
|
|
138365
139022
|
* Write a system variable by name. Validates against the snapshot BEFORE any
|
|
138366
139023
|
* network call: an unknown or read-only variable throws {@link ValidationError}
|
|
138367
139024
|
* (no write is attempted). Throws if no hub.
|
|
138368
139025
|
*/
|
|
138369
|
-
async setSystemVariable(
|
|
139026
|
+
async setSystemVariable(name2, value) {
|
|
138370
139027
|
const hub = this.#requireHub();
|
|
138371
|
-
const sysvar = this.#sysvars.find((v) => v.name ===
|
|
138372
|
-
if (sysvar === void 0) throw new ValidationError(`Unknown system variable "${
|
|
138373
|
-
if (!sysvar.writable) throw new ValidationError(`System variable "${
|
|
138374
|
-
await hub.setSystemVariable(
|
|
139028
|
+
const sysvar = this.#sysvars.find((v) => v.name === name2);
|
|
139029
|
+
if (sysvar === void 0) throw new ValidationError(`Unknown system variable "${name2}".`);
|
|
139030
|
+
if (!sysvar.writable) throw new ValidationError(`System variable "${name2}" is read-only.`);
|
|
139031
|
+
await hub.setSystemVariable(name2, value);
|
|
138375
139032
|
}
|
|
138376
139033
|
/**
|
|
138377
139034
|
* An immutable snapshot of every known program (empty when no hub). Refreshed
|
|
@@ -138404,65 +139061,65 @@ var Homematic = class {
|
|
|
138404
139061
|
return this.#customEntityList.map((entity) => toHmCustomEntity(entity));
|
|
138405
139062
|
}
|
|
138406
139063
|
/** Set a climate entity's target temperature (clamped to its range). */
|
|
138407
|
-
async climateSetTemperature(device,
|
|
138408
|
-
await this.#climate(device,
|
|
139064
|
+
async climateSetTemperature(device, channel2, temperature) {
|
|
139065
|
+
await this.#climate(device, channel2).setTemperature(temperature);
|
|
138409
139066
|
}
|
|
138410
139067
|
/** Set a climate entity's operating mode. */
|
|
138411
|
-
async climateSetMode(device,
|
|
138412
|
-
await this.#climate(device,
|
|
139068
|
+
async climateSetMode(device, channel2, mode) {
|
|
139069
|
+
await this.#climate(device, channel2).setMode(mode);
|
|
138413
139070
|
}
|
|
138414
139071
|
/** Enable or disable a climate entity's boost mode. */
|
|
138415
|
-
async climateSetBoost(device,
|
|
138416
|
-
await this.#climate(device,
|
|
139072
|
+
async climateSetBoost(device, channel2, on) {
|
|
139073
|
+
await this.#climate(device, channel2).setBoost(on);
|
|
138417
139074
|
}
|
|
138418
139075
|
/** Turn a switch entity on. */
|
|
138419
|
-
async switchTurnOn(device,
|
|
138420
|
-
await this.#switch(device,
|
|
139076
|
+
async switchTurnOn(device, channel2) {
|
|
139077
|
+
await this.#switch(device, channel2).turnOn();
|
|
138421
139078
|
}
|
|
138422
139079
|
/** Turn a switch entity off. */
|
|
138423
|
-
async switchTurnOff(device,
|
|
138424
|
-
await this.#switch(device,
|
|
139080
|
+
async switchTurnOff(device, channel2) {
|
|
139081
|
+
await this.#switch(device, channel2).turnOff();
|
|
138425
139082
|
}
|
|
138426
139083
|
/** Turn a light entity on (full brightness, or `brightness` 0..255 when given). */
|
|
138427
|
-
async lightTurnOn(device,
|
|
138428
|
-
const light = this.#light(device,
|
|
139084
|
+
async lightTurnOn(device, channel2, brightness) {
|
|
139085
|
+
const light = this.#light(device, channel2);
|
|
138429
139086
|
await (brightness === void 0 ? light.turnOn() : light.turnOn(brightness));
|
|
138430
139087
|
}
|
|
138431
139088
|
/** Turn a light entity off. */
|
|
138432
|
-
async lightTurnOff(device,
|
|
138433
|
-
await this.#light(device,
|
|
139089
|
+
async lightTurnOff(device, channel2) {
|
|
139090
|
+
await this.#light(device, channel2).turnOff();
|
|
138434
139091
|
}
|
|
138435
139092
|
/** Set a light entity's brightness (0..255). */
|
|
138436
|
-
async lightSetBrightness(device,
|
|
138437
|
-
await this.#light(device,
|
|
139093
|
+
async lightSetBrightness(device, channel2, brightness) {
|
|
139094
|
+
await this.#light(device, channel2).setBrightness(brightness);
|
|
138438
139095
|
}
|
|
138439
139096
|
/** Open a cover entity fully. */
|
|
138440
|
-
async coverOpen(device,
|
|
138441
|
-
await this.#cover(device,
|
|
139097
|
+
async coverOpen(device, channel2) {
|
|
139098
|
+
await this.#cover(device, channel2).open();
|
|
138442
139099
|
}
|
|
138443
139100
|
/** Close a cover entity fully. */
|
|
138444
|
-
async coverClose(device,
|
|
138445
|
-
await this.#cover(device,
|
|
139101
|
+
async coverClose(device, channel2) {
|
|
139102
|
+
await this.#cover(device, channel2).close();
|
|
138446
139103
|
}
|
|
138447
139104
|
/** Stop a cover entity where it is. */
|
|
138448
|
-
async coverStop(device,
|
|
138449
|
-
await this.#cover(device,
|
|
139105
|
+
async coverStop(device, channel2) {
|
|
139106
|
+
await this.#cover(device, channel2).stop();
|
|
138450
139107
|
}
|
|
138451
139108
|
/** Move a cover entity to `position` (0..100). */
|
|
138452
|
-
async coverSetPosition(device,
|
|
138453
|
-
await this.#cover(device,
|
|
139109
|
+
async coverSetPosition(device, channel2, position) {
|
|
139110
|
+
await this.#cover(device, channel2).setPosition(position);
|
|
138454
139111
|
}
|
|
138455
139112
|
/** Lock a lock entity. */
|
|
138456
|
-
async lockLock(device,
|
|
138457
|
-
await this.#lock(device,
|
|
139113
|
+
async lockLock(device, channel2) {
|
|
139114
|
+
await this.#lock(device, channel2).lock();
|
|
138458
139115
|
}
|
|
138459
139116
|
/** Unlock a lock entity. */
|
|
138460
|
-
async lockUnlock(device,
|
|
138461
|
-
await this.#lock(device,
|
|
139117
|
+
async lockUnlock(device, channel2) {
|
|
139118
|
+
await this.#lock(device, channel2).unlock();
|
|
138462
139119
|
}
|
|
138463
139120
|
/** Release a lock entity's latch (open). */
|
|
138464
|
-
async lockOpen(device,
|
|
138465
|
-
await this.#lock(device,
|
|
139121
|
+
async lockOpen(device, channel2) {
|
|
139122
|
+
await this.#lock(device, channel2).open();
|
|
138466
139123
|
}
|
|
138467
139124
|
/**
|
|
138468
139125
|
* Resolve the live custom entity for `(device, channel)`, asserting its
|
|
@@ -138470,36 +139127,36 @@ var Homematic = class {
|
|
|
138470
139127
|
* channel address (normalised like the {@link DataPointRef} resolver). Throws
|
|
138471
139128
|
* {@link ValidationError} when absent or of the wrong kind.
|
|
138472
139129
|
*/
|
|
138473
|
-
#entity(device,
|
|
138474
|
-
const channelAddress2 = typeof
|
|
139130
|
+
#entity(device, channel2, expectedKind) {
|
|
139131
|
+
const channelAddress2 = typeof channel2 === "string" && (channel2.includes(":") || channel2.startsWith(`${device}:`)) ? channel2 : `${device}:${channel2}`;
|
|
138475
139132
|
const entity = this.#customEntitiesByKey.get(`${device}:${channelAddress2}`);
|
|
138476
139133
|
if (entity === void 0) throw new ValidationError(`No custom entity for "${device}" channel "${channelAddress2}".`);
|
|
138477
139134
|
if (entity.kind !== expectedKind) throw new ValidationError(`Custom entity "${device}" channel "${channelAddress2}" is a ${entity.kind}, not a ${expectedKind}.`);
|
|
138478
139135
|
return entity;
|
|
138479
139136
|
}
|
|
138480
|
-
#climate(device,
|
|
138481
|
-
const entity = this.#entity(device,
|
|
139137
|
+
#climate(device, channel2) {
|
|
139138
|
+
const entity = this.#entity(device, channel2, "climate");
|
|
138482
139139
|
if (!(entity instanceof ClimateEntity)) throw new ValidationError(`Custom entity for "${device}" is not a climate entity.`);
|
|
138483
139140
|
return entity;
|
|
138484
139141
|
}
|
|
138485
|
-
#switch(device,
|
|
138486
|
-
const entity = this.#entity(device,
|
|
139142
|
+
#switch(device, channel2) {
|
|
139143
|
+
const entity = this.#entity(device, channel2, "switch");
|
|
138487
139144
|
if (!(entity instanceof SwitchEntity)) throw new ValidationError(`Custom entity for "${device}" is not a switch entity.`);
|
|
138488
139145
|
return entity;
|
|
138489
139146
|
}
|
|
138490
|
-
#light(device,
|
|
138491
|
-
const entity = this.#entity(device,
|
|
139147
|
+
#light(device, channel2) {
|
|
139148
|
+
const entity = this.#entity(device, channel2, "light");
|
|
138492
139149
|
if (!(entity instanceof DimmerEntity)) throw new ValidationError(`Custom entity for "${device}" is not a light entity.`);
|
|
138493
139150
|
return entity;
|
|
138494
139151
|
}
|
|
138495
|
-
#cover(device,
|
|
138496
|
-
const channelAddress2 = typeof
|
|
139152
|
+
#cover(device, channel2) {
|
|
139153
|
+
const channelAddress2 = typeof channel2 === "string" && (channel2.includes(":") || channel2.startsWith(`${device}:`)) ? channel2 : `${device}:${channel2}`;
|
|
138497
139154
|
const entity = this.#customEntitiesByKey.get(`${device}:${channelAddress2}`);
|
|
138498
139155
|
if (entity === void 0 || !(entity instanceof CoverEntity)) throw new ValidationError(`No cover custom entity for "${device}" channel "${channelAddress2}".`);
|
|
138499
139156
|
return entity;
|
|
138500
139157
|
}
|
|
138501
|
-
#lock(device,
|
|
138502
|
-
const entity = this.#entity(device,
|
|
139158
|
+
#lock(device, channel2) {
|
|
139159
|
+
const entity = this.#entity(device, channel2, "lock");
|
|
138503
139160
|
if (entity instanceof IpLockEntity || entity instanceof RfLockEntity) return entity;
|
|
138504
139161
|
throw new ValidationError(`Custom entity for "${device}" is not a lock entity.`);
|
|
138505
139162
|
}
|
|
@@ -138571,7 +139228,7 @@ var Homematic = class {
|
|
|
138571
139228
|
const bus = this.#central.eventBus;
|
|
138572
139229
|
this.#unsubscribers.push(bus.subscribe({
|
|
138573
139230
|
type: "valueReceived",
|
|
138574
|
-
handler: (event) => this.#onValueReceived(event.dpk, event.value, event.receivedAt)
|
|
139231
|
+
handler: (event) => this.#onValueReceived(event.dpk, event.value, event.receivedAt, event.origin === "event")
|
|
138575
139232
|
}), bus.subscribe({
|
|
138576
139233
|
type: "deviceAdded",
|
|
138577
139234
|
handler: (event) => this.#onDeviceAdded(event.address)
|
|
@@ -138604,16 +139261,22 @@ var Homematic = class {
|
|
|
138604
139261
|
dp.applyCcuValue(entry.value, entry.at);
|
|
138605
139262
|
}
|
|
138606
139263
|
}
|
|
138607
|
-
|
|
139264
|
+
/**
|
|
139265
|
+
* An ACTION parameter (`PRESS_SHORT`, `PRESS_LONG`, …) is an occurrence, not a
|
|
139266
|
+
* state: every press arrives as the same `true`, so "unchanged" must not
|
|
139267
|
+
* swallow it. A pushed event of an ACTION parameter is always emitted; a
|
|
139268
|
+
* seeded read-back of one never is (it would replay an old press).
|
|
139269
|
+
*/
|
|
139270
|
+
#onValueReceived(dpk, value, receivedAt, pushed) {
|
|
138608
139271
|
const dp = this.#dataPointsById.get(dpkToUniqueId(dpk));
|
|
138609
139272
|
if (dp === void 0) return;
|
|
138610
139273
|
const result = dp.applyCcuValue(value, receivedAt);
|
|
138611
|
-
if (!result.changed) return;
|
|
138612
|
-
const
|
|
139274
|
+
if (dp.type === "ACTION" ? !pushed : !result.changed) return;
|
|
139275
|
+
const channel2 = dp.dpk.channelAddress;
|
|
138613
139276
|
this.#emitter.emit("valueChanged", {
|
|
138614
139277
|
dpId: dp.id,
|
|
138615
|
-
device: deviceAddressOf4(
|
|
138616
|
-
channel,
|
|
139278
|
+
device: deviceAddressOf4(channel2),
|
|
139279
|
+
channel: channel2,
|
|
138617
139280
|
parameter: dp.parameter,
|
|
138618
139281
|
value: result.next,
|
|
138619
139282
|
prevValue: result.prev,
|
|
@@ -138641,8 +139304,8 @@ var Homematic = class {
|
|
|
138641
139304
|
if (dp2 === void 0) throw new ValidationError(`Unknown data point id "${ref}".`);
|
|
138642
139305
|
return dp2;
|
|
138643
139306
|
}
|
|
138644
|
-
const
|
|
138645
|
-
const channelAddress2 = typeof
|
|
139307
|
+
const channel2 = ref.channel;
|
|
139308
|
+
const channelAddress2 = typeof channel2 === "string" && (channel2.includes(":") || channel2.startsWith(`${ref.device}:`)) ? channel2 : `${ref.device}:${channel2}`;
|
|
138646
139309
|
const device = this.#devicesByAddress.get(ref.device);
|
|
138647
139310
|
if (device === void 0) throw new ValidationError(`Unknown device "${ref.device}".`);
|
|
138648
139311
|
const dpId = dpkToUniqueId(makeDpk(device.interfaceId, channelAddress2, "VALUES", ref.parameter));
|
|
@@ -138814,11 +139477,11 @@ function toHmDataPoint(dp) {
|
|
|
138814
139477
|
}
|
|
138815
139478
|
function toHmCustomEntity(entity) {
|
|
138816
139479
|
const device = entity.deviceAddress;
|
|
138817
|
-
const
|
|
139480
|
+
const channel2 = entity.primaryChannelAddress;
|
|
138818
139481
|
if (entity instanceof ClimateEntity) return {
|
|
138819
139482
|
kind: "climate",
|
|
138820
139483
|
device,
|
|
138821
|
-
channel,
|
|
139484
|
+
channel: channel2,
|
|
138822
139485
|
currentTemperature: entity.currentTemperature,
|
|
138823
139486
|
targetTemperature: entity.targetTemperature,
|
|
138824
139487
|
currentHumidity: entity.currentHumidity,
|
|
@@ -138832,20 +139495,20 @@ function toHmCustomEntity(entity) {
|
|
|
138832
139495
|
if (entity instanceof SwitchEntity) return {
|
|
138833
139496
|
kind: "switch",
|
|
138834
139497
|
device,
|
|
138835
|
-
channel,
|
|
139498
|
+
channel: channel2,
|
|
138836
139499
|
isOn: entity.isOn
|
|
138837
139500
|
};
|
|
138838
139501
|
if (entity instanceof DimmerEntity) return {
|
|
138839
139502
|
kind: "light",
|
|
138840
139503
|
device,
|
|
138841
|
-
channel,
|
|
139504
|
+
channel: channel2,
|
|
138842
139505
|
isOn: entity.isOn,
|
|
138843
139506
|
brightness: entity.brightness
|
|
138844
139507
|
};
|
|
138845
139508
|
if (entity instanceof CoverEntity) return {
|
|
138846
139509
|
kind: entity.kind === "blind" ? "blind" : "cover",
|
|
138847
139510
|
device,
|
|
138848
|
-
channel,
|
|
139511
|
+
channel: channel2,
|
|
138849
139512
|
channels: entity.channelAddresses,
|
|
138850
139513
|
statusChannels: entity.statusChannelAddresses,
|
|
138851
139514
|
currentPosition: entity.currentPosition,
|
|
@@ -138856,18 +139519,18 @@ function toHmCustomEntity(entity) {
|
|
|
138856
139519
|
if (entity instanceof IpLockEntity || entity instanceof RfLockEntity) return {
|
|
138857
139520
|
kind: "lock",
|
|
138858
139521
|
device,
|
|
138859
|
-
channel,
|
|
139522
|
+
channel: channel2,
|
|
138860
139523
|
isLocked: entity.isLocked
|
|
138861
139524
|
};
|
|
138862
139525
|
throw new ValidationError(`Unsupported custom entity kind "${entity.kind}".`);
|
|
138863
139526
|
}
|
|
138864
139527
|
function toHmDevice(device, hubRooms, hubFunctions, renamed) {
|
|
138865
|
-
const channels = device.channels.map((
|
|
138866
|
-
address:
|
|
138867
|
-
index:
|
|
138868
|
-
...
|
|
138869
|
-
name: renamed?.get(
|
|
138870
|
-
dataPoints:
|
|
139528
|
+
const channels = device.channels.map((channel2) => ({
|
|
139529
|
+
address: channel2.address,
|
|
139530
|
+
index: channel2.index,
|
|
139531
|
+
...channel2.type !== void 0 ? { type: channel2.type } : {},
|
|
139532
|
+
name: renamed?.get(channel2.address) ?? channel2.name ?? null,
|
|
139533
|
+
dataPoints: channel2.dataPoints.map(toHmDataPoint)
|
|
138871
139534
|
}));
|
|
138872
139535
|
const rooms = unionStrings(device.rooms, hubRooms);
|
|
138873
139536
|
const functions = unionStrings(device.functions, hubFunctions);
|
|
@@ -138898,13 +139561,13 @@ function toHmSysVar(sysvar) {
|
|
|
138898
139561
|
...sysvar.max !== void 0 ? { max: sysvar.max } : {}
|
|
138899
139562
|
};
|
|
138900
139563
|
}
|
|
138901
|
-
function toHmProgram(
|
|
139564
|
+
function toHmProgram(program2) {
|
|
138902
139565
|
return {
|
|
138903
|
-
id:
|
|
138904
|
-
name:
|
|
138905
|
-
isActive:
|
|
138906
|
-
isInternal:
|
|
138907
|
-
...
|
|
139566
|
+
id: program2.id,
|
|
139567
|
+
name: program2.name,
|
|
139568
|
+
isActive: program2.isActive,
|
|
139569
|
+
isInternal: program2.isInternal,
|
|
139570
|
+
...program2.lastExecuteTime !== void 0 ? { lastExecuteTime: program2.lastExecuteTime } : {}
|
|
138908
139571
|
};
|
|
138909
139572
|
}
|
|
138910
139573
|
function aggregateByDevice(byChannel) {
|
|
@@ -138912,7 +139575,7 @@ function aggregateByDevice(byChannel) {
|
|
|
138912
139575
|
for (const [address, names] of byChannel) {
|
|
138913
139576
|
const deviceAddress = deviceAddressOf4(address);
|
|
138914
139577
|
const existing = out.get(deviceAddress) ?? [];
|
|
138915
|
-
for (const
|
|
139578
|
+
for (const name2 of names) if (!existing.includes(name2)) existing.push(name2);
|
|
138916
139579
|
out.set(deviceAddress, existing);
|
|
138917
139580
|
}
|
|
138918
139581
|
return out;
|
|
@@ -138920,8 +139583,8 @@ function aggregateByDevice(byChannel) {
|
|
|
138920
139583
|
function unionStrings(base, extra) {
|
|
138921
139584
|
if ((base === void 0 || base.length === 0) && (extra === void 0 || extra.length === 0)) return;
|
|
138922
139585
|
const out = [];
|
|
138923
|
-
for (const
|
|
138924
|
-
for (const
|
|
139586
|
+
for (const name2 of base ?? []) if (!out.includes(name2)) out.push(name2);
|
|
139587
|
+
for (const name2 of extra ?? []) if (!out.includes(name2)) out.push(name2);
|
|
138925
139588
|
return out;
|
|
138926
139589
|
}
|
|
138927
139590
|
var HM_DELETE_FLAGS = {
|
|
@@ -139187,7 +139850,7 @@ function buildCcuProgramHandlers(deps) {
|
|
|
139187
139850
|
const facade = connectedFacade(deps, input.integrationId);
|
|
139188
139851
|
const program = programById(facade, input.programId);
|
|
139189
139852
|
if (program.isInternal) refuse("internal");
|
|
139190
|
-
const { removed } = await facade.
|
|
139853
|
+
const { removed } = await facade.deleteProgram(program.id);
|
|
139191
139854
|
if (!removed) refuse("unknown-program");
|
|
139192
139855
|
logProgram(deps, "Homematic: program deleted", [], {
|
|
139193
139856
|
integrationId: input.integrationId,
|
|
@@ -139384,6 +140047,11 @@ function buildCcuRoomHandlers(deps) {
|
|
|
139384
140047
|
* page). Reads are `query`; every CCU write is a `mutation` whose input carries
|
|
139385
140048
|
* the operator's `confirmed` flag.
|
|
139386
140049
|
*/
|
|
140050
|
+
/**
|
|
140051
|
+
* The library's diagnosis, passed through as it is: a read-only report for an
|
|
140052
|
+
* operator and an agent, shaped and documented by nodehomematic.
|
|
140053
|
+
*/
|
|
140054
|
+
var KeyEventDiagnosisSchema = custom((value) => typeof value === "object" && value !== null);
|
|
139387
140055
|
var homematicActions = defineCustomActions({
|
|
139388
140056
|
discoverCcu: customAction(object({}), object({
|
|
139389
140057
|
hosts: array(object({
|
|
@@ -139524,6 +140192,10 @@ var homematicActions = defineCustomActions({
|
|
|
139524
140192
|
kind: "query",
|
|
139525
140193
|
auth: "admin"
|
|
139526
140194
|
}),
|
|
140195
|
+
diagnoseCcuKeyEvents: customAction(DeviceRefSchema, KeyEventDiagnosisSchema, {
|
|
140196
|
+
kind: "query",
|
|
140197
|
+
auth: "admin"
|
|
140198
|
+
}),
|
|
139527
140199
|
setCcuValue: customAction(SetValueInputSchema, OkResultSchema, {
|
|
139528
140200
|
kind: "mutation",
|
|
139529
140201
|
auth: "admin"
|
|
@@ -139975,8 +140647,17 @@ var HmChildDevice = class extends BaseDevice {
|
|
|
139975
140647
|
this.seedTriggerUnsubs = [];
|
|
139976
140648
|
}
|
|
139977
140649
|
};
|
|
139978
|
-
|
|
139979
|
-
|
|
140650
|
+
//#endregion
|
|
140651
|
+
//#region src/homematic-decode.ts
|
|
140652
|
+
/** HmIP OFF is MANU with the CCU off temperature ({@link HM_OFF_SETPOINT_C}). */
|
|
140653
|
+
var HM_OFF_SETPOINT_C = 4.5;
|
|
140654
|
+
/**
|
|
140655
|
+
* Is `target` the off setpoint? OFF is the device's own minimum setpoint when
|
|
140656
|
+
* known (a HmIP-BWTH clamps the 4.5 write to its 5.0 minimum and reports 5),
|
|
140657
|
+
* {@link HM_OFF_SETPOINT_C} otherwise.
|
|
140658
|
+
*/
|
|
140659
|
+
function isHmOffSetpoint(target, offSetpointC = HM_OFF_SETPOINT_C) {
|
|
140660
|
+
return target !== null && target <= offSetpointC;
|
|
139980
140661
|
}
|
|
139981
140662
|
/**
|
|
139982
140663
|
* HmIP `SET_POINT_MODE` index → library climate mode.
|
|
@@ -140179,16 +140860,16 @@ function decodeLock(parameter, value, now) {
|
|
|
140179
140860
|
* (current °C), HUMIDITY (%), SET_POINT_MODE (ENUM, readable mode),
|
|
140180
140861
|
* BOOST_MODE (bool). `CONTROL_MODE` is write-only on HmIP and ignored here.
|
|
140181
140862
|
*/
|
|
140182
|
-
function modeWithHmOffTarget(previous, target) {
|
|
140183
|
-
if (isHmOffSetpoint(target)) return previous.mode === "auto" ? "auto" : "off";
|
|
140863
|
+
function modeWithHmOffTarget(previous, target, offSetpointC) {
|
|
140864
|
+
if (isHmOffSetpoint(target, offSetpointC)) return previous.mode === "auto" ? "auto" : "off";
|
|
140184
140865
|
if (previous.mode === "off") return previous.lastActiveMode ?? "heat";
|
|
140185
140866
|
return previous.mode;
|
|
140186
140867
|
}
|
|
140187
|
-
function decodeClimate(previous, parameter, value, now) {
|
|
140868
|
+
function decodeClimate(previous, parameter, value, now, offSetpointC = HM_OFF_SETPOINT_C) {
|
|
140188
140869
|
if (parameter === "SET_POINT_TEMPERATURE" && typeof value === "number") return {
|
|
140189
140870
|
...previous,
|
|
140190
140871
|
target: value,
|
|
140191
|
-
mode: modeWithHmOffTarget(previous, value),
|
|
140872
|
+
mode: modeWithHmOffTarget(previous, value, offSetpointC),
|
|
140192
140873
|
lastFetchedAt: now
|
|
140193
140874
|
};
|
|
140194
140875
|
if (parameter === "ACTUAL_TEMPERATURE" && typeof value === "number") return {
|
|
@@ -140204,7 +140885,7 @@ function decodeClimate(previous, parameter, value, now) {
|
|
|
140204
140885
|
if (parameter === "SET_POINT_MODE") {
|
|
140205
140886
|
const mode = fromHmSetPointMode(value);
|
|
140206
140887
|
if (mode === null) return null;
|
|
140207
|
-
const resolved = mode === "heat" && isHmOffSetpoint(previous.target) ? "off" : mode;
|
|
140888
|
+
const resolved = mode === "heat" && isHmOffSetpoint(previous.target, offSetpointC) ? "off" : mode;
|
|
140208
140889
|
return {
|
|
140209
140890
|
...previous,
|
|
140210
140891
|
mode: resolved,
|
|
@@ -140353,15 +141034,17 @@ var HmActuatorDevice = class extends HmChildDevice {
|
|
|
140353
141034
|
const facade = this.requireFacade();
|
|
140354
141035
|
const prev = this.runtimeState.getCapState("climate-control") ?? COLD_CLIMATE;
|
|
140355
141036
|
const hmMode = toHmClimateMode(mode);
|
|
140356
|
-
|
|
141037
|
+
const offC = this.climateOffSetpointC();
|
|
141038
|
+
if (hmMode === "off" && prev.target !== null && prev.target > offC) this.climateRestoreTargetC = prev.target;
|
|
140357
141039
|
await facade.climateSetMode(this.address, channel, hmMode);
|
|
140358
|
-
if (
|
|
141040
|
+
if (hmMode === "off" && offC !== 4.5) await facade.climateSetTemperature(this.address, channel, offC);
|
|
141041
|
+
if (mode === "heat" && (prev.mode === "off" || isHmOffSetpoint(prev.target, offC))) {
|
|
140359
141042
|
const restore = this.climateRestoreTargetC ?? 21;
|
|
140360
141043
|
await facade.climateSetTemperature(this.address, channel, restore);
|
|
140361
141044
|
}
|
|
140362
141045
|
},
|
|
140363
141046
|
setTarget: async ({ target }) => {
|
|
140364
|
-
if (target >
|
|
141047
|
+
if (target > this.climateOffSetpointC()) this.climateRestoreTargetC = target;
|
|
140365
141048
|
await this.requireFacade().climateSetTemperature(this.address, channel, target);
|
|
140366
141049
|
},
|
|
140367
141050
|
setPreset: async ({ preset }) => {
|
|
@@ -140378,6 +141061,15 @@ var HmActuatorDevice = class extends HmChildDevice {
|
|
|
140378
141061
|
this.runtimeState.setCapState("climate-control", COLD_CLIMATE);
|
|
140379
141062
|
this.registeredCap = "climate-control";
|
|
140380
141063
|
}
|
|
141064
|
+
/**
|
|
141065
|
+
* The off setpoint of THIS thermostat: the entity's own minimum setpoint
|
|
141066
|
+
* (the library reads it from the SETPOINT datapoint metadata), else the
|
|
141067
|
+
* CCU default {@link HM_OFF_SETPOINT_C}.
|
|
141068
|
+
*/
|
|
141069
|
+
climateOffSetpointC() {
|
|
141070
|
+
const entity = this.facade?.customEntities().find((e) => e.device === this.address && e.channel === this.actuatorChannel);
|
|
141071
|
+
return entity?.kind === "climate" ? entity.minTemp : HM_OFF_SETPOINT_C;
|
|
141072
|
+
}
|
|
140381
141073
|
handleValueChanged(event, origin) {
|
|
140382
141074
|
const now = event.ts || Date.now();
|
|
140383
141075
|
const { parameter, value } = event;
|
|
@@ -140394,7 +141086,9 @@ var HmActuatorDevice = class extends HmChildDevice {
|
|
|
140394
141086
|
if (cap === "cover") return this.applyCover(parameter, value, now, origin);
|
|
140395
141087
|
if (cap === "lock-control") return this.applyLock(parameter, value, now, origin);
|
|
140396
141088
|
if (cap === "climate-control") {
|
|
140397
|
-
const
|
|
141089
|
+
const prev = this.runtimeState.getCapState("climate-control") ?? COLD_CLIMATE;
|
|
141090
|
+
const offC = this.climateOffSetpointC();
|
|
141091
|
+
const next = decodeClimate(prev, parameter, value, now, offC);
|
|
140398
141092
|
if (next === null && parameter === "SET_POINT_MODE") this.ctx.logger.debug("Homematic climate: SET_POINT_MODE unknown — mode unchanged", {
|
|
140399
141093
|
tags: { deviceId: this.id },
|
|
140400
141094
|
meta: {
|
|
@@ -140403,7 +141097,7 @@ var HmActuatorDevice = class extends HmChildDevice {
|
|
|
140403
141097
|
}
|
|
140404
141098
|
});
|
|
140405
141099
|
if (next) {
|
|
140406
|
-
if (next.target !== null && next.target >
|
|
141100
|
+
if (next.target !== null && next.target > offC) this.climateRestoreTargetC = next.target;
|
|
140407
141101
|
this.runtimeState.setCapState("climate-control", next);
|
|
140408
141102
|
}
|
|
140409
141103
|
}
|