@camstack/addon-provider-homematic 1.2.191 → 1.2.192

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/dist/addon.js CHANGED
@@ -44082,6 +44082,59 @@ function macroOnly(macro) {
44082
44082
  };
44083
44083
  }
44084
44084
  }
44085
+ var EventVocabularyKindSchema = _enum([
44086
+ "press",
44087
+ "long-press",
44088
+ "long-press-start",
44089
+ "release",
44090
+ "repeat",
44091
+ "double-press",
44092
+ "other"
44093
+ ]);
44094
+ /** The part of the device an event comes from: a button, a channel. */
44095
+ var EventVocabularySourceSchema = object({
44096
+ id: string().min(1),
44097
+ label: string().min(1)
44098
+ });
44099
+ /** One scalar field of an event's `data`, by dotted path. */
44100
+ var EventVocabularyFieldSchema = object({
44101
+ path: string().min(1),
44102
+ kind: _enum([
44103
+ "string",
44104
+ "number",
44105
+ "boolean",
44106
+ "enum"
44107
+ ]),
44108
+ enumValues: array(string()).optional(),
44109
+ label: string().min(1).optional()
44110
+ });
44111
+ var EventVocabularyEntrySchema = object({
44112
+ /** The native token, verbatim. */
44113
+ id: string().min(1),
44114
+ source: EventVocabularySourceSchema.optional(),
44115
+ label: string().min(1),
44116
+ description: string().optional(),
44117
+ kind: EventVocabularyKindSchema.optional(),
44118
+ payload: array(EventVocabularyFieldSchema).optional()
44119
+ });
44120
+ /**
44121
+ * The vocabulary of a source that declares tokens and nothing else: one
44122
+ * entry per token, labelled with the token itself.
44123
+ */
44124
+ function plainEventVocabulary(eventTypes) {
44125
+ return [...new Set(eventTypes)].filter((eventType) => eventType !== "").map((eventType) => ({
44126
+ id: eventType,
44127
+ label: eventType
44128
+ }));
44129
+ }
44130
+ /** The native tokens of a vocabulary, each once, in declaration order. */
44131
+ function eventTypesOfVocabulary(vocabulary) {
44132
+ return [...new Set(vocabulary.map((entry) => entry.id))];
44133
+ }
44134
+ /** The entry a fire belongs to: same token, same source (or both without one). */
44135
+ function findVocabularyEntry(vocabulary, eventType, sourceId) {
44136
+ return vocabulary.find((entry) => entry.id === eventType && entry.source?.id === sourceId);
44137
+ }
44085
44138
  Math.PI / 180;
44086
44139
  /**
44087
44140
  * WHEN something happens, as data (D983) — the one time vocabulary of the
@@ -44289,6 +44342,33 @@ var ScheduleLeafSchema = object({
44289
44342
  /** @deprecated legacy cron — new schedules use `at`. */
44290
44343
  cron: string().min(1).max(120).optional()
44291
44344
  }).refine((leaf) => leaf.at === void 0 !== (leaf.cron === void 0), { message: "a schedule names exactly one of `at` (a time spec) and `cron` (legacy)" }).refine((leaf) => leaf.days === void 0 || leaf.at !== void 0, { message: "`days` goes with `at`; a cron expression carries its own days" });
44345
+ /**
44346
+ * One payload predicate of a `device-fired` row: the value at `path` inside
44347
+ * the fire's `data` (dotted) equals `equals`. Compared strictly, no coercion.
44348
+ */
44349
+ var DeviceFiredMatchSchema = object({
44350
+ path: string().min(1).max(120),
44351
+ equals: union([
44352
+ string(),
44353
+ number$1(),
44354
+ boolean()
44355
+ ])
44356
+ });
44357
+ /**
44358
+ * "fires": one device of the `event-emitter` capability reported an event
44359
+ * (D1045). Every list is an OR, the lists together an AND; an absent list does
44360
+ * not narrow. `eventIds` are the device's own tokens, `sourceIds` the parts of
44361
+ * the device (a button), `kinds` the shared press kinds of its vocabulary.
44362
+ */
44363
+ var DeviceFiredLeafSchema = object({
44364
+ kind: literal("device-fired"),
44365
+ ...eventLeafId,
44366
+ deviceId: number$1().int().nonnegative(),
44367
+ eventIds: array(string().min(1)).min(1).max(64).optional(),
44368
+ sourceIds: array(string().min(1)).min(1).max(64).optional(),
44369
+ kinds: array(EventVocabularyKindSchema).min(1).optional(),
44370
+ match: array(DeviceFiredMatchSchema).min(1).max(8).optional()
44371
+ });
44292
44372
  var ManualLeafSchema = object({
44293
44373
  kind: literal("manual"),
44294
44374
  ...eventLeafId
@@ -44430,6 +44510,7 @@ var AutomationWhenSchema = lazy(() => discriminatedUnion("kind", [
44430
44510
  }),
44431
44511
  DeviceBecomesLeafSchema,
44432
44512
  DeviceEventLeafSchema,
44513
+ DeviceFiredLeafSchema,
44433
44514
  ScheduleLeafSchema,
44434
44515
  ManualLeafSchema,
44435
44516
  IntervalLeafSchema,
@@ -44444,6 +44525,7 @@ var AutomationWhenSchema = lazy(() => discriminatedUnion("kind", [
44444
44525
  var EVENT_KINDS = new Set([
44445
44526
  "device-becomes",
44446
44527
  "device-event",
44528
+ "device-fired",
44447
44529
  "schedule",
44448
44530
  "manual",
44449
44531
  "interval",
@@ -44524,6 +44606,7 @@ function hasEmptyContainer(node) {
44524
44606
  var LEAF_WORDS = {
44525
44607
  "device-becomes": "a device value that becomes",
44526
44608
  "device-event": "a device event",
44609
+ "device-fired": "a device firing an event",
44527
44610
  schedule: "a schedule",
44528
44611
  manual: "a manual run",
44529
44612
  interval: "an interval",
@@ -45167,6 +45250,16 @@ var BECOMES_DESCRIPTIONS = {
45167
45250
  from: "the value before the change, empty when it is not known",
45168
45251
  to: "the value it changed to"
45169
45252
  };
45253
+ /**
45254
+ * A fire's payload is offered too, as `data.<path>` (`{{vars.data.channel}}`):
45255
+ * those names depend on the device, so they are not in this list.
45256
+ */
45257
+ var FIRED_DESCRIPTIONS = {
45258
+ deviceId: "the device that fired",
45259
+ eventType: "the event, as the device names it",
45260
+ sourceId: "the part of the device that fired (a button), empty when it names none",
45261
+ eventKind: "the kind of press (press, long-press …), empty when the device declares none"
45262
+ };
45170
45263
  function describe$1(descriptions) {
45171
45264
  return Object.entries(descriptions).map(([name, description]) => ({
45172
45265
  name,
@@ -45175,12 +45268,74 @@ function describe$1(descriptions) {
45175
45268
  }
45176
45269
  describe$1(DETECTION_DESCRIPTIONS);
45177
45270
  describe$1(STATIONARY_DESCRIPTIONS);
45271
+ describe$1(FIRED_DESCRIPTIONS).map((v) => v.name === "deviceId" ? {
45272
+ ...v,
45273
+ hintKey: "firedDeviceId"
45274
+ } : v);
45178
45275
  describe$1(BECOMES_DESCRIPTIONS).map((v) => v.name === "deviceId" ? {
45179
45276
  ...v,
45180
45277
  hintKey: "becomesDeviceId"
45181
45278
  } : v);
45182
45279
  new Set(Object.values(COCO_TO_MACRO.mapping));
45183
45280
  /**
45281
+ * Generic stateless event emitter. Installed on a `DeviceType.EventEmitter`
45282
+ * device. Carries the device's EXACT declared event vocabulary verbatim
45283
+ * (NO normalization). Two shapes:
45284
+ * - structured source (HA `event.*` entity) → `vocabulary` is the fixed
45285
+ * declared set (e.g. press_short, press_long, …).
45286
+ * - generic/legacy source (HA bus events, e.g. zha_event) → `vocabulary`
45287
+ * is [] (open) and `lastEvent.data` carries the complex payload.
45288
+ * `vocabulary` (D1044) names each event for a person and types it for a
45289
+ * rule; `eventTypes` is its list of native tokens, kept for older readers.
45290
+ * A fire names the part of the device it came from in `sourceId` when the
45291
+ * vocabulary declares sources (a remote's buttons).
45292
+ * `seq` is monotonic so two identical events still produce distinct slice writes.
45293
+ */
45294
+ var EventFireSchema = object({
45295
+ deviceId: number$1(),
45296
+ eventType: string(),
45297
+ sourceId: string().optional(),
45298
+ data: record(string(), unknown()).nullable(),
45299
+ timestamp: number$1().meta(readingMeta("none")),
45300
+ seq: number$1().meta(readingMeta("count"))
45301
+ });
45302
+ var EventEmitterStatusSchema = object({
45303
+ eventTypes: array(string()),
45304
+ /**
45305
+ * Required of a provider by the type. A status written before the field
45306
+ * existed still parses, as an empty vocabulary: read it through
45307
+ * `readEventVocabulary`, which then answers with the plain tokens.
45308
+ */
45309
+ vocabulary: array(EventVocabularyEntrySchema).default([]),
45310
+ lastEvent: EventFireSchema.nullable(),
45311
+ eventCountSinceStart: number$1().meta(readingMeta("count"))
45312
+ });
45313
+ var eventEmitterCapability = {
45314
+ name: "event-emitter",
45315
+ scope: "device",
45316
+ deviceNative: true,
45317
+ mode: "singleton",
45318
+ deviceTypes: [DeviceType.EventEmitter],
45319
+ methods: {},
45320
+ events: { onEvent: { data: EventFireSchema } },
45321
+ status: {
45322
+ schema: EventEmitterStatusSchema,
45323
+ kind: "push"
45324
+ },
45325
+ runtimeState: EventEmitterStatusSchema,
45326
+ /**
45327
+ * Runtime-state durability: **session** — `eventCountSinceStart` names its own scope.
45328
+ *
45329
+ * See `RuntimeStateDurability`. Enforced by
45330
+ * `scripts/check-runtime-state-durability.ts`.
45331
+ */
45332
+ durability: "session",
45333
+ /**
45334
+ * History (D850): none — `eventCountSinceStart` resets with the addon; events live in ledgers.
45335
+ */
45336
+ history: "none"
45337
+ };
45338
+ /**
45184
45339
  * Schedulers (D983) — an entity that performs actions over the day.
45185
45340
  *
45186
45341
  * A scheduler has profiles; a profile has weekdays and a timeline of POINTS.
@@ -45438,6 +45593,7 @@ var AutomationConditionTraceNodeSchema = object({
45438
45593
  "triggered-by",
45439
45594
  "device-becomes",
45440
45595
  "device-event",
45596
+ "device-fired",
45441
45597
  "schedule",
45442
45598
  "interval",
45443
45599
  "manual",
@@ -56667,117 +56823,6 @@ var enumSensorCapability = {
56667
56823
  * whether persisting is worth a SQLite commit. */
56668
56824
  volatileStateFields: ["lastFetchedAt", "timestamp"]
56669
56825
  };
56670
- var EventVocabularyKindSchema = _enum([
56671
- "press",
56672
- "long-press",
56673
- "long-press-start",
56674
- "release",
56675
- "repeat",
56676
- "double-press",
56677
- "other"
56678
- ]);
56679
- /** The part of the device an event comes from: a button, a channel. */
56680
- var EventVocabularySourceSchema = object({
56681
- id: string().min(1),
56682
- label: string().min(1)
56683
- });
56684
- /** One scalar field of an event's `data`, by dotted path. */
56685
- var EventVocabularyFieldSchema = object({
56686
- path: string().min(1),
56687
- kind: _enum([
56688
- "string",
56689
- "number",
56690
- "boolean",
56691
- "enum"
56692
- ]),
56693
- enumValues: array(string()).optional(),
56694
- label: string().min(1).optional()
56695
- });
56696
- var EventVocabularyEntrySchema = object({
56697
- /** The native token, verbatim. */
56698
- id: string().min(1),
56699
- source: EventVocabularySourceSchema.optional(),
56700
- label: string().min(1),
56701
- description: string().optional(),
56702
- kind: EventVocabularyKindSchema.optional(),
56703
- payload: array(EventVocabularyFieldSchema).optional()
56704
- });
56705
- /**
56706
- * The vocabulary of a source that declares tokens and nothing else: one
56707
- * entry per token, labelled with the token itself.
56708
- */
56709
- function plainEventVocabulary(eventTypes) {
56710
- return [...new Set(eventTypes)].filter((eventType) => eventType !== "").map((eventType) => ({
56711
- id: eventType,
56712
- label: eventType
56713
- }));
56714
- }
56715
- /** The native tokens of a vocabulary, each once, in declaration order. */
56716
- function eventTypesOfVocabulary(vocabulary) {
56717
- return [...new Set(vocabulary.map((entry) => entry.id))];
56718
- }
56719
- /** The entry a fire belongs to: same token, same source (or both without one). */
56720
- function findVocabularyEntry(vocabulary, eventType, sourceId) {
56721
- return vocabulary.find((entry) => entry.id === eventType && entry.source?.id === sourceId);
56722
- }
56723
- /**
56724
- * Generic stateless event emitter. Installed on a `DeviceType.EventEmitter`
56725
- * device. Carries the device's EXACT declared event vocabulary verbatim
56726
- * (NO normalization). Two shapes:
56727
- * - structured source (HA `event.*` entity) → `vocabulary` is the fixed
56728
- * declared set (e.g. press_short, press_long, …).
56729
- * - generic/legacy source (HA bus events, e.g. zha_event) → `vocabulary`
56730
- * is [] (open) and `lastEvent.data` carries the complex payload.
56731
- * `vocabulary` (D1044) names each event for a person and types it for a
56732
- * rule; `eventTypes` is its list of native tokens, kept for older readers.
56733
- * A fire names the part of the device it came from in `sourceId` when the
56734
- * vocabulary declares sources (a remote's buttons).
56735
- * `seq` is monotonic so two identical events still produce distinct slice writes.
56736
- */
56737
- var EventFireSchema = object({
56738
- deviceId: number$1(),
56739
- eventType: string(),
56740
- sourceId: string().optional(),
56741
- data: record(string(), unknown()).nullable(),
56742
- timestamp: number$1().meta(readingMeta("none")),
56743
- seq: number$1().meta(readingMeta("count"))
56744
- });
56745
- var EventEmitterStatusSchema = object({
56746
- eventTypes: array(string()),
56747
- /**
56748
- * Required of a provider by the type. A status written before the field
56749
- * existed still parses, as an empty vocabulary: read it through
56750
- * `readEventVocabulary`, which then answers with the plain tokens.
56751
- */
56752
- vocabulary: array(EventVocabularyEntrySchema).default([]),
56753
- lastEvent: EventFireSchema.nullable(),
56754
- eventCountSinceStart: number$1().meta(readingMeta("count"))
56755
- });
56756
- var eventEmitterCapability = {
56757
- name: "event-emitter",
56758
- scope: "device",
56759
- deviceNative: true,
56760
- mode: "singleton",
56761
- deviceTypes: [DeviceType.EventEmitter],
56762
- methods: {},
56763
- events: { onEvent: { data: EventFireSchema } },
56764
- status: {
56765
- schema: EventEmitterStatusSchema,
56766
- kind: "push"
56767
- },
56768
- runtimeState: EventEmitterStatusSchema,
56769
- /**
56770
- * Runtime-state durability: **session** — `eventCountSinceStart` names its own scope.
56771
- *
56772
- * See `RuntimeStateDurability`. Enforced by
56773
- * `scripts/check-runtime-state-durability.ts`.
56774
- */
56775
- durability: "session",
56776
- /**
56777
- * History (D850): none — `eventCountSinceStart` resets with the addon; events live in ledgers.
56778
- */
56779
- history: "none"
56780
- };
56781
56826
  var IdentitySchema = object({
56782
56827
  id: string(),
56783
56828
  name: string(),
@@ -59353,6 +59398,12 @@ var IntegrationLiteSchema = object({
59353
59398
  var AvailableIntegrationTypeSchema = object({
59354
59399
  addonId: string(),
59355
59400
  name: string(),
59401
+ /**
59402
+ * Product name a new integration is prefilled from (`<label> - Home`).
59403
+ * Absent: the client uses `name`. Set when the catalog title is not the
59404
+ * product (Bosch SHC, MQTT).
59405
+ */
59406
+ providerLabel: string().optional(),
59356
59407
  description: string(),
59357
59408
  iconUrl: string().nullable(),
59358
59409
  color: string(),
@@ -103184,6 +103235,38 @@ function bestLocationMatch(externalName, existing, threshold = .8) {
103184
103235
  return best;
103185
103236
  }
103186
103237
  /**
103238
+ * Names chosen when an integration or a Gateway device is created.
103239
+ * A stored name is never rewritten from these helpers.
103240
+ */
103241
+ var HOME_SUFFIX = "Home";
103242
+ function collapse(value) {
103243
+ return value.trim().replace(/\s+/g, " ");
103244
+ }
103245
+ /** "KLF-200" → "KLF200". A hyphen between words ("Home Hub") stays. */
103246
+ function compactModelToken(value) {
103247
+ return value.replace(/([A-Za-z])-(\d)/g, "$1$2");
103248
+ }
103249
+ /** Prefill for a new integration: "<provider> - Home". The operator can edit it. */
103250
+ function defaultIntegrationName(providerLabel) {
103251
+ const label = collapse(providerLabel);
103252
+ if (label.length === 0) return HOME_SUFFIX;
103253
+ return `${label} - ${HOME_SUFFIX}`;
103254
+ }
103255
+ /**
103256
+ * A Gateway device: "<Brand> <Model>". An unknown model is the brand alone
103257
+ * (the caller passes the brand-level fallback it already has, e.g. "Velux KLF-200").
103258
+ */
103259
+ function gatewayDeviceName(brand, model) {
103260
+ const brandPart = compactModelToken(collapse(brand));
103261
+ const raw = collapse(model ?? "");
103262
+ if (raw.length === 0) return brandPart;
103263
+ const modelPart = compactModelToken(raw);
103264
+ const prefix = `${brandPart.toLowerCase()} `;
103265
+ if (modelPart.toLowerCase() === brandPart.toLowerCase()) return brandPart;
103266
+ if (modelPart.toLowerCase().startsWith(prefix)) return modelPart;
103267
+ return `${brandPart} ${modelPart}`;
103268
+ }
103269
+ /**
103187
103270
  * Closes the gap D49 leaves: an integration deleted while its provider was down never emits an
103188
103271
  * event the provider sees. An integration id absent from an ANSWERED list is only a suspect; its
103189
103272
  * devices go (through the provider's own removeDevices) when a SECOND answered read, at least
@@ -130126,7 +130209,7 @@ function buildCcuGatewayCandidate(input) {
130126
130209
  const adoptedId = input.adopted.get(nativeId) ?? null;
130127
130210
  return {
130128
130211
  childNativeId: nativeId,
130129
- name: input.integrationName,
130212
+ name: gatewayDeviceName("Homematic", "CCU3"),
130130
130213
  type: DeviceType.Gateway,
130131
130214
  status: input.online ? "online" : "offline",
130132
130215
  metadata: {
@@ -130395,7 +130478,7 @@ function buildHmAdoptionProvider(deps) {
130395
130478
  const { deviceId } = await adoptGateway({
130396
130479
  integrationId,
130397
130480
  nativeId,
130398
- name: perCandidate?.[nativeId]?.name ?? registry.getName(integrationId) ?? "Homematic CCU"
130481
+ name: perCandidate?.[nativeId]?.name ?? gatewayDeviceName("Homematic", "CCU3")
130399
130482
  });
130400
130483
  adopted.push({
130401
130484
  childNativeId: nativeId,
@@ -130598,7 +130681,7 @@ function homematicDiscoveryCandidates(proposals) {
130598
130681
  return proposals.map((found) => ({
130599
130682
  stableId: `homematic:${found.id}`,
130600
130683
  type: DeviceType.Gateway,
130601
- suggestedName: found.name,
130684
+ suggestedName: defaultIntegrationName("Homematic"),
130602
130685
  prefilledConfig: { host: found.host },
130603
130686
  setupIntegration: true
130604
130687
  }));