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