@camstack/types 1.2.562 → 1.2.564

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.
Files changed (43) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/addon.js +3 -2
  3. package/dist/addon.mjs +3 -2
  4. package/dist/capabilities/cluster-update.cap.d.ts +16 -0
  5. package/dist/capabilities/device-manager.cap.d.ts +18 -17
  6. package/dist/capabilities/device-provider.cap.d.ts +7 -7
  7. package/dist/capabilities/device-search.d.ts +8 -6
  8. package/dist/capabilities/energy-system.cap.d.ts +10 -0
  9. package/dist/capabilities/media-player.cap.d.ts +3 -0
  10. package/dist/capabilities/notification-rules.cap.d.ts +4 -0
  11. package/dist/capabilities/remote.cap.d.ts +1 -0
  12. package/dist/capabilities/smtp-provider.cap.d.ts +2 -0
  13. package/dist/capabilities/switch.cap.d.ts +5 -0
  14. package/dist/client.js +48 -1
  15. package/dist/client.mjs +48 -1
  16. package/dist/{convert-BmtM6K-5.js → convert-BI8iTXn6.js} +15 -0
  17. package/dist/{convert-BAzH15HU.mjs → convert-BwMfbk5b.mjs} +15 -0
  18. package/dist/device/cap-vocabulary/index.d.ts +1 -1
  19. package/dist/device/cap-vocabulary/resolve.d.ts +6 -0
  20. package/dist/device/hero/build-hero-model.d.ts +3 -0
  21. package/dist/device/hero/hero-fragment.d.ts +3 -0
  22. package/dist/device/hero/hero-row.d.ts +1 -1
  23. package/dist/device/hero/media-player-view.d.ts +2 -1
  24. package/dist/device/source-info.d.ts +1 -1
  25. package/dist/generated/addon-api.d.ts +7 -0
  26. package/dist/generated/addon-cap-facts.d.ts +1 -1
  27. package/dist/generated/collection-array-methods.d.ts +1 -1
  28. package/dist/generated/history-catalog.d.ts +1 -1
  29. package/dist/generated/method-access-map.d.ts +1 -1
  30. package/dist/generated/method-device-selectors.d.ts +2 -2
  31. package/dist/index.d.ts +3 -1
  32. package/dist/index.js +434 -53
  33. package/dist/index.mjs +427 -54
  34. package/dist/notification/degrade-engine.d.ts +5 -0
  35. package/dist/notification/email-image-bytes.d.ts +26 -0
  36. package/dist/notification/email-mime.d.ts +52 -0
  37. package/dist/{sleep-Cb2px0Nb.js → sleep-B1IED7ED.js} +61 -32
  38. package/dist/{sleep-Cykc2bzi.mjs → sleep-D7hCDd7y.mjs} +61 -32
  39. package/dist/units/quantity.d.ts +1 -1
  40. package/dist/units/unit-table.d.ts +1 -1
  41. package/dist/units-lean.js +1 -1
  42. package/dist/units-lean.mjs +1 -1
  43. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_sleep = require("./sleep-Cb2px0Nb.js");
2
+ const require_sleep = require("./sleep-B1IED7ED.js");
3
3
  const require_event_category = require("./event-category-Ps2LC8dN.js");
4
4
  const require_composed_stable_id = require("./composed-stable-id-Bp33yrYi.js");
5
5
  const require_implemented_methods = require("./implemented-methods-CDYOCn9a.js");
6
6
  const require_node_color = require("./node-color.js");
7
- const require_convert = require("./convert-BmtM6K-5.js");
7
+ const require_convert = require("./convert-BI8iTXn6.js");
8
8
  const require_enums = require("./enums.js");
9
9
  let zod = require("zod");
10
10
  let node_crypto = require("node:crypto");
@@ -46322,7 +46322,9 @@ var ClusterUpdateFailureReasonSchema = zod.z.enum([
46322
46322
  "status-unreadable",
46323
46323
  "addon-update-failed",
46324
46324
  "addons-not-converged",
46325
- "interrupted"
46325
+ "interrupted",
46326
+ "timeout-stall",
46327
+ "timeout-ceiling"
46326
46328
  ]);
46327
46329
  var ClusterUpdateStepSchema = zod.z.object({
46328
46330
  kind: ClusterUpdateStepKindSchema,
@@ -48187,6 +48189,12 @@ var MediaPlayerStatusSchema = zod.z.object({
48187
48189
  /** Mute toggle distinct from volume=0. Null when no mute surface.
48188
48190
  * Pair with `DeviceFeature.MediaPlayerMute`. */
48189
48191
  isMuted: zod.z.boolean().nullable(),
48192
+ /**
48193
+ * True only when the provider READS the mute state back from the device.
48194
+ * Absent or false: mute is a momentary key. A non-null `isMuted` is not a
48195
+ * reading on its own — an infrared send can leave a value without this flag.
48196
+ */
48197
+ muteReadback: zod.z.boolean().optional(),
48190
48198
  /** Active source / input. Empty when no source surface. */
48191
48199
  source: zod.z.string(),
48192
48200
  /** Selectable sources. Empty when no source surface.
@@ -50030,9 +50038,17 @@ function forwardSourceRefs(composition) {
50030
50038
  const refs = composition.features.flatMap((feature, index) => feature.kind === "fields" && require_implemented_methods.compositionFeatureEnabled(feature) ? featureForwards(feature, index).map((forward) => forward.command.source) : []);
50031
50039
  return [...new Map(refs.map((ref) => [require_implemented_methods.compositionSourceKey(ref), ref])).values()];
50032
50040
  }
50041
+ /**
50042
+ * `switch.toggle` is not a forward. Native-cap registration installs one
50043
+ * default that reads the slice and calls this provider's `setState`, and a
50044
+ * composed switch already forwards `setState`.
50045
+ */
50046
+ function servedByRegistrationDefault(def, method) {
50047
+ return def.name === "switch" && method === "toggle";
50048
+ }
50033
50049
  /** The methods a BUILT cap must give a command: served, and not answered by the composer itself. */
50034
50050
  function commandedMethods(def) {
50035
- return Object.entries(def.methods).filter(([name, m]) => m.systemOnly !== true && def.composedMethods?.[name] === void 0).map(([name]) => name);
50051
+ return Object.entries(def.methods).filter(([name, m]) => m.systemOnly !== true && def.composedMethods?.[name] === void 0 && !servedByRegistrationDefault(def, name)).map(([name]) => name);
50036
50052
  }
50037
50053
  /**
50038
50054
  * The `commands` of a `media-player` feature served by the `remote` extension:
@@ -50558,7 +50574,7 @@ function groupTemplate(id) {
50558
50574
  //#region src/generated/history-catalog.ts
50559
50575
  /**
50560
50576
  * Cap history catalog, projected from every `*.cap.ts` `history` block.
50561
- * 45 caps with series (103 series), 37 caps answered `'none'`.
50577
+ * 45 caps with series (104 series), 37 caps answered `'none'`.
50562
50578
  * Field keys are `runtimeState` paths (`a.b` into fixed objects only).
50563
50579
  */
50564
50580
  var HISTORY_CATALOG = {
@@ -50779,6 +50795,12 @@ var HISTORY_CATALOG = {
50779
50795
  kind: "counter",
50780
50796
  unit: "kWh",
50781
50797
  displayName: "Storage discharged"
50798
+ },
50799
+ "storage.healthPct": {
50800
+ kind: "gauge",
50801
+ unit: "%",
50802
+ deadband: 1,
50803
+ displayName: "Storage health"
50782
50804
  }
50783
50805
  },
50784
50806
  "enum-sensor": { "value": {
@@ -55428,9 +55450,15 @@ function siteZoneKey(label) {
55428
55450
  var DEVICE_SEARCH_DEFAULT_LIMIT = 50;
55429
55451
  var DEVICE_SEARCH_MAX_LIMIT = 200;
55430
55452
  var DeviceSearchRequiresSchema = zod.z.object({
55431
- /** Capability names the field wants a value of. */
55432
- caps: zod.z.array(zod.z.string()).readonly(),
55433
- /** `any` (default): a device with one of them is compatible. `all`: it must hold every one. */
55453
+ /** Capability names the field wants a value of. Absent when the field wants actions only. */
55454
+ caps: zod.z.array(zod.z.string()).readonly().optional(),
55455
+ /**
55456
+ * Vocabulary action ids (`cover.open`) the device must offer. Compatible means
55457
+ * the device's bindings resolve those actions; `values` stays empty when no
55458
+ * cap was required. `mode` applies the same way as for `caps`.
55459
+ */
55460
+ actions: zod.z.array(zod.z.string()).readonly().optional(),
55461
+ /** `any` (default): one of the named caps, and one of the named actions, is enough. `all`: every one. */
55434
55462
  mode: zod.z.enum(["any", "all"]).optional()
55435
55463
  });
55436
55464
  var DeviceSearchFiltersSchema = zod.z.object({
@@ -60288,7 +60316,9 @@ var EnergyStorageSchema = zod.z.object({
60288
60316
  /** Lifetime discharged, kWh. */
60289
60317
  dischargedKwh: zod.z.number().nullable().meta(require_sleep.readingMeta("energy")),
60290
60318
  chargedTodayKwh: zod.z.number().nullable().meta(require_sleep.readingMeta("energy")),
60291
- dischargedTodayKwh: zod.z.number().nullable().meta(require_sleep.readingMeta("energy"))
60319
+ dischargedTodayKwh: zod.z.number().nullable().meta(require_sleep.readingMeta("energy")),
60320
+ /** State of health, 0..100. Null when the system did not report it. */
60321
+ healthPct: zod.z.number().nullable().meta(require_sleep.readingMeta("percentage"))
60292
60322
  });
60293
60323
  var EnergySystemStatusSchema = zod.z.object({
60294
60324
  solar: EnergySolarSchema.nullable(),
@@ -60411,6 +60441,12 @@ var energySystemCapability = {
60411
60441
  kind: "counter",
60412
60442
  unit: "kWh",
60413
60443
  displayName: "Storage discharged"
60444
+ },
60445
+ "storage.healthPct": {
60446
+ kind: "gauge",
60447
+ unit: "%",
60448
+ deadband: 1,
60449
+ displayName: "Storage health"
60414
60450
  }
60415
60451
  } },
60416
60452
  volatileStateFields: ["lastFetchedAt"],
@@ -63910,7 +63946,7 @@ var HeroModelSchema = zod.z.object({
63910
63946
  *
63911
63947
  * - `extras` are the further inline controls of the types that carry more than one
63912
63948
  * ({@link ROW_EXTRAS_BY_TYPE}): climate setpoint, a robot's return to base,
63913
- * a player's volume and remote. Each is a control the model already has, named by id,
63949
+ * a player's volume and remote, an automation's enabled switch. Each is a control the model already has, named by id,
63914
63950
  * in that order and at most {@link ROW_EXTRAS_MAX}; one the model lacks, or lists in
63915
63951
  * `gated`, is absent, and the one `primary` already is never repeats. Empty = the
63916
63952
  * row of an older server: `primary` alone.
@@ -64026,7 +64062,8 @@ var ROW_EXTRAS_BY_TYPE = {
64026
64062
  [require_composed_stable_id.DeviceType.Climate]: ["climate.target"],
64027
64063
  [require_composed_stable_id.DeviceType.Vacuum]: ["vacuum.base"],
64028
64064
  [require_composed_stable_id.DeviceType.LawnMower]: ["mower.dock"],
64029
- [require_composed_stable_id.DeviceType.MediaPlayer]: ["volume.level", REMOTE_OPEN_ACTION_ID]
64065
+ [require_composed_stable_id.DeviceType.MediaPlayer]: ["volume.level", REMOTE_OPEN_ACTION_ID],
64066
+ [require_composed_stable_id.DeviceType.Automation]: ["automation.enabled"]
64030
64067
  };
64031
64068
  var controlId = (c) => c.kind === "action" ? c.action.id : c.id;
64032
64069
  function extraOf(model, id) {
@@ -81831,6 +81868,13 @@ var NcHistoryEntrySchema = zod.z.object({
81831
81868
  error: zod.z.string().optional(),
81832
81869
  subject: NcHistorySubjectSchema,
81833
81870
  /**
81871
+ * The title and body actually sent, frozen at delivery. Absent on a row
81872
+ * still pending, a row suppressed before a notification was built, and a
81873
+ * row delivered before this field shipped.
81874
+ */
81875
+ title: zod.z.string().optional(),
81876
+ body: zod.z.string().optional(),
81877
+ /**
81834
81878
  * Ids of the artefacts (still, then gif, then clip) this row's successful
81835
81879
  * delivery indexed in the artefact library — a REFERENCE, never the bytes
81836
81880
  * (an artefact is often megabytes; this row is durable JSON rewritten on
@@ -93587,7 +93631,8 @@ var ServerUpdateActionResultSchema = zod.z.object({
93587
93631
  outcome: ServerUpdateOutcomeSchema.optional(),
93588
93632
  /**
93589
93633
  * Stable, greppable cause for `refused` / `failed` (the engine's
93590
- * `UpdateRefusalReason`, `staging-failed`, …). `null` on success.
93634
+ * `UpdateRefusalReason`, `staging-failed`, `timeout-stall`,
93635
+ * `timeout-ceiling`). `null` on success.
93591
93636
  */
93592
93637
  reason: zod.z.string().nullable().optional(),
93593
93638
  /**
@@ -93756,6 +93801,157 @@ var smokeCapability = {
93756
93801
  }
93757
93802
  };
93758
93803
  //#endregion
93804
+ //#region src/notification/email-mime.ts
93805
+ /**
93806
+ * One RFC 5322 body for every mail sender.
93807
+ *
93808
+ * Gmail and the SMTP relay both call this. An HTML message with an inline image is
93809
+ * `multipart/related` (the HTML sits in `multipart/alternative` and references
93810
+ * `cid:`). A text message carries the same bytes as a normal attachment
93811
+ * (`multipart/mixed`). The image bytes are already in hand — a sender reads them
93812
+ * off a `peerBytes` ticket before calling in ({@link assembleEmailMime}).
93813
+ */
93814
+ /** How many images one email will carry. */
93815
+ var EMAIL_IMAGE_MAX_COUNT = 3;
93816
+ /** Total image bytes one email will carry. */
93817
+ var EMAIL_IMAGE_MAX_TOTAL_BYTES = 5 * 1024 * 1024;
93818
+ /**
93819
+ * Where an HTML body leaves room for the inline images: under the text, above
93820
+ * the click link. The builder replaces it; a message with no image loses it.
93821
+ */
93822
+ var EMAIL_IMAGE_SLOT = "<!--camstack-images-->";
93823
+ var EmailImagePartSchema = zod.z.object({
93824
+ ticket: require_sleep.PeerBytesTicketSchema,
93825
+ mime: zod.z.string().min(1),
93826
+ name: zod.z.string().min(1),
93827
+ contentId: zod.z.string().min(1),
93828
+ placement: zod.z.enum(["inline", "attachment"]),
93829
+ deviceId: zod.z.number().int().nonnegative().optional()
93830
+ });
93831
+ var mimeSeq = 0;
93832
+ function nextBoundary(kind) {
93833
+ mimeSeq += 1;
93834
+ return `camstack_${kind}_${mimeSeq.toString(36)}_${Date.now().toString(36)}`;
93835
+ }
93836
+ function encodeHeaderWord(value) {
93837
+ if (/^[\x20-\x7E]*$/.test(value)) return value;
93838
+ return `=?UTF-8?B?${Buffer.from(value, "utf8").toString("base64")}?=`;
93839
+ }
93840
+ function formatAddressList(addrs) {
93841
+ return (Array.isArray(addrs) ? addrs : [addrs]).join(", ");
93842
+ }
93843
+ function escapeHtml$1(value) {
93844
+ return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
93845
+ }
93846
+ function safeToken(value, fallback) {
93847
+ const cleaned = value.replace(/[\r\n"]/g, "").trim();
93848
+ return cleaned.length > 0 ? cleaned : fallback;
93849
+ }
93850
+ function base64Body(bytes) {
93851
+ const b64 = Buffer.from(bytes).toString("base64");
93852
+ const lines = [];
93853
+ for (let i = 0; i < b64.length; i += 76) lines.push(b64.slice(i, i + 76));
93854
+ return lines.join("\r\n");
93855
+ }
93856
+ function imgTag(image) {
93857
+ return `<img src="cid:${escapeHtml$1(image.contentId)}" alt="">`;
93858
+ }
93859
+ function fillSlot(html, inline) {
93860
+ return html.replaceAll(EMAIL_IMAGE_SLOT, inline.map(imgTag).join(""));
93861
+ }
93862
+ function headerLines(input) {
93863
+ const lines = [`From: ${input.from}`, `To: ${formatAddressList(input.to)}`];
93864
+ if (input.cc !== void 0 && input.cc.length > 0) lines.push(`Cc: ${formatAddressList(input.cc)}`);
93865
+ if (input.bcc !== void 0 && input.bcc.length > 0) lines.push(`Bcc: ${formatAddressList(input.bcc)}`);
93866
+ if (input.replyTo !== void 0 && input.replyTo.length > 0) lines.push(`Reply-To: ${input.replyTo}`);
93867
+ lines.push(`Subject: ${encodeHeaderWord(input.subject)}`);
93868
+ lines.push("MIME-Version: 1.0");
93869
+ return lines;
93870
+ }
93871
+ function textPart(boundary, text) {
93872
+ return [
93873
+ `--${boundary}`,
93874
+ "Content-Type: text/plain; charset=\"UTF-8\"",
93875
+ "Content-Transfer-Encoding: 8bit",
93876
+ "",
93877
+ text
93878
+ ];
93879
+ }
93880
+ function htmlPart(boundary, html) {
93881
+ return [
93882
+ `--${boundary}`,
93883
+ "Content-Type: text/html; charset=\"UTF-8\"",
93884
+ "Content-Transfer-Encoding: 8bit",
93885
+ "",
93886
+ html
93887
+ ];
93888
+ }
93889
+ function imagePart(boundary, image) {
93890
+ const mime = safeToken(image.mime, "image/jpeg");
93891
+ const name = safeToken(image.name, "image.jpg");
93892
+ const disposition = image.placement === "inline" ? "inline" : "attachment";
93893
+ const lines = [
93894
+ `--${boundary}`,
93895
+ `Content-Type: ${mime}`,
93896
+ "Content-Transfer-Encoding: base64",
93897
+ `Content-Disposition: ${disposition}; filename="${name}"`
93898
+ ];
93899
+ if (image.placement === "inline") lines.push(`Content-ID: <${safeToken(image.contentId, "image")}>`);
93900
+ lines.push("", base64Body(image.bytes));
93901
+ return lines;
93902
+ }
93903
+ function alternative(outer, text, html) {
93904
+ const inner = nextBoundary("alt");
93905
+ return [
93906
+ `--${outer}`,
93907
+ `Content-Type: multipart/alternative; boundary="${inner}"`,
93908
+ "",
93909
+ ...textPart(inner, text),
93910
+ ...htmlPart(inner, html),
93911
+ `--${inner}--`
93912
+ ];
93913
+ }
93914
+ function simpleMessage(input, html) {
93915
+ const lines = headerLines(input);
93916
+ if (html !== void 0) {
93917
+ const boundary = nextBoundary("alt");
93918
+ lines.push(`Content-Type: multipart/alternative; boundary="${boundary}"`, "");
93919
+ lines.push(...textPart(boundary, input.text), ...htmlPart(boundary, html), `--${boundary}--`);
93920
+ return lines;
93921
+ }
93922
+ lines.push("Content-Type: text/plain; charset=\"UTF-8\"", "Content-Transfer-Encoding: 8bit", "", input.text);
93923
+ return lines;
93924
+ }
93925
+ function mixedMessage(input, html, files) {
93926
+ const boundary = nextBoundary("mix");
93927
+ const lines = headerLines(input);
93928
+ lines.push(`Content-Type: multipart/mixed; boundary="${boundary}"`, "");
93929
+ if (html !== void 0) lines.push(...alternative(boundary, input.text, html));
93930
+ else lines.push(...textPart(boundary, input.text));
93931
+ for (const image of files) lines.push(...imagePart(boundary, image));
93932
+ lines.push(`--${boundary}--`);
93933
+ return lines;
93934
+ }
93935
+ function relatedMessage(input, html, inline, attached) {
93936
+ const boundary = nextBoundary("rel");
93937
+ const lines = headerLines(input);
93938
+ lines.push(`Content-Type: multipart/related; boundary="${boundary}"; type="multipart/alternative"`, "", ...alternative(boundary, input.text, html));
93939
+ for (const image of inline) lines.push(...imagePart(boundary, image));
93940
+ for (const image of attached) lines.push(...imagePart(boundary, image));
93941
+ lines.push(`--${boundary}--`);
93942
+ return lines;
93943
+ }
93944
+ /** Render one mail. No I/O: the caller has already decided which images survived. */
93945
+ function buildRawMime(input) {
93946
+ const images = input.images ?? [];
93947
+ const inline = images.filter((image) => image.placement === "inline");
93948
+ const attached = images.filter((image) => image.placement === "attachment");
93949
+ const html = input.html !== void 0 && input.html.length > 0 ? fillSlot(input.html, inline) : void 0;
93950
+ if (html !== void 0 && inline.length > 0) return relatedMessage(input, html, inline, attached).join("\r\n");
93951
+ if (attached.length > 0 || inline.length > 0) return mixedMessage(input, html, attached.length > 0 ? attached : inline).join("\r\n");
93952
+ return simpleMessage(input, html).join("\r\n");
93953
+ }
93954
+ //#endregion
93759
93955
  //#region src/capabilities/smtp-provider.cap.ts
93760
93956
  /**
93761
93957
  * `smtp-provider` — pluggable email delivery surface.
@@ -93766,8 +93962,8 @@ var smokeCapability = {
93766
93962
  * ready provider OR target a specific addonId.
93767
93963
  *
93768
93964
  * The shape stays small on purpose — `sendEmail` is enough for the
93769
- * 90% case. Attachments / HTML templating / multi-part are room for
93770
- * future fields without breaking the existing call sites.
93965
+ * 90% case. An image is not a byte field on this method (D613): `images`
93966
+ * names `peerBytes` tickets the sender opens and folds into one MIME body.
93771
93967
  */
93772
93968
  var EmailAddressSchema = zod.z.email();
93773
93969
  /**
@@ -93794,7 +93990,12 @@ var SendEmailInputSchema = zod.z.object({
93794
93990
  * for clients that strip HTML — including most spam filters). */
93795
93991
  text: zod.z.string(),
93796
93992
  /** Optional HTML body. Renders alongside `text` as multi-part. */
93797
- html: zod.z.string().optional()
93993
+ html: zod.z.string().optional(),
93994
+ /**
93995
+ * Images the caller already offered over `peerBytes`. Absent = a mail with
93996
+ * no image. The sender opens each ticket; one it cannot read is left out.
93997
+ */
93998
+ images: zod.z.array(EmailImagePartSchema).max(3).optional()
93798
93999
  });
93799
94000
  var SendEmailResultSchema = zod.z.object({
93800
94001
  messageId: zod.z.string(),
@@ -95255,34 +95456,46 @@ var switchCapability = {
95255
95456
  require_composed_stable_id.DeviceType.Light,
95256
95457
  require_composed_stable_id.DeviceType.Fan
95257
95458
  ],
95258
- methods: { setState: require_sleep.method(zod.z.object({
95259
- deviceId: zod.z.number(),
95260
- on: zod.z.boolean()
95261
- }), zod.z.void(), {
95262
- kind: "mutation",
95263
- auth: "protected",
95264
- actions: [{
95265
- id: "switch.on",
95266
- label: require_sleep.t("Turn on", "Accendi"),
95267
- phrase: require_sleep.t("Turn on {device}", "Accendi {device}"),
95268
- icon: "power",
95269
- effect: {
95270
- field: "on",
95271
- value: true
95272
- },
95273
- args: { on: true }
95274
- }, {
95275
- id: "switch.off",
95276
- label: require_sleep.t("Turn off", "Spegni"),
95277
- phrase: require_sleep.t("Turn off {device}", "Spegni {device}"),
95278
- icon: "power-off",
95279
- effect: {
95280
- field: "on",
95281
- value: false
95282
- },
95283
- args: { on: false }
95284
- }]
95285
- }) },
95459
+ methods: {
95460
+ setState: require_sleep.method(zod.z.object({
95461
+ deviceId: zod.z.number(),
95462
+ on: zod.z.boolean()
95463
+ }), zod.z.void(), {
95464
+ kind: "mutation",
95465
+ auth: "protected",
95466
+ actions: [{
95467
+ id: "switch.on",
95468
+ label: require_sleep.t("Turn on", "Accendi"),
95469
+ phrase: require_sleep.t("Turn on {device}", "Accendi {device}"),
95470
+ icon: "power",
95471
+ effect: {
95472
+ field: "on",
95473
+ value: true
95474
+ },
95475
+ args: { on: true }
95476
+ }, {
95477
+ id: "switch.off",
95478
+ label: require_sleep.t("Turn off", "Spegni"),
95479
+ phrase: require_sleep.t("Turn off {device}", "Spegni {device}"),
95480
+ icon: "power-off",
95481
+ effect: {
95482
+ field: "on",
95483
+ value: false
95484
+ },
95485
+ args: { on: false }
95486
+ }]
95487
+ }),
95488
+ toggle: require_sleep.optionalMethod(zod.z.object({ deviceId: zod.z.number() }), zod.z.void(), {
95489
+ kind: "mutation",
95490
+ auth: "protected",
95491
+ actions: [{
95492
+ id: "switch.toggle",
95493
+ label: require_sleep.t("Toggle", "Commuta"),
95494
+ phrase: require_sleep.t("Toggle {device}", "Commuta {device}"),
95495
+ icon: "toggle-right"
95496
+ }]
95497
+ })
95498
+ },
95286
95499
  events: { onStateChanged: {
95287
95500
  data: zod.z.object({
95288
95501
  deviceId: zod.z.number(),
@@ -113216,7 +113429,11 @@ var temperatureContribution = contribution("temperature-sensor", TemperatureSens
113216
113429
  var humidityContribution = contribution("humidity-sensor", HumiditySensorStatusSchema, (slice) => measured(sensorFragment(slice?.humidity ?? null, "humidity", "droplets", "Humidity", "Umidità", `${Math.round(slice?.humidity ?? 0)}%`), slice?.humidity == null ? emptyMeasurement("humidity") : humidityMeasurement(slice.humidity, slice.lastFetchedAt)));
113217
113430
  var pressureContribution = contribution("pressure-sensor", PressureSensorStatusSchema, (slice) => sensorFragment(slice?.pressure ?? null, "pressure", "gauge", "Pressure", "Pressione", `${Math.round(slice?.pressure ?? 0)} hPa`));
113218
113431
  var illuminanceContribution = contribution("ambient-light-sensor", AmbientLightSensorStatusSchema, (slice) => sensorFragment(slice?.illuminance ?? null, "illuminance", "sun", "Light", "Luce", `${Math.round(slice?.illuminance ?? 0)} lx`));
113219
- var numericContribution = contribution("numeric-sensor", NumericSensorStatusSchema, (slice) => sensorFragment(slice?.value ?? null, "reading", "gauge", "Value", "Valore", String(Number((slice?.value ?? 0).toFixed(2)))));
113432
+ var numericContribution = contribution("numeric-sensor", NumericSensorStatusSchema, (slice, ctx) => {
113433
+ const unit = ctx.quantity == null ? void 0 : require_sleep.baseUnitOf(ctx.quantity);
113434
+ const text = String(Number((slice?.value ?? 0).toFixed(2)));
113435
+ return sensorFragment(slice?.value ?? null, "reading", "gauge", "Value", "Valore", unit === void 0 ? text : `${text} ${unit}`);
113436
+ });
113220
113437
  var enumContribution = contribution("enum-sensor", EnumSensorStatusSchema, (slice) => {
113221
113438
  if (slice === void 0 || slice.value === "") return measured({ reading: reading("sensor", "unknown") }, emptyMeasurement("text"));
113222
113439
  if (slice.timestamp === true) return { reading: reading("sensor", "on") };
@@ -113717,7 +113934,7 @@ function deriveFromStatus(status, features) {
113717
113934
  volume,
113718
113935
  mute: has(require_composed_stable_id.DeviceFeature.MediaPlayerMute) || volume === "slider" && status.isMuted !== null,
113719
113936
  volumeKnown: status.volumeLevel !== null,
113720
- muteKnown: status.isMuted !== null,
113937
+ muteKnown: status.muteReadback === true,
113721
113938
  artworkUrl: artworkOf(status),
113722
113939
  source: hasSource ? {
113723
113940
  current: sourceName,
@@ -114131,11 +114348,15 @@ function volumeControls(view, volumeLevel, muted) {
114131
114348
  valueArg: "volumeLevel"
114132
114349
  });
114133
114350
  if (view.volume === "steps") controls.push(asAction(action("volume.down", require_sleep.t("Volume down", "Volume giù"), "volume-1", "media-player", "volumeDown")), asAction(action("volume.up", require_sleep.t("Volume up", "Volume su"), "volume-2", "media-player", "volumeUp")));
114134
- if (view.mute) controls.push({
114351
+ if (view.mute && !view.muteKnown) controls.push({
114352
+ kind: "action",
114353
+ action: action("volume.mute", require_sleep.t("Mute", "Muto"), "volume-x", "media-player", "setMute", { muted: true })
114354
+ });
114355
+ else if (view.mute) controls.push({
114135
114356
  kind: "toggle",
114136
114357
  id: "volume.mute",
114137
114358
  label: require_sleep.t("Mute", "Muto"),
114138
- on: view.muteKnown ? muted : null,
114359
+ on: muted,
114139
114360
  turnOn: action("volume.mute", require_sleep.t("Mute", "Muto"), "volume-x", "media-player", "setMute", { muted: true }),
114140
114361
  turnOff: action("volume.unmute", require_sleep.t("Unmute", "Riattiva"), "volume-2", "media-player", "setMute", { muted: false })
114141
114362
  });
@@ -115391,14 +115612,17 @@ function historyLabelOf(type) {
115391
115612
  }
115392
115613
  /**
115393
115614
  * A sensor that measures exactly ONE thing is drawn as that reading. Two measuring
115394
- * caps (a temperature and a humidity on one device) keep today's card, and so does
115395
- * an offline device: its reading is no longer current.
115615
+ * caps (a temperature and a humidity on one device) keep today's card. An offline
115616
+ * device keeps the measurement but with NO value: its last reading is no longer
115617
+ * current, so the card draws its normal self with an empty "—" (D393), never a
115618
+ * stale number and never a 0.
115396
115619
  */
115397
115620
  function measurementOf(input, fragments) {
115398
- if (input.device.type !== require_composed_stable_id.DeviceType.Sensor || !input.device.online) return void 0;
115621
+ if (input.device.type !== require_composed_stable_id.DeviceType.Sensor) return void 0;
115399
115622
  const measured = fragments.flatMap((f) => f.measurement === void 0 ? [] : [f.measurement]);
115400
115623
  const only = measured.length === 1 ? measured[0] : void 0;
115401
- return only !== void 0 && measurementFitsRole(only, input.device.role) ? only : void 0;
115624
+ if (only === void 0 || !measurementFitsRole(only, input.device.role)) return void 0;
115625
+ return input.device.online ? only : emptyMeasurement(only.quantity);
115402
115626
  }
115403
115627
  function sceneOf(role, type, fragments) {
115404
115628
  const parts = fragments.flatMap((f) => f.scene === void 0 ? [] : [f.scene]);
@@ -115418,7 +115642,8 @@ function buildHeroModel(input) {
115418
115642
  now: input.now,
115419
115643
  running: runningOf(input),
115420
115644
  remoteCommands: input.remoteCommands,
115421
- caps: input.caps
115645
+ caps: input.caps,
115646
+ quantity: device.quantity ?? null
115422
115647
  };
115423
115648
  const contributed = HERO_CAP_CONTRIBUTIONS.filter((c) => input.caps.includes(c.cap)).map((c) => ({
115424
115649
  cap: c.cap,
@@ -124940,6 +125165,13 @@ var METHOD_ACCESS_MAP = Object.freeze({
124940
125165
  access: "create",
124941
125166
  role: "viewer"
124942
125167
  },
125168
+ "switch.toggle": {
125169
+ capName: "switch",
125170
+ capScope: "device",
125171
+ addonId: null,
125172
+ access: "create",
125173
+ role: "viewer"
125174
+ },
124943
125175
  "system.debugWatch": {
124944
125176
  capName: "system",
124945
125177
  capScope: "system",
@@ -126591,6 +126823,16 @@ function actionsForDevice(bindings, deviceType, role) {
126591
126823
  }
126592
126824
  return out;
126593
126825
  }
126826
+ /**
126827
+ * Whether a device offers the vocabulary actions, with the same `any` / `all`
126828
+ * rule a cap require uses. An empty list passes. This is the one check the
126829
+ * device search and the command picker share.
126830
+ */
126831
+ function deviceOffersActions(bindings, actionIds, mode = "any", deviceType) {
126832
+ if (actionIds.length === 0) return true;
126833
+ const offered = new Set(actionsForDevice(bindings, deviceType).map((action) => action.id));
126834
+ return mode === "all" ? actionIds.every((id) => offered.has(id)) : actionIds.some((id) => offered.has(id));
126835
+ }
126594
126836
  function resolveEnumValue(v) {
126595
126837
  const phrase = v.phrase ?? fill(BECOMES, {
126596
126838
  en: { value: v.label.en },
@@ -131130,6 +131372,12 @@ var METHOD_DEVICE_SELECTORS = Object.freeze({
131130
131372
  form: "single",
131131
131373
  optional: false
131132
131374
  }],
131375
+ "smtpProvider.sendEmail": [{
131376
+ name: "images",
131377
+ form: "object-array",
131378
+ optional: true,
131379
+ itemField: "deviceId"
131380
+ }],
131133
131381
  "snapshot.applyDeviceSettingsPatch": [{
131134
131382
  name: "deviceId",
131135
131383
  form: "single",
@@ -131296,6 +131544,11 @@ var METHOD_DEVICE_SELECTORS = Object.freeze({
131296
131544
  form: "single",
131297
131545
  optional: false
131298
131546
  }],
131547
+ "switch.toggle": [{
131548
+ name: "deviceId",
131549
+ form: "single",
131550
+ optional: false
131551
+ }],
131299
131552
  "system.debugWatch": [{
131300
131553
  name: "deviceIds",
131301
131554
  form: "array",
@@ -131757,6 +132010,7 @@ var SYSTEM_SCOPE_DEVICE_METHODS = [
131757
132010
  "remote.sendCommand",
131758
132011
  "remote.sendMediaCommand",
131759
132012
  "remote.setConfig",
132013
+ "smtpProvider.sendEmail",
131760
132014
  "storageAdmin.readRecords",
131761
132015
  "streamBroker.acquireEgressTranscode",
131762
132016
  "streamBroker.applyDeviceSettingsPatch",
@@ -134376,12 +134630,92 @@ function prepareNotification(caps, n) {
134376
134630
  sound,
134377
134631
  ttl,
134378
134632
  tag,
134633
+ ...n.deviceId !== void 0 ? { deviceId: n.deviceId } : {},
134379
134634
  ...n.delivery !== void 0 ? { delivery: n.delivery } : {},
134380
134635
  bodyParts,
134381
134636
  renderedAs
134382
134637
  };
134383
134638
  }
134384
134639
  //#endregion
134640
+ //#region src/notification/email-image-bytes.ts
134641
+ function asBytes(chunk) {
134642
+ if (chunk instanceof Uint8Array) return chunk;
134643
+ if (typeof chunk === "string") return Buffer.from(chunk);
134644
+ throw new Error("email image: unexpected stream chunk");
134645
+ }
134646
+ async function readBody(opened, maxBytes) {
134647
+ if (opened.declaredBytes !== null && opened.declaredBytes > maxBytes) {
134648
+ opened.cancel("email image over cap");
134649
+ throw new Error(`attachment exceeds maxBytes (${opened.declaredBytes} > ${maxBytes})`);
134650
+ }
134651
+ const chunks = [];
134652
+ let total = 0;
134653
+ for await (const chunk of opened.stream) {
134654
+ const bytes = asBytes(chunk);
134655
+ total += bytes.byteLength;
134656
+ if (total > maxBytes) {
134657
+ opened.cancel("email image over cap");
134658
+ throw new Error(`attachment exceeds maxBytes (>${maxBytes})`);
134659
+ }
134660
+ chunks.push(bytes);
134661
+ }
134662
+ if (total === 0) throw new Error("email image was empty");
134663
+ const out = new Uint8Array(total);
134664
+ let offset = 0;
134665
+ for (const chunk of chunks) {
134666
+ out.set(chunk, offset);
134667
+ offset += chunk.byteLength;
134668
+ }
134669
+ return out;
134670
+ }
134671
+ async function readTicket(open, ticket, maxBytes) {
134672
+ const opened = await open(ticket);
134673
+ if (opened.kind === "refused") throw new Error(`email image unavailable: ${opened.code}`);
134674
+ return readBody(opened.body, maxBytes);
134675
+ }
134676
+ /** The images that fit. Each failure is handed to `onDropped` and skipped. */
134677
+ async function materializeEmailImages(images, open, onDropped) {
134678
+ if (images === void 0 || images.length === 0) return [];
134679
+ const out = [];
134680
+ let used = 0;
134681
+ for (const image of images) {
134682
+ const room = EMAIL_IMAGE_MAX_TOTAL_BYTES - used;
134683
+ if (room <= 0) {
134684
+ onDropped("attachment exceeds maxBytes (total cap)", image.deviceId);
134685
+ continue;
134686
+ }
134687
+ try {
134688
+ const bytes = await readTicket(open, image.ticket, room);
134689
+ used += bytes.byteLength;
134690
+ out.push({
134691
+ bytes,
134692
+ mime: image.mime,
134693
+ name: image.name,
134694
+ contentId: image.contentId,
134695
+ placement: image.placement
134696
+ });
134697
+ } catch (err) {
134698
+ onDropped(err instanceof Error ? err.message : String(err), image.deviceId);
134699
+ }
134700
+ }
134701
+ return out;
134702
+ }
134703
+ /** Tickets in, one MIME body out. The same call for Gmail and SMTP. */
134704
+ async function assembleEmailMime(input, open, onDropped) {
134705
+ const images = await materializeEmailImages(input.images, open, onDropped);
134706
+ return buildRawMime({
134707
+ from: input.from,
134708
+ to: input.to,
134709
+ subject: input.subject,
134710
+ text: input.text,
134711
+ ...input.cc !== void 0 ? { cc: input.cc } : {},
134712
+ ...input.bcc !== void 0 ? { bcc: input.bcc } : {},
134713
+ ...input.replyTo !== void 0 ? { replyTo: input.replyTo } : {},
134714
+ ...input.html !== void 0 ? { html: input.html } : {},
134715
+ ...images.length > 0 ? { images } : {}
134716
+ });
134717
+ }
134718
+ //#endregion
134385
134719
  //#region src/notification/attachment-url.ts
134386
134720
  /** Build a {@link PublicEndpointReader} over `local-network.getAddresses`. */
134387
134721
  function publicEndpointReaderFrom(source) {
@@ -137028,6 +137362,28 @@ var STATE_SUMMARY_VARS = [
137028
137362
  systemEventKinds: [...SUMMARISABLE],
137029
137363
  systemEventDeliveries: ["summary"]
137030
137364
  },
137365
+ {
137366
+ name: "offlineCount",
137367
+ label: "Summary: how many went offline",
137368
+ example: "2",
137369
+ group: "system",
137370
+ families: ["rule"],
137371
+ fields: [...RULE_TEXT],
137372
+ kinds: ["system"],
137373
+ systemEventKinds: [...SUMMARISABLE],
137374
+ systemEventDeliveries: ["summary"]
137375
+ },
137376
+ {
137377
+ name: "onlineCount",
137378
+ label: "Summary: how many came back",
137379
+ example: "5",
137380
+ group: "system",
137381
+ families: ["rule"],
137382
+ fields: [...RULE_TEXT],
137383
+ kinds: ["system"],
137384
+ systemEventKinds: [...SUMMARISABLE],
137385
+ systemEventDeliveries: ["summary"]
137386
+ },
137031
137387
  {
137032
137388
  name: "summaryCount",
137033
137389
  label: "Summary: items reported",
@@ -137118,6 +137474,21 @@ var NC_TEMPLATE_VARS = [
137118
137474
  kinds: ["detection", "system"],
137119
137475
  systemEventKinds: [...COMBINED_ALARM]
137120
137476
  },
137477
+ {
137478
+ name: "headline",
137479
+ label: "Subject and place",
137480
+ description: "The default detection title: the label when one is set, otherwise the translated class, then the zone or the device. The subject alone when neither place is known.",
137481
+ example: "Persona — Uscio",
137482
+ group: "subject",
137483
+ families: ["rule"],
137484
+ fields: [...RULE_TEXT],
137485
+ kinds: [
137486
+ "detection",
137487
+ "occupancy",
137488
+ "sound",
137489
+ "sensor"
137490
+ ]
137491
+ },
137121
137492
  {
137122
137493
  name: "subject",
137123
137494
  label: "Subject sentence",
@@ -137412,7 +137783,7 @@ var NC_TEMPLATE_VARS = [
137412
137783
  families: ["rule"],
137413
137784
  fields: [...RULE_TEXT],
137414
137785
  kinds: ["system"],
137415
- systemEventKinds: ["device-command"]
137786
+ systemEventKinds: ["device-command", "alarm-disarmed"]
137416
137787
  },
137417
137788
  {
137418
137789
  name: "deviceLabel",
@@ -142722,6 +143093,8 @@ var DIMENSION_QUANTITY = {
142722
143093
  angle: "angle",
142723
143094
  "sound-level": "sound-level",
142724
143095
  "signal-level": "signal-level",
143096
+ "signal-ratio": "signal-ratio",
143097
+ frequency: "frequency",
142725
143098
  "colour-temperature": "colour-temperature",
142726
143099
  bitrate: "bitrate",
142727
143100
  rate: "rate"
@@ -146293,6 +146666,9 @@ exports.DoorbellStatusSchema = DoorbellStatusSchema;
146293
146666
  exports.DraftKindSchema = DraftKindSchema;
146294
146667
  exports.DraftSiteDeviceSchema = DraftSiteDeviceSchema;
146295
146668
  exports.DraftSiteSchema = DraftSiteSchema;
146669
+ exports.EMAIL_IMAGE_MAX_COUNT = EMAIL_IMAGE_MAX_COUNT;
146670
+ exports.EMAIL_IMAGE_MAX_TOTAL_BYTES = EMAIL_IMAGE_MAX_TOTAL_BYTES;
146671
+ exports.EMAIL_IMAGE_SLOT = EMAIL_IMAGE_SLOT;
146296
146672
  exports.EMBEDDING_MODEL_FAILED = EMBEDDING_MODEL_FAILED;
146297
146673
  exports.EMBEDDING_REQUIREMENTS_FAILED = EMBEDDING_REQUIREMENTS_FAILED;
146298
146674
  exports.EMBEDDING_REQUIREMENTS_UNAVAILABLE = EMBEDDING_REQUIREMENTS_UNAVAILABLE;
@@ -146335,6 +146711,7 @@ exports.EgressRateControlSchema = EgressRateControlSchema;
146335
146711
  exports.EgressTranscodeRequestSchema = EgressTranscodeRequestSchema;
146336
146712
  exports.EgressTranscodeSchema = EgressTranscodeSchema;
146337
146713
  exports.ElementConfigStore = ElementConfigStore;
146714
+ exports.EmailImagePartSchema = EmailImagePartSchema;
146338
146715
  exports.EmbeddingFailedModelSchema = EmbeddingFailedModelSchema;
146339
146716
  exports.EmbeddingFailedRequirementSchema = EmbeddingFailedRequirementSchema;
146340
146717
  exports.EmbeddingInfoSchema = EmbeddingInfoSchema;
@@ -148216,6 +148593,7 @@ exports.asJsonObject = require_sleep.asJsonObject;
148216
148593
  exports.asNumber = require_sleep.asNumber;
148217
148594
  exports.asRecordsError = require_sleep.asRecordsError;
148218
148595
  exports.asString = require_sleep.asString;
148596
+ exports.assembleEmailMime = assembleEmailMime;
148219
148597
  exports.assertDeviceOffers = require_sleep.assertDeviceOffers;
148220
148598
  exports.assertInstanceUnused = assertInstanceUnused;
148221
148599
  exports.assertOwnExportInstance = assertOwnExportInstance;
@@ -148274,6 +148652,7 @@ exports.buildNcTaxonomy = buildNcTaxonomy;
148274
148652
  exports.buildNotificationTargetInstances = buildNotificationTargetInstances;
148275
148653
  exports.buildPlusCatalogClassMap = buildPlusCatalogClassMap;
148276
148654
  exports.buildPowerSwitch = buildPowerSwitch;
148655
+ exports.buildRawMime = buildRawMime;
148277
148656
  exports.buildRepairPrompt = buildRepairPrompt;
148278
148657
  exports.buildRoleScopes = buildRoleScopes;
148279
148658
  exports.buildSecretRef = require_sleep.buildSecretRef;
@@ -148535,6 +148914,7 @@ exports.deviceHistoryCapability = deviceHistoryCapability;
148535
148914
  exports.deviceIconKey = deviceIconKey;
148536
148915
  exports.deviceManagerCapability = deviceManagerCapability;
148537
148916
  exports.deviceMatchesProfile = deviceMatchesProfile;
148917
+ exports.deviceOffersActions = deviceOffersActions;
148538
148918
  exports.deviceOpsCapability = require_sleep.deviceOpsCapability;
148539
148919
  exports.deviceProviderCapability = deviceProviderCapability;
148540
148920
  exports.deviceRefusalFromMessage = deviceRefusalFromMessage;
@@ -148950,6 +149330,7 @@ exports.markFieldEdited = markFieldEdited;
148950
149330
  exports.markdownToHtmlLite = markdownToHtmlLite;
148951
149331
  exports.markdownToText = markdownToText;
148952
149332
  exports.maskUrlCredentials = require_sleep.maskUrlCredentials;
149333
+ exports.materializeEmailImages = materializeEmailImages;
148953
149334
  exports.maxDurationMs = require_implemented_methods.maxDurationMs;
148954
149335
  exports.mayReadLocation = mayReadLocation;
148955
149336
  exports.mayWriteToLocation = mayWriteToLocation;