@camstack/addon-export-alexa 1.2.181 → 1.2.182

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.
@@ -5987,7 +5987,7 @@ var ZodIssueCode = {
5987
5987
  var ZodFirstPartyTypeKind;
5988
5988
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5989
5989
  //#endregion
5990
- //#region ../types/dist/sleep-DV4qxEyD.mjs
5990
+ //#region ../types/dist/sleep-BkzQdpzF.mjs
5991
5991
  /**
5992
5992
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5993
5993
  * window to float samples (D455).
@@ -9189,7 +9189,7 @@ function defineRecordKinds(specs) {
9189
9189
  retention: spec.retention,
9190
9190
  deviceRemoval: spec.deviceRemoval,
9191
9191
  maxDataBytes: spec.maxDataBytes,
9192
- secretPaths: [...secretPaths],
9192
+ secretPaths: [...new Set([...secretPaths, ...spec.retiredSecretPaths ?? []])],
9193
9193
  secretArrayKeys: spec.secretArrayKeys === void 0 ? void 0 : { ...spec.secretArrayKeys },
9194
9194
  transactFamily: spec.transactFamily,
9195
9195
  entry: spec.entry === void 0 ? void 0 : {
@@ -9220,6 +9220,7 @@ function defineEntryKind(name, spec) {
9220
9220
  ...spec.database === void 0 ? {} : { database: spec.database },
9221
9221
  ...spec.indexes === void 0 ? {} : { indexes: spec.indexes },
9222
9222
  ...spec.secretArrayKeys === void 0 ? {} : { secretArrayKeys: spec.secretArrayKeys },
9223
+ ...spec.retiredSecretPaths === void 0 ? {} : { retiredSecretPaths: spec.retiredSecretPaths },
9223
9224
  entry: {
9224
9225
  title: spec.title,
9225
9226
  ...spec.nameField === void 0 ? {} : { nameField: spec.nameField }
@@ -11903,7 +11904,7 @@ object({
11903
11904
  params: record(string(), union([string(), number()])).optional()
11904
11905
  });
11905
11906
  //#endregion
11906
- //#region ../types/dist/composition-BodkvOV0.mjs
11907
+ //#region ../types/dist/composition-CRNwcFYY.mjs
11907
11908
  /**
11908
11909
  * The ffmpeg build every CamStack node downloads, per platform and arch.
11909
11910
  *
@@ -12666,38 +12667,6 @@ function validateExpressionSource(src) {
12666
12667
  return null;
12667
12668
  }
12668
12669
  /**
12669
- * One power reading becomes a washer, dryer or dishwasher (D944 helper).
12670
- *
12671
- * Standby of the control board is under 5 W; a motor or a heater is far
12672
- * above that, so 5 W is the line. A door lock or a short pump spike is not
12673
- * a cycle, so running starts only after 30 s above the line.
12674
- *
12675
- * A wash, dry or dishwasher pause (soak, heat-wait, heater off between
12676
- * bursts) lasts several minutes. Ending the cycle on the first dip would
12677
- * report "finished" in the middle of the program, so the stop dwell is
12678
- * 10 minutes on every type. The number is stored per type so one machine
12679
- * can move later without moving the others.
12680
- */
12681
- var APPLIANCE_TEMPLATE_ID = "appliance";
12682
- var APPLIANCE_KINDS = [
12683
- "washer",
12684
- "dryer",
12685
- "dishwasher"
12686
- ];
12687
- DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher;
12688
- /**
12689
- * A dumb plug-in stove or heater, built from a smart plug (a `Heater`).
12690
- *
12691
- * The plug is the actuator: `switch.setState` is a FORWARD to the plug's own
12692
- * (D967), so the heater switches exactly as the plug does. Running is the
12693
- * plug being on; when a power reading is also named, running is the draw
12694
- * staying above the line instead (a plug left on with the stove's own
12695
- * thermostat open is not heating). 50 W is far above any standby and below
12696
- * the smallest radiator.
12697
- */
12698
- var HEATER_TEMPLATE_ID = "heater";
12699
- DeviceType.Heater;
12700
- /**
12701
12670
  * Statistics and integrals over a history read (D944).
12702
12671
  *
12703
12672
  * Pure: the same points always give the same answer, so a restart recomputes
@@ -12841,34 +12810,6 @@ var HelperSpecSchema = discriminatedUnion("kind", [
12841
12810
  /** Actuator groups only. Readings leave this unset. */
12842
12811
  active: ActiveCriterionSchema.optional()
12843
12812
  }),
12844
- object({
12845
- kind: literal("appliance"),
12846
- templateId: literal(APPLIANCE_TEMPLATE_ID),
12847
- appliance: _enum(APPLIANCE_KINDS),
12848
- thresholdWatts: number().positive(),
12849
- startDwellMs: number().int().nonnegative(),
12850
- stopDwellMs: number().int().nonnegative(),
12851
- member: HelperMemberSchema,
12852
- /**
12853
- * The plug that powers the appliance (`switch.on`). Optional: when set, the
12854
- * composition carries a `power-source` feature, so the hub can cut and restore
12855
- * that plug (power-source link of a NEW-target composition).
12856
- */
12857
- powerSwitch: HelperMemberSchema.optional(),
12858
- /** How long a forced restart keeps the plug off; the cap's default when unset. */
12859
- offSeconds: number().optional()
12860
- }),
12861
- object({
12862
- kind: literal("heater"),
12863
- templateId: literal(HEATER_TEMPLATE_ID),
12864
- /** The plug, read and commanded at `switch.on`. */
12865
- plug: HelperMemberSchema,
12866
- /** The plug's power reading, when it has one: running is then the draw, not the switch. */
12867
- meter: HelperMemberSchema.optional(),
12868
- thresholdWatts: number().positive(),
12869
- startDwellMs: number().int().nonnegative(),
12870
- stopDwellMs: number().int().nonnegative()
12871
- }),
12872
12813
  object({
12873
12814
  kind: literal("statistic"),
12874
12815
  stat: _enum(STATISTIC_STATS),
@@ -13092,7 +13033,7 @@ var CompositionSchema = object({
13092
13033
  kind: literal("existing"),
13093
13034
  device: CompositionSourceRefSchema
13094
13035
  })]),
13095
- features: array(CompositionFeatureSchema).min(1).max(16),
13036
+ features: array(CompositionFeatureSchema).min(0).max(16),
13096
13037
  /**
13097
13038
  * Present when the block is a helper template. Absent on a free
13098
13039
  * composition (the room example, device 4603). The editor reads this,
@@ -13491,15 +13432,23 @@ var RecordIntegrationInstances = class {
13491
13432
  viewOf(record) {
13492
13433
  const shown = secretViewsOf(this.records.owner, this.kind.name, record.id, this.kind.declaration, record.data);
13493
13434
  const rawName = record.data[this.nameField];
13435
+ const kind = this.hooks.kindOf?.(record.data);
13436
+ const health = this.hooks.health?.(record.data, record.id);
13494
13437
  return {
13495
13438
  id: record.id,
13496
13439
  name: typeof rawName === "string" ? rawName : record.id,
13497
13440
  configured: this.hooks.configured(record.data),
13498
13441
  enabled: record.data.enabled !== false,
13499
- formValues: shown
13442
+ formValues: shown,
13443
+ ...kind !== void 0 ? { kind } : {},
13444
+ ...health?.status !== void 0 ? { status: health.status } : {},
13445
+ ...health?.lastCheckedAt !== void 0 ? { lastCheckedAt: health.lastCheckedAt } : {}
13500
13446
  };
13501
13447
  }
13502
- describe = async () => this.hooks.description;
13448
+ describe = async () => this.hooks.mintId === void 0 ? this.hooks.description : {
13449
+ ...this.hooks.description,
13450
+ mintsId: true
13451
+ };
13503
13452
  instanceFormSchema = async ({ id }) => this.hooks.formSchema(id);
13504
13453
  listInstances = async () => {
13505
13454
  return (await this.handle.query({ limit: INSTANCES_LIST_MAX })).records.map((record) => this.viewOf(record));
@@ -13509,13 +13458,18 @@ var RecordIntegrationInstances = class {
13509
13458
  return record === null ? null : this.viewOf(record);
13510
13459
  };
13511
13460
  /** Insert ONE row (`ifRev: 0`: an existing id is refused, never overwritten). */
13512
- createInstance = async ({ id, name }) => {
13461
+ createInstance = async ({ id, name, kind }) => {
13462
+ const minted = id ?? this.hooks.mintId?.({
13463
+ name,
13464
+ ...kind !== void 0 ? { kind } : {}
13465
+ });
13466
+ if (minted === void 0) throw new Error("createInstance needs an id: this provider does not mint one");
13513
13467
  await this.handle.put({
13514
- id,
13515
- data: this.hooks.initialBody(name)
13468
+ id: minted,
13469
+ data: this.hooks.initialBody(name, kind)
13516
13470
  }, { ifRev: 0 });
13517
- await this.hooks.onChanged?.(id);
13518
- return { id };
13471
+ await this.hooks.onChanged?.(minted);
13472
+ return { id: minted };
13519
13473
  };
13520
13474
  updateInstance = async ({ id, name, values }) => {
13521
13475
  const patch = {};
@@ -49236,49 +49190,6 @@ function actuator(input) {
49236
49190
  };
49237
49191
  }
49238
49192
  new Map(GROUP_TEMPLATES.map((template) => [template.id, template]));
49239
- var PowerSourceRefusalReasonSchema = _enum([
49240
- "no-power-source",
49241
- "switch-missing",
49242
- "switch-offline",
49243
- "switch-unknown",
49244
- "restart-in-progress",
49245
- "switch-call-failed"
49246
- ]);
49247
- var PowerSourceActionResultSchema = discriminatedUnion("accepted", [object({ accepted: literal(true) }), object({
49248
- accepted: literal(false),
49249
- reason: PowerSourceRefusalReasonSchema,
49250
- /** One line for the operator, naming the switch. */
49251
- message: string()
49252
- })]);
49253
- var PowerSourceInfoSchema = object({
49254
- /** False when the device has no power source linked; the rest is then empty. */
49255
- linked: boolean(),
49256
- switchDeviceId: number().nullable(),
49257
- switchName: string().nullable(),
49258
- /** The switch's on/off state, or null when it is unknown. Never false for unknown (D393). */
49259
- switchOn: boolean().nullable(),
49260
- switchOnline: boolean().nullable(),
49261
- restartInProgress: boolean(),
49262
- offSeconds: number().int()
49263
- });
49264
- object({
49265
- /** Null while the switch has not reported: unknown is never `false` (D393). */
49266
- switchOn: boolean().nullable(),
49267
- offSeconds: number().int(),
49268
- lastFetchedAt: number()
49269
- });
49270
- DeviceType.Gateway, DeviceType.Hub, 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;
49271
- var deviceInput$2 = object({ deviceId: number().int().nonnegative() });
49272
- systemMethod(deviceInput$2, PowerSourceInfoSchema, { auth: "admin" }), systemMethod(deviceInput$2, PowerSourceActionResultSchema, {
49273
- kind: "mutation",
49274
- auth: "admin"
49275
- }), systemMethod(deviceInput$2, PowerSourceActionResultSchema, {
49276
- kind: "mutation",
49277
- auth: "admin"
49278
- }), systemMethod(deviceInput$2, PowerSourceActionResultSchema, {
49279
- kind: "mutation",
49280
- auth: "admin"
49281
- });
49282
49193
  DeviceFeature.LightColorRgb, DeviceFeature.LightColorHsv, DeviceFeature.LightColorMired;
49283
49194
  DeviceType.Camera;
49284
49195
  `${COMPOSED_DEVICE_STABLE_ID_PREFIX}`;
@@ -49306,6 +49217,165 @@ var ComposableCapabilitiesSchema = object({ caps: array(object({
49306
49217
  }).optional()
49307
49218
  })) });
49308
49219
  /**
49220
+ * A saved Customize assignment (D936). The schema is the type: callers use
49221
+ * `z.infer`, they do not restate the shape.
49222
+ */
49223
+ var OverrideSourceSchema = object({
49224
+ addonId: string().min(1),
49225
+ stableId: string().min(1),
49226
+ cap: string().min(1),
49227
+ fieldPath: string().min(1)
49228
+ });
49229
+ var IdentityTransformDraftSchema = object({ kind: literal("identity") });
49230
+ var InvertTransformDraftSchema = object({ kind: literal("invert") });
49231
+ var ThresholdTransformDraftSchema = object({
49232
+ kind: literal("threshold"),
49233
+ comparison: _enum(["gte", "lte"]),
49234
+ threshold: number(),
49235
+ startDwellMs: number().nonnegative(),
49236
+ stopDwellMs: number().nonnegative()
49237
+ });
49238
+ var CustomizeTransformDraftSchema = discriminatedUnion("kind", [
49239
+ IdentityTransformDraftSchema,
49240
+ InvertTransformDraftSchema,
49241
+ ThresholdTransformDraftSchema,
49242
+ object({
49243
+ kind: literal("linear"),
49244
+ scale: number(),
49245
+ offset: number(),
49246
+ clampMin: number().optional(),
49247
+ clampMax: number().optional()
49248
+ }),
49249
+ object({
49250
+ kind: literal("enum-map"),
49251
+ mapping: record(string(), string().nullable())
49252
+ }),
49253
+ object({ kind: literal("number") })
49254
+ ]);
49255
+ var ScalarOverrideDraftSchema = object({
49256
+ kind: literal("scalar"),
49257
+ cap: string().min(1),
49258
+ targetId: string().min(1),
49259
+ source: OverrideSourceSchema,
49260
+ transform: CustomizeTransformDraftSchema
49261
+ });
49262
+ var KeyedArrayOverrideDraftSchema = object({
49263
+ kind: literal("keyedArray"),
49264
+ cap: string().min(1),
49265
+ targetId: string().min(1),
49266
+ key: string().min(1),
49267
+ label: string().min(1),
49268
+ fieldPath: string().min(1),
49269
+ source: OverrideSourceSchema,
49270
+ transform: CustomizeTransformDraftSchema
49271
+ });
49272
+ var PulseOverrideDraftSchema = object({
49273
+ kind: literal("pulse"),
49274
+ cap: string().min(1),
49275
+ targetId: string().min(1),
49276
+ enabled: boolean(),
49277
+ debounceMs: number().nonnegative(),
49278
+ edges: array(_enum([
49279
+ "rising",
49280
+ "button",
49281
+ "native-event"
49282
+ ])).min(1).optional(),
49283
+ sources: array(OverrideSourceSchema).min(1)
49284
+ });
49285
+ var SpanSourceDraftSchema = OverrideSourceSchema.extend({ mode: _enum([
49286
+ "in-addition",
49287
+ "confirm",
49288
+ "replace"
49289
+ ]).optional() });
49290
+ discriminatedUnion("kind", [
49291
+ ScalarOverrideDraftSchema,
49292
+ KeyedArrayOverrideDraftSchema,
49293
+ PulseOverrideDraftSchema,
49294
+ object({
49295
+ kind: literal("span"),
49296
+ cap: string().min(1),
49297
+ targetId: string().min(1),
49298
+ timeoutMs: number().nonnegative(),
49299
+ cooldownMs: number().nonnegative().optional(),
49300
+ sources: array(SpanSourceDraftSchema)
49301
+ })
49302
+ ]);
49303
+ object({
49304
+ targetId: string().min(1),
49305
+ configured: boolean(),
49306
+ source: _enum(["native", "assigned"]),
49307
+ state: _enum([
49308
+ "active",
49309
+ "stale",
49310
+ "released",
49311
+ "unavailable"
49312
+ ]),
49313
+ reason: string().nullable()
49314
+ });
49315
+ /**
49316
+ * What a running-threshold proposal says (planning#405). The schema is the
49317
+ * type: the algorithm, the capability method and the UI all read `z.infer`.
49318
+ *
49319
+ * A proposal is read-only advice: it carries the numbers it was derived from
49320
+ * (`evidence`) so the operator can judge it, and an `insufficient` answer names
49321
+ * WHY with a typed reason and the catalog defaults, never an invented number.
49322
+ */
49323
+ var RunningProposalTierSchema = _enum(["raw", "5m"]);
49324
+ var RunningProposalConfidenceSchema = _enum([
49325
+ "high",
49326
+ "medium",
49327
+ "low"
49328
+ ]);
49329
+ var RunningProposalInsufficientReasonSchema = _enum([
49330
+ "no-history",
49331
+ "span-too-short",
49332
+ "truncated",
49333
+ "no-idle-floor",
49334
+ "no-runs",
49335
+ "no-separation"
49336
+ ]);
49337
+ var RunningProposalReplaySchema = object({
49338
+ /** Intervals the real dwell expression held true over the window. */
49339
+ intervals: number().int().nonnegative(),
49340
+ /** Intervals outside every run, or a second interval inside one. */
49341
+ extra: number().int().nonnegative(),
49342
+ /** Runs without an interval of their own (none, or merged into a neighbour). */
49343
+ missed: number().int().nonnegative()
49344
+ });
49345
+ var RunningProposalEvidenceSchema = object({
49346
+ tier: RunningProposalTierSchema,
49347
+ spanMs: number().nonnegative(),
49348
+ from: number(),
49349
+ to: number(),
49350
+ points: number().int().nonnegative(),
49351
+ runsFound: number().int().nonnegative(),
49352
+ pausesFound: number().int().nonnegative(),
49353
+ longestPauseMs: number().nonnegative(),
49354
+ idleFloorW: number(),
49355
+ noiseCeilingW: number(),
49356
+ plateauW: number(),
49357
+ replay: RunningProposalReplaySchema
49358
+ });
49359
+ var RunningProposalInsufficientEvidenceSchema = object({
49360
+ spanMs: number().nonnegative(),
49361
+ points: number().int().nonnegative(),
49362
+ runsFound: number().int().nonnegative()
49363
+ });
49364
+ var RunningThresholdProposalSchema = discriminatedUnion("state", [object({
49365
+ state: literal("proposal"),
49366
+ transform: ThresholdTransformDraftSchema,
49367
+ evidence: RunningProposalEvidenceSchema,
49368
+ confidence: RunningProposalConfidenceSchema,
49369
+ /** Why the confidence is not higher; empty when nothing held it back. */
49370
+ notes: array(string())
49371
+ }), object({
49372
+ state: literal("insufficient"),
49373
+ reason: RunningProposalInsufficientReasonSchema,
49374
+ evidence: RunningProposalInsufficientEvidenceSchema,
49375
+ /** The catalog defaults, offered as what stands when nothing better is known. */
49376
+ fallback: ThresholdTransformDraftSchema
49377
+ })]);
49378
+ /**
49309
49379
  * The report of a one-shot "move this owner's plaintext secrets into the
49310
49380
  * keychain" run (D878). COUNTS only - never a value, never a ref.
49311
49381
  *
@@ -49595,6 +49665,14 @@ method(object({}), object({ blocks: array(CoreBlockSchema) }), { auth: "admin" }
49595
49665
  kind: "mutation",
49596
49666
  auth: "admin",
49597
49667
  access: "view"
49668
+ }), method(object({
49669
+ deviceId: number().int(),
49670
+ cap: string().min(1),
49671
+ fieldPath: string().min(1),
49672
+ deviceType: _enum(DeviceType).optional()
49673
+ }), RunningThresholdProposalSchema, {
49674
+ auth: "admin",
49675
+ access: "view"
49598
49676
  }), method(object({
49599
49677
  blockId: string().min(1),
49600
49678
  trace: AutomationRunTraceSchema.optional(),
@@ -50403,7 +50481,53 @@ method(object({
50403
50481
  * exposes only the COMMON surface: link state, supported device
50404
50482
  * kinds (so the UI can filter the device picker), and per-device
50405
50483
  * expose/unexpose.
50484
+ *
50485
+ * INSTANCES. One export addon can serve several independent targets (a
50486
+ * HomeKit bridge, a Home Assistant broker). `listInstances` names them.
50487
+ * `instanceId` on a READ is optional: absent = the whole addon (linked if any
50488
+ * enabled instance is, `exposedDeviceCount` = distinct devices, `setup` = the
50489
+ * default instance's); present = that instance; an id the provider does not
50490
+ * serve is refused with `ExportInstanceUnknownError` (`export-instance-unknown`),
50491
+ * never answered empty. `instanceId` on a WRITE is REQUIRED: a membership
50492
+ * change always names the target it changes. A single-instance provider
50493
+ * accepts an absent id on a read or its own id, and refuses any other.
50494
+ */
50495
+ /** Which instance of an export addon a call addresses. Absent on a read = the whole addon. */
50496
+ var InstanceIdSchema$1 = string().min(1);
50497
+ var InstancePinSchema = object({ instanceId: InstanceIdSchema$1.optional() });
50498
+ /** One independent export target of an addon. */
50499
+ var ExportInstanceSchema = object({
50500
+ instanceId: InstanceIdSchema$1,
50501
+ name: string(),
50502
+ enabled: boolean(),
50503
+ kind: string().optional()
50504
+ });
50505
+ var EXPORT_INSTANCE_UNKNOWN = "export-instance-unknown";
50506
+ /** The named failure of an `instanceId` the provider does not serve. The message starts with the code. */
50507
+ var ExportInstanceUnknownError = class extends Error {
50508
+ code = EXPORT_INSTANCE_UNKNOWN;
50509
+ instanceId;
50510
+ constructor(addon, instanceId) {
50511
+ super(`${EXPORT_INSTANCE_UNKNOWN}: ${addon} serves no instance "${instanceId}"`);
50512
+ this.name = "ExportInstanceUnknownError";
50513
+ this.instanceId = instanceId;
50514
+ }
50515
+ };
50516
+ /**
50517
+ * The instance a `getStatus` call names. The cap's `status` block injects a per-device
50518
+ * `getStatus({ deviceId })` beside the method's own `{ instanceId? }`, so the provider sees
50519
+ * both shapes; only the second names an instance (a per-device status read is addon-wide).
50520
+ */
50521
+ function statusInstanceOf(input) {
50522
+ return "instanceId" in input ? input.instanceId : void 0;
50523
+ }
50524
+ /**
50525
+ * A single-instance provider's check: an absent id or its own passes, any other throws
50526
+ * `ExportInstanceUnknownError`.
50406
50527
  */
50528
+ function assertOwnExportInstance(addon, own, instanceId) {
50529
+ if (instanceId !== void 0 && instanceId !== own) throw new ExportInstanceUnknownError(addon, instanceId);
50530
+ }
50407
50531
  var LinkStateSchema = _enum([
50408
50532
  "unlinked",
50409
50533
  "linked",
@@ -50454,10 +50578,14 @@ var ExposedDeviceSchema = object({
50454
50578
  capabilities: array(string()).optional()
50455
50579
  });
50456
50580
  var ExposeInputSchema = object({
50581
+ instanceId: InstanceIdSchema$1,
50457
50582
  deviceId: string(),
50458
50583
  capabilities: array(string()).optional()
50459
50584
  });
50460
- var UnexposeInputSchema = object({ deviceId: string() });
50585
+ var UnexposeInputSchema = object({
50586
+ instanceId: InstanceIdSchema$1,
50587
+ deviceId: string()
50588
+ });
50461
50589
  /**
50462
50590
  * What an exporter may expose besides devices (D968). An action and a
50463
50591
  * notification target are LIST ENTRIES, never devices (D954): they enter an
@@ -50486,8 +50614,14 @@ var ExposedEntitySchema = object({
50486
50614
  entity: ExportEntityRefSchema,
50487
50615
  exposedAs: string().optional()
50488
50616
  });
50489
- var ExposeEntityInputSchema = object({ entity: ExportEntityRefSchema });
50490
- var UnexposeEntityInputSchema = object({ entity: ExportEntityRefSchema });
50617
+ var ExposeEntityInputSchema = object({
50618
+ instanceId: InstanceIdSchema$1,
50619
+ entity: ExportEntityRefSchema
50620
+ });
50621
+ var UnexposeEntityInputSchema = object({
50622
+ instanceId: InstanceIdSchema$1,
50623
+ entity: ExportEntityRefSchema
50624
+ });
50491
50625
  var deviceExportCapability = {
50492
50626
  name: "device-export",
50493
50627
  scope: "system",
@@ -50507,9 +50641,10 @@ var deviceExportCapability = {
50507
50641
  */
50508
50642
  exposesDeviceSettings: true,
50509
50643
  methods: {
50510
- getStatus: method(_void(), DeviceExportStatusSchema),
50511
- listSupportedDeviceKinds: method(_void(), array(DeviceKindSchema)),
50512
- listExposedDevices: method(_void(), array(ExposedDeviceSchema)),
50644
+ getStatus: method(InstancePinSchema, DeviceExportStatusSchema),
50645
+ listInstances: method(_void(), array(ExportInstanceSchema)),
50646
+ listSupportedDeviceKinds: method(InstancePinSchema, array(DeviceKindSchema)),
50647
+ listExposedDevices: method(InstancePinSchema, array(ExposedDeviceSchema)),
50513
50648
  exposeDevice: method(ExposeInputSchema, _void(), {
50514
50649
  kind: "mutation",
50515
50650
  auth: "admin"
@@ -50519,7 +50654,7 @@ var deviceExportCapability = {
50519
50654
  auth: "admin"
50520
50655
  }),
50521
50656
  listSupportedEntityKinds: optionalMethod(_void(), array(ExportEntityKindSchema)),
50522
- listExposedEntities: optionalMethod(_void(), array(ExposedEntitySchema)),
50657
+ listExposedEntities: optionalMethod(InstancePinSchema, array(ExposedEntitySchema)),
50523
50658
  exposeEntity: optionalMethod(ExposeEntityInputSchema, _void(), {
50524
50659
  kind: "mutation",
50525
50660
  auth: "admin"
@@ -53724,15 +53859,15 @@ var FanPresetCaptureResultSchema = object({
53724
53859
  items: array(FanCaptureItemSchema),
53725
53860
  omitted: array(FanCaptureOmissionSchema)
53726
53861
  });
53727
- var deviceInput$1 = object({ deviceId: number().int().nonnegative() });
53862
+ var deviceInput$2 = object({ deviceId: number().int().nonnegative() });
53728
53863
  DeviceType.Fan;
53729
- method(deviceInput$1, array(FanPresetSchema), { auth: "protected" }), method(deviceInput$1.extend({ presets: array(FanPresetSchema).max(12) }), FanPresetsSetResultSchema, {
53864
+ method(deviceInput$2, array(FanPresetSchema), { auth: "protected" }), method(deviceInput$2.extend({ presets: array(FanPresetSchema).max(12) }), FanPresetsSetResultSchema, {
53730
53865
  kind: "mutation",
53731
53866
  auth: "admin"
53732
- }), method(deviceInput$1.extend({ presetId: string().min(1) }), FanPresetApplyResultSchema, {
53867
+ }), method(deviceInput$2.extend({ presetId: string().min(1) }), FanPresetApplyResultSchema, {
53733
53868
  kind: "mutation",
53734
53869
  auth: "protected"
53735
- }), method(deviceInput$1.extend({
53870
+ }), method(deviceInput$2.extend({
53736
53871
  fields: array(FanCaptureFieldSchema).optional(),
53737
53872
  steps: array(ActionStepSchema).max(20).default([])
53738
53873
  }), FanPresetCaptureResultSchema, { auth: "protected" });
@@ -54264,13 +54399,50 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
54264
54399
  */
54265
54400
  var ConfigSchemaPassthrough$3 = custom();
54266
54401
  var IntegrationInstanceIdSchema = string().min(1);
54402
+ var IntegrationInstanceModeSchema = _enum(["single", "multiple"]);
54403
+ /**
54404
+ * One kind of instance a provider can create (an adapter, an account type). The sign-in and
54405
+ * connect fields follow the `broker` contract (`broker.cap.ts`): `signIn.basePath` is a
54406
+ * hub-relative route set speaking the sign-in contract, `connectPath` / `disconnectPath` open an
54407
+ * interactive account link (popup) and may carry `{{brokerId}}`, which the UI replaces with the
54408
+ * instance id.
54409
+ */
54410
+ var IntegrationInstanceKindSchema = object({
54411
+ /** Stable id of the kind, sent back as `createInstance.kind`. */
54412
+ id: string().min(1),
54413
+ label: string().min(1),
54414
+ /** The kind signs in through a server-held interactive session. */
54415
+ signIn: object({
54416
+ basePath: string().min(1),
54417
+ methods: array(_enum(["device-code", "proxy"])).optional()
54418
+ }).optional(),
54419
+ /** Relative hub path to start an interactive account link of an instance of this kind. */
54420
+ connectPath: string().min(1).optional(),
54421
+ /** Relative hub path to disconnect that account. */
54422
+ disconnectPath: string().min(1).optional()
54423
+ });
54267
54424
  var IntegrationInstanceDescriptionSchema = object({
54268
54425
  /** `single`: at most one instance can exist (Loki). `multiple`: an account each. */
54269
- instanceMode: _enum(["single", "multiple"]),
54426
+ instanceMode: IntegrationInstanceModeSchema,
54270
54427
  /** What the instance is, for the UI (`destination`, `relay`, `account`). */
54271
54428
  kind: string(),
54272
54429
  /** True when `testInstance` really probes the remote. */
54273
- canTest: boolean()
54430
+ canTest: boolean(),
54431
+ /**
54432
+ * The kinds an instance can be of. Absent or one entry: nothing to choose; more than one: the
54433
+ * Add flow asks which first and sends it as `createInstance.kind`.
54434
+ */
54435
+ kinds: array(IntegrationInstanceKindSchema).optional(),
54436
+ /**
54437
+ * The provider accepts `createInstance.id` for an id that once existed (an adopted id, because
54438
+ * devices carry it). The UI then offers "restore under its old id" on Add. Absent means no.
54439
+ */
54440
+ allowRestoreId: boolean().optional(),
54441
+ /**
54442
+ * `createInstance` without an `id` works: the provider mints it. Absent means the caller must
54443
+ * send an id (the UI then mints an opaque one).
54444
+ */
54445
+ mintsId: boolean().optional()
54274
54446
  });
54275
54447
  var IntegrationInstanceStatusSchema = object({
54276
54448
  state: _enum([
@@ -54279,7 +54451,9 @@ var IntegrationInstanceStatusSchema = object({
54279
54451
  "error",
54280
54452
  "unknown"
54281
54453
  ]),
54282
- detail: string().optional()
54454
+ detail: string().optional(),
54455
+ /** A short human word for the state ("Signed in", "Token expired"); shown instead of `state`. */
54456
+ label: string().optional()
54283
54457
  });
54284
54458
  var IntegrationInstanceSchema = object({
54285
54459
  id: IntegrationInstanceIdSchema,
@@ -54291,9 +54465,13 @@ var IntegrationInstanceSchema = object({
54291
54465
  * (`enabled !== false`, so a row written before the field existed is on).
54292
54466
  */
54293
54467
  enabled: boolean(),
54468
+ /** The kind of this instance (one of `describe().kinds[].id`), when the provider has kinds. */
54469
+ kind: string().optional(),
54294
54470
  /** Values for the instance form; a secret is a `SecretFieldView`, never text. */
54295
54471
  formValues: record(string(), unknown()),
54296
- status: IntegrationInstanceStatusSchema.optional()
54472
+ status: IntegrationInstanceStatusSchema.optional(),
54473
+ /** Epoch ms of the last probe of the remote that produced `status`; absent when never checked. */
54474
+ lastCheckedAt: number().optional()
54297
54475
  });
54298
54476
  var IntegrationInstancePatchSchema = object({
54299
54477
  id: IntegrationInstanceIdSchema,
@@ -54311,10 +54489,14 @@ var integrationInstancesCapability = {
54311
54489
  instanceFormSchema: method(object({ id: IntegrationInstanceIdSchema.nullable() }), ConfigSchemaPassthrough$3, { auth: "admin" }),
54312
54490
  listInstances: method(_void(), array(IntegrationInstanceSchema).readonly(), { auth: "admin" }),
54313
54491
  getInstance: method(object({ id: IntegrationInstanceIdSchema }), IntegrationInstanceSchema.nullable(), { auth: "admin" }),
54314
- /** Insert the typed record under the given id (a duplicate id is refused). */
54492
+ /**
54493
+ * Insert the typed record. With `id` it is stored under that id (a duplicate id is refused);
54494
+ * without one the PROVIDER mints it and answers it. `kind` picks one of `describe().kinds`.
54495
+ */
54315
54496
  createInstance: method(object({
54316
- id: IntegrationInstanceIdSchema,
54317
- name: string().min(1)
54497
+ id: IntegrationInstanceIdSchema.optional(),
54498
+ name: string().min(1),
54499
+ kind: string().min(1).optional()
54318
54500
  }), object({ id: string() }), {
54319
54501
  kind: "mutation",
54320
54502
  auth: "admin"
@@ -56146,6 +56328,11 @@ var LogEntrySchema = object({
56146
56328
  * flight, and not asking for the next slice ends the scan.
56147
56329
  */
56148
56330
  var LogReadQuerySchema = object({
56331
+ /**
56332
+ * Which destination INSTANCE answers (a destination addon may hold several records). Absent ⇒
56333
+ * the provider's first readable one, so a caller written before instances existed is unchanged.
56334
+ */
56335
+ instanceId: string().min(1).max(200).optional(),
56149
56336
  /** Correlates `cancelRead`. Caller-chosen, unique per in-flight read. */
56150
56337
  requestId: string().min(1).max(64).optional(),
56151
56338
  /** The device the line is about (`tags.deviceId`, numeric). */
@@ -56208,6 +56395,8 @@ var LogReadResultSchema = object({
56208
56395
  /** True when `cancelRead` ended this slice early. */
56209
56396
  cancelled: boolean().optional()
56210
56397
  });
56398
+ /** Names one destination instance; absent ⇒ the provider's first readable one. */
56399
+ var LogInstanceSelectorSchema = object({ instanceId: string().min(1).max(200).optional() });
56211
56400
  var LogReadCapabilitiesSchema = object({
56212
56401
  /** False ⇒ this destination only ships lines (console, forwarder, an unconfigured Loki). */
56213
56402
  readable: boolean(),
@@ -56226,7 +56415,7 @@ var LogReadCapabilitiesSchema = object({
56226
56415
  /** How far back the store reaches, when the provider knows (days). */
56227
56416
  retentionDays: number().nullable()
56228
56417
  });
56229
- method(LogEntrySchema, _void(), { kind: "mutation" }), optionalMethod(_void(), LogReadCapabilitiesSchema, { auth: "admin" }), optionalMethod(LogReadQuerySchema, LogReadResultSchema, { auth: "admin" }), optionalMethod(object({ requestId: string().min(1).max(64) }), object({ cancelled: boolean() }), {
56418
+ method(LogEntrySchema, _void(), { kind: "mutation" }), optionalMethod(LogInstanceSelectorSchema, LogReadCapabilitiesSchema, { auth: "admin" }), optionalMethod(LogReadQuerySchema, LogReadResultSchema, { auth: "admin" }), optionalMethod(object({ requestId: string().min(1).max(64) }), object({ cancelled: boolean() }), {
56230
56419
  kind: "mutation",
56231
56420
  auth: "admin"
56232
56421
  });
@@ -67814,6 +68003,49 @@ object({
67814
68003
  DeviceType.PetFeeder,
67815
68004
  DeviceType.Heater
67816
68005
  ].filter((type) => type !== DeviceType.Sensor);
68006
+ var PowerSourceRefusalReasonSchema = _enum([
68007
+ "no-power-source",
68008
+ "switch-missing",
68009
+ "switch-offline",
68010
+ "switch-unknown",
68011
+ "restart-in-progress",
68012
+ "switch-call-failed"
68013
+ ]);
68014
+ var PowerSourceActionResultSchema = discriminatedUnion("accepted", [object({ accepted: literal(true) }), object({
68015
+ accepted: literal(false),
68016
+ reason: PowerSourceRefusalReasonSchema,
68017
+ /** One line for the operator, naming the switch. */
68018
+ message: string()
68019
+ })]);
68020
+ var PowerSourceInfoSchema = object({
68021
+ /** False when the device has no power source linked; the rest is then empty. */
68022
+ linked: boolean(),
68023
+ switchDeviceId: number().nullable(),
68024
+ switchName: string().nullable(),
68025
+ /** The switch's on/off state, or null when it is unknown. Never false for unknown (D393). */
68026
+ switchOn: boolean().nullable(),
68027
+ switchOnline: boolean().nullable(),
68028
+ restartInProgress: boolean(),
68029
+ offSeconds: number().int()
68030
+ });
68031
+ object({
68032
+ /** Null while the switch has not reported: unknown is never `false` (D393). */
68033
+ switchOn: boolean().nullable(),
68034
+ offSeconds: number().int(),
68035
+ lastFetchedAt: number()
68036
+ });
68037
+ DeviceType.Gateway, DeviceType.Hub, 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;
68038
+ var deviceInput$1 = object({ deviceId: number().int().nonnegative() });
68039
+ systemMethod(deviceInput$1, PowerSourceInfoSchema, { auth: "admin" }), systemMethod(deviceInput$1, PowerSourceActionResultSchema, {
68040
+ kind: "mutation",
68041
+ auth: "admin"
68042
+ }), systemMethod(deviceInput$1, PowerSourceActionResultSchema, {
68043
+ kind: "mutation",
68044
+ auth: "admin"
68045
+ }), systemMethod(deviceInput$1, PowerSourceActionResultSchema, {
68046
+ kind: "mutation",
68047
+ auth: "admin"
68048
+ });
67817
68049
  /**
67818
68050
  * Presence cap. Models HA `person.*` and `device_tracker.*` entities
67819
68051
  * on `DeviceType.Presence`. Read-only — no setters: presence is
@@ -75886,6 +76118,25 @@ function buildDescriptor(capName, kind) {
75886
76118
  * contributes one entry per bound cap present in this map.
75887
76119
  */
75888
76120
  var EVENT_KIND_BY_CAP = Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
76121
+ /**
76122
+ * What a remote key is CALLED and what it LOOKS like, for every role (D963),
76123
+ * shared by the admin UI and the viewer. A role is data on the wire; each
76124
+ * client resolves its name from `label` (English and Italian side by side) and
76125
+ * its glyph from `icon`, a lucide id from the shared icon catalogue — the
76126
+ * server sends an id, a client maps it to its own icon set.
76127
+ *
76128
+ * `legend` is text printed on the key INSTEAD of a glyph (a digit has no
76129
+ * pictogram): a client that can draw text shows it, one that cannot falls back
76130
+ * to `icon`.
76131
+ */
76132
+ function digit(n) {
76133
+ return {
76134
+ label: t(n, n),
76135
+ icon: "hash",
76136
+ legend: n
76137
+ };
76138
+ }
76139
+ digit("0"), digit("1"), digit("2"), digit("3"), digit("4"), digit("5"), digit("6"), digit("7"), digit("8"), digit("9");
75889
76140
  DeviceFeature.MediaPlayerPower, DeviceFeature.MediaPlayerVolumeStep, DeviceFeature.MediaPlayerChannelStep, DeviceFeature.MediaPlayerMute, DeviceFeature.MediaPlayerStop, DeviceFeature.MediaPlayerNext, DeviceFeature.MediaPlayerPrevious;
75890
76141
  var btn = (idSuffix, row, col, init) => ({
75891
76142
  idSuffix,
@@ -76013,6 +76264,34 @@ discriminatedUnion("kind", [object({
76013
76264
  kind: literal("pronto"),
76014
76265
  code: string()
76015
76266
  })]);
76267
+ /**
76268
+ * Propose a running threshold from a device's own power history (planning#405).
76269
+ *
76270
+ * Pure and deterministic: the same series gives the same answer. The series is
76271
+ * a HELD-VALUE step series — a point's value stands until the next point — which
76272
+ * is how device-history stores a gauge, so "time at a level" is exact, not a
76273
+ * count of samples.
76274
+ *
76275
+ * 1. idle floor F = time-weighted median; noise ceiling N = highest value seen
76276
+ * near F. A device that is not near one level most of the time has no floor.
76277
+ * 2. coarse activity = above max(2N, N + 5 W); consecutive stretches are episodes.
76278
+ * 3. gaps between episodes split in two by the largest log-scale jump (>= 3x):
76279
+ * the short ones are pauses INSIDE a run (a soak), the long ones separate runs.
76280
+ * 4. T = geometric mean of N and the plateau's 10th percentile, snapped to a
76281
+ * grid a person would type; stop dwell covers the longest pause; start dwell
76282
+ * covers the longest standby blip above T.
76283
+ * 5. the numbers are proved by REPLAY through the real `dwell` evaluation: each
76284
+ * run must hold exactly one true interval and nothing may flap outside.
76285
+ */
76286
+ var SECOND_MS = 1e3;
76287
+ var MINUTE_MS$1 = 60 * SECOND_MS;
76288
+ 24 * (60 * MINUTE_MS$1);
76289
+ 10 * MINUTE_MS$1;
76290
+ 30 * SECOND_MS;
76291
+ 60 * SECOND_MS;
76292
+ 20 * MINUTE_MS$1;
76293
+ 10 * SECOND_MS;
76294
+ 10 * SECOND_MS;
76016
76295
  DeviceFeature.FanSpeed, DeviceFeature.FanPreset, DeviceFeature.FanDirection, DeviceFeature.FanOscillating, DeviceFeature.CoverStoppable, DeviceFeature.CoverPositionable, DeviceFeature.CoverTilt, DeviceFeature.ValvePositionable, DeviceFeature.MediaPlayerVolume, DeviceFeature.ClimateFanMode;
76017
76296
  SOURCE_CAPS.filter((cap) => cap !== "switch" && cap !== "motion");
76018
76297
  String.raw`rose\(active(\d+), changed(\d+), (\d+(?:\.\d+)?)\)`;
@@ -77554,6 +77833,13 @@ Object.freeze({
77554
77833
  access: "create",
77555
77834
  role: "admin"
77556
77835
  },
77836
+ "coreBlocks.proposeRunningThreshold": {
77837
+ capName: "core-blocks",
77838
+ capScope: "system",
77839
+ addonId: null,
77840
+ access: "view",
77841
+ role: "admin"
77842
+ },
77557
77843
  "coreBlocks.reportAutomationRun": {
77558
77844
  capName: "core-blocks",
77559
77845
  capScope: "system",
@@ -78065,6 +78351,13 @@ Object.freeze({
78065
78351
  access: "view",
78066
78352
  role: "admin"
78067
78353
  },
78354
+ "deviceExport.listInstances": {
78355
+ capName: "device-export",
78356
+ capScope: "system",
78357
+ addonId: null,
78358
+ access: "view",
78359
+ role: "admin"
78360
+ },
78068
78361
  "deviceExport.listSupportedDeviceKinds": {
78069
78362
  capName: "device-export",
78070
78363
  capScope: "system",
@@ -87037,6 +87330,11 @@ Object.freeze({
87037
87330
  form: "single",
87038
87331
  optional: false
87039
87332
  }],
87333
+ "coreBlocks.proposeRunningThreshold": [{
87334
+ name: "deviceId",
87335
+ form: "single",
87336
+ optional: false
87337
+ }],
87040
87338
  "cover.close": [{
87041
87339
  name: "deviceId",
87042
87340
  form: "single",
@@ -89700,99 +89998,6 @@ Object.freeze({
89700
89998
  "network-access": "ingress",
89701
89999
  "smtp-provider": "email"
89702
90000
  });
89703
- /**
89704
- * A saved Customize assignment (D936). The schema is the type: callers use
89705
- * `z.infer`, they do not restate the shape.
89706
- */
89707
- var OverrideSourceSchema = object({
89708
- addonId: string().min(1),
89709
- stableId: string().min(1),
89710
- cap: string().min(1),
89711
- fieldPath: string().min(1)
89712
- });
89713
- var CustomizeTransformDraftSchema = discriminatedUnion("kind", [
89714
- object({ kind: literal("identity") }),
89715
- object({ kind: literal("invert") }),
89716
- object({
89717
- kind: literal("threshold"),
89718
- comparison: _enum(["gte", "lte"]),
89719
- threshold: number(),
89720
- startDwellMs: number().nonnegative(),
89721
- stopDwellMs: number().nonnegative()
89722
- }),
89723
- object({
89724
- kind: literal("linear"),
89725
- scale: number(),
89726
- offset: number(),
89727
- clampMin: number().optional(),
89728
- clampMax: number().optional()
89729
- }),
89730
- object({
89731
- kind: literal("enum-map"),
89732
- mapping: record(string(), string().nullable())
89733
- }),
89734
- object({ kind: literal("number") })
89735
- ]);
89736
- var ScalarOverrideDraftSchema = object({
89737
- kind: literal("scalar"),
89738
- cap: string().min(1),
89739
- targetId: string().min(1),
89740
- source: OverrideSourceSchema,
89741
- transform: CustomizeTransformDraftSchema
89742
- });
89743
- var KeyedArrayOverrideDraftSchema = object({
89744
- kind: literal("keyedArray"),
89745
- cap: string().min(1),
89746
- targetId: string().min(1),
89747
- key: string().min(1),
89748
- label: string().min(1),
89749
- fieldPath: string().min(1),
89750
- source: OverrideSourceSchema,
89751
- transform: CustomizeTransformDraftSchema
89752
- });
89753
- var PulseOverrideDraftSchema = object({
89754
- kind: literal("pulse"),
89755
- cap: string().min(1),
89756
- targetId: string().min(1),
89757
- enabled: boolean(),
89758
- debounceMs: number().nonnegative(),
89759
- edges: array(_enum([
89760
- "rising",
89761
- "button",
89762
- "native-event"
89763
- ])).min(1).optional(),
89764
- sources: array(OverrideSourceSchema).min(1)
89765
- });
89766
- var SpanSourceDraftSchema = OverrideSourceSchema.extend({ mode: _enum([
89767
- "in-addition",
89768
- "confirm",
89769
- "replace"
89770
- ]).optional() });
89771
- discriminatedUnion("kind", [
89772
- ScalarOverrideDraftSchema,
89773
- KeyedArrayOverrideDraftSchema,
89774
- PulseOverrideDraftSchema,
89775
- object({
89776
- kind: literal("span"),
89777
- cap: string().min(1),
89778
- targetId: string().min(1),
89779
- timeoutMs: number().nonnegative(),
89780
- cooldownMs: number().nonnegative().optional(),
89781
- sources: array(SpanSourceDraftSchema)
89782
- })
89783
- ]);
89784
- object({
89785
- targetId: string().min(1),
89786
- configured: boolean(),
89787
- source: _enum(["native", "assigned"]),
89788
- state: _enum([
89789
- "active",
89790
- "stale",
89791
- "released",
89792
- "unavailable"
89793
- ]),
89794
- reason: string().nullable()
89795
- });
89796
90001
  var G711_SCALE_CORRECTION_DB = {
89797
90002
  PCMU: 20 * Math.log10(4),
89798
90003
  PCMA: 20 * Math.log10(8)
@@ -103468,6 +103673,8 @@ function hasUnresolvedCredential(entry) {
103468
103673
  if (typeof entry !== "object" || entry === null) return false;
103469
103674
  return "accessToken" in entry && isSecretMarker(entry.accessToken) || "refreshToken" in entry && isSecretMarker(entry.refreshToken) || "brokerCredential" in entry && isSecretMarker(entry.brokerCredential);
103470
103675
  }
103676
+ /** The one export instance this addon serves. */
103677
+ var EXPORT_ALEXA_ADDON_ID = "export-alexa";
103471
103678
  var ExportAlexaAddon = class extends BaseAddon {
103472
103679
  /** Hidden state that is a credential — kept in the keychain, never the blob (D787). */
103473
103680
  secretStatePaths = [
@@ -103634,30 +103841,55 @@ var ExportAlexaAddon = class extends BaseAddon {
103634
103841
  actionScenes.reconcile().catch((err) => {
103635
103842
  this.ctx.logger.warn("export-alexa: action scene reconcile at boot failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
103636
103843
  });
103844
+ const ownInstance = (instanceId) => assertOwnExportInstance("export-alexa", EXPORT_ALEXA_ADDON_ID, instanceId);
103637
103845
  const deviceExportProvider = {
103638
- getStatus: async () => ({
103639
- linkState: this.view.linkedAccounts.length > 0 ? "linked" : "unlinked",
103640
- exposedDeviceCount: this.config.exposed.length,
103641
- setup: await this.buildSetupBlock()
103642
- }),
103643
- listSupportedDeviceKinds: async () => [...SUPPORTED_KINDS],
103644
- listExposedDevices: async () => this.config.exposed.map((e) => ({ deviceId: String(e.deviceId) })),
103645
- exposeDevice: async ({ deviceId }) => this.exposeDevice(deviceId),
103646
- unexposeDevice: async ({ deviceId }) => this.unexposeDevice(deviceId),
103846
+ getStatus: async (input) => {
103847
+ ownInstance(statusInstanceOf(input));
103848
+ return {
103849
+ linkState: this.view.linkedAccounts.length > 0 ? "linked" : "unlinked",
103850
+ exposedDeviceCount: this.config.exposed.length,
103851
+ setup: await this.buildSetupBlock()
103852
+ };
103853
+ },
103854
+ listInstances: async () => [{
103855
+ instanceId: EXPORT_ALEXA_ADDON_ID,
103856
+ name: "Alexa",
103857
+ enabled: true,
103858
+ kind: "alexa-skill"
103859
+ }],
103860
+ listSupportedDeviceKinds: async ({ instanceId }) => {
103861
+ ownInstance(instanceId);
103862
+ return [...SUPPORTED_KINDS];
103863
+ },
103864
+ listExposedDevices: async ({ instanceId }) => {
103865
+ ownInstance(instanceId);
103866
+ return this.config.exposed.map((e) => ({ deviceId: String(e.deviceId) }));
103867
+ },
103868
+ exposeDevice: async ({ instanceId, deviceId }) => {
103869
+ ownInstance(instanceId);
103870
+ return this.exposeDevice(deviceId);
103871
+ },
103872
+ unexposeDevice: async ({ instanceId, deviceId }) => {
103873
+ ownInstance(instanceId);
103874
+ return this.unexposeDevice(deviceId);
103875
+ },
103647
103876
  listSupportedEntityKinds: async () => ["device", "action"],
103648
- listExposedEntities: async () => {
103877
+ listExposedEntities: async ({ instanceId }) => {
103878
+ ownInstance(instanceId);
103649
103879
  await actionScenes.reconcile();
103650
103880
  return [...this.config.exposed.map((e) => ({ entity: {
103651
103881
  kind: "device",
103652
103882
  deviceId: String(e.deviceId)
103653
103883
  } })), ...actionScenes.list()];
103654
103884
  },
103655
- exposeEntity: async ({ entity }) => {
103885
+ exposeEntity: async ({ instanceId, entity }) => {
103886
+ ownInstance(instanceId);
103656
103887
  if (entity.kind === "device") return this.exposeDevice(entity.deviceId);
103657
103888
  if (entity.kind === "action") return actionScenes.expose(entity.actionId);
103658
103889
  throw new Error("export-alexa: a notification target cannot be exported to Alexa");
103659
103890
  },
103660
- unexposeEntity: async ({ entity }) => {
103891
+ unexposeEntity: async ({ instanceId, entity }) => {
103892
+ ownInstance(instanceId);
103661
103893
  if (entity.kind === "device") return this.unexposeDevice(entity.deviceId);
103662
103894
  if (entity.kind === "action") return actionScenes.unexpose(entity.actionId);
103663
103895
  throw new Error("export-alexa: a notification target cannot be exported to Alexa");