@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.
@@ -6016,7 +6016,7 @@ var ZodIssueCode = {
6016
6016
  var ZodFirstPartyTypeKind;
6017
6017
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
6018
6018
  //#endregion
6019
- //#region ../types/dist/sleep-DV4qxEyD.mjs
6019
+ //#region ../types/dist/sleep-BkzQdpzF.mjs
6020
6020
  /**
6021
6021
  * The audio chunk plane's byte format, and the ONE expansion from a coded
6022
6022
  * window to float samples (D455).
@@ -9218,7 +9218,7 @@ function defineRecordKinds(specs) {
9218
9218
  retention: spec.retention,
9219
9219
  deviceRemoval: spec.deviceRemoval,
9220
9220
  maxDataBytes: spec.maxDataBytes,
9221
- secretPaths: [...secretPaths],
9221
+ secretPaths: [...new Set([...secretPaths, ...spec.retiredSecretPaths ?? []])],
9222
9222
  secretArrayKeys: spec.secretArrayKeys === void 0 ? void 0 : { ...spec.secretArrayKeys },
9223
9223
  transactFamily: spec.transactFamily,
9224
9224
  entry: spec.entry === void 0 ? void 0 : {
@@ -9249,6 +9249,7 @@ function defineEntryKind(name, spec) {
9249
9249
  ...spec.database === void 0 ? {} : { database: spec.database },
9250
9250
  ...spec.indexes === void 0 ? {} : { indexes: spec.indexes },
9251
9251
  ...spec.secretArrayKeys === void 0 ? {} : { secretArrayKeys: spec.secretArrayKeys },
9252
+ ...spec.retiredSecretPaths === void 0 ? {} : { retiredSecretPaths: spec.retiredSecretPaths },
9252
9253
  entry: {
9253
9254
  title: spec.title,
9254
9255
  ...spec.nameField === void 0 ? {} : { nameField: spec.nameField }
@@ -11932,7 +11933,7 @@ object({
11932
11933
  params: record(string(), union([string(), number()])).optional()
11933
11934
  });
11934
11935
  //#endregion
11935
- //#region ../types/dist/composition-BodkvOV0.mjs
11936
+ //#region ../types/dist/composition-CRNwcFYY.mjs
11936
11937
  /**
11937
11938
  * The ffmpeg build every CamStack node downloads, per platform and arch.
11938
11939
  *
@@ -12695,38 +12696,6 @@ function validateExpressionSource(src) {
12695
12696
  return null;
12696
12697
  }
12697
12698
  /**
12698
- * One power reading becomes a washer, dryer or dishwasher (D944 helper).
12699
- *
12700
- * Standby of the control board is under 5 W; a motor or a heater is far
12701
- * above that, so 5 W is the line. A door lock or a short pump spike is not
12702
- * a cycle, so running starts only after 30 s above the line.
12703
- *
12704
- * A wash, dry or dishwasher pause (soak, heat-wait, heater off between
12705
- * bursts) lasts several minutes. Ending the cycle on the first dip would
12706
- * report "finished" in the middle of the program, so the stop dwell is
12707
- * 10 minutes on every type. The number is stored per type so one machine
12708
- * can move later without moving the others.
12709
- */
12710
- var APPLIANCE_TEMPLATE_ID = "appliance";
12711
- var APPLIANCE_KINDS = [
12712
- "washer",
12713
- "dryer",
12714
- "dishwasher"
12715
- ];
12716
- DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher;
12717
- /**
12718
- * A dumb plug-in stove or heater, built from a smart plug (a `Heater`).
12719
- *
12720
- * The plug is the actuator: `switch.setState` is a FORWARD to the plug's own
12721
- * (D967), so the heater switches exactly as the plug does. Running is the
12722
- * plug being on; when a power reading is also named, running is the draw
12723
- * staying above the line instead (a plug left on with the stove's own
12724
- * thermostat open is not heating). 50 W is far above any standby and below
12725
- * the smallest radiator.
12726
- */
12727
- var HEATER_TEMPLATE_ID = "heater";
12728
- DeviceType.Heater;
12729
- /**
12730
12699
  * Statistics and integrals over a history read (D944).
12731
12700
  *
12732
12701
  * Pure: the same points always give the same answer, so a restart recomputes
@@ -12870,34 +12839,6 @@ var HelperSpecSchema = discriminatedUnion("kind", [
12870
12839
  /** Actuator groups only. Readings leave this unset. */
12871
12840
  active: ActiveCriterionSchema.optional()
12872
12841
  }),
12873
- object({
12874
- kind: literal("appliance"),
12875
- templateId: literal(APPLIANCE_TEMPLATE_ID),
12876
- appliance: _enum(APPLIANCE_KINDS),
12877
- thresholdWatts: number().positive(),
12878
- startDwellMs: number().int().nonnegative(),
12879
- stopDwellMs: number().int().nonnegative(),
12880
- member: HelperMemberSchema,
12881
- /**
12882
- * The plug that powers the appliance (`switch.on`). Optional: when set, the
12883
- * composition carries a `power-source` feature, so the hub can cut and restore
12884
- * that plug (power-source link of a NEW-target composition).
12885
- */
12886
- powerSwitch: HelperMemberSchema.optional(),
12887
- /** How long a forced restart keeps the plug off; the cap's default when unset. */
12888
- offSeconds: number().optional()
12889
- }),
12890
- object({
12891
- kind: literal("heater"),
12892
- templateId: literal(HEATER_TEMPLATE_ID),
12893
- /** The plug, read and commanded at `switch.on`. */
12894
- plug: HelperMemberSchema,
12895
- /** The plug's power reading, when it has one: running is then the draw, not the switch. */
12896
- meter: HelperMemberSchema.optional(),
12897
- thresholdWatts: number().positive(),
12898
- startDwellMs: number().int().nonnegative(),
12899
- stopDwellMs: number().int().nonnegative()
12900
- }),
12901
12842
  object({
12902
12843
  kind: literal("statistic"),
12903
12844
  stat: _enum(STATISTIC_STATS),
@@ -13121,7 +13062,7 @@ var CompositionSchema = object({
13121
13062
  kind: literal("existing"),
13122
13063
  device: CompositionSourceRefSchema
13123
13064
  })]),
13124
- features: array(CompositionFeatureSchema).min(1).max(16),
13065
+ features: array(CompositionFeatureSchema).min(0).max(16),
13125
13066
  /**
13126
13067
  * Present when the block is a helper template. Absent on a free
13127
13068
  * composition (the room example, device 4603). The editor reads this,
@@ -13520,15 +13461,23 @@ var RecordIntegrationInstances = class {
13520
13461
  viewOf(record) {
13521
13462
  const shown = secretViewsOf(this.records.owner, this.kind.name, record.id, this.kind.declaration, record.data);
13522
13463
  const rawName = record.data[this.nameField];
13464
+ const kind = this.hooks.kindOf?.(record.data);
13465
+ const health = this.hooks.health?.(record.data, record.id);
13523
13466
  return {
13524
13467
  id: record.id,
13525
13468
  name: typeof rawName === "string" ? rawName : record.id,
13526
13469
  configured: this.hooks.configured(record.data),
13527
13470
  enabled: record.data.enabled !== false,
13528
- formValues: shown
13471
+ formValues: shown,
13472
+ ...kind !== void 0 ? { kind } : {},
13473
+ ...health?.status !== void 0 ? { status: health.status } : {},
13474
+ ...health?.lastCheckedAt !== void 0 ? { lastCheckedAt: health.lastCheckedAt } : {}
13529
13475
  };
13530
13476
  }
13531
- describe = async () => this.hooks.description;
13477
+ describe = async () => this.hooks.mintId === void 0 ? this.hooks.description : {
13478
+ ...this.hooks.description,
13479
+ mintsId: true
13480
+ };
13532
13481
  instanceFormSchema = async ({ id }) => this.hooks.formSchema(id);
13533
13482
  listInstances = async () => {
13534
13483
  return (await this.handle.query({ limit: INSTANCES_LIST_MAX })).records.map((record) => this.viewOf(record));
@@ -13538,13 +13487,18 @@ var RecordIntegrationInstances = class {
13538
13487
  return record === null ? null : this.viewOf(record);
13539
13488
  };
13540
13489
  /** Insert ONE row (`ifRev: 0`: an existing id is refused, never overwritten). */
13541
- createInstance = async ({ id, name }) => {
13490
+ createInstance = async ({ id, name, kind }) => {
13491
+ const minted = id ?? this.hooks.mintId?.({
13492
+ name,
13493
+ ...kind !== void 0 ? { kind } : {}
13494
+ });
13495
+ if (minted === void 0) throw new Error("createInstance needs an id: this provider does not mint one");
13542
13496
  await this.handle.put({
13543
- id,
13544
- data: this.hooks.initialBody(name)
13497
+ id: minted,
13498
+ data: this.hooks.initialBody(name, kind)
13545
13499
  }, { ifRev: 0 });
13546
- await this.hooks.onChanged?.(id);
13547
- return { id };
13500
+ await this.hooks.onChanged?.(minted);
13501
+ return { id: minted };
13548
13502
  };
13549
13503
  updateInstance = async ({ id, name, values }) => {
13550
13504
  const patch = {};
@@ -49265,49 +49219,6 @@ function actuator(input) {
49265
49219
  };
49266
49220
  }
49267
49221
  new Map(GROUP_TEMPLATES.map((template) => [template.id, template]));
49268
- var PowerSourceRefusalReasonSchema = _enum([
49269
- "no-power-source",
49270
- "switch-missing",
49271
- "switch-offline",
49272
- "switch-unknown",
49273
- "restart-in-progress",
49274
- "switch-call-failed"
49275
- ]);
49276
- var PowerSourceActionResultSchema = discriminatedUnion("accepted", [object({ accepted: literal(true) }), object({
49277
- accepted: literal(false),
49278
- reason: PowerSourceRefusalReasonSchema,
49279
- /** One line for the operator, naming the switch. */
49280
- message: string()
49281
- })]);
49282
- var PowerSourceInfoSchema = object({
49283
- /** False when the device has no power source linked; the rest is then empty. */
49284
- linked: boolean(),
49285
- switchDeviceId: number().nullable(),
49286
- switchName: string().nullable(),
49287
- /** The switch's on/off state, or null when it is unknown. Never false for unknown (D393). */
49288
- switchOn: boolean().nullable(),
49289
- switchOnline: boolean().nullable(),
49290
- restartInProgress: boolean(),
49291
- offSeconds: number().int()
49292
- });
49293
- object({
49294
- /** Null while the switch has not reported: unknown is never `false` (D393). */
49295
- switchOn: boolean().nullable(),
49296
- offSeconds: number().int(),
49297
- lastFetchedAt: number()
49298
- });
49299
- 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;
49300
- var deviceInput$2 = object({ deviceId: number().int().nonnegative() });
49301
- systemMethod(deviceInput$2, PowerSourceInfoSchema, { auth: "admin" }), systemMethod(deviceInput$2, PowerSourceActionResultSchema, {
49302
- kind: "mutation",
49303
- auth: "admin"
49304
- }), systemMethod(deviceInput$2, PowerSourceActionResultSchema, {
49305
- kind: "mutation",
49306
- auth: "admin"
49307
- }), systemMethod(deviceInput$2, PowerSourceActionResultSchema, {
49308
- kind: "mutation",
49309
- auth: "admin"
49310
- });
49311
49222
  DeviceFeature.LightColorRgb, DeviceFeature.LightColorHsv, DeviceFeature.LightColorMired;
49312
49223
  DeviceType.Camera;
49313
49224
  `${COMPOSED_DEVICE_STABLE_ID_PREFIX}`;
@@ -49335,6 +49246,165 @@ var ComposableCapabilitiesSchema = object({ caps: array(object({
49335
49246
  }).optional()
49336
49247
  })) });
49337
49248
  /**
49249
+ * A saved Customize assignment (D936). The schema is the type: callers use
49250
+ * `z.infer`, they do not restate the shape.
49251
+ */
49252
+ var OverrideSourceSchema = object({
49253
+ addonId: string().min(1),
49254
+ stableId: string().min(1),
49255
+ cap: string().min(1),
49256
+ fieldPath: string().min(1)
49257
+ });
49258
+ var IdentityTransformDraftSchema = object({ kind: literal("identity") });
49259
+ var InvertTransformDraftSchema = object({ kind: literal("invert") });
49260
+ var ThresholdTransformDraftSchema = object({
49261
+ kind: literal("threshold"),
49262
+ comparison: _enum(["gte", "lte"]),
49263
+ threshold: number(),
49264
+ startDwellMs: number().nonnegative(),
49265
+ stopDwellMs: number().nonnegative()
49266
+ });
49267
+ var CustomizeTransformDraftSchema = discriminatedUnion("kind", [
49268
+ IdentityTransformDraftSchema,
49269
+ InvertTransformDraftSchema,
49270
+ ThresholdTransformDraftSchema,
49271
+ object({
49272
+ kind: literal("linear"),
49273
+ scale: number(),
49274
+ offset: number(),
49275
+ clampMin: number().optional(),
49276
+ clampMax: number().optional()
49277
+ }),
49278
+ object({
49279
+ kind: literal("enum-map"),
49280
+ mapping: record(string(), string().nullable())
49281
+ }),
49282
+ object({ kind: literal("number") })
49283
+ ]);
49284
+ var ScalarOverrideDraftSchema = object({
49285
+ kind: literal("scalar"),
49286
+ cap: string().min(1),
49287
+ targetId: string().min(1),
49288
+ source: OverrideSourceSchema,
49289
+ transform: CustomizeTransformDraftSchema
49290
+ });
49291
+ var KeyedArrayOverrideDraftSchema = object({
49292
+ kind: literal("keyedArray"),
49293
+ cap: string().min(1),
49294
+ targetId: string().min(1),
49295
+ key: string().min(1),
49296
+ label: string().min(1),
49297
+ fieldPath: string().min(1),
49298
+ source: OverrideSourceSchema,
49299
+ transform: CustomizeTransformDraftSchema
49300
+ });
49301
+ var PulseOverrideDraftSchema = object({
49302
+ kind: literal("pulse"),
49303
+ cap: string().min(1),
49304
+ targetId: string().min(1),
49305
+ enabled: boolean(),
49306
+ debounceMs: number().nonnegative(),
49307
+ edges: array(_enum([
49308
+ "rising",
49309
+ "button",
49310
+ "native-event"
49311
+ ])).min(1).optional(),
49312
+ sources: array(OverrideSourceSchema).min(1)
49313
+ });
49314
+ var SpanSourceDraftSchema = OverrideSourceSchema.extend({ mode: _enum([
49315
+ "in-addition",
49316
+ "confirm",
49317
+ "replace"
49318
+ ]).optional() });
49319
+ discriminatedUnion("kind", [
49320
+ ScalarOverrideDraftSchema,
49321
+ KeyedArrayOverrideDraftSchema,
49322
+ PulseOverrideDraftSchema,
49323
+ object({
49324
+ kind: literal("span"),
49325
+ cap: string().min(1),
49326
+ targetId: string().min(1),
49327
+ timeoutMs: number().nonnegative(),
49328
+ cooldownMs: number().nonnegative().optional(),
49329
+ sources: array(SpanSourceDraftSchema)
49330
+ })
49331
+ ]);
49332
+ object({
49333
+ targetId: string().min(1),
49334
+ configured: boolean(),
49335
+ source: _enum(["native", "assigned"]),
49336
+ state: _enum([
49337
+ "active",
49338
+ "stale",
49339
+ "released",
49340
+ "unavailable"
49341
+ ]),
49342
+ reason: string().nullable()
49343
+ });
49344
+ /**
49345
+ * What a running-threshold proposal says (planning#405). The schema is the
49346
+ * type: the algorithm, the capability method and the UI all read `z.infer`.
49347
+ *
49348
+ * A proposal is read-only advice: it carries the numbers it was derived from
49349
+ * (`evidence`) so the operator can judge it, and an `insufficient` answer names
49350
+ * WHY with a typed reason and the catalog defaults, never an invented number.
49351
+ */
49352
+ var RunningProposalTierSchema = _enum(["raw", "5m"]);
49353
+ var RunningProposalConfidenceSchema = _enum([
49354
+ "high",
49355
+ "medium",
49356
+ "low"
49357
+ ]);
49358
+ var RunningProposalInsufficientReasonSchema = _enum([
49359
+ "no-history",
49360
+ "span-too-short",
49361
+ "truncated",
49362
+ "no-idle-floor",
49363
+ "no-runs",
49364
+ "no-separation"
49365
+ ]);
49366
+ var RunningProposalReplaySchema = object({
49367
+ /** Intervals the real dwell expression held true over the window. */
49368
+ intervals: number().int().nonnegative(),
49369
+ /** Intervals outside every run, or a second interval inside one. */
49370
+ extra: number().int().nonnegative(),
49371
+ /** Runs without an interval of their own (none, or merged into a neighbour). */
49372
+ missed: number().int().nonnegative()
49373
+ });
49374
+ var RunningProposalEvidenceSchema = object({
49375
+ tier: RunningProposalTierSchema,
49376
+ spanMs: number().nonnegative(),
49377
+ from: number(),
49378
+ to: number(),
49379
+ points: number().int().nonnegative(),
49380
+ runsFound: number().int().nonnegative(),
49381
+ pausesFound: number().int().nonnegative(),
49382
+ longestPauseMs: number().nonnegative(),
49383
+ idleFloorW: number(),
49384
+ noiseCeilingW: number(),
49385
+ plateauW: number(),
49386
+ replay: RunningProposalReplaySchema
49387
+ });
49388
+ var RunningProposalInsufficientEvidenceSchema = object({
49389
+ spanMs: number().nonnegative(),
49390
+ points: number().int().nonnegative(),
49391
+ runsFound: number().int().nonnegative()
49392
+ });
49393
+ var RunningThresholdProposalSchema = discriminatedUnion("state", [object({
49394
+ state: literal("proposal"),
49395
+ transform: ThresholdTransformDraftSchema,
49396
+ evidence: RunningProposalEvidenceSchema,
49397
+ confidence: RunningProposalConfidenceSchema,
49398
+ /** Why the confidence is not higher; empty when nothing held it back. */
49399
+ notes: array(string())
49400
+ }), object({
49401
+ state: literal("insufficient"),
49402
+ reason: RunningProposalInsufficientReasonSchema,
49403
+ evidence: RunningProposalInsufficientEvidenceSchema,
49404
+ /** The catalog defaults, offered as what stands when nothing better is known. */
49405
+ fallback: ThresholdTransformDraftSchema
49406
+ })]);
49407
+ /**
49338
49408
  * The report of a one-shot "move this owner's plaintext secrets into the
49339
49409
  * keychain" run (D878). COUNTS only - never a value, never a ref.
49340
49410
  *
@@ -49624,6 +49694,14 @@ method(object({}), object({ blocks: array(CoreBlockSchema) }), { auth: "admin" }
49624
49694
  kind: "mutation",
49625
49695
  auth: "admin",
49626
49696
  access: "view"
49697
+ }), method(object({
49698
+ deviceId: number().int(),
49699
+ cap: string().min(1),
49700
+ fieldPath: string().min(1),
49701
+ deviceType: _enum(DeviceType).optional()
49702
+ }), RunningThresholdProposalSchema, {
49703
+ auth: "admin",
49704
+ access: "view"
49627
49705
  }), method(object({
49628
49706
  blockId: string().min(1),
49629
49707
  trace: AutomationRunTraceSchema.optional(),
@@ -50432,7 +50510,53 @@ method(object({
50432
50510
  * exposes only the COMMON surface: link state, supported device
50433
50511
  * kinds (so the UI can filter the device picker), and per-device
50434
50512
  * expose/unexpose.
50513
+ *
50514
+ * INSTANCES. One export addon can serve several independent targets (a
50515
+ * HomeKit bridge, a Home Assistant broker). `listInstances` names them.
50516
+ * `instanceId` on a READ is optional: absent = the whole addon (linked if any
50517
+ * enabled instance is, `exposedDeviceCount` = distinct devices, `setup` = the
50518
+ * default instance's); present = that instance; an id the provider does not
50519
+ * serve is refused with `ExportInstanceUnknownError` (`export-instance-unknown`),
50520
+ * never answered empty. `instanceId` on a WRITE is REQUIRED: a membership
50521
+ * change always names the target it changes. A single-instance provider
50522
+ * accepts an absent id on a read or its own id, and refuses any other.
50523
+ */
50524
+ /** Which instance of an export addon a call addresses. Absent on a read = the whole addon. */
50525
+ var InstanceIdSchema$1 = string().min(1);
50526
+ var InstancePinSchema = object({ instanceId: InstanceIdSchema$1.optional() });
50527
+ /** One independent export target of an addon. */
50528
+ var ExportInstanceSchema = object({
50529
+ instanceId: InstanceIdSchema$1,
50530
+ name: string(),
50531
+ enabled: boolean(),
50532
+ kind: string().optional()
50533
+ });
50534
+ var EXPORT_INSTANCE_UNKNOWN = "export-instance-unknown";
50535
+ /** The named failure of an `instanceId` the provider does not serve. The message starts with the code. */
50536
+ var ExportInstanceUnknownError = class extends Error {
50537
+ code = EXPORT_INSTANCE_UNKNOWN;
50538
+ instanceId;
50539
+ constructor(addon, instanceId) {
50540
+ super(`${EXPORT_INSTANCE_UNKNOWN}: ${addon} serves no instance "${instanceId}"`);
50541
+ this.name = "ExportInstanceUnknownError";
50542
+ this.instanceId = instanceId;
50543
+ }
50544
+ };
50545
+ /**
50546
+ * The instance a `getStatus` call names. The cap's `status` block injects a per-device
50547
+ * `getStatus({ deviceId })` beside the method's own `{ instanceId? }`, so the provider sees
50548
+ * both shapes; only the second names an instance (a per-device status read is addon-wide).
50549
+ */
50550
+ function statusInstanceOf(input) {
50551
+ return "instanceId" in input ? input.instanceId : void 0;
50552
+ }
50553
+ /**
50554
+ * A single-instance provider's check: an absent id or its own passes, any other throws
50555
+ * `ExportInstanceUnknownError`.
50435
50556
  */
50557
+ function assertOwnExportInstance(addon, own, instanceId) {
50558
+ if (instanceId !== void 0 && instanceId !== own) throw new ExportInstanceUnknownError(addon, instanceId);
50559
+ }
50436
50560
  var LinkStateSchema = _enum([
50437
50561
  "unlinked",
50438
50562
  "linked",
@@ -50483,10 +50607,14 @@ var ExposedDeviceSchema = object({
50483
50607
  capabilities: array(string()).optional()
50484
50608
  });
50485
50609
  var ExposeInputSchema = object({
50610
+ instanceId: InstanceIdSchema$1,
50486
50611
  deviceId: string(),
50487
50612
  capabilities: array(string()).optional()
50488
50613
  });
50489
- var UnexposeInputSchema = object({ deviceId: string() });
50614
+ var UnexposeInputSchema = object({
50615
+ instanceId: InstanceIdSchema$1,
50616
+ deviceId: string()
50617
+ });
50490
50618
  /**
50491
50619
  * What an exporter may expose besides devices (D968). An action and a
50492
50620
  * notification target are LIST ENTRIES, never devices (D954): they enter an
@@ -50515,8 +50643,14 @@ var ExposedEntitySchema = object({
50515
50643
  entity: ExportEntityRefSchema,
50516
50644
  exposedAs: string().optional()
50517
50645
  });
50518
- var ExposeEntityInputSchema = object({ entity: ExportEntityRefSchema });
50519
- var UnexposeEntityInputSchema = object({ entity: ExportEntityRefSchema });
50646
+ var ExposeEntityInputSchema = object({
50647
+ instanceId: InstanceIdSchema$1,
50648
+ entity: ExportEntityRefSchema
50649
+ });
50650
+ var UnexposeEntityInputSchema = object({
50651
+ instanceId: InstanceIdSchema$1,
50652
+ entity: ExportEntityRefSchema
50653
+ });
50520
50654
  var deviceExportCapability = {
50521
50655
  name: "device-export",
50522
50656
  scope: "system",
@@ -50536,9 +50670,10 @@ var deviceExportCapability = {
50536
50670
  */
50537
50671
  exposesDeviceSettings: true,
50538
50672
  methods: {
50539
- getStatus: method(_void(), DeviceExportStatusSchema),
50540
- listSupportedDeviceKinds: method(_void(), array(DeviceKindSchema)),
50541
- listExposedDevices: method(_void(), array(ExposedDeviceSchema)),
50673
+ getStatus: method(InstancePinSchema, DeviceExportStatusSchema),
50674
+ listInstances: method(_void(), array(ExportInstanceSchema)),
50675
+ listSupportedDeviceKinds: method(InstancePinSchema, array(DeviceKindSchema)),
50676
+ listExposedDevices: method(InstancePinSchema, array(ExposedDeviceSchema)),
50542
50677
  exposeDevice: method(ExposeInputSchema, _void(), {
50543
50678
  kind: "mutation",
50544
50679
  auth: "admin"
@@ -50548,7 +50683,7 @@ var deviceExportCapability = {
50548
50683
  auth: "admin"
50549
50684
  }),
50550
50685
  listSupportedEntityKinds: optionalMethod(_void(), array(ExportEntityKindSchema)),
50551
- listExposedEntities: optionalMethod(_void(), array(ExposedEntitySchema)),
50686
+ listExposedEntities: optionalMethod(InstancePinSchema, array(ExposedEntitySchema)),
50552
50687
  exposeEntity: optionalMethod(ExposeEntityInputSchema, _void(), {
50553
50688
  kind: "mutation",
50554
50689
  auth: "admin"
@@ -53753,15 +53888,15 @@ var FanPresetCaptureResultSchema = object({
53753
53888
  items: array(FanCaptureItemSchema),
53754
53889
  omitted: array(FanCaptureOmissionSchema)
53755
53890
  });
53756
- var deviceInput$1 = object({ deviceId: number().int().nonnegative() });
53891
+ var deviceInput$2 = object({ deviceId: number().int().nonnegative() });
53757
53892
  DeviceType.Fan;
53758
- method(deviceInput$1, array(FanPresetSchema), { auth: "protected" }), method(deviceInput$1.extend({ presets: array(FanPresetSchema).max(12) }), FanPresetsSetResultSchema, {
53893
+ method(deviceInput$2, array(FanPresetSchema), { auth: "protected" }), method(deviceInput$2.extend({ presets: array(FanPresetSchema).max(12) }), FanPresetsSetResultSchema, {
53759
53894
  kind: "mutation",
53760
53895
  auth: "admin"
53761
- }), method(deviceInput$1.extend({ presetId: string().min(1) }), FanPresetApplyResultSchema, {
53896
+ }), method(deviceInput$2.extend({ presetId: string().min(1) }), FanPresetApplyResultSchema, {
53762
53897
  kind: "mutation",
53763
53898
  auth: "protected"
53764
- }), method(deviceInput$1.extend({
53899
+ }), method(deviceInput$2.extend({
53765
53900
  fields: array(FanCaptureFieldSchema).optional(),
53766
53901
  steps: array(ActionStepSchema).max(20).default([])
53767
53902
  }), FanPresetCaptureResultSchema, { auth: "protected" });
@@ -54293,13 +54428,50 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
54293
54428
  */
54294
54429
  var ConfigSchemaPassthrough$3 = custom();
54295
54430
  var IntegrationInstanceIdSchema = string().min(1);
54431
+ var IntegrationInstanceModeSchema = _enum(["single", "multiple"]);
54432
+ /**
54433
+ * One kind of instance a provider can create (an adapter, an account type). The sign-in and
54434
+ * connect fields follow the `broker` contract (`broker.cap.ts`): `signIn.basePath` is a
54435
+ * hub-relative route set speaking the sign-in contract, `connectPath` / `disconnectPath` open an
54436
+ * interactive account link (popup) and may carry `{{brokerId}}`, which the UI replaces with the
54437
+ * instance id.
54438
+ */
54439
+ var IntegrationInstanceKindSchema = object({
54440
+ /** Stable id of the kind, sent back as `createInstance.kind`. */
54441
+ id: string().min(1),
54442
+ label: string().min(1),
54443
+ /** The kind signs in through a server-held interactive session. */
54444
+ signIn: object({
54445
+ basePath: string().min(1),
54446
+ methods: array(_enum(["device-code", "proxy"])).optional()
54447
+ }).optional(),
54448
+ /** Relative hub path to start an interactive account link of an instance of this kind. */
54449
+ connectPath: string().min(1).optional(),
54450
+ /** Relative hub path to disconnect that account. */
54451
+ disconnectPath: string().min(1).optional()
54452
+ });
54296
54453
  var IntegrationInstanceDescriptionSchema = object({
54297
54454
  /** `single`: at most one instance can exist (Loki). `multiple`: an account each. */
54298
- instanceMode: _enum(["single", "multiple"]),
54455
+ instanceMode: IntegrationInstanceModeSchema,
54299
54456
  /** What the instance is, for the UI (`destination`, `relay`, `account`). */
54300
54457
  kind: string(),
54301
54458
  /** True when `testInstance` really probes the remote. */
54302
- canTest: boolean()
54459
+ canTest: boolean(),
54460
+ /**
54461
+ * The kinds an instance can be of. Absent or one entry: nothing to choose; more than one: the
54462
+ * Add flow asks which first and sends it as `createInstance.kind`.
54463
+ */
54464
+ kinds: array(IntegrationInstanceKindSchema).optional(),
54465
+ /**
54466
+ * The provider accepts `createInstance.id` for an id that once existed (an adopted id, because
54467
+ * devices carry it). The UI then offers "restore under its old id" on Add. Absent means no.
54468
+ */
54469
+ allowRestoreId: boolean().optional(),
54470
+ /**
54471
+ * `createInstance` without an `id` works: the provider mints it. Absent means the caller must
54472
+ * send an id (the UI then mints an opaque one).
54473
+ */
54474
+ mintsId: boolean().optional()
54303
54475
  });
54304
54476
  var IntegrationInstanceStatusSchema = object({
54305
54477
  state: _enum([
@@ -54308,7 +54480,9 @@ var IntegrationInstanceStatusSchema = object({
54308
54480
  "error",
54309
54481
  "unknown"
54310
54482
  ]),
54311
- detail: string().optional()
54483
+ detail: string().optional(),
54484
+ /** A short human word for the state ("Signed in", "Token expired"); shown instead of `state`. */
54485
+ label: string().optional()
54312
54486
  });
54313
54487
  var IntegrationInstanceSchema = object({
54314
54488
  id: IntegrationInstanceIdSchema,
@@ -54320,9 +54494,13 @@ var IntegrationInstanceSchema = object({
54320
54494
  * (`enabled !== false`, so a row written before the field existed is on).
54321
54495
  */
54322
54496
  enabled: boolean(),
54497
+ /** The kind of this instance (one of `describe().kinds[].id`), when the provider has kinds. */
54498
+ kind: string().optional(),
54323
54499
  /** Values for the instance form; a secret is a `SecretFieldView`, never text. */
54324
54500
  formValues: record(string(), unknown()),
54325
- status: IntegrationInstanceStatusSchema.optional()
54501
+ status: IntegrationInstanceStatusSchema.optional(),
54502
+ /** Epoch ms of the last probe of the remote that produced `status`; absent when never checked. */
54503
+ lastCheckedAt: number().optional()
54326
54504
  });
54327
54505
  var IntegrationInstancePatchSchema = object({
54328
54506
  id: IntegrationInstanceIdSchema,
@@ -54340,10 +54518,14 @@ var integrationInstancesCapability = {
54340
54518
  instanceFormSchema: method(object({ id: IntegrationInstanceIdSchema.nullable() }), ConfigSchemaPassthrough$3, { auth: "admin" }),
54341
54519
  listInstances: method(_void(), array(IntegrationInstanceSchema).readonly(), { auth: "admin" }),
54342
54520
  getInstance: method(object({ id: IntegrationInstanceIdSchema }), IntegrationInstanceSchema.nullable(), { auth: "admin" }),
54343
- /** Insert the typed record under the given id (a duplicate id is refused). */
54521
+ /**
54522
+ * Insert the typed record. With `id` it is stored under that id (a duplicate id is refused);
54523
+ * without one the PROVIDER mints it and answers it. `kind` picks one of `describe().kinds`.
54524
+ */
54344
54525
  createInstance: method(object({
54345
- id: IntegrationInstanceIdSchema,
54346
- name: string().min(1)
54526
+ id: IntegrationInstanceIdSchema.optional(),
54527
+ name: string().min(1),
54528
+ kind: string().min(1).optional()
54347
54529
  }), object({ id: string() }), {
54348
54530
  kind: "mutation",
54349
54531
  auth: "admin"
@@ -56175,6 +56357,11 @@ var LogEntrySchema = object({
56175
56357
  * flight, and not asking for the next slice ends the scan.
56176
56358
  */
56177
56359
  var LogReadQuerySchema = object({
56360
+ /**
56361
+ * Which destination INSTANCE answers (a destination addon may hold several records). Absent ⇒
56362
+ * the provider's first readable one, so a caller written before instances existed is unchanged.
56363
+ */
56364
+ instanceId: string().min(1).max(200).optional(),
56178
56365
  /** Correlates `cancelRead`. Caller-chosen, unique per in-flight read. */
56179
56366
  requestId: string().min(1).max(64).optional(),
56180
56367
  /** The device the line is about (`tags.deviceId`, numeric). */
@@ -56237,6 +56424,8 @@ var LogReadResultSchema = object({
56237
56424
  /** True when `cancelRead` ended this slice early. */
56238
56425
  cancelled: boolean().optional()
56239
56426
  });
56427
+ /** Names one destination instance; absent ⇒ the provider's first readable one. */
56428
+ var LogInstanceSelectorSchema = object({ instanceId: string().min(1).max(200).optional() });
56240
56429
  var LogReadCapabilitiesSchema = object({
56241
56430
  /** False ⇒ this destination only ships lines (console, forwarder, an unconfigured Loki). */
56242
56431
  readable: boolean(),
@@ -56255,7 +56444,7 @@ var LogReadCapabilitiesSchema = object({
56255
56444
  /** How far back the store reaches, when the provider knows (days). */
56256
56445
  retentionDays: number().nullable()
56257
56446
  });
56258
- 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() }), {
56447
+ 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() }), {
56259
56448
  kind: "mutation",
56260
56449
  auth: "admin"
56261
56450
  });
@@ -67843,6 +68032,49 @@ object({
67843
68032
  DeviceType.PetFeeder,
67844
68033
  DeviceType.Heater
67845
68034
  ].filter((type) => type !== DeviceType.Sensor);
68035
+ var PowerSourceRefusalReasonSchema = _enum([
68036
+ "no-power-source",
68037
+ "switch-missing",
68038
+ "switch-offline",
68039
+ "switch-unknown",
68040
+ "restart-in-progress",
68041
+ "switch-call-failed"
68042
+ ]);
68043
+ var PowerSourceActionResultSchema = discriminatedUnion("accepted", [object({ accepted: literal(true) }), object({
68044
+ accepted: literal(false),
68045
+ reason: PowerSourceRefusalReasonSchema,
68046
+ /** One line for the operator, naming the switch. */
68047
+ message: string()
68048
+ })]);
68049
+ var PowerSourceInfoSchema = object({
68050
+ /** False when the device has no power source linked; the rest is then empty. */
68051
+ linked: boolean(),
68052
+ switchDeviceId: number().nullable(),
68053
+ switchName: string().nullable(),
68054
+ /** The switch's on/off state, or null when it is unknown. Never false for unknown (D393). */
68055
+ switchOn: boolean().nullable(),
68056
+ switchOnline: boolean().nullable(),
68057
+ restartInProgress: boolean(),
68058
+ offSeconds: number().int()
68059
+ });
68060
+ object({
68061
+ /** Null while the switch has not reported: unknown is never `false` (D393). */
68062
+ switchOn: boolean().nullable(),
68063
+ offSeconds: number().int(),
68064
+ lastFetchedAt: number()
68065
+ });
68066
+ 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;
68067
+ var deviceInput$1 = object({ deviceId: number().int().nonnegative() });
68068
+ systemMethod(deviceInput$1, PowerSourceInfoSchema, { auth: "admin" }), systemMethod(deviceInput$1, PowerSourceActionResultSchema, {
68069
+ kind: "mutation",
68070
+ auth: "admin"
68071
+ }), systemMethod(deviceInput$1, PowerSourceActionResultSchema, {
68072
+ kind: "mutation",
68073
+ auth: "admin"
68074
+ }), systemMethod(deviceInput$1, PowerSourceActionResultSchema, {
68075
+ kind: "mutation",
68076
+ auth: "admin"
68077
+ });
67846
68078
  /**
67847
68079
  * Presence cap. Models HA `person.*` and `device_tracker.*` entities
67848
68080
  * on `DeviceType.Presence`. Read-only — no setters: presence is
@@ -75915,6 +76147,25 @@ function buildDescriptor(capName, kind) {
75915
76147
  * contributes one entry per bound cap present in this map.
75916
76148
  */
75917
76149
  var EVENT_KIND_BY_CAP = Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
76150
+ /**
76151
+ * What a remote key is CALLED and what it LOOKS like, for every role (D963),
76152
+ * shared by the admin UI and the viewer. A role is data on the wire; each
76153
+ * client resolves its name from `label` (English and Italian side by side) and
76154
+ * its glyph from `icon`, a lucide id from the shared icon catalogue — the
76155
+ * server sends an id, a client maps it to its own icon set.
76156
+ *
76157
+ * `legend` is text printed on the key INSTEAD of a glyph (a digit has no
76158
+ * pictogram): a client that can draw text shows it, one that cannot falls back
76159
+ * to `icon`.
76160
+ */
76161
+ function digit(n) {
76162
+ return {
76163
+ label: t(n, n),
76164
+ icon: "hash",
76165
+ legend: n
76166
+ };
76167
+ }
76168
+ digit("0"), digit("1"), digit("2"), digit("3"), digit("4"), digit("5"), digit("6"), digit("7"), digit("8"), digit("9");
75918
76169
  DeviceFeature.MediaPlayerPower, DeviceFeature.MediaPlayerVolumeStep, DeviceFeature.MediaPlayerChannelStep, DeviceFeature.MediaPlayerMute, DeviceFeature.MediaPlayerStop, DeviceFeature.MediaPlayerNext, DeviceFeature.MediaPlayerPrevious;
75919
76170
  var btn = (idSuffix, row, col, init) => ({
75920
76171
  idSuffix,
@@ -76042,6 +76293,34 @@ discriminatedUnion("kind", [object({
76042
76293
  kind: literal("pronto"),
76043
76294
  code: string()
76044
76295
  })]);
76296
+ /**
76297
+ * Propose a running threshold from a device's own power history (planning#405).
76298
+ *
76299
+ * Pure and deterministic: the same series gives the same answer. The series is
76300
+ * a HELD-VALUE step series — a point's value stands until the next point — which
76301
+ * is how device-history stores a gauge, so "time at a level" is exact, not a
76302
+ * count of samples.
76303
+ *
76304
+ * 1. idle floor F = time-weighted median; noise ceiling N = highest value seen
76305
+ * near F. A device that is not near one level most of the time has no floor.
76306
+ * 2. coarse activity = above max(2N, N + 5 W); consecutive stretches are episodes.
76307
+ * 3. gaps between episodes split in two by the largest log-scale jump (>= 3x):
76308
+ * the short ones are pauses INSIDE a run (a soak), the long ones separate runs.
76309
+ * 4. T = geometric mean of N and the plateau's 10th percentile, snapped to a
76310
+ * grid a person would type; stop dwell covers the longest pause; start dwell
76311
+ * covers the longest standby blip above T.
76312
+ * 5. the numbers are proved by REPLAY through the real `dwell` evaluation: each
76313
+ * run must hold exactly one true interval and nothing may flap outside.
76314
+ */
76315
+ var SECOND_MS = 1e3;
76316
+ var MINUTE_MS$1 = 60 * SECOND_MS;
76317
+ 24 * (60 * MINUTE_MS$1);
76318
+ 10 * MINUTE_MS$1;
76319
+ 30 * SECOND_MS;
76320
+ 60 * SECOND_MS;
76321
+ 20 * MINUTE_MS$1;
76322
+ 10 * SECOND_MS;
76323
+ 10 * SECOND_MS;
76045
76324
  DeviceFeature.FanSpeed, DeviceFeature.FanPreset, DeviceFeature.FanDirection, DeviceFeature.FanOscillating, DeviceFeature.CoverStoppable, DeviceFeature.CoverPositionable, DeviceFeature.CoverTilt, DeviceFeature.ValvePositionable, DeviceFeature.MediaPlayerVolume, DeviceFeature.ClimateFanMode;
76046
76325
  SOURCE_CAPS.filter((cap) => cap !== "switch" && cap !== "motion");
76047
76326
  String.raw`rose\(active(\d+), changed(\d+), (\d+(?:\.\d+)?)\)`;
@@ -77583,6 +77862,13 @@ Object.freeze({
77583
77862
  access: "create",
77584
77863
  role: "admin"
77585
77864
  },
77865
+ "coreBlocks.proposeRunningThreshold": {
77866
+ capName: "core-blocks",
77867
+ capScope: "system",
77868
+ addonId: null,
77869
+ access: "view",
77870
+ role: "admin"
77871
+ },
77586
77872
  "coreBlocks.reportAutomationRun": {
77587
77873
  capName: "core-blocks",
77588
77874
  capScope: "system",
@@ -78094,6 +78380,13 @@ Object.freeze({
78094
78380
  access: "view",
78095
78381
  role: "admin"
78096
78382
  },
78383
+ "deviceExport.listInstances": {
78384
+ capName: "device-export",
78385
+ capScope: "system",
78386
+ addonId: null,
78387
+ access: "view",
78388
+ role: "admin"
78389
+ },
78097
78390
  "deviceExport.listSupportedDeviceKinds": {
78098
78391
  capName: "device-export",
78099
78392
  capScope: "system",
@@ -87066,6 +87359,11 @@ Object.freeze({
87066
87359
  form: "single",
87067
87360
  optional: false
87068
87361
  }],
87362
+ "coreBlocks.proposeRunningThreshold": [{
87363
+ name: "deviceId",
87364
+ form: "single",
87365
+ optional: false
87366
+ }],
87069
87367
  "cover.close": [{
87070
87368
  name: "deviceId",
87071
87369
  form: "single",
@@ -89729,99 +90027,6 @@ Object.freeze({
89729
90027
  "network-access": "ingress",
89730
90028
  "smtp-provider": "email"
89731
90029
  });
89732
- /**
89733
- * A saved Customize assignment (D936). The schema is the type: callers use
89734
- * `z.infer`, they do not restate the shape.
89735
- */
89736
- var OverrideSourceSchema = object({
89737
- addonId: string().min(1),
89738
- stableId: string().min(1),
89739
- cap: string().min(1),
89740
- fieldPath: string().min(1)
89741
- });
89742
- var CustomizeTransformDraftSchema = discriminatedUnion("kind", [
89743
- object({ kind: literal("identity") }),
89744
- object({ kind: literal("invert") }),
89745
- object({
89746
- kind: literal("threshold"),
89747
- comparison: _enum(["gte", "lte"]),
89748
- threshold: number(),
89749
- startDwellMs: number().nonnegative(),
89750
- stopDwellMs: number().nonnegative()
89751
- }),
89752
- object({
89753
- kind: literal("linear"),
89754
- scale: number(),
89755
- offset: number(),
89756
- clampMin: number().optional(),
89757
- clampMax: number().optional()
89758
- }),
89759
- object({
89760
- kind: literal("enum-map"),
89761
- mapping: record(string(), string().nullable())
89762
- }),
89763
- object({ kind: literal("number") })
89764
- ]);
89765
- var ScalarOverrideDraftSchema = object({
89766
- kind: literal("scalar"),
89767
- cap: string().min(1),
89768
- targetId: string().min(1),
89769
- source: OverrideSourceSchema,
89770
- transform: CustomizeTransformDraftSchema
89771
- });
89772
- var KeyedArrayOverrideDraftSchema = object({
89773
- kind: literal("keyedArray"),
89774
- cap: string().min(1),
89775
- targetId: string().min(1),
89776
- key: string().min(1),
89777
- label: string().min(1),
89778
- fieldPath: string().min(1),
89779
- source: OverrideSourceSchema,
89780
- transform: CustomizeTransformDraftSchema
89781
- });
89782
- var PulseOverrideDraftSchema = object({
89783
- kind: literal("pulse"),
89784
- cap: string().min(1),
89785
- targetId: string().min(1),
89786
- enabled: boolean(),
89787
- debounceMs: number().nonnegative(),
89788
- edges: array(_enum([
89789
- "rising",
89790
- "button",
89791
- "native-event"
89792
- ])).min(1).optional(),
89793
- sources: array(OverrideSourceSchema).min(1)
89794
- });
89795
- var SpanSourceDraftSchema = OverrideSourceSchema.extend({ mode: _enum([
89796
- "in-addition",
89797
- "confirm",
89798
- "replace"
89799
- ]).optional() });
89800
- discriminatedUnion("kind", [
89801
- ScalarOverrideDraftSchema,
89802
- KeyedArrayOverrideDraftSchema,
89803
- PulseOverrideDraftSchema,
89804
- object({
89805
- kind: literal("span"),
89806
- cap: string().min(1),
89807
- targetId: string().min(1),
89808
- timeoutMs: number().nonnegative(),
89809
- cooldownMs: number().nonnegative().optional(),
89810
- sources: array(SpanSourceDraftSchema)
89811
- })
89812
- ]);
89813
- object({
89814
- targetId: string().min(1),
89815
- configured: boolean(),
89816
- source: _enum(["native", "assigned"]),
89817
- state: _enum([
89818
- "active",
89819
- "stale",
89820
- "released",
89821
- "unavailable"
89822
- ]),
89823
- reason: string().nullable()
89824
- });
89825
90030
  var G711_SCALE_CORRECTION_DB = {
89826
90031
  PCMU: 20 * Math.log10(4),
89827
90032
  PCMA: 20 * Math.log10(8)
@@ -103497,6 +103702,8 @@ function hasUnresolvedCredential(entry) {
103497
103702
  if (typeof entry !== "object" || entry === null) return false;
103498
103703
  return "accessToken" in entry && isSecretMarker(entry.accessToken) || "refreshToken" in entry && isSecretMarker(entry.refreshToken) || "brokerCredential" in entry && isSecretMarker(entry.brokerCredential);
103499
103704
  }
103705
+ /** The one export instance this addon serves. */
103706
+ var EXPORT_ALEXA_ADDON_ID = "export-alexa";
103500
103707
  var ExportAlexaAddon = class extends BaseAddon {
103501
103708
  /** Hidden state that is a credential — kept in the keychain, never the blob (D787). */
103502
103709
  secretStatePaths = [
@@ -103663,30 +103870,55 @@ var ExportAlexaAddon = class extends BaseAddon {
103663
103870
  actionScenes.reconcile().catch((err) => {
103664
103871
  this.ctx.logger.warn("export-alexa: action scene reconcile at boot failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
103665
103872
  });
103873
+ const ownInstance = (instanceId) => assertOwnExportInstance("export-alexa", EXPORT_ALEXA_ADDON_ID, instanceId);
103666
103874
  const deviceExportProvider = {
103667
- getStatus: async () => ({
103668
- linkState: this.view.linkedAccounts.length > 0 ? "linked" : "unlinked",
103669
- exposedDeviceCount: this.config.exposed.length,
103670
- setup: await this.buildSetupBlock()
103671
- }),
103672
- listSupportedDeviceKinds: async () => [...SUPPORTED_KINDS],
103673
- listExposedDevices: async () => this.config.exposed.map((e) => ({ deviceId: String(e.deviceId) })),
103674
- exposeDevice: async ({ deviceId }) => this.exposeDevice(deviceId),
103675
- unexposeDevice: async ({ deviceId }) => this.unexposeDevice(deviceId),
103875
+ getStatus: async (input) => {
103876
+ ownInstance(statusInstanceOf(input));
103877
+ return {
103878
+ linkState: this.view.linkedAccounts.length > 0 ? "linked" : "unlinked",
103879
+ exposedDeviceCount: this.config.exposed.length,
103880
+ setup: await this.buildSetupBlock()
103881
+ };
103882
+ },
103883
+ listInstances: async () => [{
103884
+ instanceId: EXPORT_ALEXA_ADDON_ID,
103885
+ name: "Alexa",
103886
+ enabled: true,
103887
+ kind: "alexa-skill"
103888
+ }],
103889
+ listSupportedDeviceKinds: async ({ instanceId }) => {
103890
+ ownInstance(instanceId);
103891
+ return [...SUPPORTED_KINDS];
103892
+ },
103893
+ listExposedDevices: async ({ instanceId }) => {
103894
+ ownInstance(instanceId);
103895
+ return this.config.exposed.map((e) => ({ deviceId: String(e.deviceId) }));
103896
+ },
103897
+ exposeDevice: async ({ instanceId, deviceId }) => {
103898
+ ownInstance(instanceId);
103899
+ return this.exposeDevice(deviceId);
103900
+ },
103901
+ unexposeDevice: async ({ instanceId, deviceId }) => {
103902
+ ownInstance(instanceId);
103903
+ return this.unexposeDevice(deviceId);
103904
+ },
103676
103905
  listSupportedEntityKinds: async () => ["device", "action"],
103677
- listExposedEntities: async () => {
103906
+ listExposedEntities: async ({ instanceId }) => {
103907
+ ownInstance(instanceId);
103678
103908
  await actionScenes.reconcile();
103679
103909
  return [...this.config.exposed.map((e) => ({ entity: {
103680
103910
  kind: "device",
103681
103911
  deviceId: String(e.deviceId)
103682
103912
  } })), ...actionScenes.list()];
103683
103913
  },
103684
- exposeEntity: async ({ entity }) => {
103914
+ exposeEntity: async ({ instanceId, entity }) => {
103915
+ ownInstance(instanceId);
103685
103916
  if (entity.kind === "device") return this.exposeDevice(entity.deviceId);
103686
103917
  if (entity.kind === "action") return actionScenes.expose(entity.actionId);
103687
103918
  throw new Error("export-alexa: a notification target cannot be exported to Alexa");
103688
103919
  },
103689
- unexposeEntity: async ({ entity }) => {
103920
+ unexposeEntity: async ({ instanceId, entity }) => {
103921
+ ownInstance(instanceId);
103690
103922
  if (entity.kind === "device") return this.unexposeDevice(entity.deviceId);
103691
103923
  if (entity.kind === "action") return actionScenes.unexpose(entity.actionId);
103692
103924
  throw new Error("export-alexa: a notification target cannot be exported to Alexa");