@camstack/server 1.2.815 → 1.2.816
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/package.json +4 -5
- package/system/dist/{agent-https-eMihTWJ4.mjs → agent-https-CK_B6QXQ.mjs} +1 -1
- package/system/dist/{agent-https-Dwbpz4K6.js → agent-https-pirjJaDw.js} +1 -1
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
- package/system/dist/builtins/alerts/alerts.addon.js +1 -1
- package/system/dist/builtins/alerts/alerts.addon.mjs +1 -1
- package/system/dist/builtins/autotrack/index.js +1 -1
- package/system/dist/builtins/autotrack/index.mjs +1 -1
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +2 -2
- package/system/dist/builtins/calendars/calendars.addon.js +1 -1
- package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
- package/system/dist/builtins/camera-grid/index.js +1 -1
- package/system/dist/builtins/camera-grid/index.mjs +1 -1
- package/system/dist/builtins/composer/composer.addon.js +3 -3
- package/system/dist/builtins/composer/composer.addon.mjs +3 -3
- package/system/dist/builtins/console-logging/index.js +1 -1
- package/system/dist/builtins/console-logging/index.mjs +1 -1
- package/system/dist/builtins/core-blocks/core-blocks.addon.js +3 -3
- package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +3 -3
- package/system/dist/builtins/device-history/device-history.addon.js +2 -2
- package/system/dist/builtins/device-history/device-history.addon.mjs +2 -2
- package/system/dist/builtins/device-manager/device-manager.addon.js +64 -5
- package/system/dist/builtins/device-manager/device-manager.addon.mjs +64 -5
- package/system/dist/builtins/device-manager/last-active-mode.d.ts +1 -0
- package/system/dist/builtins/device-manager/runtime-state-persist-gate.d.ts +9 -0
- package/system/dist/builtins/hub-forwarder/index.js +1 -1
- package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
- package/system/dist/builtins/keychain/index.js +4 -4
- package/system/dist/builtins/keychain/index.mjs +4 -4
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
- package/system/dist/builtins/local-auth/local-auth.addon.js +2 -2
- package/system/dist/builtins/local-auth/local-auth.addon.mjs +2 -2
- package/system/dist/builtins/local-network/local-network.addon.js +2 -2
- package/system/dist/builtins/local-network/local-network.addon.mjs +2 -2
- package/system/dist/builtins/loki-logging/index.js +1 -1
- package/system/dist/builtins/loki-logging/index.mjs +1 -1
- package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
- package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
- package/system/dist/builtins/platform-probe/index.js +1 -1
- package/system/dist/builtins/platform-probe/index.mjs +1 -1
- package/system/dist/builtins/record-entries/index.js +1 -1
- package/system/dist/builtins/record-entries/index.mjs +1 -1
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
- package/system/dist/builtins/snapshot/index.js +1 -1
- package/system/dist/builtins/snapshot/index.mjs +1 -1
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
- package/system/dist/builtins/sqlite-storage/index.js +1 -1
- package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +3 -3
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +3 -3
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
- package/system/dist/builtins/system-config/system-config.addon.js +3 -3
- package/system/dist/builtins/system-config/system-config.addon.mjs +284 -284
- package/system/dist/builtins/winston-logging/index.js +1 -1
- package/system/dist/builtins/winston-logging/index.mjs +1 -1
- package/system/dist/{capture-engine-uxR5sOQN.js → capture-engine-9qCs6J2S.js} +1 -1
- package/system/dist/{capture-engine-CYPDOIF6.mjs → capture-engine-MPu8CRiM.mjs} +1 -1
- package/system/dist/{composition-sources-CU3p3INI.mjs → composition-sources-CAPpmqL0.mjs} +1 -1
- package/system/dist/{composition-sources-DkvntZci.js → composition-sources-N-9OE7DA.js} +1 -1
- package/system/dist/{constants-DMFJ6Fky.mjs → constants-D75PEb9b.mjs} +1 -1
- package/system/dist/{constants-BP-Txn_J.js → constants-o31-vUsL.js} +1 -1
- package/system/dist/{device-ca-D-0zxmFi.js → device-ca-C3wqsnBw.js} +1 -1
- package/system/dist/{device-ca-tmcd_VBC.mjs → device-ca-D9C75-ee.mjs} +1 -1
- package/system/dist/{dist-CznnwtQ8.js → dist-BmEptO1d.js} +2441 -169
- package/system/dist/{dist-DmCVWvtK.mjs → dist-DBoCrtvm.mjs} +2441 -169
- package/system/dist/file-host-worker.js +1 -1
- package/system/dist/file-host-worker.mjs +1 -1
- package/system/dist/{hub-mdns-ciao-FTf16-JR.js → hub-mdns-ciao-B8Lh4Gx1.js} +2 -2
- package/system/dist/{hub-mdns-ciao-DbwyiHD5.mjs → hub-mdns-ciao-ho8U9Zs6.mjs} +2 -2
- package/system/dist/index.js +8 -8
- package/system/dist/index.mjs +8 -8
- package/system/dist/{legacy-integration-rows-door-CASQgifG.mjs → legacy-integration-rows-door-Cc47aOOP.mjs} +1 -1
- package/system/dist/{legacy-integration-rows-door-gW0xpMJI.js → legacy-integration-rows-door-v-8WFbCS.js} +1 -1
- package/system/dist/{restore-archive-B9TEFWRE.js → restore-archive-BYOda1Dl.js} +1 -1
- package/system/dist/{restore-archive-DlaC_gyl.mjs → restore-archive-DS-Hgq3V.mjs} +82 -82
- package/system/dist/{wal-maintenance-Da2Rozz6.js → wal-maintenance-D5CHoEtS.js} +0 -0
- package/system/dist/{wal-maintenance-Cn164tp0.mjs → wal-maintenance-DtqrYJN3.mjs} +0 -0
- package/system/package.json +1 -1
|
@@ -1211,7 +1211,7 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
|
|
|
1211
1211
|
return DeviceRole;
|
|
1212
1212
|
}({});
|
|
1213
1213
|
//#endregion
|
|
1214
|
-
//#region ../types/dist/sleep-
|
|
1214
|
+
//#region ../types/dist/sleep-CfYvHNFz.mjs
|
|
1215
1215
|
/**
|
|
1216
1216
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
1217
1217
|
* window to float samples (D455).
|
|
@@ -11939,6 +11939,18 @@ Object.freeze({
|
|
|
11939
11939
|
{
|
|
11940
11940
|
"path": "tempStep",
|
|
11941
11941
|
"valueType": "number"
|
|
11942
|
+
},
|
|
11943
|
+
{
|
|
11944
|
+
"path": "lastActiveMode",
|
|
11945
|
+
"valueType": "enum",
|
|
11946
|
+
"enumValues": [
|
|
11947
|
+
"heat",
|
|
11948
|
+
"cool",
|
|
11949
|
+
"auto",
|
|
11950
|
+
"heat_cool",
|
|
11951
|
+
"fan_only",
|
|
11952
|
+
"dry"
|
|
11953
|
+
]
|
|
11942
11954
|
}
|
|
11943
11955
|
],
|
|
11944
11956
|
"color": [
|
|
@@ -13363,6 +13375,10 @@ Object.freeze({
|
|
|
13363
13375
|
{
|
|
13364
13376
|
"path": "maxTemp",
|
|
13365
13377
|
"valueType": "number"
|
|
13378
|
+
},
|
|
13379
|
+
{
|
|
13380
|
+
"path": "lastActiveMode",
|
|
13381
|
+
"valueType": "string"
|
|
13366
13382
|
}
|
|
13367
13383
|
],
|
|
13368
13384
|
"weather": [
|
|
@@ -50674,6 +50690,12 @@ var ClimateControlStatusSchema = zod.z.object({
|
|
|
50674
50690
|
maxTemp: zod.z.number().nullable().optional().meta(readingMeta("temperature")),
|
|
50675
50691
|
/** Setpoint granularity, Celsius (0.5, 1). Absent / null = not reported. */
|
|
50676
50692
|
tempStep: zod.z.number().positive().nullable().optional().meta(readingMeta("temperature")),
|
|
50693
|
+
/**
|
|
50694
|
+
* The last non-off mode the device reported. Kept by the device-state mirror on every
|
|
50695
|
+
* write (providers never set it), so "turn on" can return to it. Absent until the device
|
|
50696
|
+
* has reported a running mode.
|
|
50697
|
+
*/
|
|
50698
|
+
lastActiveMode: HvacModeSchema.exclude(["off"]).optional(),
|
|
50677
50699
|
/** Ms epoch when the slice was last updated (push or command). */
|
|
50678
50700
|
lastFetchedAt: zod.z.number()
|
|
50679
50701
|
});
|
|
@@ -50758,7 +50780,8 @@ var climateControlCapability = {
|
|
|
50758
50780
|
* See `RuntimeStateDurability`. Enforced by
|
|
50759
50781
|
* `scripts/check-runtime-state-durability.ts`.
|
|
50760
50782
|
*/
|
|
50761
|
-
durability: "
|
|
50783
|
+
durability: "restored",
|
|
50784
|
+
restoredStateFields: ["lastActiveMode"],
|
|
50762
50785
|
/**
|
|
50763
50786
|
* History (D850): recorded series. Celsius by contract; setpoints keep every change (`minIntervalMs: 0`).
|
|
50764
50787
|
*/
|
|
@@ -52050,7 +52073,7 @@ function irSourceProblem(source) {
|
|
|
52050
52073
|
throw err;
|
|
52051
52074
|
}
|
|
52052
52075
|
}
|
|
52053
|
-
function same(a, b) {
|
|
52076
|
+
function same$1(a, b) {
|
|
52054
52077
|
return a.trim().toLowerCase() === b.trim().toLowerCase();
|
|
52055
52078
|
}
|
|
52056
52079
|
/** The `digits` source that declares this channel number, or null. */
|
|
@@ -52064,7 +52087,7 @@ function findChannelSource(sources, number) {
|
|
|
52064
52087
|
* the number reach the same source; nothing else is guessed.
|
|
52065
52088
|
*/
|
|
52066
52089
|
function resolveRemoteSource(sources, query) {
|
|
52067
|
-
const byName = sources.find((source) => same(source.name, query));
|
|
52090
|
+
const byName = sources.find((source) => same$1(source.name, query));
|
|
52068
52091
|
if (byName !== void 0) return byName;
|
|
52069
52092
|
const byId = sources.find((source) => source.id === query.trim());
|
|
52070
52093
|
if (byId !== void 0) return byId;
|
|
@@ -61724,7 +61747,7 @@ var enumSensorCapability = {
|
|
|
61724
61747
|
} } },
|
|
61725
61748
|
/** Clock fields: written, but excluded from the compare that decides
|
|
61726
61749
|
* whether persisting is worth a SQLite commit. */
|
|
61727
|
-
volatileStateFields: ["lastFetchedAt"]
|
|
61750
|
+
volatileStateFields: ["lastFetchedAt", "timestamp"]
|
|
61728
61751
|
};
|
|
61729
61752
|
/**
|
|
61730
61753
|
* Generic stateless event emitter. Installed on a `DeviceType.EventEmitter`
|
|
@@ -63301,21 +63324,50 @@ var HeroRowIdSchema = zod.z.enum([
|
|
|
63301
63324
|
"volume",
|
|
63302
63325
|
"source",
|
|
63303
63326
|
"contact",
|
|
63304
|
-
"motion-trigger"
|
|
63327
|
+
"motion-trigger",
|
|
63328
|
+
"lock",
|
|
63329
|
+
"alarm",
|
|
63330
|
+
"fan",
|
|
63331
|
+
"vacuum",
|
|
63332
|
+
"mower",
|
|
63333
|
+
"feeder",
|
|
63334
|
+
"fountain",
|
|
63335
|
+
"pump-cycle",
|
|
63336
|
+
"automation",
|
|
63337
|
+
"script",
|
|
63338
|
+
"do-not-disturb",
|
|
63339
|
+
"brightness",
|
|
63340
|
+
"color",
|
|
63341
|
+
"cover",
|
|
63342
|
+
"valve",
|
|
63343
|
+
"humidifier",
|
|
63344
|
+
"update",
|
|
63345
|
+
"button",
|
|
63346
|
+
"climate-mode",
|
|
63347
|
+
"climate-fan",
|
|
63348
|
+
"setpoint",
|
|
63349
|
+
"channel",
|
|
63350
|
+
"control"
|
|
63305
63351
|
]);
|
|
63306
|
-
|
|
63307
|
-
var HeroArgsSchema = zod.z.record(zod.z.string(), zod.z.union([
|
|
63352
|
+
var HeroArgValueSchema = zod.z.lazy(() => zod.z.union([
|
|
63308
63353
|
zod.z.string(),
|
|
63309
63354
|
zod.z.number(),
|
|
63310
|
-
zod.z.boolean()
|
|
63355
|
+
zod.z.boolean(),
|
|
63356
|
+
zod.z.record(zod.z.string(), HeroArgValueSchema)
|
|
63311
63357
|
]));
|
|
63358
|
+
var HeroArgsSchema = zod.z.record(zod.z.string(), HeroArgValueSchema);
|
|
63312
63359
|
/** A cap method called on the hero's device. */
|
|
63313
63360
|
var HeroCallSchema = zod.z.object({
|
|
63314
63361
|
cap: zod.z.string(),
|
|
63315
63362
|
method: zod.z.string(),
|
|
63316
63363
|
args: HeroArgsSchema
|
|
63317
63364
|
});
|
|
63318
|
-
var HeroConfirmSchema = zod.z.enum([
|
|
63365
|
+
var HeroConfirmSchema = zod.z.enum([
|
|
63366
|
+
"off-while-running",
|
|
63367
|
+
"unlock",
|
|
63368
|
+
"install",
|
|
63369
|
+
"press"
|
|
63370
|
+
]);
|
|
63319
63371
|
var HeroActionSchema = zod.z.object({
|
|
63320
63372
|
/** Unique within the model; the `gated` list and the specs name it. */
|
|
63321
63373
|
id: zod.z.string(),
|
|
@@ -63411,7 +63463,11 @@ var HeroConsumptionSlotSchema = zod.z.discriminatedUnion("kind", [zod.z.object({
|
|
|
63411
63463
|
})]);
|
|
63412
63464
|
var HeroOwnPowerSlotSchema = zod.z.object({
|
|
63413
63465
|
/** Which cap the power is switched through; the renderer never needs it. */
|
|
63414
|
-
source: zod.z.enum([
|
|
63466
|
+
source: zod.z.enum([
|
|
63467
|
+
"switch",
|
|
63468
|
+
"media-player",
|
|
63469
|
+
"climate-control"
|
|
63470
|
+
]),
|
|
63415
63471
|
/** `null` = unknown, never off. */
|
|
63416
63472
|
on: zod.z.boolean().nullable(),
|
|
63417
63473
|
assumed: zod.z.boolean(),
|
|
@@ -63448,7 +63504,23 @@ var HeroFactSchema = zod.z.object({
|
|
|
63448
63504
|
"remaining",
|
|
63449
63505
|
"volume",
|
|
63450
63506
|
"source",
|
|
63451
|
-
"consumables"
|
|
63507
|
+
"consumables",
|
|
63508
|
+
"since",
|
|
63509
|
+
"speed",
|
|
63510
|
+
"progress",
|
|
63511
|
+
"level",
|
|
63512
|
+
"last-run",
|
|
63513
|
+
"event",
|
|
63514
|
+
"members",
|
|
63515
|
+
"failures",
|
|
63516
|
+
"reading",
|
|
63517
|
+
"climate",
|
|
63518
|
+
"temperature",
|
|
63519
|
+
"humidity",
|
|
63520
|
+
"pressure",
|
|
63521
|
+
"air-quality",
|
|
63522
|
+
"illuminance",
|
|
63523
|
+
"valve"
|
|
63452
63524
|
]),
|
|
63453
63525
|
icon: IconKeySchema.nullable(),
|
|
63454
63526
|
text: HeroTextSchema,
|
|
@@ -92608,6 +92680,11 @@ var WaterHeaterStatusSchema = zod.z.object({
|
|
|
92608
92680
|
minTemp: zod.z.number().nullable().meta(readingMeta("temperature")),
|
|
92609
92681
|
/** HA `max_temp` attribute. Null when not reported. */
|
|
92610
92682
|
maxTemp: zod.z.number().nullable().meta(readingMeta("temperature")),
|
|
92683
|
+
/**
|
|
92684
|
+
* The last operation mode other than `off` the device reported. Kept by the device-state
|
|
92685
|
+
* mirror on every write (providers never set it), so "turn on" can return to it.
|
|
92686
|
+
*/
|
|
92687
|
+
lastActiveMode: zod.z.string().optional(),
|
|
92611
92688
|
/** Ms epoch when the slice was last updated. */
|
|
92612
92689
|
lastChangedAt: zod.z.number()
|
|
92613
92690
|
});
|
|
@@ -92655,7 +92732,8 @@ var waterHeaterCapability = {
|
|
|
92655
92732
|
* See `RuntimeStateDurability`. Enforced by
|
|
92656
92733
|
* `scripts/check-runtime-state-durability.ts`.
|
|
92657
92734
|
*/
|
|
92658
|
-
durability: "
|
|
92735
|
+
durability: "restored",
|
|
92736
|
+
restoredStateFields: ["lastActiveMode"],
|
|
92659
92737
|
/**
|
|
92660
92738
|
* History (D850): recorded series. The schema carries no unit; providers publish Celsius. Setpoint keeps every change.
|
|
92661
92739
|
*/
|
|
@@ -95293,7 +95371,7 @@ var ACTUATOR_TEMPLATE_IDS = [
|
|
|
95293
95371
|
"media-player",
|
|
95294
95372
|
"climate"
|
|
95295
95373
|
];
|
|
95296
|
-
function row$
|
|
95374
|
+
function row$2(cap, method, requires = null, confirm = false) {
|
|
95297
95375
|
return {
|
|
95298
95376
|
cap,
|
|
95299
95377
|
method,
|
|
@@ -95303,41 +95381,41 @@ function row$1(cap, method, requires = null, confirm = false) {
|
|
|
95303
95381
|
}
|
|
95304
95382
|
/** The first row's cap is the type's own: always offered, members without it are skipped. */
|
|
95305
95383
|
var ACTUATOR_METHODS = {
|
|
95306
|
-
switch: [row$
|
|
95384
|
+
switch: [row$2("switch", "setState")],
|
|
95307
95385
|
light: [
|
|
95308
|
-
row$
|
|
95309
|
-
row$
|
|
95310
|
-
row$
|
|
95386
|
+
row$2("switch", "setState"),
|
|
95387
|
+
row$2("brightness", "setBrightness"),
|
|
95388
|
+
row$2("color", "setColor")
|
|
95311
95389
|
],
|
|
95312
95390
|
fan: [
|
|
95313
|
-
row$
|
|
95314
|
-
row$
|
|
95315
|
-
row$
|
|
95316
|
-
row$
|
|
95317
|
-
row$
|
|
95391
|
+
row$2("switch", "setState"),
|
|
95392
|
+
row$2("fan-control", "setPercentage", DeviceFeature.FanSpeed),
|
|
95393
|
+
row$2("fan-control", "setPreset", DeviceFeature.FanPreset),
|
|
95394
|
+
row$2("fan-control", "setDirection", DeviceFeature.FanDirection),
|
|
95395
|
+
row$2("fan-control", "setOscillating", DeviceFeature.FanOscillating)
|
|
95318
95396
|
],
|
|
95319
95397
|
cover: [
|
|
95320
|
-
row$
|
|
95321
|
-
row$
|
|
95322
|
-
row$
|
|
95323
|
-
row$
|
|
95324
|
-
row$
|
|
95398
|
+
row$2("cover", "open"),
|
|
95399
|
+
row$2("cover", "close"),
|
|
95400
|
+
row$2("cover", "stop", DeviceFeature.CoverStoppable),
|
|
95401
|
+
row$2("cover", "setPosition", DeviceFeature.CoverPositionable),
|
|
95402
|
+
row$2("cover", "setTiltPosition", DeviceFeature.CoverTilt)
|
|
95325
95403
|
],
|
|
95326
95404
|
valve: [
|
|
95327
|
-
row$
|
|
95328
|
-
row$
|
|
95329
|
-
row$
|
|
95405
|
+
row$2("valve", "open"),
|
|
95406
|
+
row$2("valve", "close"),
|
|
95407
|
+
row$2("valve", "setPosition", DeviceFeature.ValvePositionable)
|
|
95330
95408
|
],
|
|
95331
|
-
lock: [row$
|
|
95409
|
+
lock: [row$2("lock-control", "lock"), row$2("lock-control", "unlock", null, true)],
|
|
95332
95410
|
"media-player": [
|
|
95333
|
-
row$
|
|
95334
|
-
row$
|
|
95335
|
-
row$
|
|
95411
|
+
row$2("media-player", "play"),
|
|
95412
|
+
row$2("media-player", "pause"),
|
|
95413
|
+
row$2("media-player", "setVolume", DeviceFeature.MediaPlayerVolume)
|
|
95336
95414
|
],
|
|
95337
95415
|
climate: [
|
|
95338
|
-
row$
|
|
95339
|
-
row$
|
|
95340
|
-
row$
|
|
95416
|
+
row$2("climate-control", "setMode"),
|
|
95417
|
+
row$2("climate-control", "setTarget"),
|
|
95418
|
+
row$2("climate-control", "setFanMode", DeviceFeature.ClimateFanMode)
|
|
95341
95419
|
]
|
|
95342
95420
|
};
|
|
95343
95421
|
/**
|
|
@@ -97490,6 +97568,1670 @@ function resolveMutate(router, method) {
|
|
|
97490
97568
|
const mutate = proc.mutate;
|
|
97491
97569
|
return typeof mutate === "function" ? mutate : null;
|
|
97492
97570
|
}
|
|
97571
|
+
/** Parses the raw slice with the cap's own schema; `undefined` when it does not parse. */
|
|
97572
|
+
function contribution(cap, schema, build) {
|
|
97573
|
+
return {
|
|
97574
|
+
cap,
|
|
97575
|
+
contribute: (raw, ctx) => {
|
|
97576
|
+
const parsed = schema.safeParse(raw);
|
|
97577
|
+
return build(parsed.success ? parsed.data : void 0, ctx);
|
|
97578
|
+
}
|
|
97579
|
+
};
|
|
97580
|
+
}
|
|
97581
|
+
function action(id, label, icon, cap, method, args = {}, emphasis = "normal", confirm = null) {
|
|
97582
|
+
return {
|
|
97583
|
+
id,
|
|
97584
|
+
label,
|
|
97585
|
+
icon,
|
|
97586
|
+
call: {
|
|
97587
|
+
cap,
|
|
97588
|
+
method,
|
|
97589
|
+
args
|
|
97590
|
+
},
|
|
97591
|
+
emphasis,
|
|
97592
|
+
confirm
|
|
97593
|
+
};
|
|
97594
|
+
}
|
|
97595
|
+
var asAction = (a) => ({
|
|
97596
|
+
kind: "action",
|
|
97597
|
+
action: a
|
|
97598
|
+
});
|
|
97599
|
+
function reading(source, state, assumed = false, title) {
|
|
97600
|
+
return title === void 0 ? {
|
|
97601
|
+
source,
|
|
97602
|
+
state,
|
|
97603
|
+
assumed
|
|
97604
|
+
} : {
|
|
97605
|
+
source,
|
|
97606
|
+
state,
|
|
97607
|
+
assumed,
|
|
97608
|
+
title
|
|
97609
|
+
};
|
|
97610
|
+
}
|
|
97611
|
+
function fact(id, icon, text, tone = "muted") {
|
|
97612
|
+
return {
|
|
97613
|
+
id,
|
|
97614
|
+
icon,
|
|
97615
|
+
text,
|
|
97616
|
+
tone
|
|
97617
|
+
};
|
|
97618
|
+
}
|
|
97619
|
+
function row$1(id, icon, status, controls = []) {
|
|
97620
|
+
return {
|
|
97621
|
+
id,
|
|
97622
|
+
icon,
|
|
97623
|
+
status,
|
|
97624
|
+
controls: [...controls]
|
|
97625
|
+
};
|
|
97626
|
+
}
|
|
97627
|
+
/** "5 min" / "3 h" / "2 d" since `at`; `null` when the moment is unknown (0) or in the future. */
|
|
97628
|
+
function elapsedText(at, now) {
|
|
97629
|
+
if (at <= 0 || at > now) return null;
|
|
97630
|
+
const min = Math.floor((now - at) / 6e4);
|
|
97631
|
+
if (min < 1) return t("just now", "adesso");
|
|
97632
|
+
if (min < 60) return t(`${min} min ago`, `${min} min fa`);
|
|
97633
|
+
const h = Math.floor(min / 60);
|
|
97634
|
+
if (h < 48) return t(`${h} h ago`, `${h} h fa`);
|
|
97635
|
+
const d = Math.floor(h / 24);
|
|
97636
|
+
return t(`${d} d ago`, `${d} g fa`);
|
|
97637
|
+
}
|
|
97638
|
+
/** Joins words with " · ", skipping what is not there. */
|
|
97639
|
+
function joinText(parts) {
|
|
97640
|
+
const present = parts.filter((p) => p !== null);
|
|
97641
|
+
if (present.length === 0) return null;
|
|
97642
|
+
return t(present.map((p) => p.en).join(" · "), present.map((p) => p.it).join(" · "));
|
|
97643
|
+
}
|
|
97644
|
+
/**
|
|
97645
|
+
* What the access and automation caps add to a hero (D1023): a lock, an alarm
|
|
97646
|
+
* panel, an automation, a script and a media player's do-not-disturb. Every
|
|
97647
|
+
* contribution is typed against the cap's own status schema; a slice that does
|
|
97648
|
+
* not parse reads as "not answered" and the state is `unknown`, never `off`
|
|
97649
|
+
* (D315/D393). Nothing is guessed: with an unknown state the actions the cap
|
|
97650
|
+
* offers are offered separately.
|
|
97651
|
+
*/
|
|
97652
|
+
var LOCK_WORDS = {
|
|
97653
|
+
locked: {
|
|
97654
|
+
state: "on",
|
|
97655
|
+
title: t("Locked", "Chiusa"),
|
|
97656
|
+
door: "closed"
|
|
97657
|
+
},
|
|
97658
|
+
unlocked: {
|
|
97659
|
+
state: "standby",
|
|
97660
|
+
title: t("Unlocked", "Aperta"),
|
|
97661
|
+
door: "open"
|
|
97662
|
+
},
|
|
97663
|
+
locking: {
|
|
97664
|
+
state: "running",
|
|
97665
|
+
title: t("Locking", "In chiusura"),
|
|
97666
|
+
door: "closed"
|
|
97667
|
+
},
|
|
97668
|
+
unlocking: {
|
|
97669
|
+
state: "running",
|
|
97670
|
+
title: t("Unlocking", "In apertura"),
|
|
97671
|
+
door: "open"
|
|
97672
|
+
},
|
|
97673
|
+
jammed: {
|
|
97674
|
+
state: "alert",
|
|
97675
|
+
title: t("Jammed", "Bloccata"),
|
|
97676
|
+
door: null
|
|
97677
|
+
},
|
|
97678
|
+
"door-open": {
|
|
97679
|
+
state: "standby",
|
|
97680
|
+
title: t("Door open", "Porta aperta"),
|
|
97681
|
+
door: "open"
|
|
97682
|
+
}
|
|
97683
|
+
};
|
|
97684
|
+
var lockAction = (primary) => action("lock.lock", t("Lock", "Chiudi"), "lock", "lock-control", "lock", {}, primary ? "primary" : "normal");
|
|
97685
|
+
var unlockAction = (primary) => action("lock.unlock", t("Unlock", "Apri"), "lock-open", "lock-control", "unlock", {}, primary ? "primary" : "normal", "unlock");
|
|
97686
|
+
function lockControls(state, latch) {
|
|
97687
|
+
const open = asAction(action("lock.open", t("Open latch", "Apri il chiavistello"), "door-open", "lock-control", "open", {}, "normal", "unlock"));
|
|
97688
|
+
switch (state) {
|
|
97689
|
+
case "locked": return [asAction(unlockAction(true)), ...latch ? [open] : []];
|
|
97690
|
+
case "unlocked": return [asAction(lockAction(true)), ...latch ? [open] : []];
|
|
97691
|
+
case "jammed": return [asAction(unlockAction(false)), asAction(lockAction(false))];
|
|
97692
|
+
case null: return [asAction(lockAction(false)), asAction(unlockAction(false))];
|
|
97693
|
+
default: return [];
|
|
97694
|
+
}
|
|
97695
|
+
}
|
|
97696
|
+
var lockContribution = contribution("lock-control", LockControlStatusSchema, (slice, ctx) => {
|
|
97697
|
+
const state = slice?.state ?? null;
|
|
97698
|
+
const words = state === null ? null : LOCK_WORDS[state];
|
|
97699
|
+
const since = slice === void 0 ? null : elapsedText(slice.lastChangedAt, ctx.now);
|
|
97700
|
+
const title = words?.title ?? t("Unknown", "Sconosciuto");
|
|
97701
|
+
return {
|
|
97702
|
+
reading: reading("lock-control", words?.state ?? "unknown", false, words?.title),
|
|
97703
|
+
rows: [row$1("lock", state === "locked" || state === "locking" ? "lock" : "lock-open", joinText([title, since]), lockControls(state, ctx.features.includes(DeviceFeature.LockOpen)))],
|
|
97704
|
+
...since === null || words === null ? {} : { facts: [fact("since", "clock", since, "muted")] },
|
|
97705
|
+
...words?.door == null ? {} : { scene: { mode: words.door } }
|
|
97706
|
+
};
|
|
97707
|
+
});
|
|
97708
|
+
var ALARM_WORDS = {
|
|
97709
|
+
disarmed: {
|
|
97710
|
+
state: "off",
|
|
97711
|
+
title: t("Disarmed", "Disinserito")
|
|
97712
|
+
},
|
|
97713
|
+
armed_home: {
|
|
97714
|
+
state: "on",
|
|
97715
|
+
title: t("Armed home", "Inserito in casa")
|
|
97716
|
+
},
|
|
97717
|
+
armed_away: {
|
|
97718
|
+
state: "on",
|
|
97719
|
+
title: t("Armed away", "Inserito fuori casa")
|
|
97720
|
+
},
|
|
97721
|
+
armed_night: {
|
|
97722
|
+
state: "on",
|
|
97723
|
+
title: t("Armed night", "Inserito notte")
|
|
97724
|
+
},
|
|
97725
|
+
armed_vacation: {
|
|
97726
|
+
state: "on",
|
|
97727
|
+
title: t("Armed vacation", "Inserito vacanza")
|
|
97728
|
+
},
|
|
97729
|
+
armed_custom_bypass: {
|
|
97730
|
+
state: "on",
|
|
97731
|
+
title: t("Armed with bypass", "Inserito con esclusioni")
|
|
97732
|
+
},
|
|
97733
|
+
arming: {
|
|
97734
|
+
state: "standby",
|
|
97735
|
+
title: t("Arming", "Inserimento")
|
|
97736
|
+
},
|
|
97737
|
+
disarming: {
|
|
97738
|
+
state: "standby",
|
|
97739
|
+
title: t("Disarming", "Disinserimento")
|
|
97740
|
+
},
|
|
97741
|
+
pending: {
|
|
97742
|
+
state: "standby",
|
|
97743
|
+
title: t("Entry delay", "Ritardo di ingresso")
|
|
97744
|
+
},
|
|
97745
|
+
triggered: {
|
|
97746
|
+
state: "alert",
|
|
97747
|
+
title: t("Triggered", "Allarme in corso")
|
|
97748
|
+
}
|
|
97749
|
+
};
|
|
97750
|
+
var ARM_LABELS = {
|
|
97751
|
+
home: t("Arm home", "Inserisci in casa"),
|
|
97752
|
+
away: t("Arm away", "Inserisci fuori casa"),
|
|
97753
|
+
night: t("Arm night", "Inserisci notte"),
|
|
97754
|
+
vacation: t("Arm vacation", "Inserisci vacanza"),
|
|
97755
|
+
custom_bypass: t("Arm with bypass", "Inserisci con esclusioni")
|
|
97756
|
+
};
|
|
97757
|
+
var ALARM_MODES = [
|
|
97758
|
+
"home",
|
|
97759
|
+
"away",
|
|
97760
|
+
"night",
|
|
97761
|
+
"vacation",
|
|
97762
|
+
"custom_bypass"
|
|
97763
|
+
];
|
|
97764
|
+
function alarmControls(state, modes, requiresCode) {
|
|
97765
|
+
if (requiresCode) return [];
|
|
97766
|
+
const disarm = asAction(action("alarm.disarm", t("Disarm", "Disinserisci"), "shield-off", "alarm-panel", "disarm", {}, "primary"));
|
|
97767
|
+
const arm = (primaryFirst) => modes.map((mode, i) => asAction(action(`alarm.arm.${mode}`, ARM_LABELS[mode], "shield-check", "alarm-panel", "arm", { mode }, primaryFirst && i === 0 ? "primary" : "normal")));
|
|
97768
|
+
switch (state) {
|
|
97769
|
+
case "disarmed": return arm(true);
|
|
97770
|
+
case "arming":
|
|
97771
|
+
case "disarming": return [];
|
|
97772
|
+
case null: return [];
|
|
97773
|
+
default: return [disarm];
|
|
97774
|
+
}
|
|
97775
|
+
}
|
|
97776
|
+
var ACCESS_FAMILY_CONTRIBUTIONS = {
|
|
97777
|
+
"lock-control": lockContribution,
|
|
97778
|
+
"alarm-panel": contribution("alarm-panel", AlarmPanelStatusSchema, (slice, ctx) => {
|
|
97779
|
+
const state = slice?.state ?? null;
|
|
97780
|
+
const words = state === null ? null : ALARM_WORDS[state];
|
|
97781
|
+
const since = slice === void 0 ? null : elapsedText(slice.lastChangedAt, ctx.now);
|
|
97782
|
+
const modes = slice === void 0 ? ALARM_MODES : slice.availableModes;
|
|
97783
|
+
return {
|
|
97784
|
+
reading: reading("alarm-panel", words?.state ?? "unknown", false, words?.title),
|
|
97785
|
+
rows: [row$1("alarm", state === "triggered" ? "shield-alert" : state === "disarmed" ? "shield-off" : "shield-check", joinText([words?.title ?? t("Unknown", "Sconosciuto"), since]), alarmControls(state, modes, slice?.requiresCode ?? false))],
|
|
97786
|
+
...since === null || words === null ? {} : { facts: [fact("since", "clock", since, state === "triggered" ? "danger" : "muted")] }
|
|
97787
|
+
};
|
|
97788
|
+
}),
|
|
97789
|
+
"automation-control": contribution("automation-control", AutomationControlStatusSchema, (slice, ctx) => {
|
|
97790
|
+
const failed = slice?.lastError != null;
|
|
97791
|
+
const state = slice === void 0 ? "unknown" : failed ? "alert" : slice.isRunning ? "running" : slice.enabled ? "on" : "off";
|
|
97792
|
+
const title = slice === void 0 ? void 0 : failed ? t("Failed", "In errore") : slice.isRunning ? t("Running", "In esecuzione") : slice.enabled ? t("Enabled", "Attiva") : t("Disabled", "Disattivata");
|
|
97793
|
+
const last = slice === void 0 ? null : elapsedText(slice.lastTriggeredAt, ctx.now);
|
|
97794
|
+
const run = action("automation.run", t("Run now", "Esegui ora"), "play", "automation-control", "trigger", {}, "primary");
|
|
97795
|
+
const toggle = {
|
|
97796
|
+
kind: "toggle",
|
|
97797
|
+
id: "automation.enabled",
|
|
97798
|
+
label: t("Enabled", "Attiva"),
|
|
97799
|
+
on: slice?.enabled ?? null,
|
|
97800
|
+
turnOn: action("automation.enable", t("Enable", "Attiva"), "play", "automation-control", "enable"),
|
|
97801
|
+
turnOff: action("automation.disable", t("Disable", "Disattiva"), "square", "automation-control", "disable")
|
|
97802
|
+
};
|
|
97803
|
+
return {
|
|
97804
|
+
reading: reading("automation-control", state, false, title),
|
|
97805
|
+
rows: [row$1("automation", "workflow", joinText([
|
|
97806
|
+
title ?? t("Unknown", "Sconosciuto"),
|
|
97807
|
+
last === null ? null : t(`Ran ${last.en}`, `Eseguita ${last.it}`),
|
|
97808
|
+
slice?.lastError == null ? null : t(slice.lastError, slice.lastError)
|
|
97809
|
+
]), [asAction(run), toggle])],
|
|
97810
|
+
...last === null ? {} : { facts: [fact("last-run", "clock", last, failed ? "danger" : "muted")] }
|
|
97811
|
+
};
|
|
97812
|
+
}),
|
|
97813
|
+
"script-runner": contribution("script-runner", ScriptRunnerStatusSchema, (slice, ctx) => {
|
|
97814
|
+
const failed = slice?.lastRunSuccess === false;
|
|
97815
|
+
const state = slice === void 0 ? "unknown" : slice.isRunning ? "running" : failed ? "alert" : "idle";
|
|
97816
|
+
const title = slice === void 0 ? void 0 : slice.isRunning ? t("Running", "In esecuzione") : failed ? t("Failed", "In errore") : t("Ready", "Pronto");
|
|
97817
|
+
const last = slice === void 0 ? null : elapsedText(slice.lastRunAt, ctx.now);
|
|
97818
|
+
const control = slice?.isRunning === true ? action("script.stop", t("Stop", "Ferma"), "square", "script-runner", "stop", {}, "primary") : action("script.run", t("Run", "Esegui"), "play", "script-runner", "run", {}, "primary");
|
|
97819
|
+
return {
|
|
97820
|
+
reading: reading("script-runner", state, false, title),
|
|
97821
|
+
rows: [row$1("script", "scroll-text", joinText([
|
|
97822
|
+
title ?? t("Unknown", "Sconosciuto"),
|
|
97823
|
+
last === null ? null : t(`Ran ${last.en}`, `Eseguito ${last.it}`),
|
|
97824
|
+
slice?.lastError == null ? null : t(slice.lastError, slice.lastError)
|
|
97825
|
+
]), [asAction(control)])],
|
|
97826
|
+
...last === null ? {} : { facts: [fact("last-run", "clock", last, failed ? "danger" : "muted")] }
|
|
97827
|
+
};
|
|
97828
|
+
}),
|
|
97829
|
+
"do-not-disturb": contribution("do-not-disturb", DoNotDisturbStatusSchema, (slice) => {
|
|
97830
|
+
const on = slice?.enabled ?? null;
|
|
97831
|
+
return { rows: [row$1("do-not-disturb", "bell-off", on === null ? t("Unknown", "Sconosciuto") : on ? t("Do not disturb on", "Non disturbare attivo") : t("Do not disturb off", "Non disturbare spento"), [{
|
|
97832
|
+
kind: "toggle",
|
|
97833
|
+
id: "do-not-disturb.toggle",
|
|
97834
|
+
label: t("Do not disturb", "Non disturbare"),
|
|
97835
|
+
on,
|
|
97836
|
+
turnOn: action("do-not-disturb.on", t("Turn on", "Attiva"), "bell-off", "do-not-disturb", "setEnabled", { enabled: true }),
|
|
97837
|
+
turnOff: action("do-not-disturb.off", t("Turn off", "Disattiva"), "bell", "do-not-disturb", "setEnabled", { enabled: false })
|
|
97838
|
+
}])] };
|
|
97839
|
+
})
|
|
97840
|
+
};
|
|
97841
|
+
/**
|
|
97842
|
+
* What the household-device caps add to a hero (D1023): a fan, a robot vacuum,
|
|
97843
|
+
* a robot mower, a pet feeder, a pet fountain and its pump cycle. Typed against
|
|
97844
|
+
* each cap's own status schema; a slice that does not parse is "not answered"
|
|
97845
|
+
* (`unknown`, never `off`, D315/D393). A measurement the device did not report
|
|
97846
|
+
* is absent from the facts, never a zero (D393).
|
|
97847
|
+
*/
|
|
97848
|
+
var has$3 = (ctx, f) => ctx.features.includes(f);
|
|
97849
|
+
var unknownText = t("Unknown", "Sconosciuto");
|
|
97850
|
+
var pct$1 = (n) => t(`${Math.round(n)}%`, `${Math.round(n)}%`);
|
|
97851
|
+
var unit = (n) => Math.min(1, Math.max(0, n / 100));
|
|
97852
|
+
/** Battery as a fact, unless the device is also bound to the `battery` cap (it already says so). */
|
|
97853
|
+
function ownBattery(level, ctx) {
|
|
97854
|
+
if (level === null || ctx.caps.includes("battery")) return [];
|
|
97855
|
+
const tone = level <= 20 ? "danger" : level <= 40 ? "warning" : "success";
|
|
97856
|
+
return [fact("battery", "battery", t(`Battery ${Math.round(level)}%`, `Batteria ${Math.round(level)}%`), tone)];
|
|
97857
|
+
}
|
|
97858
|
+
var fanContribution = contribution("fan-control", FanControlStatusSchema, (slice, ctx) => {
|
|
97859
|
+
const speed = slice?.speed ?? null;
|
|
97860
|
+
const state = speed === null ? "unknown" : speed > 0 ? "running" : "off";
|
|
97861
|
+
const controls = [];
|
|
97862
|
+
if (speed !== null || has$3(ctx, DeviceFeature.FanSpeed)) controls.push({
|
|
97863
|
+
kind: "slider",
|
|
97864
|
+
id: "fan.speed",
|
|
97865
|
+
label: t("Speed", "Velocità"),
|
|
97866
|
+
value: speed,
|
|
97867
|
+
min: 0,
|
|
97868
|
+
max: 100,
|
|
97869
|
+
step: slice?.percentageStep ?? 1,
|
|
97870
|
+
unit: "%",
|
|
97871
|
+
call: {
|
|
97872
|
+
cap: "fan-control",
|
|
97873
|
+
method: "setPercentage",
|
|
97874
|
+
args: {}
|
|
97875
|
+
},
|
|
97876
|
+
valueArg: "speed"
|
|
97877
|
+
});
|
|
97878
|
+
if (slice !== void 0 && slice.availablePresets.length > 0) controls.push({
|
|
97879
|
+
kind: "picker",
|
|
97880
|
+
id: "fan.preset",
|
|
97881
|
+
label: t("Mode", "Modalità"),
|
|
97882
|
+
current: slice.preset === "" ? null : slice.preset,
|
|
97883
|
+
options: [...slice.availablePresets],
|
|
97884
|
+
call: {
|
|
97885
|
+
cap: "fan-control",
|
|
97886
|
+
method: "setPreset",
|
|
97887
|
+
args: {}
|
|
97888
|
+
},
|
|
97889
|
+
valueArg: "preset"
|
|
97890
|
+
});
|
|
97891
|
+
if (slice?.oscillating != null || has$3(ctx, DeviceFeature.FanOscillating)) controls.push({
|
|
97892
|
+
kind: "toggle",
|
|
97893
|
+
id: "fan.oscillating",
|
|
97894
|
+
label: t("Oscillate", "Oscilla"),
|
|
97895
|
+
on: slice?.oscillating ?? null,
|
|
97896
|
+
turnOn: action("fan.oscillate.on", t("Oscillate", "Oscilla"), "refresh-cw", "fan-control", "setOscillating", { oscillating: true }),
|
|
97897
|
+
turnOff: action("fan.oscillate.off", t("Hold still", "Fermo"), "square", "fan-control", "setOscillating", { oscillating: false })
|
|
97898
|
+
});
|
|
97899
|
+
if (slice?.direction != null || has$3(ctx, DeviceFeature.FanDirection)) controls.push({
|
|
97900
|
+
kind: "picker",
|
|
97901
|
+
id: "fan.direction",
|
|
97902
|
+
label: t("Direction", "Direzione"),
|
|
97903
|
+
current: slice?.direction ?? null,
|
|
97904
|
+
options: ["forward", "reverse"],
|
|
97905
|
+
call: {
|
|
97906
|
+
cap: "fan-control",
|
|
97907
|
+
method: "setDirection",
|
|
97908
|
+
args: {}
|
|
97909
|
+
},
|
|
97910
|
+
valueArg: "direction"
|
|
97911
|
+
});
|
|
97912
|
+
const speedText = speed === null ? null : pct$1(speed);
|
|
97913
|
+
const preset = slice?.preset ?? "";
|
|
97914
|
+
const status = speed === null ? unknownText : joinText([speed === 0 ? t("Off", "Spento") : t(`Speed ${speed}%`, `Velocità ${speed}%`), preset === "" ? null : t(preset, preset)]);
|
|
97915
|
+
return {
|
|
97916
|
+
reading: reading("fan-control", state),
|
|
97917
|
+
rows: [{
|
|
97918
|
+
id: "fan",
|
|
97919
|
+
icon: "fan",
|
|
97920
|
+
status,
|
|
97921
|
+
controls
|
|
97922
|
+
}],
|
|
97923
|
+
...speedText === null ? {} : {
|
|
97924
|
+
facts: [fact("speed", "fan", speedText, speed === 0 ? "muted" : "primary")],
|
|
97925
|
+
tiles: { right: [{
|
|
97926
|
+
label: t("Speed", "Velocità"),
|
|
97927
|
+
value: speedText
|
|
97928
|
+
}] },
|
|
97929
|
+
scene: { level: unit(speed ?? 0) }
|
|
97930
|
+
}
|
|
97931
|
+
};
|
|
97932
|
+
});
|
|
97933
|
+
var VACUUM_WORDS = {
|
|
97934
|
+
idle: {
|
|
97935
|
+
state: "idle",
|
|
97936
|
+
title: t("Idle", "Inattivo")
|
|
97937
|
+
},
|
|
97938
|
+
cleaning: {
|
|
97939
|
+
state: "running",
|
|
97940
|
+
title: t("Cleaning", "Pulisce")
|
|
97941
|
+
},
|
|
97942
|
+
paused: {
|
|
97943
|
+
state: "standby",
|
|
97944
|
+
title: t("Paused", "In pausa")
|
|
97945
|
+
},
|
|
97946
|
+
returning: {
|
|
97947
|
+
state: "running",
|
|
97948
|
+
title: t("Returning to base", "Torna alla base")
|
|
97949
|
+
},
|
|
97950
|
+
docked: {
|
|
97951
|
+
state: "idle",
|
|
97952
|
+
title: t("Docked", "In base")
|
|
97953
|
+
},
|
|
97954
|
+
drying: {
|
|
97955
|
+
state: "running",
|
|
97956
|
+
title: t("Drying", "Asciuga")
|
|
97957
|
+
},
|
|
97958
|
+
error: {
|
|
97959
|
+
state: "alert",
|
|
97960
|
+
title: t("Error", "Errore")
|
|
97961
|
+
}
|
|
97962
|
+
};
|
|
97963
|
+
function robotAction(cap, prefix, id, en, it, icon, method, primary = false) {
|
|
97964
|
+
return asAction(action(`${prefix}.${id}`, t(en, it), icon, cap, method, {}, primary ? "primary" : "normal"));
|
|
97965
|
+
}
|
|
97966
|
+
var vac = (id, en, it, icon, method, primary = false) => robotAction("vacuum-control", "vacuum", id, en, it, icon, method, primary);
|
|
97967
|
+
function vacuumControls(state) {
|
|
97968
|
+
const start = (primary) => vac("start", "Start", "Avvia", "play", "start", primary);
|
|
97969
|
+
const resume = vac("resume", "Resume", "Riprendi", "play", "start", true);
|
|
97970
|
+
const pause = (primary) => vac("pause", "Pause", "Pausa", "pause", "pause", primary);
|
|
97971
|
+
const base = vac("base", "Return to base", "Torna alla base", "house", "returnToBase");
|
|
97972
|
+
switch (state) {
|
|
97973
|
+
case "cleaning": return [pause(true), base];
|
|
97974
|
+
case "paused": return [resume, base];
|
|
97975
|
+
case "returning":
|
|
97976
|
+
case "drying": return [vac("stop", "Stop", "Ferma", "square", "stop")];
|
|
97977
|
+
case "idle": return [start(true), base];
|
|
97978
|
+
case "docked": return [start(true)];
|
|
97979
|
+
case "error": return [base];
|
|
97980
|
+
case null: return [
|
|
97981
|
+
start(false),
|
|
97982
|
+
pause(false),
|
|
97983
|
+
base
|
|
97984
|
+
];
|
|
97985
|
+
}
|
|
97986
|
+
}
|
|
97987
|
+
var vacuumContribution = contribution("vacuum-control", VacuumControlStatusSchema, (slice, ctx) => {
|
|
97988
|
+
const state = slice?.state ?? null;
|
|
97989
|
+
const words = state === null ? null : VACUUM_WORDS[state];
|
|
97990
|
+
const title = state === "error" && slice?.errorLabel ? t(slice.errorLabel, slice.errorLabel) : words?.title;
|
|
97991
|
+
const controls = vacuumControls(state);
|
|
97992
|
+
if (slice !== void 0 && slice.availableFanSpeeds.length > 0) controls.push({
|
|
97993
|
+
kind: "picker",
|
|
97994
|
+
id: "vacuum.suction",
|
|
97995
|
+
label: t("Suction", "Aspirazione"),
|
|
97996
|
+
current: slice.fanSpeed,
|
|
97997
|
+
options: [...slice.availableFanSpeeds],
|
|
97998
|
+
call: {
|
|
97999
|
+
cap: "vacuum-control",
|
|
98000
|
+
method: "setFanSpeed",
|
|
98001
|
+
args: {}
|
|
98002
|
+
},
|
|
98003
|
+
valueArg: "speed"
|
|
98004
|
+
});
|
|
98005
|
+
if (state !== null) controls.push(vac("locate", "Locate", "Trova", "map-pin", "locate"));
|
|
98006
|
+
const progress = state === "cleaning" ? slice?.progress ?? null : null;
|
|
98007
|
+
return {
|
|
98008
|
+
reading: reading("vacuum-control", words?.state ?? "unknown", false, title),
|
|
98009
|
+
rows: [{
|
|
98010
|
+
id: "vacuum",
|
|
98011
|
+
icon: "bot",
|
|
98012
|
+
status: title ?? unknownText,
|
|
98013
|
+
controls
|
|
98014
|
+
}],
|
|
98015
|
+
facts: [...ownBattery(slice?.batteryLevel ?? null, ctx), ...progress === null ? [] : [fact("progress", "activity", pct$1(progress), "primary")]],
|
|
98016
|
+
...progress === null ? {} : {
|
|
98017
|
+
tiles: { right: [{
|
|
98018
|
+
label: t("Progress", "Avanzamento"),
|
|
98019
|
+
value: pct$1(progress)
|
|
98020
|
+
}] },
|
|
98021
|
+
scene: { level: unit(progress) }
|
|
98022
|
+
}
|
|
98023
|
+
};
|
|
98024
|
+
});
|
|
98025
|
+
var MOWER_WORDS = {
|
|
98026
|
+
idle: {
|
|
98027
|
+
state: "idle",
|
|
98028
|
+
title: t("Idle", "Inattivo")
|
|
98029
|
+
},
|
|
98030
|
+
mowing: {
|
|
98031
|
+
state: "running",
|
|
98032
|
+
title: t("Mowing", "Taglia")
|
|
98033
|
+
},
|
|
98034
|
+
paused: {
|
|
98035
|
+
state: "standby",
|
|
98036
|
+
title: t("Paused", "In pausa")
|
|
98037
|
+
},
|
|
98038
|
+
docked: {
|
|
98039
|
+
state: "idle",
|
|
98040
|
+
title: t("Docked", "In base")
|
|
98041
|
+
},
|
|
98042
|
+
error: {
|
|
98043
|
+
state: "alert",
|
|
98044
|
+
title: t("Error", "Errore")
|
|
98045
|
+
}
|
|
98046
|
+
};
|
|
98047
|
+
var mow = (id, en, it, icon, method, primary = false) => robotAction("lawn-mower-control", "mower", id, en, it, icon, method, primary);
|
|
98048
|
+
function mowerControls(activity) {
|
|
98049
|
+
const start = (primary) => mow("start", "Start mowing", "Avvia il taglio", "play", "startMowing", primary);
|
|
98050
|
+
const pause = (primary) => mow("pause", "Pause", "Pausa", "pause", "pause", primary);
|
|
98051
|
+
const dock = mow("dock", "Return to base", "Torna alla base", "house", "dock");
|
|
98052
|
+
switch (activity) {
|
|
98053
|
+
case "mowing": return [pause(true), dock];
|
|
98054
|
+
case "paused": return [mow("resume", "Resume", "Riprendi", "play", "startMowing", true), dock];
|
|
98055
|
+
case "idle": return [start(true), dock];
|
|
98056
|
+
case "docked": return [start(true)];
|
|
98057
|
+
case "error": return [dock];
|
|
98058
|
+
case null: return [
|
|
98059
|
+
start(false),
|
|
98060
|
+
pause(false),
|
|
98061
|
+
dock
|
|
98062
|
+
];
|
|
98063
|
+
}
|
|
98064
|
+
}
|
|
98065
|
+
var mowerContribution = contribution("lawn-mower-control", LawnMowerControlStatusSchema, (slice, ctx) => {
|
|
98066
|
+
const activity = slice?.activity ?? null;
|
|
98067
|
+
const words = activity === null ? null : MOWER_WORDS[activity];
|
|
98068
|
+
const title = activity === "error" && slice?.currentCodeLabel ? t(slice.currentCodeLabel, slice.currentCodeLabel) : words?.title;
|
|
98069
|
+
const progress = activity === "mowing" ? slice?.progress ?? null : null;
|
|
98070
|
+
return {
|
|
98071
|
+
reading: reading("lawn-mower-control", words?.state ?? "unknown", false, title),
|
|
98072
|
+
rows: [{
|
|
98073
|
+
id: "mower",
|
|
98074
|
+
icon: "sprout",
|
|
98075
|
+
status: title ?? unknownText,
|
|
98076
|
+
controls: mowerControls(activity)
|
|
98077
|
+
}],
|
|
98078
|
+
facts: [...ownBattery(slice?.batteryLevel ?? null, ctx), ...progress === null ? [] : [fact("progress", "activity", pct$1(progress), "primary")]],
|
|
98079
|
+
...progress === null ? {} : {
|
|
98080
|
+
tiles: { right: [{
|
|
98081
|
+
label: t("Progress", "Avanzamento"),
|
|
98082
|
+
value: pct$1(progress)
|
|
98083
|
+
}] },
|
|
98084
|
+
scene: { level: unit(progress) }
|
|
98085
|
+
}
|
|
98086
|
+
};
|
|
98087
|
+
});
|
|
98088
|
+
function feederWords(slice) {
|
|
98089
|
+
if (slice === void 0) return null;
|
|
98090
|
+
if (slice.status === "offline") return {
|
|
98091
|
+
state: "offline",
|
|
98092
|
+
title: t("Offline", "Non raggiungibile")
|
|
98093
|
+
};
|
|
98094
|
+
if (slice.error !== null) return {
|
|
98095
|
+
state: "alert",
|
|
98096
|
+
title: t(slice.error, slice.error)
|
|
98097
|
+
};
|
|
98098
|
+
if (slice.feeding) return {
|
|
98099
|
+
state: "running",
|
|
98100
|
+
title: t("Dispensing", "Eroga")
|
|
98101
|
+
};
|
|
98102
|
+
if (slice.eating) return {
|
|
98103
|
+
state: "running",
|
|
98104
|
+
title: t("Pet is eating", "Sta mangiando")
|
|
98105
|
+
};
|
|
98106
|
+
if (slice.lowFood) return {
|
|
98107
|
+
state: "standby",
|
|
98108
|
+
title: t("Food is low", "Cibo in esaurimento")
|
|
98109
|
+
};
|
|
98110
|
+
return {
|
|
98111
|
+
state: "idle",
|
|
98112
|
+
title: t("Ready", "Pronto")
|
|
98113
|
+
};
|
|
98114
|
+
}
|
|
98115
|
+
/** The manual portion the card offers: the last one given, else the hardware minimum. */
|
|
98116
|
+
function feedArgs(slice) {
|
|
98117
|
+
if (slice.isDualHopper) return {
|
|
98118
|
+
hopper1: slice.lastFeedHopper1 ?? 4,
|
|
98119
|
+
hopper2: slice.lastFeedHopper2 ?? 4
|
|
98120
|
+
};
|
|
98121
|
+
return { grams: slice.lastFeedGrams ?? 4 };
|
|
98122
|
+
}
|
|
98123
|
+
function feederControls(slice) {
|
|
98124
|
+
return [
|
|
98125
|
+
asAction(slice.feeding ? action("feeder.cancel", t("Cancel", "Annulla"), "square", "pet-feeder", "cancelFeed", {}, "primary") : action("feeder.feed", slice.isDualHopper ? t("Feed", "Eroga") : t(`Feed ${slice.lastFeedGrams ?? 4} g`, `Eroga ${slice.lastFeedGrams ?? 4} g`), "bone", "pet-feeder", "feed", feedArgs(slice), "primary")),
|
|
98126
|
+
asAction(action("feeder.call", t("Call pet", "Chiama"), "volume-2", "pet-feeder", "callPet")),
|
|
98127
|
+
{
|
|
98128
|
+
kind: "toggle",
|
|
98129
|
+
id: "feeder.child-lock",
|
|
98130
|
+
label: t("Child lock", "Blocco bambini"),
|
|
98131
|
+
on: slice.childLock,
|
|
98132
|
+
turnOn: action("feeder.child-lock.on", t("Lock", "Blocca"), "lock", "pet-feeder", "setChildLock", { on: true }),
|
|
98133
|
+
turnOff: action("feeder.child-lock.off", t("Unlock", "Sblocca"), "lock-open", "pet-feeder", "setChildLock", { on: false })
|
|
98134
|
+
}
|
|
98135
|
+
];
|
|
98136
|
+
}
|
|
98137
|
+
var feederContribution = contribution("pet-feeder", PetFeederStatusSchema, (slice, ctx) => {
|
|
98138
|
+
const words = feederWords(slice);
|
|
98139
|
+
const last = slice?.lastFeedGrams ?? null;
|
|
98140
|
+
return {
|
|
98141
|
+
reading: reading("pet-feeder", words?.state ?? "unknown", false, words?.title),
|
|
98142
|
+
rows: [{
|
|
98143
|
+
id: "feeder",
|
|
98144
|
+
icon: "bone",
|
|
98145
|
+
status: words?.title ?? unknownText,
|
|
98146
|
+
controls: slice === void 0 ? [] : feederControls(slice)
|
|
98147
|
+
}],
|
|
98148
|
+
facts: [
|
|
98149
|
+
...slice?.lowFood === true ? [fact("level", "bone", t("Food low", "Cibo in esaurimento"), "warning")] : [],
|
|
98150
|
+
...last === null ? [] : [fact("last-run", "clock", t(`Last ${last} g`, `Ultimo ${last} g`))],
|
|
98151
|
+
...ownBattery(slice?.powerSource === "battery" ? slice.batteryPower : null, ctx)
|
|
98152
|
+
],
|
|
98153
|
+
...last === null ? {} : { tiles: { right: [{
|
|
98154
|
+
label: t("Last portion", "Ultima porzione"),
|
|
98155
|
+
value: t(`${last} g`, `${last} g`)
|
|
98156
|
+
}] } }
|
|
98157
|
+
};
|
|
98158
|
+
});
|
|
98159
|
+
var fountainContribution = contribution("pet-fountain", PetFountainStatusSchema, (slice) => {
|
|
98160
|
+
const pump = slice?.pumpRunning ?? null;
|
|
98161
|
+
const fault = slice?.error ?? null;
|
|
98162
|
+
const empty = slice?.empty === true;
|
|
98163
|
+
const state = slice === void 0 ? "unknown" : fault !== null || empty ? "alert" : pump === null ? "unknown" : pump ? "running" : "off";
|
|
98164
|
+
const title = slice === void 0 ? void 0 : fault !== null ? t(fault, fault) : empty ? t("Tank empty", "Serbatoio vuoto") : pump === null ? void 0 : pump ? t("Pump running", "Pompa attiva") : t("Pump off", "Pompa spenta");
|
|
98165
|
+
const level = slice?.waterLevel ?? null;
|
|
98166
|
+
const control = {
|
|
98167
|
+
kind: "toggle",
|
|
98168
|
+
id: "fountain.pump",
|
|
98169
|
+
label: t("Pump", "Pompa"),
|
|
98170
|
+
on: pump,
|
|
98171
|
+
turnOn: action("fountain.pump.on", t("Pump on", "Accendi la pompa"), "droplets", "pet-fountain", "setPump", { on: true }, "primary"),
|
|
98172
|
+
turnOff: action("fountain.pump.off", t("Pump off", "Spegni la pompa"), "square", "pet-fountain", "setPump", { on: false })
|
|
98173
|
+
};
|
|
98174
|
+
return {
|
|
98175
|
+
reading: reading("pet-fountain", state, false, title),
|
|
98176
|
+
rows: [{
|
|
98177
|
+
id: "fountain",
|
|
98178
|
+
icon: "droplets",
|
|
98179
|
+
status: title ?? unknownText,
|
|
98180
|
+
controls: slice === void 0 ? [] : [control]
|
|
98181
|
+
}],
|
|
98182
|
+
...level === null ? {} : {
|
|
98183
|
+
facts: [fact("level", "droplets", t(`Water ${Math.round(level)}%`, `Acqua ${Math.round(level)}%`), level <= 20 ? "warning" : "primary")],
|
|
98184
|
+
tiles: { right: [{
|
|
98185
|
+
label: t("Water", "Acqua"),
|
|
98186
|
+
value: pct$1(level)
|
|
98187
|
+
}] },
|
|
98188
|
+
scene: { level: unit(level) }
|
|
98189
|
+
}
|
|
98190
|
+
};
|
|
98191
|
+
});
|
|
98192
|
+
var minutesOf = (seconds) => Math.max(0, Math.round(seconds / 60));
|
|
98193
|
+
var DEVICES_FAMILY_CONTRIBUTIONS = {
|
|
98194
|
+
"fan-control": fanContribution,
|
|
98195
|
+
"vacuum-control": vacuumContribution,
|
|
98196
|
+
"lawn-mower-control": mowerContribution,
|
|
98197
|
+
"pet-feeder": feederContribution,
|
|
98198
|
+
"pet-fountain": fountainContribution,
|
|
98199
|
+
"pump-cycle": contribution("pump-cycle", PumpCycleStatusSchema, (slice) => {
|
|
98200
|
+
const enabled = slice?.enabled ?? null;
|
|
98201
|
+
const cycle = slice?.onTime != null && slice.offTime != null ? t(`${minutesOf(slice.onTime)} min on · ${minutesOf(slice.offTime)} min off`, `${minutesOf(slice.onTime)} min acceso · ${minutesOf(slice.offTime)} min spento`) : null;
|
|
98202
|
+
return { rows: [row$1("pump-cycle", "timer", enabled === null ? unknownText : enabled ? joinText([t("Cycling", "A cicli"), cycle]) : t("Runs continuously", "Sempre attiva"), [{
|
|
98203
|
+
kind: "toggle",
|
|
98204
|
+
id: "pump-cycle.enabled",
|
|
98205
|
+
label: t("Pump cycle", "Ciclo pompa"),
|
|
98206
|
+
on: enabled,
|
|
98207
|
+
turnOn: action("pump-cycle.on", t("Cycle the pump", "Attiva il ciclo"), "timer", "pump-cycle", "setEnabled", { on: true }),
|
|
98208
|
+
turnOff: action("pump-cycle.off", t("Run continuously", "Sempre attiva"), "timer-off", "pump-cycle", "setEnabled", { on: false })
|
|
98209
|
+
}])] };
|
|
98210
|
+
})
|
|
98211
|
+
};
|
|
98212
|
+
/**
|
|
98213
|
+
* What the moving and dimming caps add to a hero (D1023): a light's brightness
|
|
98214
|
+
* and colour, a cover, a valve and a humidifier. Moving a cover or a valve is
|
|
98215
|
+
* an ACTION the person presses, never a toggle that fires by itself; a slice
|
|
98216
|
+
* that does not parse reads `unknown`, never closed or off (D315/D393).
|
|
98217
|
+
*/
|
|
98218
|
+
var has$2 = (ctx, f) => ctx.features.includes(f);
|
|
98219
|
+
var pct = (n) => t(`${Math.round(n)}%`, `${Math.round(n)}%`);
|
|
98220
|
+
var brightnessContribution = contribution("brightness", BrightnessStatusSchema, (slice) => {
|
|
98221
|
+
const level = slice?.level ?? null;
|
|
98222
|
+
return {
|
|
98223
|
+
...level === null ? {} : { reading: reading("brightness", level > 0 ? "on" : "off") },
|
|
98224
|
+
...level === null ? {} : {
|
|
98225
|
+
facts: [fact("level", "sun-dim", pct(level), level > 0 ? "primary" : "muted")],
|
|
98226
|
+
scene: { level: level / 100 }
|
|
98227
|
+
},
|
|
98228
|
+
rows: [row$1("brightness", "sun-dim", level === null ? null : t(`Brightness ${Math.round(level)}%`, `Luminosità ${Math.round(level)}%`), [{
|
|
98229
|
+
kind: "slider",
|
|
98230
|
+
id: "brightness.level",
|
|
98231
|
+
label: t("Brightness", "Luminosità"),
|
|
98232
|
+
value: level,
|
|
98233
|
+
min: 0,
|
|
98234
|
+
max: 100,
|
|
98235
|
+
step: 1,
|
|
98236
|
+
unit: "%",
|
|
98237
|
+
call: {
|
|
98238
|
+
cap: "brightness",
|
|
98239
|
+
method: "setBrightness",
|
|
98240
|
+
args: {}
|
|
98241
|
+
},
|
|
98242
|
+
valueArg: "level"
|
|
98243
|
+
}])]
|
|
98244
|
+
};
|
|
98245
|
+
});
|
|
98246
|
+
/**
|
|
98247
|
+
* Preset colours as actions: `setColor` takes a nested `{ mode, … }` argument, which a
|
|
98248
|
+
* hero action carries (D1023). Only the modes the bulb declares are offered, each a
|
|
98249
|
+
* valid `setColor` input; a bulb that declares none is shown, not set.
|
|
98250
|
+
*/
|
|
98251
|
+
var WHITE_PRESETS = [
|
|
98252
|
+
{
|
|
98253
|
+
id: "color.warm",
|
|
98254
|
+
en: "Warm white",
|
|
98255
|
+
it: "Bianco caldo",
|
|
98256
|
+
icon: "sun",
|
|
98257
|
+
mired: 370
|
|
98258
|
+
},
|
|
98259
|
+
{
|
|
98260
|
+
id: "color.neutral",
|
|
98261
|
+
en: "Neutral white",
|
|
98262
|
+
it: "Bianco neutro",
|
|
98263
|
+
icon: "lightbulb",
|
|
98264
|
+
mired: 250
|
|
98265
|
+
},
|
|
98266
|
+
{
|
|
98267
|
+
id: "color.cool",
|
|
98268
|
+
en: "Cool white",
|
|
98269
|
+
it: "Bianco freddo",
|
|
98270
|
+
icon: "snowflake",
|
|
98271
|
+
mired: 154
|
|
98272
|
+
}
|
|
98273
|
+
];
|
|
98274
|
+
var HUE_PRESETS = [
|
|
98275
|
+
{
|
|
98276
|
+
id: "color.red",
|
|
98277
|
+
en: "Red",
|
|
98278
|
+
it: "Rosso",
|
|
98279
|
+
hue: 0
|
|
98280
|
+
},
|
|
98281
|
+
{
|
|
98282
|
+
id: "color.amber",
|
|
98283
|
+
en: "Amber",
|
|
98284
|
+
it: "Ambra",
|
|
98285
|
+
hue: 40
|
|
98286
|
+
},
|
|
98287
|
+
{
|
|
98288
|
+
id: "color.green",
|
|
98289
|
+
en: "Green",
|
|
98290
|
+
it: "Verde",
|
|
98291
|
+
hue: 120
|
|
98292
|
+
},
|
|
98293
|
+
{
|
|
98294
|
+
id: "color.cyan",
|
|
98295
|
+
en: "Cyan",
|
|
98296
|
+
it: "Ciano",
|
|
98297
|
+
hue: 180
|
|
98298
|
+
},
|
|
98299
|
+
{
|
|
98300
|
+
id: "color.blue",
|
|
98301
|
+
en: "Blue",
|
|
98302
|
+
it: "Blu",
|
|
98303
|
+
hue: 240
|
|
98304
|
+
},
|
|
98305
|
+
{
|
|
98306
|
+
id: "color.purple",
|
|
98307
|
+
en: "Purple",
|
|
98308
|
+
it: "Viola",
|
|
98309
|
+
hue: 280
|
|
98310
|
+
}
|
|
98311
|
+
];
|
|
98312
|
+
function colorControls(ctx, current) {
|
|
98313
|
+
const controls = [];
|
|
98314
|
+
if (has$2(ctx, DeviceFeature.LightColorMired)) for (const p of WHITE_PRESETS) controls.push(asAction(action(p.id, t(p.en, p.it), p.icon, "color", "setColor", { color: {
|
|
98315
|
+
mode: "mired",
|
|
98316
|
+
colorTemperature: p.mired
|
|
98317
|
+
} })));
|
|
98318
|
+
if (has$2(ctx, DeviceFeature.LightColorHsv)) {
|
|
98319
|
+
const s = current?.s ?? 100;
|
|
98320
|
+
const v = current?.v ?? 100;
|
|
98321
|
+
for (const p of HUE_PRESETS) controls.push(asAction(action(p.id, t(p.en, p.it), "palette", "color", "setColor", { color: {
|
|
98322
|
+
mode: "hsv",
|
|
98323
|
+
hsv: {
|
|
98324
|
+
h: p.hue,
|
|
98325
|
+
s,
|
|
98326
|
+
v
|
|
98327
|
+
}
|
|
98328
|
+
} })));
|
|
98329
|
+
}
|
|
98330
|
+
return controls;
|
|
98331
|
+
}
|
|
98332
|
+
var colorContribution = contribution("color", ColorStatusSchema, (slice, ctx) => {
|
|
98333
|
+
let words = null;
|
|
98334
|
+
if (slice !== void 0) {
|
|
98335
|
+
if (slice.mode === "mired" && slice.colorTemperature !== void 0 && slice.colorTemperature > 0) {
|
|
98336
|
+
const kelvin = Math.round(1e6 / slice.colorTemperature);
|
|
98337
|
+
words = t(`${kelvin} K`, `${kelvin} K`);
|
|
98338
|
+
} else if (slice.mode === "rgb" && slice.rgb !== void 0) {
|
|
98339
|
+
const c = `RGB ${slice.rgb.r}, ${slice.rgb.g}, ${slice.rgb.b}`;
|
|
98340
|
+
words = t(c, c);
|
|
98341
|
+
} else if (slice.mode === "hsv" && slice.hsv !== void 0) words = t(`Hue ${Math.round(slice.hsv.h)}°`, `Tonalità ${Math.round(slice.hsv.h)}°`);
|
|
98342
|
+
}
|
|
98343
|
+
return {
|
|
98344
|
+
...words === null ? {} : { facts: [fact("reading", "palette", words)] },
|
|
98345
|
+
rows: [row$1("color", "palette", words, colorControls(ctx, slice?.mode === "hsv" && slice.hsv !== void 0 ? slice.hsv : null))]
|
|
98346
|
+
};
|
|
98347
|
+
});
|
|
98348
|
+
function travelWords(state, position) {
|
|
98349
|
+
const partial = position !== null && position > 0 && position < 100;
|
|
98350
|
+
const at = position === null ? null : Math.round(position);
|
|
98351
|
+
switch (state) {
|
|
98352
|
+
case "open": return {
|
|
98353
|
+
state: "on",
|
|
98354
|
+
title: partial ? t(`${at}% open`, `Aperto al ${at}%`) : t("Open", "Aperto"),
|
|
98355
|
+
mode: "open"
|
|
98356
|
+
};
|
|
98357
|
+
case "closed": return {
|
|
98358
|
+
state: "off",
|
|
98359
|
+
title: t("Closed", "Chiuso"),
|
|
98360
|
+
mode: "closed"
|
|
98361
|
+
};
|
|
98362
|
+
case "opening": return {
|
|
98363
|
+
state: "running",
|
|
98364
|
+
title: t("Opening", "In apertura"),
|
|
98365
|
+
mode: "open"
|
|
98366
|
+
};
|
|
98367
|
+
case "closing": return {
|
|
98368
|
+
state: "running",
|
|
98369
|
+
title: t("Closing", "In chiusura"),
|
|
98370
|
+
mode: "closed"
|
|
98371
|
+
};
|
|
98372
|
+
case "stopped": return {
|
|
98373
|
+
state: "idle",
|
|
98374
|
+
title: at === null ? t("Stopped", "Fermo") : t(`Stopped at ${at}%`, `Fermo al ${at}%`),
|
|
98375
|
+
mode: position === null ? null : position > 0 ? "open" : "closed"
|
|
98376
|
+
};
|
|
98377
|
+
}
|
|
98378
|
+
}
|
|
98379
|
+
/** Open / stop / close are actions; the one that makes sense next carries the emphasis. */
|
|
98380
|
+
function travelActions(s, state, moving) {
|
|
98381
|
+
const emphasis = (wanted) => wanted ? "primary" : "normal";
|
|
98382
|
+
const open = action(`${s.cap}.open`, t("Open", "Apri"), "arrow-up", s.cap, "open", {}, emphasis(state === "closed" || state === "closing"));
|
|
98383
|
+
const stop = action(`${s.cap}.stop`, t("Stop", "Ferma"), "square", s.cap, "stop", {}, emphasis(moving));
|
|
98384
|
+
const close = action(`${s.cap}.close`, t("Close", "Chiudi"), "arrow-down", s.cap, "close", {}, emphasis(state === "open" || state === "opening"));
|
|
98385
|
+
return s.stoppable || moving ? [
|
|
98386
|
+
open,
|
|
98387
|
+
stop,
|
|
98388
|
+
close
|
|
98389
|
+
] : [open, close];
|
|
98390
|
+
}
|
|
98391
|
+
function positionSlider(s, position) {
|
|
98392
|
+
return {
|
|
98393
|
+
kind: "slider",
|
|
98394
|
+
id: `${s.cap}.position`,
|
|
98395
|
+
label: t("Position", "Posizione"),
|
|
98396
|
+
value: position,
|
|
98397
|
+
min: 0,
|
|
98398
|
+
max: 100,
|
|
98399
|
+
step: 1,
|
|
98400
|
+
unit: "%",
|
|
98401
|
+
call: {
|
|
98402
|
+
cap: s.cap,
|
|
98403
|
+
method: "setPosition",
|
|
98404
|
+
args: {}
|
|
98405
|
+
},
|
|
98406
|
+
valueArg: "position"
|
|
98407
|
+
};
|
|
98408
|
+
}
|
|
98409
|
+
function travelFragment(s, state, position, tilt, ctx) {
|
|
98410
|
+
if (state === void 0) return {
|
|
98411
|
+
reading: reading(s.source, "unknown"),
|
|
98412
|
+
rows: [row$1(s.rowId, "arrow-up", null, travelActions(s, void 0, false).map(asAction))]
|
|
98413
|
+
};
|
|
98414
|
+
const words = travelWords(state, position);
|
|
98415
|
+
const controls = travelActions(s, state, state === "opening" || state === "closing").map(asAction);
|
|
98416
|
+
if (position !== null || s.positionable) controls.push(positionSlider(s, position));
|
|
98417
|
+
if (s.cap === "cover" && (tilt !== null || has$2(ctx, DeviceFeature.CoverTilt))) controls.push({
|
|
98418
|
+
kind: "slider",
|
|
98419
|
+
id: "cover.tilt",
|
|
98420
|
+
label: t("Tilt", "Inclinazione"),
|
|
98421
|
+
value: tilt,
|
|
98422
|
+
min: 0,
|
|
98423
|
+
max: 100,
|
|
98424
|
+
step: 1,
|
|
98425
|
+
unit: "%",
|
|
98426
|
+
call: {
|
|
98427
|
+
cap: "cover",
|
|
98428
|
+
method: "setTiltPosition",
|
|
98429
|
+
args: {}
|
|
98430
|
+
},
|
|
98431
|
+
valueArg: "tiltPosition"
|
|
98432
|
+
});
|
|
98433
|
+
return {
|
|
98434
|
+
reading: reading(s.source, words.state, false, words.title),
|
|
98435
|
+
...position === null ? {} : { facts: [fact("level", "arrow-up-down", pct(position))] },
|
|
98436
|
+
scene: {
|
|
98437
|
+
...words.mode === null ? {} : { mode: words.mode },
|
|
98438
|
+
...position === null ? {} : { level: position / 100 }
|
|
98439
|
+
},
|
|
98440
|
+
rows: [row$1(s.rowId, "arrow-up-down", joinText([words.title, position !== null && state !== "open" ? pct(position) : null]), controls)]
|
|
98441
|
+
};
|
|
98442
|
+
}
|
|
98443
|
+
var ACTUATORS_FAMILY_CONTRIBUTIONS = {
|
|
98444
|
+
brightness: brightnessContribution,
|
|
98445
|
+
color: colorContribution,
|
|
98446
|
+
cover: contribution("cover", CoverStatusSchema, (slice, ctx) => travelFragment({
|
|
98447
|
+
cap: "cover",
|
|
98448
|
+
rowId: "cover",
|
|
98449
|
+
source: "cover",
|
|
98450
|
+
stoppable: has$2(ctx, DeviceFeature.CoverStoppable),
|
|
98451
|
+
positionable: has$2(ctx, DeviceFeature.CoverPositionable)
|
|
98452
|
+
}, slice?.state, slice?.position ?? null, slice?.tiltPosition ?? null, ctx)),
|
|
98453
|
+
valve: contribution("valve", ValveStatusSchema, (slice, ctx) => travelFragment({
|
|
98454
|
+
cap: "valve",
|
|
98455
|
+
rowId: "valve",
|
|
98456
|
+
source: "valve",
|
|
98457
|
+
stoppable: false,
|
|
98458
|
+
positionable: has$2(ctx, DeviceFeature.ValvePositionable)
|
|
98459
|
+
}, slice?.state, slice?.position ?? null, null, ctx)),
|
|
98460
|
+
humidifier: contribution("humidifier", HumidifierStatusSchema, (slice) => {
|
|
98461
|
+
if (slice === void 0) return { reading: reading("humidifier", "unknown") };
|
|
98462
|
+
const action_ = slice.action;
|
|
98463
|
+
let state = "off";
|
|
98464
|
+
let title = t("Off", "Spento");
|
|
98465
|
+
if (slice.on) if (action_ === "humidifying") {
|
|
98466
|
+
state = "running";
|
|
98467
|
+
title = t("Humidifying", "Umidifica");
|
|
98468
|
+
} else if (action_ === "drying") {
|
|
98469
|
+
state = "running";
|
|
98470
|
+
title = t("Drying", "Deumidifica");
|
|
98471
|
+
} else if (action_ === "idle") {
|
|
98472
|
+
state = "idle";
|
|
98473
|
+
title = t("Idle", "In attesa");
|
|
98474
|
+
} else {
|
|
98475
|
+
state = "on";
|
|
98476
|
+
title = t("On", "Acceso");
|
|
98477
|
+
}
|
|
98478
|
+
const controls = [{
|
|
98479
|
+
kind: "toggle",
|
|
98480
|
+
id: "humidifier.power",
|
|
98481
|
+
label: t("Power", "Accensione"),
|
|
98482
|
+
on: slice.on,
|
|
98483
|
+
turnOn: action("humidifier.on", t("Turn on", "Accendi"), "power", "humidifier", "setOn", { on: true }),
|
|
98484
|
+
turnOff: action("humidifier.off", t("Turn off", "Spegni"), "power-off", "humidifier", "setOn", { on: false })
|
|
98485
|
+
}];
|
|
98486
|
+
if (slice.targetHumidity !== null) controls.push({
|
|
98487
|
+
kind: "slider",
|
|
98488
|
+
id: "humidifier.target",
|
|
98489
|
+
label: t("Target", "Obiettivo"),
|
|
98490
|
+
value: slice.targetHumidity,
|
|
98491
|
+
min: slice.minHumidity ?? 0,
|
|
98492
|
+
max: slice.maxHumidity ?? 100,
|
|
98493
|
+
step: 1,
|
|
98494
|
+
unit: "%",
|
|
98495
|
+
call: {
|
|
98496
|
+
cap: "humidifier",
|
|
98497
|
+
method: "setTargetHumidity",
|
|
98498
|
+
args: {}
|
|
98499
|
+
},
|
|
98500
|
+
valueArg: "humidity"
|
|
98501
|
+
});
|
|
98502
|
+
if (slice.availableModes.length > 0) controls.push({
|
|
98503
|
+
kind: "picker",
|
|
98504
|
+
id: "humidifier.mode",
|
|
98505
|
+
label: t("Mode", "Modalità"),
|
|
98506
|
+
current: slice.mode,
|
|
98507
|
+
options: [...slice.availableModes],
|
|
98508
|
+
call: {
|
|
98509
|
+
cap: "humidifier",
|
|
98510
|
+
method: "setMode",
|
|
98511
|
+
args: {}
|
|
98512
|
+
},
|
|
98513
|
+
valueArg: "mode"
|
|
98514
|
+
});
|
|
98515
|
+
const now = slice.currentHumidity;
|
|
98516
|
+
return {
|
|
98517
|
+
reading: reading("humidifier", state, false, title),
|
|
98518
|
+
...now === null ? {} : { facts: [fact("level", "droplets", pct(now), "info")] },
|
|
98519
|
+
...slice.targetHumidity === null ? {} : { tiles: { right: [{
|
|
98520
|
+
label: t("Target", "Obiettivo"),
|
|
98521
|
+
value: pct(slice.targetHumidity)
|
|
98522
|
+
}] } },
|
|
98523
|
+
...now === null ? {} : { scene: { level: now / 100 } },
|
|
98524
|
+
rows: [row$1("humidifier", "droplets", joinText([title, slice.mode === null ? null : t(slice.mode, slice.mode)]), controls)]
|
|
98525
|
+
};
|
|
98526
|
+
})
|
|
98527
|
+
};
|
|
98528
|
+
var GROUPS_FAMILY_CONTRIBUTIONS = {
|
|
98529
|
+
"group-active": contribution("group-active", GroupActiveSchema, (slice) => {
|
|
98530
|
+
if (slice === void 0) return { reading: reading("group-active", "unknown") };
|
|
98531
|
+
return { reading: reading("group-active", slice.active ? "on" : "off", false, slice.active ? t("Active", "Attivo") : t("Inactive", "Non attivo")) };
|
|
98532
|
+
}),
|
|
98533
|
+
"group-status": contribution("group-status", GroupStatusSchema, (slice) => {
|
|
98534
|
+
if (slice === void 0) return {};
|
|
98535
|
+
const text = slice.excluded === 0 ? t(`${slice.total} members`, `${slice.total} membri`) : t(`${slice.included} of ${slice.total} reporting`, `${slice.included} di ${slice.total} rispondono`);
|
|
98536
|
+
return {
|
|
98537
|
+
facts: [fact("members", "users", text, slice.excluded === 0 ? "muted" : "warning")],
|
|
98538
|
+
tiles: { left: [{
|
|
98539
|
+
label: t("Members", "Membri"),
|
|
98540
|
+
value: text
|
|
98541
|
+
}] }
|
|
98542
|
+
};
|
|
98543
|
+
}),
|
|
98544
|
+
"group-commands": contribution("group-commands", GroupCommandsSchema, (slice) => {
|
|
98545
|
+
if (slice === void 0) return {};
|
|
98546
|
+
const failed = slice.results.filter((r) => !r.ok).length;
|
|
98547
|
+
if (failed === 0) return {};
|
|
98548
|
+
const total = slice.results.length;
|
|
98549
|
+
return { facts: [fact("failures", "triangle-alert", t(`${failed} of ${total} failed`, `${failed} di ${total} falliti`), "danger")] };
|
|
98550
|
+
}),
|
|
98551
|
+
"event-emitter": contribution("event-emitter", EventEmitterStatusSchema, (slice, ctx) => {
|
|
98552
|
+
if (slice === void 0) return { reading: reading("event-emitter", "unknown") };
|
|
98553
|
+
const last = slice.lastEvent;
|
|
98554
|
+
const ago = last === null ? null : elapsedText(last.timestamp, ctx.now);
|
|
98555
|
+
return {
|
|
98556
|
+
reading: reading("event-emitter", "idle", false, t("Listening", "In ascolto")),
|
|
98557
|
+
...last === null ? {} : { facts: [fact("event", "radio-tower", ago === null ? t(last.eventType, last.eventType) : t(`${last.eventType} · ${ago.en}`, `${last.eventType} · ${ago.it}`), "primary")] },
|
|
98558
|
+
tiles: { right: [{
|
|
98559
|
+
label: t("Events", "Eventi"),
|
|
98560
|
+
value: t(`${slice.eventCountSinceStart}`, `${slice.eventCountSinceStart}`)
|
|
98561
|
+
}] }
|
|
98562
|
+
};
|
|
98563
|
+
})
|
|
98564
|
+
};
|
|
98565
|
+
/**
|
|
98566
|
+
* What the sensing caps add to a hero (D1023): the alarm sensors (smoke, flood,
|
|
98567
|
+
* gas, tamper, vibration), motion, presence, the doorbell, the generic binary
|
|
98568
|
+
* and meter, the weather station, a firmware update, an image and the two
|
|
98569
|
+
* caps a person acts on directly (a button, a control).
|
|
98570
|
+
*
|
|
98571
|
+
* A sensor's title is its READING ("Clear" / "Detected"), never a power word:
|
|
98572
|
+
* the generic On / Off belong to something that can be switched. A slice that
|
|
98573
|
+
* does not parse is "not answered" and reads `unknown`, never clear (D315/D393);
|
|
98574
|
+
* a measurement the device did not report is absent, never a zero (D393).
|
|
98575
|
+
*/
|
|
98576
|
+
/** The recency of a transition as the top line's "since" fact; absent when never observed. */
|
|
98577
|
+
function sinceFact(at, now, tone = "muted") {
|
|
98578
|
+
if (at === null) return [];
|
|
98579
|
+
const ago = elapsedText(at, now);
|
|
98580
|
+
return ago === null ? [] : [fact("since", "clock", ago, tone)];
|
|
98581
|
+
}
|
|
98582
|
+
function detection(spec) {
|
|
98583
|
+
return contribution(spec.cap, spec.schema, (slice, ctx) => {
|
|
98584
|
+
if (slice === void 0) return { reading: reading(spec.source, "unknown") };
|
|
98585
|
+
const tripped = spec.flag(slice);
|
|
98586
|
+
const changed = spec.changedAt(slice);
|
|
98587
|
+
return {
|
|
98588
|
+
reading: reading(spec.source, tripped ? spec.yesState : "idle", false, tripped ? spec.words.yes : spec.words.no),
|
|
98589
|
+
facts: sinceFact(changed === 0 ? null : changed, ctx.now, tripped ? "danger" : "muted")
|
|
98590
|
+
};
|
|
98591
|
+
});
|
|
98592
|
+
}
|
|
98593
|
+
var detected = {
|
|
98594
|
+
yes: t("Detected", "Rilevato"),
|
|
98595
|
+
no: t("Clear", "Libero")
|
|
98596
|
+
};
|
|
98597
|
+
var smokeContribution = detection({
|
|
98598
|
+
cap: "smoke",
|
|
98599
|
+
source: "smoke",
|
|
98600
|
+
schema: SmokeStatusSchema,
|
|
98601
|
+
words: {
|
|
98602
|
+
yes: t("Smoke detected", "Fumo rilevato"),
|
|
98603
|
+
no: t("Clear", "Nessun fumo")
|
|
98604
|
+
},
|
|
98605
|
+
yesState: "alert",
|
|
98606
|
+
flag: (s) => s.detected,
|
|
98607
|
+
changedAt: (s) => s.lastChangedAt
|
|
98608
|
+
});
|
|
98609
|
+
var floodContribution = detection({
|
|
98610
|
+
cap: "flood",
|
|
98611
|
+
source: "flood",
|
|
98612
|
+
schema: FloodStatusSchema,
|
|
98613
|
+
words: {
|
|
98614
|
+
yes: t("Leak detected", "Perdita rilevata"),
|
|
98615
|
+
no: t("Dry", "Asciutto")
|
|
98616
|
+
},
|
|
98617
|
+
yesState: "alert",
|
|
98618
|
+
flag: (s) => s.flooded,
|
|
98619
|
+
changedAt: (s) => s.lastChangedAt
|
|
98620
|
+
});
|
|
98621
|
+
var gasContribution = detection({
|
|
98622
|
+
cap: "gas",
|
|
98623
|
+
source: "gas",
|
|
98624
|
+
schema: GasStatusSchema,
|
|
98625
|
+
words: {
|
|
98626
|
+
yes: t("Gas detected", "Gas rilevato"),
|
|
98627
|
+
no: t("Clear", "Nessun gas")
|
|
98628
|
+
},
|
|
98629
|
+
yesState: "alert",
|
|
98630
|
+
flag: (s) => s.detected,
|
|
98631
|
+
changedAt: (s) => s.lastChangedAt
|
|
98632
|
+
});
|
|
98633
|
+
var tamperContribution = detection({
|
|
98634
|
+
cap: "tamper",
|
|
98635
|
+
source: "tamper",
|
|
98636
|
+
schema: TamperStatusSchema,
|
|
98637
|
+
words: {
|
|
98638
|
+
yes: t("Tampered", "Manomesso"),
|
|
98639
|
+
no: t("Secure", "Integro")
|
|
98640
|
+
},
|
|
98641
|
+
yesState: "alert",
|
|
98642
|
+
flag: (s) => s.tampered,
|
|
98643
|
+
changedAt: (s) => s.lastChangedAt
|
|
98644
|
+
});
|
|
98645
|
+
var vibrationContribution = detection({
|
|
98646
|
+
cap: "vibration",
|
|
98647
|
+
source: "vibration",
|
|
98648
|
+
schema: VibrationStatusSchema,
|
|
98649
|
+
words: {
|
|
98650
|
+
yes: t("Vibration", "Vibrazione"),
|
|
98651
|
+
no: t("Still", "Fermo")
|
|
98652
|
+
},
|
|
98653
|
+
yesState: "on",
|
|
98654
|
+
flag: (s) => s.detected,
|
|
98655
|
+
changedAt: (s) => s.lastChangedAt
|
|
98656
|
+
});
|
|
98657
|
+
var binaryContribution = detection({
|
|
98658
|
+
cap: "binary",
|
|
98659
|
+
source: "binary",
|
|
98660
|
+
schema: BinaryStatusSchema,
|
|
98661
|
+
words: {
|
|
98662
|
+
yes: t("Active", "Attivo"),
|
|
98663
|
+
no: t("Inactive", "Inattivo")
|
|
98664
|
+
},
|
|
98665
|
+
yesState: "on",
|
|
98666
|
+
flag: (s) => s.on,
|
|
98667
|
+
changedAt: (s) => s.lastChangedAt
|
|
98668
|
+
});
|
|
98669
|
+
var motionContribution = contribution("motion", MotionStatusSchema, (slice, ctx) => {
|
|
98670
|
+
if (slice === void 0) return { reading: reading("motion", "unknown") };
|
|
98671
|
+
const last = slice.lastDetectedAt;
|
|
98672
|
+
const ago = last === null ? null : elapsedText(last, ctx.now);
|
|
98673
|
+
return {
|
|
98674
|
+
reading: reading("motion", slice.detected ? "on" : "idle", false, slice.detected ? detected.yes : t("Clear", "Nessun movimento")),
|
|
98675
|
+
...ago === null ? {} : { facts: [fact("since", "clock", t(`Last motion ${ago.en}`, `Ultimo movimento ${ago.it}`), slice.detected ? "primary" : "muted")] }
|
|
98676
|
+
};
|
|
98677
|
+
});
|
|
98678
|
+
var presenceContribution = contribution("presence", PresenceStatusSchema, (slice, ctx) => {
|
|
98679
|
+
if (slice === void 0) return { reading: reading("presence", "unknown") };
|
|
98680
|
+
const zone = slice.state;
|
|
98681
|
+
const home = zone === "home";
|
|
98682
|
+
const away = zone === "not_home";
|
|
98683
|
+
const title = home ? t("Home", "A casa") : away ? t("Away", "Fuori casa") : t(zone, zone);
|
|
98684
|
+
const facts = [];
|
|
98685
|
+
if (slice.location !== null && slice.location !== "") facts.push(fact("reading", "map-pin", t(slice.location, slice.location)));
|
|
98686
|
+
facts.push(...sinceFact(slice.lastChangedAt === 0 ? null : slice.lastChangedAt, ctx.now));
|
|
98687
|
+
return {
|
|
98688
|
+
reading: reading("presence", away ? "off" : "on", false, title),
|
|
98689
|
+
facts
|
|
98690
|
+
};
|
|
98691
|
+
});
|
|
98692
|
+
/** A ring this recent still reads as "ringing". */
|
|
98693
|
+
var RINGING_MS = 3e4;
|
|
98694
|
+
var doorbellContribution = contribution("doorbell", DoorbellStatusSchema, (slice, ctx) => {
|
|
98695
|
+
if (slice === void 0) return { reading: reading("doorbell", "unknown") };
|
|
98696
|
+
const last = slice.lastPressedAt;
|
|
98697
|
+
const ago = last === null ? null : elapsedText(last, ctx.now);
|
|
98698
|
+
const ringing = last !== null && ctx.now >= last && ctx.now - last < RINGING_MS;
|
|
98699
|
+
const title = ringing ? t("Ringing", "Suona") : ago === null ? t("No ring yet", "Nessun squillo") : t(`Last ring ${ago.en}`, `Ultimo squillo ${ago.it}`);
|
|
98700
|
+
const count = slice.pressCountSinceStart;
|
|
98701
|
+
return {
|
|
98702
|
+
...ctx.caps.includes("motion") && !ringing ? {} : { reading: reading("doorbell", ringing ? "on" : "idle", false, title) },
|
|
98703
|
+
facts: [...ctx.caps.includes("motion") && !ringing ? [fact("event", "bell", title)] : [], ...count > 0 ? [fact("event", "bell-ring", t(`${count} ring${count === 1 ? "" : "s"}`, `${count} squilli`))] : []]
|
|
98704
|
+
};
|
|
98705
|
+
});
|
|
98706
|
+
var number = (n) => `${Number(n.toFixed(2))}`;
|
|
98707
|
+
var meterContribution = contribution("meter", MeterStatusSchema, (slice, ctx) => {
|
|
98708
|
+
if (slice === void 0 || slice.value === null) return { reading: reading("meter", "unknown") };
|
|
98709
|
+
const value = number(slice.value);
|
|
98710
|
+
return {
|
|
98711
|
+
reading: reading("meter", "idle", false, t(value, value)),
|
|
98712
|
+
facts: sinceFact(slice.lastFetchedAt === 0 ? null : slice.lastFetchedAt, ctx.now)
|
|
98713
|
+
};
|
|
98714
|
+
});
|
|
98715
|
+
var CONDITION_WORDS = {
|
|
98716
|
+
sunny: t("Sunny", "Soleggiato"),
|
|
98717
|
+
"clear-night": t("Clear night", "Notte serena"),
|
|
98718
|
+
cloudy: t("Cloudy", "Nuvoloso"),
|
|
98719
|
+
partlycloudy: t("Partly cloudy", "Parzialmente nuvoloso"),
|
|
98720
|
+
rainy: t("Rain", "Pioggia"),
|
|
98721
|
+
pouring: t("Heavy rain", "Pioggia forte"),
|
|
98722
|
+
snowy: t("Snow", "Neve"),
|
|
98723
|
+
"snowy-rainy": t("Sleet", "Nevischio"),
|
|
98724
|
+
fog: t("Fog", "Nebbia"),
|
|
98725
|
+
windy: t("Windy", "Ventoso"),
|
|
98726
|
+
"windy-variant": t("Windy", "Ventoso"),
|
|
98727
|
+
lightning: t("Thunderstorm", "Temporale"),
|
|
98728
|
+
"lightning-rainy": t("Thunderstorm", "Temporale"),
|
|
98729
|
+
hail: t("Hail", "Grandine"),
|
|
98730
|
+
exceptional: t("Exceptional", "Eccezionale")
|
|
98731
|
+
};
|
|
98732
|
+
var weatherContribution = contribution("weather", WeatherStatusSchema, (slice, ctx) => {
|
|
98733
|
+
if (slice === void 0) return { reading: reading("weather", "unknown") };
|
|
98734
|
+
const { condition, temperature, humidity, pressure, windSpeed } = slice;
|
|
98735
|
+
const celsius = temperature === null ? null : `${number(temperature)}°C`;
|
|
98736
|
+
const word = condition === null ? null : CONDITION_WORDS[condition] ?? t(condition, condition);
|
|
98737
|
+
const title = word ?? (celsius === null ? null : t(celsius, celsius));
|
|
98738
|
+
if (title === null) return { reading: reading("weather", "unknown") };
|
|
98739
|
+
const facts = [];
|
|
98740
|
+
if (celsius !== null && word !== null) facts.push(fact("reading", "thermometer", t(celsius, celsius), "primary"));
|
|
98741
|
+
if (humidity !== null) facts.push(fact("reading", "droplets", t(`${Math.round(humidity)}%`, `${Math.round(humidity)}%`)));
|
|
98742
|
+
if (windSpeed !== null) facts.push(fact("reading", "wind", t(`${number(windSpeed)} m/s`, `${number(windSpeed)} m/s`)));
|
|
98743
|
+
if (pressure !== null) facts.push(fact("reading", "gauge", t(`${Math.round(pressure)} hPa`, `${Math.round(pressure)} hPa`)));
|
|
98744
|
+
facts.push(...sinceFact(slice.lastFetchedAt === 0 ? null : slice.lastFetchedAt, ctx.now));
|
|
98745
|
+
const left = [];
|
|
98746
|
+
if (humidity !== null) left.push({
|
|
98747
|
+
label: t("Humidity", "Umidità"),
|
|
98748
|
+
value: t(`${Math.round(humidity)}%`, `${Math.round(humidity)}%`)
|
|
98749
|
+
});
|
|
98750
|
+
if (pressure !== null) left.push({
|
|
98751
|
+
label: t("Pressure", "Pressione"),
|
|
98752
|
+
value: t(`${Math.round(pressure)} hPa`, `${Math.round(pressure)} hPa`)
|
|
98753
|
+
});
|
|
98754
|
+
const right = windSpeed === null ? [] : [{
|
|
98755
|
+
label: t("Wind", "Vento"),
|
|
98756
|
+
value: t(`${number(windSpeed)} m/s`, `${number(windSpeed)} m/s`)
|
|
98757
|
+
}];
|
|
98758
|
+
return {
|
|
98759
|
+
reading: reading("weather", "on", false, title),
|
|
98760
|
+
facts,
|
|
98761
|
+
tiles: {
|
|
98762
|
+
left,
|
|
98763
|
+
right
|
|
98764
|
+
}
|
|
98765
|
+
};
|
|
98766
|
+
});
|
|
98767
|
+
var updateContribution = contribution("update", UpdateStatusSchema, (slice) => {
|
|
98768
|
+
if (slice === void 0) return { reading: reading("update", "unknown") };
|
|
98769
|
+
const { currentVersion, availableVersion, inProgress, updatable } = slice;
|
|
98770
|
+
const pending = availableVersion !== null && availableVersion !== "" && availableVersion !== currentVersion;
|
|
98771
|
+
if (!pending && currentVersion === null && !inProgress) return { reading: reading("update", "unknown") };
|
|
98772
|
+
const state = inProgress ? "running" : pending ? "standby" : "idle";
|
|
98773
|
+
const title = inProgress ? t("Updating", "Aggiornamento in corso") : pending ? t("Update available", "Aggiornamento disponibile") : t("Up to date", "Aggiornato");
|
|
98774
|
+
const versions = currentVersion === null ? pending ? t(`${availableVersion}`, `${availableVersion}`) : null : pending ? t(`${currentVersion} → ${availableVersion}`, `${currentVersion} → ${availableVersion}`) : t(`Version ${currentVersion}`, `Versione ${currentVersion}`);
|
|
98775
|
+
const install = pending && updatable && !inProgress ? [asAction(action("update.install", t("Install", "Installa"), "download", "update", "installUpdate", {}, "primary", "install"))] : [];
|
|
98776
|
+
return {
|
|
98777
|
+
reading: reading("update", state, false, title),
|
|
98778
|
+
facts: versions === null ? [] : [fact("reading", "download", versions, pending ? "warning" : "muted")],
|
|
98779
|
+
rows: [row$1("update", "download", versions, install)]
|
|
98780
|
+
};
|
|
98781
|
+
});
|
|
98782
|
+
var imageContribution = contribution("image", ImageStatusSchema, (slice, ctx) => {
|
|
98783
|
+
if (slice === void 0) return { reading: reading("image", "unknown") };
|
|
98784
|
+
if (slice.url === null) return { reading: reading("image", "idle", false, t("No image yet", "Nessuna immagine")) };
|
|
98785
|
+
const ago = slice.lastUpdated === null ? null : elapsedText(slice.lastUpdated, ctx.now);
|
|
98786
|
+
return {
|
|
98787
|
+
reading: reading("image", "on", false, ago === null ? t("Image", "Immagine") : t(`Updated ${ago.en}`, `Aggiornata ${ago.it}`)),
|
|
98788
|
+
artworkUrl: slice.url
|
|
98789
|
+
};
|
|
98790
|
+
});
|
|
98791
|
+
/** A button has no state to read: it is always ready, so it is never `unknown`. */
|
|
98792
|
+
var buttonContribution = {
|
|
98793
|
+
cap: "button",
|
|
98794
|
+
contribute: () => ({
|
|
98795
|
+
reading: reading("button", "idle", false, t("Ready", "Pronto")),
|
|
98796
|
+
rows: [row$1("button", "pointer", null, [asAction(action("button.press", t("Press", "Premi"), "pointer", "button", "press", {}, "primary", "press"))])]
|
|
98797
|
+
})
|
|
98798
|
+
};
|
|
98799
|
+
var controlContribution = contribution("control", ControlStatusSchema, (slice, ctx) => {
|
|
98800
|
+
if (slice === void 0) return { reading: reading("control", "unknown") };
|
|
98801
|
+
const text = typeof slice.value === "number" ? number(slice.value) : slice.value;
|
|
98802
|
+
return {
|
|
98803
|
+
reading: reading("control", "on", false, t(text, text)),
|
|
98804
|
+
facts: sinceFact(slice.lastChangedAt === 0 ? null : slice.lastChangedAt, ctx.now),
|
|
98805
|
+
rows: controlRows(slice)
|
|
98806
|
+
};
|
|
98807
|
+
});
|
|
98808
|
+
var CONTROL_LABEL = t("Value", "Valore");
|
|
98809
|
+
/** A number with known bounds is a slider, a choice a picker; text and dates stay read-only. */
|
|
98810
|
+
function controlRows(slice) {
|
|
98811
|
+
if (slice.kind === "numeric" && typeof slice.value === "number") {
|
|
98812
|
+
if (slice.min === void 0 || slice.max === void 0) return [];
|
|
98813
|
+
return [row$1("control", "sliders-horizontal", null, [{
|
|
98814
|
+
kind: "slider",
|
|
98815
|
+
id: "control.value",
|
|
98816
|
+
label: CONTROL_LABEL,
|
|
98817
|
+
value: slice.value,
|
|
98818
|
+
min: slice.min,
|
|
98819
|
+
max: slice.max,
|
|
98820
|
+
step: slice.step ?? 1,
|
|
98821
|
+
unit: "",
|
|
98822
|
+
call: {
|
|
98823
|
+
cap: "control",
|
|
98824
|
+
method: "setValue",
|
|
98825
|
+
args: { control: { kind: "numeric" } }
|
|
98826
|
+
},
|
|
98827
|
+
valueArg: "control.value"
|
|
98828
|
+
}])];
|
|
98829
|
+
}
|
|
98830
|
+
if (slice.kind === "select" && typeof slice.value === "string") return [row$1("control", "sliders-horizontal", null, [{
|
|
98831
|
+
kind: "picker",
|
|
98832
|
+
id: "control.value",
|
|
98833
|
+
label: CONTROL_LABEL,
|
|
98834
|
+
current: slice.value,
|
|
98835
|
+
options: slice.options,
|
|
98836
|
+
call: {
|
|
98837
|
+
cap: "control",
|
|
98838
|
+
method: "setValue",
|
|
98839
|
+
args: { control: { kind: "select" } }
|
|
98840
|
+
},
|
|
98841
|
+
valueArg: "control.value"
|
|
98842
|
+
}])];
|
|
98843
|
+
return [];
|
|
98844
|
+
}
|
|
98845
|
+
var SENSORS_FAMILY_CONTRIBUTIONS = {
|
|
98846
|
+
smoke: smokeContribution,
|
|
98847
|
+
flood: floodContribution,
|
|
98848
|
+
gas: gasContribution,
|
|
98849
|
+
tamper: tamperContribution,
|
|
98850
|
+
vibration: vibrationContribution,
|
|
98851
|
+
binary: binaryContribution,
|
|
98852
|
+
motion: motionContribution,
|
|
98853
|
+
presence: presenceContribution,
|
|
98854
|
+
doorbell: doorbellContribution,
|
|
98855
|
+
meter: meterContribution,
|
|
98856
|
+
weather: weatherContribution,
|
|
98857
|
+
update: updateContribution,
|
|
98858
|
+
image: imageContribution,
|
|
98859
|
+
button: buttonContribution,
|
|
98860
|
+
control: controlContribution
|
|
98861
|
+
};
|
|
98862
|
+
var MODE_LABEL = {
|
|
98863
|
+
off: t("Off", "Spento"),
|
|
98864
|
+
heat: t("Heating", "Riscalda"),
|
|
98865
|
+
cool: t("Cooling", "Freddo"),
|
|
98866
|
+
auto: t("Auto", "Auto"),
|
|
98867
|
+
heat_cool: t("Heat/Cool", "Caldo/Freddo"),
|
|
98868
|
+
fan_only: t("Fan only", "Solo ventola"),
|
|
98869
|
+
dry: t("Drying", "Deumidifica")
|
|
98870
|
+
};
|
|
98871
|
+
var SCENE_MODE = {
|
|
98872
|
+
off: null,
|
|
98873
|
+
heat: "heat",
|
|
98874
|
+
cool: "cool",
|
|
98875
|
+
auto: "auto",
|
|
98876
|
+
heat_cool: "auto",
|
|
98877
|
+
fan_only: "fan",
|
|
98878
|
+
dry: "dry"
|
|
98879
|
+
};
|
|
98880
|
+
/** Without a remembered mode, "turn on" picks the first of these the device accepts. */
|
|
98881
|
+
var ON_MODE_PREFERENCE = [
|
|
98882
|
+
"auto",
|
|
98883
|
+
"heat_cool",
|
|
98884
|
+
"heat",
|
|
98885
|
+
"cool"
|
|
98886
|
+
];
|
|
98887
|
+
/** 22 -> "22", 22.3 -> "22.3": a trailing zero is noise on a thermostat. */
|
|
98888
|
+
function formatDegrees(value) {
|
|
98889
|
+
return `${Number(value.toFixed(1))}°`;
|
|
98890
|
+
}
|
|
98891
|
+
/** "Turn on" returns to the mode the device last ran when it still accepts it, else the fixed order. */
|
|
98892
|
+
function onModeOf(available, last) {
|
|
98893
|
+
const candidates = available.filter((m) => m !== "off");
|
|
98894
|
+
if (last !== void 0 && candidates.includes(last)) return last;
|
|
98895
|
+
for (const preferred of ON_MODE_PREFERENCE) if (candidates.includes(preferred)) return preferred;
|
|
98896
|
+
return candidates[0] ?? null;
|
|
98897
|
+
}
|
|
98898
|
+
function deriveClimateView(slice) {
|
|
98899
|
+
const range = rangeFrom(slice.minTemp, slice.maxTemp, slice.tempStep);
|
|
98900
|
+
const level = levelWithin(slice.target, range);
|
|
98901
|
+
return {
|
|
98902
|
+
mode: slice.mode,
|
|
98903
|
+
isOff: slice.mode === "off",
|
|
98904
|
+
modeLabel: MODE_LABEL[slice.mode],
|
|
98905
|
+
target: slice.target,
|
|
98906
|
+
measured: slice.currentTemp,
|
|
98907
|
+
targetRange: slice.targetLow !== null && slice.targetHigh !== null ? {
|
|
98908
|
+
low: slice.targetLow,
|
|
98909
|
+
high: slice.targetHigh
|
|
98910
|
+
} : null,
|
|
98911
|
+
targetHumidity: slice.targetHumidity,
|
|
98912
|
+
humidity: slice.currentHumidity,
|
|
98913
|
+
range,
|
|
98914
|
+
availableModes: slice.availableModes,
|
|
98915
|
+
sceneMode: SCENE_MODE[slice.mode],
|
|
98916
|
+
level,
|
|
98917
|
+
onMode: onModeOf(slice.availableModes, slice.lastActiveMode)
|
|
98918
|
+
};
|
|
98919
|
+
}
|
|
98920
|
+
/** "22° (22.3°)": the setpoint and, in brackets, what is measured. The mode is the headline, not repeated here. */
|
|
98921
|
+
function thermalStatusText(target, measured) {
|
|
98922
|
+
const goal = target === null ? "" : typeof target === "string" ? target : formatDegrees(target);
|
|
98923
|
+
const now = measured === null ? "" : formatDegrees(measured);
|
|
98924
|
+
const temps = goal !== "" && now !== "" ? `${goal} (${now})` : goal !== "" ? goal : now;
|
|
98925
|
+
return temps === "" ? null : t(temps, temps);
|
|
98926
|
+
}
|
|
98927
|
+
function climateStatusText(view) {
|
|
98928
|
+
const range = view.targetRange;
|
|
98929
|
+
return thermalStatusText(view.target !== null ? view.target : range === null ? null : `${Number(range.low.toFixed(1))}–${formatDegrees(range.high)}`, view.measured);
|
|
98930
|
+
}
|
|
98931
|
+
/** The setpoint inside its range, 0..1. */
|
|
98932
|
+
function levelWithin(value, range) {
|
|
98933
|
+
if (value === null || range === null) return null;
|
|
98934
|
+
return Math.min(1, Math.max(0, (value - range.min) / (range.max - range.min)));
|
|
98935
|
+
}
|
|
98936
|
+
function rangeFrom(min, max, step) {
|
|
98937
|
+
if (min === null || min === void 0) return null;
|
|
98938
|
+
if (max === null || max === void 0 || max <= min) return null;
|
|
98939
|
+
return {
|
|
98940
|
+
min,
|
|
98941
|
+
max,
|
|
98942
|
+
step: step ?? 1
|
|
98943
|
+
};
|
|
98944
|
+
}
|
|
98945
|
+
/**
|
|
98946
|
+
* The climate family's contributions to a hero (D1023): `climate-control`,
|
|
98947
|
+
* `water-heater`, `heating-valve`, and the read-only sensors. Capabilities
|
|
98948
|
+
* contribute, types never do (D14). A slice that is absent or does not parse is
|
|
98949
|
+
* "not answered": the state reads unknown, no row is drawn (D315, D393).
|
|
98950
|
+
*/
|
|
98951
|
+
var same = (text) => t(text, text);
|
|
98952
|
+
function tile(en, it, value) {
|
|
98953
|
+
return {
|
|
98954
|
+
label: t(en, it),
|
|
98955
|
+
value: same(value)
|
|
98956
|
+
};
|
|
98957
|
+
}
|
|
98958
|
+
function setpointSlider(id, cap, method, valueArg, value, range) {
|
|
98959
|
+
return {
|
|
98960
|
+
kind: "slider",
|
|
98961
|
+
id,
|
|
98962
|
+
label: t("Target", "Obiettivo"),
|
|
98963
|
+
value,
|
|
98964
|
+
min: range.min,
|
|
98965
|
+
max: range.max,
|
|
98966
|
+
step: range.step,
|
|
98967
|
+
unit: "°",
|
|
98968
|
+
call: {
|
|
98969
|
+
cap,
|
|
98970
|
+
method,
|
|
98971
|
+
args: {}
|
|
98972
|
+
},
|
|
98973
|
+
valueArg
|
|
98974
|
+
};
|
|
98975
|
+
}
|
|
98976
|
+
function setpointRow(status, slider) {
|
|
98977
|
+
return slider === null ? [] : [{
|
|
98978
|
+
id: "setpoint",
|
|
98979
|
+
icon: "thermometer",
|
|
98980
|
+
status,
|
|
98981
|
+
controls: [slider]
|
|
98982
|
+
}];
|
|
98983
|
+
}
|
|
98984
|
+
var climateContribution = contribution("climate-control", ClimateControlStatusSchema, (slice, ctx) => {
|
|
98985
|
+
if (slice === void 0) return { reading: reading("climate-control", "unknown") };
|
|
98986
|
+
const view = deriveClimateView(slice);
|
|
98987
|
+
const status = climateStatusText(view);
|
|
98988
|
+
const facts = [];
|
|
98989
|
+
if (status !== null) facts.push(fact("climate", "thermometer", status));
|
|
98990
|
+
if (view.humidity !== null) facts.push(fact("humidity", "droplets", same(`${Math.round(view.humidity)}%`)));
|
|
98991
|
+
if (view.targetHumidity !== null) facts.push(fact("humidity", "droplets", same(`→ ${Math.round(view.targetHumidity)}%`)));
|
|
98992
|
+
const left = [];
|
|
98993
|
+
const right = [];
|
|
98994
|
+
if (view.measured !== null) left.push(tile("Indoor", "In casa", formatDegrees(view.measured)));
|
|
98995
|
+
if (view.humidity !== null) left.push(tile("Humidity", "Umidità", `${Math.round(view.humidity)}%`));
|
|
98996
|
+
const modeControls = [{
|
|
98997
|
+
kind: "picker",
|
|
98998
|
+
id: "climate.mode",
|
|
98999
|
+
label: t("Mode", "Modalità"),
|
|
99000
|
+
current: view.mode,
|
|
99001
|
+
options: [...view.availableModes],
|
|
99002
|
+
call: {
|
|
99003
|
+
cap: "climate-control",
|
|
99004
|
+
method: "setMode",
|
|
99005
|
+
args: {}
|
|
99006
|
+
},
|
|
99007
|
+
valueArg: "mode"
|
|
99008
|
+
}];
|
|
99009
|
+
if (slice.availablePresets.length > 0) modeControls.push({
|
|
99010
|
+
kind: "picker",
|
|
99011
|
+
id: "climate.preset",
|
|
99012
|
+
label: t("Preset", "Preset"),
|
|
99013
|
+
current: slice.preset === "" ? null : slice.preset,
|
|
99014
|
+
options: [...slice.availablePresets],
|
|
99015
|
+
call: {
|
|
99016
|
+
cap: "climate-control",
|
|
99017
|
+
method: "setPreset",
|
|
99018
|
+
args: {}
|
|
99019
|
+
},
|
|
99020
|
+
valueArg: "preset"
|
|
99021
|
+
});
|
|
99022
|
+
const fanControls = [];
|
|
99023
|
+
if (slice.availableFanModes.length > 0) fanControls.push({
|
|
99024
|
+
kind: "picker",
|
|
99025
|
+
id: "climate.fan",
|
|
99026
|
+
label: t("Fan", "Ventola"),
|
|
99027
|
+
current: slice.fanMode === "" ? null : slice.fanMode,
|
|
99028
|
+
options: [...slice.availableFanModes],
|
|
99029
|
+
call: {
|
|
99030
|
+
cap: "climate-control",
|
|
99031
|
+
method: "setFanMode",
|
|
99032
|
+
args: {}
|
|
99033
|
+
},
|
|
99034
|
+
valueArg: "fanMode"
|
|
99035
|
+
});
|
|
99036
|
+
const swing = (id, en, it, method, on, feature) => ctx.features.includes(feature) ? [{
|
|
99037
|
+
kind: "toggle",
|
|
99038
|
+
id,
|
|
99039
|
+
label: t(en, it),
|
|
99040
|
+
on,
|
|
99041
|
+
turnOn: action(`${id}.on`, t(en, it), "wind", "climate-control", method, { on: true }),
|
|
99042
|
+
turnOff: action(`${id}.off`, t(en, it), "wind", "climate-control", method, { on: false })
|
|
99043
|
+
}] : [];
|
|
99044
|
+
fanControls.push(...swing("climate.swing-vertical", "Swing vertical", "Oscillazione verticale", "setSwingVertical", slice.swingVertical, DeviceFeature.ClimateSwingVertical), ...swing("climate.swing-horizontal", "Swing horizontal", "Oscillazione orizzontale", "setSwingHorizontal", slice.swingHorizontal, DeviceFeature.ClimateSwingHorizontal));
|
|
99045
|
+
const rows = [{
|
|
99046
|
+
id: "climate-mode",
|
|
99047
|
+
icon: "thermometer",
|
|
99048
|
+
status: view.modeLabel,
|
|
99049
|
+
controls: modeControls
|
|
99050
|
+
}];
|
|
99051
|
+
if (fanControls.length > 0) rows.push({
|
|
99052
|
+
id: "climate-fan",
|
|
99053
|
+
icon: "fan",
|
|
99054
|
+
status: slice.fanMode === "" ? null : same(slice.fanMode),
|
|
99055
|
+
controls: fanControls
|
|
99056
|
+
});
|
|
99057
|
+
rows.push(...setpointRow(view.target === null ? null : same(formatDegrees(view.target)), view.range === null || view.target === null ? null : setpointSlider("climate.target", "climate-control", "setTarget", "target", view.target, view.range)));
|
|
99058
|
+
const sceneMode = view.sceneMode;
|
|
99059
|
+
return {
|
|
99060
|
+
reading: reading("climate-control", view.isOff ? "off" : "on"),
|
|
99061
|
+
title: view.modeLabel,
|
|
99062
|
+
facts,
|
|
99063
|
+
...left.length === 0 && right.length === 0 ? {} : { tiles: {
|
|
99064
|
+
left,
|
|
99065
|
+
right
|
|
99066
|
+
} },
|
|
99067
|
+
scene: {
|
|
99068
|
+
...sceneMode === null ? {} : { mode: sceneMode },
|
|
99069
|
+
...view.level === null ? {} : { level: view.level }
|
|
99070
|
+
},
|
|
99071
|
+
...view.onMode === null ? {} : { ownPower: {
|
|
99072
|
+
source: "climate-control",
|
|
99073
|
+
on: !view.isOff,
|
|
99074
|
+
assumed: false,
|
|
99075
|
+
turnOn: action("own-power.on", t("Turn on", "Accendi"), "power", "climate-control", "setMode", { mode: view.onMode }),
|
|
99076
|
+
turnOff: action("own-power.off", t("Turn off", "Spegni"), "power-off", "climate-control", "setMode", { mode: "off" })
|
|
99077
|
+
} },
|
|
99078
|
+
rows
|
|
99079
|
+
};
|
|
99080
|
+
});
|
|
99081
|
+
var WATER_ON_PREFERENCE = [
|
|
99082
|
+
"eco",
|
|
99083
|
+
"electric",
|
|
99084
|
+
"heat_pump",
|
|
99085
|
+
"performance"
|
|
99086
|
+
];
|
|
99087
|
+
function capitalised(word) {
|
|
99088
|
+
return same(word.charAt(0).toUpperCase() + word.slice(1).replace(/_/g, " "));
|
|
99089
|
+
}
|
|
99090
|
+
var waterHeaterContribution = contribution("water-heater", WaterHeaterStatusSchema, (slice) => {
|
|
99091
|
+
if (slice === void 0 || slice.operationMode === null) return { reading: reading("climate-control", "unknown") };
|
|
99092
|
+
const isOff = slice.operationMode === "off";
|
|
99093
|
+
const label = capitalised(slice.operationMode);
|
|
99094
|
+
const status = thermalStatusText(slice.targetTemp, slice.currentTemp);
|
|
99095
|
+
const range = rangeFrom(slice.minTemp, slice.maxTemp, 1);
|
|
99096
|
+
const candidates = slice.availableModes.filter((m) => m !== "off");
|
|
99097
|
+
const last = slice.lastActiveMode;
|
|
99098
|
+
const onMode = last !== void 0 && candidates.includes(last) ? last : WATER_ON_PREFERENCE.find((m) => candidates.includes(m)) ?? candidates[0] ?? null;
|
|
99099
|
+
const modeControls = [{
|
|
99100
|
+
kind: "picker",
|
|
99101
|
+
id: "water-heater.mode",
|
|
99102
|
+
label: t("Mode", "Modalità"),
|
|
99103
|
+
current: slice.operationMode,
|
|
99104
|
+
options: [...slice.availableModes],
|
|
99105
|
+
call: {
|
|
99106
|
+
cap: "water-heater",
|
|
99107
|
+
method: "setOperationMode",
|
|
99108
|
+
args: {}
|
|
99109
|
+
},
|
|
99110
|
+
valueArg: "mode"
|
|
99111
|
+
}];
|
|
99112
|
+
if (slice.away !== null) modeControls.push({
|
|
99113
|
+
kind: "toggle",
|
|
99114
|
+
id: "water-heater.away",
|
|
99115
|
+
label: t("Away", "Assente"),
|
|
99116
|
+
on: slice.away,
|
|
99117
|
+
turnOn: action("water-heater.away.on", t("Away", "Assente"), "house", "water-heater", "setAway", { on: true }),
|
|
99118
|
+
turnOff: action("water-heater.away.off", t("Away", "Assente"), "house", "water-heater", "setAway", { on: false })
|
|
99119
|
+
});
|
|
99120
|
+
const rows = [{
|
|
99121
|
+
id: "climate-mode",
|
|
99122
|
+
icon: "flame",
|
|
99123
|
+
status: label,
|
|
99124
|
+
controls: modeControls
|
|
99125
|
+
}, ...setpointRow(slice.targetTemp === null ? null : same(formatDegrees(slice.targetTemp)), range === null || slice.targetTemp === null ? null : setpointSlider("water-heater.target", "water-heater", "setTargetTemp", "temp", slice.targetTemp, range))];
|
|
99126
|
+
const level = levelWithin(slice.targetTemp, range);
|
|
99127
|
+
return {
|
|
99128
|
+
reading: reading("climate-control", isOff ? "off" : "on"),
|
|
99129
|
+
title: label,
|
|
99130
|
+
facts: status === null ? [] : [fact("climate", "flame", status)],
|
|
99131
|
+
...slice.currentTemp === null ? {} : { tiles: { left: [tile("Water", "Acqua", formatDegrees(slice.currentTemp))] } },
|
|
99132
|
+
scene: {
|
|
99133
|
+
...isOff ? {} : { mode: "heat" },
|
|
99134
|
+
...level === null ? {} : { level }
|
|
99135
|
+
},
|
|
99136
|
+
...onMode === null ? {} : { ownPower: {
|
|
99137
|
+
source: "climate-control",
|
|
99138
|
+
on: !isOff,
|
|
99139
|
+
assumed: false,
|
|
99140
|
+
turnOn: action("own-power.on", t("Turn on", "Accendi"), "power", "water-heater", "setOperationMode", { mode: onMode }),
|
|
99141
|
+
turnOff: action("own-power.off", t("Turn off", "Spegni"), "power-off", "water-heater", "setOperationMode", { mode: "off" })
|
|
99142
|
+
} },
|
|
99143
|
+
rows
|
|
99144
|
+
};
|
|
99145
|
+
});
|
|
99146
|
+
var heatingValveContribution = contribution("heating-valve", HeatingValveStatusSchema, (slice) => {
|
|
99147
|
+
const position = slice?.position ?? null;
|
|
99148
|
+
if (position === null) return { reading: reading("sensor", "unknown") };
|
|
99149
|
+
const text = same(`${Math.round(position)}%`);
|
|
99150
|
+
return {
|
|
99151
|
+
reading: reading("sensor", position > 0 ? "running" : "idle"),
|
|
99152
|
+
facts: [fact("valve", "gauge", t(`Valve ${text.en}`, `Valvola ${text.it}`))],
|
|
99153
|
+
tiles: { right: [tile("Valve", "Valvola", text.en)] },
|
|
99154
|
+
scene: { level: position / 100 }
|
|
99155
|
+
};
|
|
99156
|
+
});
|
|
99157
|
+
/** One reading fact plus its tile; a value that did not answer says nothing and the state stays unknown. */
|
|
99158
|
+
function sensorFragment(value, id, icon, en, it, text) {
|
|
99159
|
+
if (value === null) return { reading: reading("sensor", "unknown") };
|
|
99160
|
+
return {
|
|
99161
|
+
reading: reading("sensor", "on"),
|
|
99162
|
+
title: same(text),
|
|
99163
|
+
facts: [fact(id, icon, same(text))],
|
|
99164
|
+
tiles: { right: [tile(en, it, text)] }
|
|
99165
|
+
};
|
|
99166
|
+
}
|
|
99167
|
+
var temperatureContribution = contribution("temperature-sensor", TemperatureSensorStatusSchema, (slice) => sensorFragment(slice?.temperature ?? null, "temperature", "thermometer", "Temperature", "Temperatura", formatDegrees(slice?.temperature ?? 0)));
|
|
99168
|
+
var humidityContribution = contribution("humidity-sensor", HumiditySensorStatusSchema, (slice) => sensorFragment(slice?.humidity ?? null, "humidity", "droplets", "Humidity", "Umidità", `${Math.round(slice?.humidity ?? 0)}%`));
|
|
99169
|
+
var pressureContribution = contribution("pressure-sensor", PressureSensorStatusSchema, (slice) => sensorFragment(slice?.pressure ?? null, "pressure", "gauge", "Pressure", "Pressione", `${Math.round(slice?.pressure ?? 0)} hPa`));
|
|
99170
|
+
var illuminanceContribution = contribution("ambient-light-sensor", AmbientLightSensorStatusSchema, (slice) => sensorFragment(slice?.illuminance ?? null, "illuminance", "sun", "Light", "Luce", `${Math.round(slice?.illuminance ?? 0)} lx`));
|
|
99171
|
+
var numericContribution = contribution("numeric-sensor", NumericSensorStatusSchema, (slice) => sensorFragment(slice?.value ?? null, "reading", "gauge", "Value", "Valore", String(Number((slice?.value ?? 0).toFixed(2)))));
|
|
99172
|
+
var enumContribution = contribution("enum-sensor", EnumSensorStatusSchema, (slice) => {
|
|
99173
|
+
if (slice === void 0 || slice.value === "") return { reading: reading("sensor", "unknown") };
|
|
99174
|
+
if (slice.timestamp === true) return { reading: reading("sensor", "on") };
|
|
99175
|
+
return sensorFragment(slice.value, "reading", "gauge", "State", "Stato", slice.value);
|
|
99176
|
+
});
|
|
99177
|
+
/** Index bands: the headline of an air-quality sensor is a word, not a number. */
|
|
99178
|
+
function airQualityWord(aqi) {
|
|
99179
|
+
if (aqi <= 50) return t("Good", "Buona");
|
|
99180
|
+
if (aqi <= 100) return t("Moderate", "Discreta");
|
|
99181
|
+
if (aqi <= 150) return t("Poor", "Scadente");
|
|
99182
|
+
return t("Unhealthy", "Malsana");
|
|
99183
|
+
}
|
|
99184
|
+
/** The climate family, in the order their fragments are merged (a valve's level outranks a setpoint's). */
|
|
99185
|
+
var CLIMATE_FAMILY_CONTRIBUTIONS = {
|
|
99186
|
+
"heating-valve": heatingValveContribution,
|
|
99187
|
+
"climate-control": climateContribution,
|
|
99188
|
+
"water-heater": waterHeaterContribution,
|
|
99189
|
+
"temperature-sensor": temperatureContribution,
|
|
99190
|
+
"humidity-sensor": humidityContribution,
|
|
99191
|
+
"pressure-sensor": pressureContribution,
|
|
99192
|
+
"air-quality-sensor": contribution("air-quality-sensor", AirQualitySensorStatusSchema, (slice) => {
|
|
99193
|
+
if (slice === void 0) return { reading: reading("sensor", "unknown") };
|
|
99194
|
+
const parts = [];
|
|
99195
|
+
if (slice.aqi !== void 0) parts.push({
|
|
99196
|
+
label: "AQI",
|
|
99197
|
+
value: String(Math.round(slice.aqi))
|
|
99198
|
+
});
|
|
99199
|
+
if (slice.co2 !== void 0) parts.push({
|
|
99200
|
+
label: "CO₂",
|
|
99201
|
+
value: `${Math.round(slice.co2)} ppm`
|
|
99202
|
+
});
|
|
99203
|
+
if (slice.pm25 !== void 0) parts.push({
|
|
99204
|
+
label: "PM2.5",
|
|
99205
|
+
value: `${Math.round(slice.pm25)} µg/m³`
|
|
99206
|
+
});
|
|
99207
|
+
if (slice.voc !== void 0) parts.push({
|
|
99208
|
+
label: "VOC",
|
|
99209
|
+
value: `${Math.round(slice.voc)} ppb`
|
|
99210
|
+
});
|
|
99211
|
+
if (slice.pm10 !== void 0) parts.push({
|
|
99212
|
+
label: "PM10",
|
|
99213
|
+
value: `${Math.round(slice.pm10)} µg/m³`
|
|
99214
|
+
});
|
|
99215
|
+
if (parts.length === 0) return { reading: reading("sensor", "unknown") };
|
|
99216
|
+
return {
|
|
99217
|
+
reading: reading("sensor", "on"),
|
|
99218
|
+
...slice.aqi === void 0 ? {} : { title: airQualityWord(slice.aqi) },
|
|
99219
|
+
facts: parts.map((p) => fact("air-quality", "wind", same(`${p.label} ${p.value}`))),
|
|
99220
|
+
tiles: { right: parts.slice(0, 2).map((p) => tile(p.label, p.label, p.value)) }
|
|
99221
|
+
};
|
|
99222
|
+
}),
|
|
99223
|
+
"carbon-monoxide": contribution("carbon-monoxide", CarbonMonoxideStatusSchema, (slice) => {
|
|
99224
|
+
if (slice === void 0) return { reading: reading("sensor", "unknown") };
|
|
99225
|
+
return {
|
|
99226
|
+
reading: reading("sensor", slice.detected ? "alert" : "idle"),
|
|
99227
|
+
title: slice.detected ? t("CO detected", "CO rilevato") : t("Air clear", "Aria libera"),
|
|
99228
|
+
facts: [fact("reading", slice.detected ? "triangle-alert" : "shield-check", slice.detected ? t("CO detected", "CO rilevato") : t("Air clear", "Aria libera"), slice.detected ? "danger" : "muted")]
|
|
99229
|
+
};
|
|
99230
|
+
}),
|
|
99231
|
+
"ambient-light-sensor": illuminanceContribution,
|
|
99232
|
+
"numeric-sensor": numericContribution,
|
|
99233
|
+
"enum-sensor": enumContribution
|
|
99234
|
+
};
|
|
97493
99235
|
var NO_TRANSPORT = {
|
|
97494
99236
|
playPause: false,
|
|
97495
99237
|
previous: false,
|
|
@@ -97540,6 +99282,7 @@ var UNKNOWN_VIEW = {
|
|
|
97540
99282
|
artworkUrl: null,
|
|
97541
99283
|
mute: false,
|
|
97542
99284
|
source: null,
|
|
99285
|
+
channel: null,
|
|
97543
99286
|
shuffle: false,
|
|
97544
99287
|
repeat: false,
|
|
97545
99288
|
shuffleReadOnly: false,
|
|
@@ -97604,6 +99347,13 @@ function derivePowerGatedView(status, features, extras) {
|
|
|
97604
99347
|
runningReading
|
|
97605
99348
|
};
|
|
97606
99349
|
}
|
|
99350
|
+
/** The channel being watched: only a media item the device itself calls a channel. */
|
|
99351
|
+
function channelOf(status) {
|
|
99352
|
+
const media = status.currentMedia;
|
|
99353
|
+
if (media === null || media === void 0 || media.type !== "channel") return null;
|
|
99354
|
+
const title = media.title.trim();
|
|
99355
|
+
return title === "" ? null : title;
|
|
99356
|
+
}
|
|
97607
99357
|
function deriveFromStatus(status, features) {
|
|
97608
99358
|
const has = (f) => features?.includes(f) ?? false;
|
|
97609
99359
|
const canSwitchPower = has(DeviceFeature.MediaPlayerPower);
|
|
@@ -97645,53 +99395,22 @@ function deriveFromStatus(status, features) {
|
|
|
97645
99395
|
options,
|
|
97646
99396
|
selectable: has(DeviceFeature.MediaPlayerSelectSource) && options.length > 1
|
|
97647
99397
|
} : null,
|
|
99398
|
+
channel: has(DeviceFeature.MediaPlayerChannelStep) ? { current: channelOf(status) } : null,
|
|
97648
99399
|
shuffle: has(DeviceFeature.MediaPlayerShuffle) && status.shuffle !== null,
|
|
97649
99400
|
repeat: has(DeviceFeature.MediaPlayerRepeat) && status.repeat !== null
|
|
97650
99401
|
};
|
|
97651
99402
|
}
|
|
97652
|
-
/**
|
|
97653
|
-
|
|
97654
|
-
|
|
97655
|
-
|
|
97656
|
-
|
|
97657
|
-
|
|
97658
|
-
|
|
97659
|
-
|
|
97660
|
-
|
|
97661
|
-
|
|
97662
|
-
|
|
97663
|
-
return {
|
|
97664
|
-
id,
|
|
97665
|
-
label,
|
|
97666
|
-
icon,
|
|
97667
|
-
call: {
|
|
97668
|
-
cap,
|
|
97669
|
-
method,
|
|
97670
|
-
args
|
|
97671
|
-
},
|
|
97672
|
-
emphasis,
|
|
97673
|
-
confirm
|
|
97674
|
-
};
|
|
97675
|
-
}
|
|
97676
|
-
var asAction = (a) => ({
|
|
97677
|
-
kind: "action",
|
|
97678
|
-
action: a
|
|
97679
|
-
});
|
|
97680
|
-
function reading(source, state, assumed = false) {
|
|
97681
|
-
return {
|
|
97682
|
-
source,
|
|
97683
|
-
state,
|
|
97684
|
-
assumed
|
|
97685
|
-
};
|
|
97686
|
-
}
|
|
97687
|
-
function fact(id, icon, text, tone = "muted") {
|
|
97688
|
-
return {
|
|
97689
|
-
id,
|
|
97690
|
-
icon,
|
|
97691
|
-
text,
|
|
97692
|
-
tone
|
|
97693
|
-
};
|
|
97694
|
-
}
|
|
99403
|
+
/**
|
|
99404
|
+
* What each capability contributes to a hero (D1023). The map is typed against
|
|
99405
|
+
* the cap's own status schema: a slice is parsed at the boundary, and one that
|
|
99406
|
+
* does not parse reads as "not answered", never as a value.
|
|
99407
|
+
*
|
|
99408
|
+
* Capabilities contribute, device types never do (D14): nothing here looks at a
|
|
99409
|
+
* vendor. A type only chooses which ROWS its layout carries and how it looks.
|
|
99410
|
+
* `HERO_CAP_COVERAGE` (the second file of this directory) says, for every
|
|
99411
|
+
* device cap, whether it contributes and why it does not; the guard
|
|
99412
|
+
* `scripts/check-cap-hero-contributions.ts` keeps it complete.
|
|
99413
|
+
*/
|
|
97695
99414
|
function minutesLeft(seconds) {
|
|
97696
99415
|
const m = Math.ceil(seconds / 60);
|
|
97697
99416
|
return t(`${m} min left`, `${m} min rimanenti`);
|
|
@@ -98049,6 +99768,15 @@ var HERO_CAP_CONTRIBUTIONS = [
|
|
|
98049
99768
|
status: null,
|
|
98050
99769
|
controls: volume
|
|
98051
99770
|
});
|
|
99771
|
+
if (view.channel !== null) {
|
|
99772
|
+
const channel = view.channel.current;
|
|
99773
|
+
rows.push({
|
|
99774
|
+
id: "channel",
|
|
99775
|
+
icon: "tv",
|
|
99776
|
+
status: channel === null ? null : t(channel, channel),
|
|
99777
|
+
controls: [asAction(action("channel.down", t("Channel down", "Canale giù"), "chevron-down", "media-player", "channelDown")), asAction(action("channel.up", t("Channel up", "Canale su"), "chevron-up", "media-player", "channelUp"))]
|
|
99778
|
+
});
|
|
99779
|
+
}
|
|
98052
99780
|
if (view.source !== null) {
|
|
98053
99781
|
const current = view.source.current === "" ? null : view.source.current;
|
|
98054
99782
|
rows.push({
|
|
@@ -98109,7 +99837,13 @@ var HERO_CAP_CONTRIBUTIONS = [
|
|
|
98109
99837
|
powerSourceContribution,
|
|
98110
99838
|
remoteContribution,
|
|
98111
99839
|
consumablesContribution,
|
|
98112
|
-
dishwasherContribution
|
|
99840
|
+
dishwasherContribution,
|
|
99841
|
+
...Object.values(ACCESS_FAMILY_CONTRIBUTIONS),
|
|
99842
|
+
...Object.values(DEVICES_FAMILY_CONTRIBUTIONS),
|
|
99843
|
+
...Object.values(GROUPS_FAMILY_CONTRIBUTIONS),
|
|
99844
|
+
...Object.values(ACTUATORS_FAMILY_CONTRIBUTIONS),
|
|
99845
|
+
...Object.values(SENSORS_FAMILY_CONTRIBUTIONS),
|
|
99846
|
+
...Object.values(CLIMATE_FAMILY_CONTRIBUTIONS)
|
|
98113
99847
|
];
|
|
98114
99848
|
/**
|
|
98115
99849
|
* The FIXED layout of each device type's hero (D1023). A layout lives in this
|
|
@@ -98128,7 +99862,9 @@ var MEDIA_PLAYER_LAYOUT = { rows: [
|
|
|
98128
99862
|
"now-playing",
|
|
98129
99863
|
"playback",
|
|
98130
99864
|
"volume",
|
|
98131
|
-
"
|
|
99865
|
+
"channel",
|
|
99866
|
+
"source",
|
|
99867
|
+
"do-not-disturb"
|
|
98132
99868
|
] };
|
|
98133
99869
|
var APPLIANCE_LAYOUT = { rows: ["cycle"] };
|
|
98134
99870
|
/** Its Home Connect PowerState is a secondary row action, never the own-power slot. */
|
|
@@ -98137,40 +99873,66 @@ var DISHWASHER_LAYOUT = { rows: [
|
|
|
98137
99873
|
"program",
|
|
98138
99874
|
"appliance-power"
|
|
98139
99875
|
] };
|
|
99876
|
+
var CLIMATE_LAYOUT = { rows: [
|
|
99877
|
+
"climate-mode",
|
|
99878
|
+
"climate-fan",
|
|
99879
|
+
"setpoint"
|
|
99880
|
+
] };
|
|
98140
99881
|
var SWITCH_LAYOUT = { rows: ["motion-trigger"] };
|
|
99882
|
+
var LOCK_LAYOUT = { rows: ["lock"] };
|
|
99883
|
+
var ALARM_LAYOUT = { rows: ["alarm"] };
|
|
99884
|
+
var FAN_LAYOUT = { rows: ["fan"] };
|
|
99885
|
+
var VACUUM_LAYOUT = { rows: ["vacuum"] };
|
|
99886
|
+
var MOWER_LAYOUT = { rows: ["mower"] };
|
|
99887
|
+
var FEEDER_LAYOUT = { rows: ["feeder"] };
|
|
99888
|
+
var FOUNTAIN_LAYOUT = { rows: ["fountain", "pump-cycle"] };
|
|
99889
|
+
var AUTOMATION_LAYOUT = { rows: ["automation"] };
|
|
99890
|
+
var SCRIPT_LAYOUT = { rows: ["script"] };
|
|
99891
|
+
var LIGHT_LAYOUT = { rows: [
|
|
99892
|
+
"brightness",
|
|
99893
|
+
"color",
|
|
99894
|
+
"contact",
|
|
99895
|
+
"motion-trigger"
|
|
99896
|
+
] };
|
|
99897
|
+
var COVER_LAYOUT = { rows: ["cover"] };
|
|
99898
|
+
var VALVE_LAYOUT = { rows: ["valve"] };
|
|
99899
|
+
var HUMIDIFIER_LAYOUT = { rows: ["humidifier"] };
|
|
99900
|
+
var UPDATE_LAYOUT = { rows: ["update"] };
|
|
99901
|
+
var CONTROL_LAYOUT = { rows: ["control"] };
|
|
99902
|
+
var BUTTON_LAYOUT = { rows: ["button"] };
|
|
98141
99903
|
var HERO_LAYOUT_BY_TYPE = {
|
|
98142
99904
|
[DeviceType.Camera]: HERO_LAYOUT_DEFAULT,
|
|
98143
99905
|
[DeviceType.Hub]: HERO_LAYOUT_DEFAULT,
|
|
98144
|
-
[DeviceType.Light]:
|
|
99906
|
+
[DeviceType.Light]: LIGHT_LAYOUT,
|
|
98145
99907
|
[DeviceType.Siren]: HERO_LAYOUT_DEFAULT,
|
|
98146
99908
|
[DeviceType.Switch]: SWITCH_LAYOUT,
|
|
98147
99909
|
[DeviceType.Sensor]: HERO_LAYOUT_DEFAULT,
|
|
98148
|
-
[DeviceType.Thermostat]:
|
|
98149
|
-
[DeviceType.Climate]:
|
|
98150
|
-
[DeviceType.Button]:
|
|
99910
|
+
[DeviceType.Thermostat]: CLIMATE_LAYOUT,
|
|
99911
|
+
[DeviceType.Climate]: CLIMATE_LAYOUT,
|
|
99912
|
+
[DeviceType.Button]: BUTTON_LAYOUT,
|
|
98151
99913
|
[DeviceType.EventEmitter]: HERO_LAYOUT_DEFAULT,
|
|
98152
|
-
[DeviceType.Update]:
|
|
99914
|
+
[DeviceType.Update]: UPDATE_LAYOUT,
|
|
98153
99915
|
[DeviceType.Generic]: HERO_LAYOUT_DEFAULT,
|
|
98154
99916
|
[DeviceType.Notifier]: HERO_LAYOUT_DEFAULT,
|
|
98155
|
-
[DeviceType.Script]:
|
|
98156
|
-
[DeviceType.Automation]:
|
|
98157
|
-
[DeviceType.Lock]:
|
|
98158
|
-
[DeviceType.Cover]:
|
|
98159
|
-
[DeviceType.Valve]:
|
|
98160
|
-
[DeviceType.Humidifier]:
|
|
98161
|
-
[DeviceType.WaterHeater]:
|
|
98162
|
-
[DeviceType.Fan]:
|
|
99917
|
+
[DeviceType.Script]: SCRIPT_LAYOUT,
|
|
99918
|
+
[DeviceType.Automation]: AUTOMATION_LAYOUT,
|
|
99919
|
+
[DeviceType.Lock]: LOCK_LAYOUT,
|
|
99920
|
+
[DeviceType.Cover]: COVER_LAYOUT,
|
|
99921
|
+
[DeviceType.Valve]: VALVE_LAYOUT,
|
|
99922
|
+
[DeviceType.Humidifier]: HUMIDIFIER_LAYOUT,
|
|
99923
|
+
[DeviceType.WaterHeater]: CLIMATE_LAYOUT,
|
|
99924
|
+
[DeviceType.Fan]: FAN_LAYOUT,
|
|
98163
99925
|
[DeviceType.MediaPlayer]: MEDIA_PLAYER_LAYOUT,
|
|
98164
|
-
[DeviceType.AlarmPanel]:
|
|
98165
|
-
[DeviceType.Control]:
|
|
99926
|
+
[DeviceType.AlarmPanel]: ALARM_LAYOUT,
|
|
99927
|
+
[DeviceType.Control]: CONTROL_LAYOUT,
|
|
98166
99928
|
[DeviceType.Presence]: HERO_LAYOUT_DEFAULT,
|
|
98167
99929
|
[DeviceType.Weather]: HERO_LAYOUT_DEFAULT,
|
|
98168
|
-
[DeviceType.Vacuum]:
|
|
98169
|
-
[DeviceType.LawnMower]:
|
|
99930
|
+
[DeviceType.Vacuum]: VACUUM_LAYOUT,
|
|
99931
|
+
[DeviceType.LawnMower]: MOWER_LAYOUT,
|
|
98170
99932
|
[DeviceType.Container]: HERO_LAYOUT_DEFAULT,
|
|
98171
99933
|
[DeviceType.Image]: HERO_LAYOUT_DEFAULT,
|
|
98172
|
-
[DeviceType.PetFeeder]:
|
|
98173
|
-
[DeviceType.PetFountain]:
|
|
99934
|
+
[DeviceType.PetFeeder]: FEEDER_LAYOUT,
|
|
99935
|
+
[DeviceType.PetFountain]: FOUNTAIN_LAYOUT,
|
|
98174
99936
|
[DeviceType.Dishwasher]: DISHWASHER_LAYOUT,
|
|
98175
99937
|
[DeviceType.Washer]: APPLIANCE_LAYOUT,
|
|
98176
99938
|
[DeviceType.Heater]: HEATER_LAYOUT,
|
|
@@ -98357,25 +100119,413 @@ var DISHWASHER_LOOK = lookOf({
|
|
|
98357
100119
|
idle: INFO,
|
|
98358
100120
|
standby: WARN
|
|
98359
100121
|
});
|
|
98360
|
-
|
|
98361
|
-
|
|
100122
|
+
/** A sensor that reads Clear or Detected: calm when clear, an alarm when it trips. */
|
|
100123
|
+
function sensorLook(icon, alertIcon = icon) {
|
|
100124
|
+
return lookOf({
|
|
100125
|
+
icon,
|
|
100126
|
+
on: [
|
|
100127
|
+
"primary",
|
|
100128
|
+
"glow",
|
|
100129
|
+
"halo"
|
|
100130
|
+
],
|
|
100131
|
+
off: MUTED,
|
|
100132
|
+
running: [
|
|
100133
|
+
"primary",
|
|
100134
|
+
"glow",
|
|
100135
|
+
"halo"
|
|
100136
|
+
],
|
|
100137
|
+
idle: [
|
|
100138
|
+
"success",
|
|
100139
|
+
"plain",
|
|
100140
|
+
"none"
|
|
100141
|
+
],
|
|
100142
|
+
standby: WARN,
|
|
100143
|
+
alert: look(alertIcon, "danger", "alert-wash", "pulse")
|
|
100144
|
+
});
|
|
100145
|
+
}
|
|
100146
|
+
var LEAK_LOOK = sensorLook("droplets");
|
|
100147
|
+
var SMOKE_LOOK = sensorLook("flame");
|
|
100148
|
+
var GAS_LOOK = sensorLook("wind");
|
|
100149
|
+
var TAMPER_LOOK = sensorLook("shield-alert");
|
|
100150
|
+
var VIBRATION_LOOK = sensorLook("vibrate");
|
|
100151
|
+
var MOTION_LOOK = sensorLook("radar", "triangle-alert");
|
|
100152
|
+
var DOORBELL_LOOK = sensorLook("bell-ring");
|
|
100153
|
+
/** A camera is a camera: never a power glyph, whatever its motion reads. */
|
|
100154
|
+
var CAMERA_LOOK = sensorLook("video", "triangle-alert");
|
|
100155
|
+
/** A bulb glows while lit. */
|
|
100156
|
+
var LIGHT_LOOK = lookOf({
|
|
100157
|
+
icon: "lightbulb",
|
|
98362
100158
|
on: [
|
|
98363
|
-
"
|
|
100159
|
+
"warning",
|
|
100160
|
+
"glow",
|
|
100161
|
+
"glow"
|
|
100162
|
+
],
|
|
100163
|
+
off: MUTED,
|
|
100164
|
+
running: [
|
|
100165
|
+
"warning",
|
|
100166
|
+
"glow",
|
|
100167
|
+
"glow"
|
|
100168
|
+
],
|
|
100169
|
+
idle: INFO,
|
|
100170
|
+
standby: WARN
|
|
100171
|
+
});
|
|
100172
|
+
/** Closed is a position, not an absence of power: the blind keeps its glyph and goes quiet. */
|
|
100173
|
+
var COVER_LOOK = lookOf({
|
|
100174
|
+
icon: "blinds",
|
|
100175
|
+
on: [
|
|
100176
|
+
"primary",
|
|
100177
|
+
"plain",
|
|
100178
|
+
"none"
|
|
100179
|
+
],
|
|
100180
|
+
off: MUTED,
|
|
100181
|
+
running: [
|
|
100182
|
+
"primary",
|
|
100183
|
+
"plain",
|
|
100184
|
+
"pulse"
|
|
100185
|
+
],
|
|
100186
|
+
idle: INFO,
|
|
100187
|
+
standby: WARN
|
|
100188
|
+
});
|
|
100189
|
+
var VALVE_LOOK = lookOf({
|
|
100190
|
+
icon: "droplet",
|
|
100191
|
+
on: [
|
|
100192
|
+
"primary",
|
|
98364
100193
|
"water",
|
|
98365
100194
|
"wave"
|
|
98366
100195
|
],
|
|
98367
100196
|
off: MUTED,
|
|
98368
100197
|
running: [
|
|
98369
|
-
"
|
|
100198
|
+
"primary",
|
|
98370
100199
|
"water",
|
|
100200
|
+
"pulse"
|
|
100201
|
+
],
|
|
100202
|
+
idle: INFO,
|
|
100203
|
+
standby: WARN
|
|
100204
|
+
});
|
|
100205
|
+
var HUMIDIFIER_LOOK = lookOf({
|
|
100206
|
+
icon: "droplets",
|
|
100207
|
+
on: [
|
|
100208
|
+
"info",
|
|
100209
|
+
"mist",
|
|
100210
|
+
"breathe"
|
|
100211
|
+
],
|
|
100212
|
+
off: MUTED,
|
|
100213
|
+
running: [
|
|
100214
|
+
"info",
|
|
100215
|
+
"mist",
|
|
98371
100216
|
"wave"
|
|
98372
100217
|
],
|
|
98373
100218
|
idle: INFO,
|
|
98374
|
-
standby: WARN
|
|
98375
|
-
alert: look("droplets", "danger", "alert-wash", "pulse")
|
|
100219
|
+
standby: WARN
|
|
98376
100220
|
});
|
|
98377
|
-
var
|
|
98378
|
-
icon: "
|
|
100221
|
+
var CONTROL_LOOK = lookOf({
|
|
100222
|
+
icon: "sliders-horizontal",
|
|
100223
|
+
on: [
|
|
100224
|
+
"primary",
|
|
100225
|
+
"plain",
|
|
100226
|
+
"none"
|
|
100227
|
+
],
|
|
100228
|
+
off: MUTED,
|
|
100229
|
+
running: [
|
|
100230
|
+
"primary",
|
|
100231
|
+
"plain",
|
|
100232
|
+
"pulse"
|
|
100233
|
+
],
|
|
100234
|
+
idle: INFO,
|
|
100235
|
+
standby: WARN
|
|
100236
|
+
});
|
|
100237
|
+
var PRESENCE_LOOK = lookOf({
|
|
100238
|
+
icon: "map-pin",
|
|
100239
|
+
on: [
|
|
100240
|
+
"success",
|
|
100241
|
+
"plain",
|
|
100242
|
+
"none"
|
|
100243
|
+
],
|
|
100244
|
+
off: MUTED,
|
|
100245
|
+
running: [
|
|
100246
|
+
"primary",
|
|
100247
|
+
"plain",
|
|
100248
|
+
"pulse"
|
|
100249
|
+
],
|
|
100250
|
+
idle: INFO,
|
|
100251
|
+
standby: WARN
|
|
100252
|
+
});
|
|
100253
|
+
var WEATHER_LOOK = lookOf({
|
|
100254
|
+
icon: "cloud-sun",
|
|
100255
|
+
on: [
|
|
100256
|
+
"info",
|
|
100257
|
+
"sky",
|
|
100258
|
+
"none"
|
|
100259
|
+
],
|
|
100260
|
+
off: MUTED,
|
|
100261
|
+
running: [
|
|
100262
|
+
"info",
|
|
100263
|
+
"sky",
|
|
100264
|
+
"none"
|
|
100265
|
+
],
|
|
100266
|
+
idle: INFO,
|
|
100267
|
+
standby: WARN
|
|
100268
|
+
});
|
|
100269
|
+
/** An update waits (warning), runs (pulse) or is done (calm). */
|
|
100270
|
+
var UPDATE_LOOK = lookOf({
|
|
100271
|
+
icon: "download",
|
|
100272
|
+
on: [
|
|
100273
|
+
"success",
|
|
100274
|
+
"plain",
|
|
100275
|
+
"none"
|
|
100276
|
+
],
|
|
100277
|
+
off: MUTED,
|
|
100278
|
+
running: [
|
|
100279
|
+
"primary",
|
|
100280
|
+
"plain",
|
|
100281
|
+
"pulse"
|
|
100282
|
+
],
|
|
100283
|
+
idle: [
|
|
100284
|
+
"success",
|
|
100285
|
+
"plain",
|
|
100286
|
+
"none"
|
|
100287
|
+
],
|
|
100288
|
+
standby: [
|
|
100289
|
+
"warning",
|
|
100290
|
+
"plain",
|
|
100291
|
+
"pulse"
|
|
100292
|
+
]
|
|
100293
|
+
});
|
|
100294
|
+
var BUTTON_LOOK = lookOf({
|
|
100295
|
+
icon: "pointer",
|
|
100296
|
+
on: [
|
|
100297
|
+
"primary",
|
|
100298
|
+
"plain",
|
|
100299
|
+
"none"
|
|
100300
|
+
],
|
|
100301
|
+
off: MUTED,
|
|
100302
|
+
running: [
|
|
100303
|
+
"primary",
|
|
100304
|
+
"plain",
|
|
100305
|
+
"pulse"
|
|
100306
|
+
],
|
|
100307
|
+
idle: INFO,
|
|
100308
|
+
standby: WARN
|
|
100309
|
+
});
|
|
100310
|
+
var IMAGE_LOOK = lookOf({
|
|
100311
|
+
icon: "image",
|
|
100312
|
+
on: [
|
|
100313
|
+
"primary",
|
|
100314
|
+
"plain",
|
|
100315
|
+
"none"
|
|
100316
|
+
],
|
|
100317
|
+
off: MUTED,
|
|
100318
|
+
running: [
|
|
100319
|
+
"primary",
|
|
100320
|
+
"plain",
|
|
100321
|
+
"pulse"
|
|
100322
|
+
],
|
|
100323
|
+
idle: INFO,
|
|
100324
|
+
standby: WARN
|
|
100325
|
+
});
|
|
100326
|
+
/** A lock is secure when locked, and says so when it is not. */
|
|
100327
|
+
var LOCK_LOOK = {
|
|
100328
|
+
...lookOf({
|
|
100329
|
+
icon: "lock",
|
|
100330
|
+
on: [
|
|
100331
|
+
"success",
|
|
100332
|
+
"plain",
|
|
100333
|
+
"none"
|
|
100334
|
+
],
|
|
100335
|
+
off: MUTED,
|
|
100336
|
+
running: [
|
|
100337
|
+
"primary",
|
|
100338
|
+
"plain",
|
|
100339
|
+
"pulse"
|
|
100340
|
+
],
|
|
100341
|
+
idle: INFO,
|
|
100342
|
+
standby: WARN
|
|
100343
|
+
}),
|
|
100344
|
+
standby: look("lock-open", "warning", "plain", "none"),
|
|
100345
|
+
off: look("lock-open", "muted", "plain", "none")
|
|
100346
|
+
};
|
|
100347
|
+
/** The shield glows while armed, blinks red in alarm and goes quiet when disarmed. */
|
|
100348
|
+
var ALARM_LOOK = {
|
|
100349
|
+
...lookOf({
|
|
100350
|
+
icon: "shield-check",
|
|
100351
|
+
on: [
|
|
100352
|
+
"success",
|
|
100353
|
+
"glow",
|
|
100354
|
+
"halo"
|
|
100355
|
+
],
|
|
100356
|
+
off: MUTED,
|
|
100357
|
+
running: [
|
|
100358
|
+
"primary",
|
|
100359
|
+
"plain",
|
|
100360
|
+
"pulse"
|
|
100361
|
+
],
|
|
100362
|
+
idle: INFO,
|
|
100363
|
+
standby: WARN
|
|
100364
|
+
}),
|
|
100365
|
+
off: look("shield-off", "muted", "plain", "none"),
|
|
100366
|
+
standby: look("shield", "warning", "plain", "pulse"),
|
|
100367
|
+
alert: look("shield-alert", "danger", "alert-wash", "blink")
|
|
100368
|
+
};
|
|
100369
|
+
/** Blades turn only while air moves. */
|
|
100370
|
+
var FAN_LOOK = lookOf({
|
|
100371
|
+
icon: "fan",
|
|
100372
|
+
on: [
|
|
100373
|
+
"success",
|
|
100374
|
+
"plain",
|
|
100375
|
+
"none"
|
|
100376
|
+
],
|
|
100377
|
+
off: MUTED,
|
|
100378
|
+
running: [
|
|
100379
|
+
"primary",
|
|
100380
|
+
"mist",
|
|
100381
|
+
"spin"
|
|
100382
|
+
],
|
|
100383
|
+
idle: INFO,
|
|
100384
|
+
standby: WARN
|
|
100385
|
+
});
|
|
100386
|
+
var VACUUM_LOOK = lookOf({
|
|
100387
|
+
icon: "bot",
|
|
100388
|
+
on: [
|
|
100389
|
+
"success",
|
|
100390
|
+
"plain",
|
|
100391
|
+
"none"
|
|
100392
|
+
],
|
|
100393
|
+
off: MUTED,
|
|
100394
|
+
running: [
|
|
100395
|
+
"primary",
|
|
100396
|
+
"plain",
|
|
100397
|
+
"pulse"
|
|
100398
|
+
],
|
|
100399
|
+
idle: INFO,
|
|
100400
|
+
standby: WARN
|
|
100401
|
+
});
|
|
100402
|
+
var MOWER_LOOK = lookOf({
|
|
100403
|
+
icon: "sprout",
|
|
100404
|
+
on: [
|
|
100405
|
+
"success",
|
|
100406
|
+
"plain",
|
|
100407
|
+
"none"
|
|
100408
|
+
],
|
|
100409
|
+
off: MUTED,
|
|
100410
|
+
running: [
|
|
100411
|
+
"primary",
|
|
100412
|
+
"plain",
|
|
100413
|
+
"pulse"
|
|
100414
|
+
],
|
|
100415
|
+
idle: INFO,
|
|
100416
|
+
standby: WARN
|
|
100417
|
+
});
|
|
100418
|
+
var FEEDER_LOOK = lookOf({
|
|
100419
|
+
icon: "bone",
|
|
100420
|
+
on: [
|
|
100421
|
+
"success",
|
|
100422
|
+
"plain",
|
|
100423
|
+
"none"
|
|
100424
|
+
],
|
|
100425
|
+
off: MUTED,
|
|
100426
|
+
running: [
|
|
100427
|
+
"primary",
|
|
100428
|
+
"plain",
|
|
100429
|
+
"pulse"
|
|
100430
|
+
],
|
|
100431
|
+
idle: INFO,
|
|
100432
|
+
standby: WARN
|
|
100433
|
+
});
|
|
100434
|
+
var FOUNTAIN_LOOK = lookOf({
|
|
100435
|
+
icon: "droplets",
|
|
100436
|
+
on: [
|
|
100437
|
+
"success",
|
|
100438
|
+
"plain",
|
|
100439
|
+
"none"
|
|
100440
|
+
],
|
|
100441
|
+
off: MUTED,
|
|
100442
|
+
running: [
|
|
100443
|
+
"primary",
|
|
100444
|
+
"water",
|
|
100445
|
+
"wave"
|
|
100446
|
+
],
|
|
100447
|
+
idle: INFO,
|
|
100448
|
+
standby: WARN
|
|
100449
|
+
});
|
|
100450
|
+
var AUTOMATION_LOOK = lookOf({
|
|
100451
|
+
icon: "workflow",
|
|
100452
|
+
on: [
|
|
100453
|
+
"success",
|
|
100454
|
+
"plain",
|
|
100455
|
+
"none"
|
|
100456
|
+
],
|
|
100457
|
+
off: MUTED,
|
|
100458
|
+
running: [
|
|
100459
|
+
"primary",
|
|
100460
|
+
"plain",
|
|
100461
|
+
"pulse"
|
|
100462
|
+
],
|
|
100463
|
+
idle: INFO,
|
|
100464
|
+
standby: WARN
|
|
100465
|
+
});
|
|
100466
|
+
var SCRIPT_LOOK = lookOf({
|
|
100467
|
+
icon: "scroll-text",
|
|
100468
|
+
on: [
|
|
100469
|
+
"success",
|
|
100470
|
+
"plain",
|
|
100471
|
+
"none"
|
|
100472
|
+
],
|
|
100473
|
+
off: MUTED,
|
|
100474
|
+
running: [
|
|
100475
|
+
"primary",
|
|
100476
|
+
"plain",
|
|
100477
|
+
"pulse"
|
|
100478
|
+
],
|
|
100479
|
+
idle: INFO,
|
|
100480
|
+
standby: WARN
|
|
100481
|
+
});
|
|
100482
|
+
var EVENT_EMITTER_LOOK = lookOf({
|
|
100483
|
+
icon: "radio-tower",
|
|
100484
|
+
on: [
|
|
100485
|
+
"success",
|
|
100486
|
+
"plain",
|
|
100487
|
+
"none"
|
|
100488
|
+
],
|
|
100489
|
+
off: MUTED,
|
|
100490
|
+
running: [
|
|
100491
|
+
"primary",
|
|
100492
|
+
"plain",
|
|
100493
|
+
"pulse"
|
|
100494
|
+
],
|
|
100495
|
+
idle: INFO,
|
|
100496
|
+
standby: WARN
|
|
100497
|
+
});
|
|
100498
|
+
/** A reading device: the value is the headline, the look only says what kind of reading it is. */
|
|
100499
|
+
function readingLook(icon, tone) {
|
|
100500
|
+
return lookOf({
|
|
100501
|
+
icon,
|
|
100502
|
+
on: [
|
|
100503
|
+
tone,
|
|
100504
|
+
"plain",
|
|
100505
|
+
"none"
|
|
100506
|
+
],
|
|
100507
|
+
off: MUTED,
|
|
100508
|
+
running: [
|
|
100509
|
+
tone,
|
|
100510
|
+
"plain",
|
|
100511
|
+
"none"
|
|
100512
|
+
],
|
|
100513
|
+
idle: [
|
|
100514
|
+
tone,
|
|
100515
|
+
"plain",
|
|
100516
|
+
"none"
|
|
100517
|
+
],
|
|
100518
|
+
standby: MUTED
|
|
100519
|
+
});
|
|
100520
|
+
}
|
|
100521
|
+
var READING_SENSOR_LOOK = readingLook("gauge", "info");
|
|
100522
|
+
var TEMPERATURE_LOOK = readingLook("thermometer", "info");
|
|
100523
|
+
var HUMIDITY_LOOK = readingLook("droplets", "info");
|
|
100524
|
+
var AIR_QUALITY_LOOK = readingLook("wind", "success");
|
|
100525
|
+
var LIGHT_SENSOR_LOOK = readingLook("sun", "warning");
|
|
100526
|
+
/** Carbon monoxide: calm is a shield, detected is the alarm. */
|
|
100527
|
+
var CO_LOOK = lookOf({
|
|
100528
|
+
icon: "shield-check",
|
|
98379
100529
|
on: [
|
|
98380
100530
|
"danger",
|
|
98381
100531
|
"alert-wash",
|
|
@@ -98387,43 +100537,109 @@ var SMOKE_LOOK = lookOf({
|
|
|
98387
100537
|
"alert-wash",
|
|
98388
100538
|
"pulse"
|
|
98389
100539
|
],
|
|
100540
|
+
idle: [
|
|
100541
|
+
"success",
|
|
100542
|
+
"plain",
|
|
100543
|
+
"none"
|
|
100544
|
+
],
|
|
100545
|
+
standby: MUTED,
|
|
100546
|
+
alert: look("triangle-alert", "danger", "alert-wash", "pulse")
|
|
100547
|
+
});
|
|
100548
|
+
/** Heating and cooling devices: the mode (see {@link HERO_MODE_LOOK}) picks the picture while on. */
|
|
100549
|
+
var THERMOSTAT_LOOK = lookOf({
|
|
100550
|
+
icon: "thermometer",
|
|
100551
|
+
on: [
|
|
100552
|
+
"primary",
|
|
100553
|
+
"plain",
|
|
100554
|
+
"none"
|
|
100555
|
+
],
|
|
100556
|
+
off: MUTED,
|
|
100557
|
+
running: [
|
|
100558
|
+
"warning",
|
|
100559
|
+
"heat-rise",
|
|
100560
|
+
"rise"
|
|
100561
|
+
],
|
|
100562
|
+
idle: INFO,
|
|
100563
|
+
standby: MUTED
|
|
100564
|
+
});
|
|
100565
|
+
var CLIMATE_LOOK = lookOf({
|
|
100566
|
+
icon: "snowflake",
|
|
100567
|
+
on: [
|
|
100568
|
+
"primary",
|
|
100569
|
+
"plain",
|
|
100570
|
+
"none"
|
|
100571
|
+
],
|
|
100572
|
+
off: MUTED,
|
|
100573
|
+
running: [
|
|
100574
|
+
"primary",
|
|
100575
|
+
"plain",
|
|
100576
|
+
"none"
|
|
100577
|
+
],
|
|
100578
|
+
idle: INFO,
|
|
100579
|
+
standby: MUTED
|
|
100580
|
+
});
|
|
100581
|
+
var WATER_HEATER_LOOK = lookOf({
|
|
100582
|
+
icon: "thermometer-sun",
|
|
100583
|
+
on: [
|
|
100584
|
+
"warning",
|
|
100585
|
+
"heat-rise",
|
|
100586
|
+
"rise"
|
|
100587
|
+
],
|
|
100588
|
+
off: MUTED,
|
|
100589
|
+
running: [
|
|
100590
|
+
"warning",
|
|
100591
|
+
"heat-rise",
|
|
100592
|
+
"rise"
|
|
100593
|
+
],
|
|
98390
100594
|
idle: INFO,
|
|
98391
|
-
standby:
|
|
98392
|
-
alert: look("flame", "danger", "alert-wash", "pulse")
|
|
100595
|
+
standby: MUTED
|
|
98393
100596
|
});
|
|
100597
|
+
/** What a climate device draws while it is on, by mode: warm air rises, cold falls, drops dry, the fan spins. */
|
|
100598
|
+
var HERO_MODE_LOOK = {
|
|
100599
|
+
heat: look("flame", "warning", "heat-rise", "rise"),
|
|
100600
|
+
cool: look("snowflake", "info", "cool-fall", "fall"),
|
|
100601
|
+
dry: look("droplets", "info", "water", "wave"),
|
|
100602
|
+
fan: look("fan", "primary", "plain", "spin"),
|
|
100603
|
+
auto: look("thermometer", "success", "glow", "glow"),
|
|
100604
|
+
playing: null,
|
|
100605
|
+
paused: null,
|
|
100606
|
+
open: null,
|
|
100607
|
+
closed: null
|
|
100608
|
+
};
|
|
100609
|
+
var MODE_LOOK_TYPES = [DeviceType.Climate, DeviceType.Thermostat];
|
|
98394
100610
|
var HERO_LOOK_BY_TYPE = {
|
|
98395
|
-
[DeviceType.Camera]:
|
|
100611
|
+
[DeviceType.Camera]: CAMERA_LOOK,
|
|
98396
100612
|
[DeviceType.Hub]: HERO_LOOK_DEFAULT,
|
|
98397
|
-
[DeviceType.Light]:
|
|
100613
|
+
[DeviceType.Light]: LIGHT_LOOK,
|
|
98398
100614
|
[DeviceType.Siren]: HERO_LOOK_DEFAULT,
|
|
98399
100615
|
[DeviceType.Switch]: SWITCH_LOOK,
|
|
98400
|
-
[DeviceType.Sensor]:
|
|
98401
|
-
[DeviceType.Thermostat]:
|
|
98402
|
-
[DeviceType.Climate]:
|
|
98403
|
-
[DeviceType.Button]:
|
|
98404
|
-
[DeviceType.EventEmitter]:
|
|
98405
|
-
[DeviceType.Update]:
|
|
100616
|
+
[DeviceType.Sensor]: READING_SENSOR_LOOK,
|
|
100617
|
+
[DeviceType.Thermostat]: THERMOSTAT_LOOK,
|
|
100618
|
+
[DeviceType.Climate]: CLIMATE_LOOK,
|
|
100619
|
+
[DeviceType.Button]: BUTTON_LOOK,
|
|
100620
|
+
[DeviceType.EventEmitter]: EVENT_EMITTER_LOOK,
|
|
100621
|
+
[DeviceType.Update]: UPDATE_LOOK,
|
|
98406
100622
|
[DeviceType.Generic]: HERO_LOOK_DEFAULT,
|
|
98407
100623
|
[DeviceType.Notifier]: HERO_LOOK_DEFAULT,
|
|
98408
|
-
[DeviceType.Script]:
|
|
98409
|
-
[DeviceType.Automation]:
|
|
98410
|
-
[DeviceType.Lock]:
|
|
98411
|
-
[DeviceType.Cover]:
|
|
98412
|
-
[DeviceType.Valve]:
|
|
98413
|
-
[DeviceType.Humidifier]:
|
|
98414
|
-
[DeviceType.WaterHeater]:
|
|
98415
|
-
[DeviceType.Fan]:
|
|
100624
|
+
[DeviceType.Script]: SCRIPT_LOOK,
|
|
100625
|
+
[DeviceType.Automation]: AUTOMATION_LOOK,
|
|
100626
|
+
[DeviceType.Lock]: LOCK_LOOK,
|
|
100627
|
+
[DeviceType.Cover]: COVER_LOOK,
|
|
100628
|
+
[DeviceType.Valve]: VALVE_LOOK,
|
|
100629
|
+
[DeviceType.Humidifier]: HUMIDIFIER_LOOK,
|
|
100630
|
+
[DeviceType.WaterHeater]: WATER_HEATER_LOOK,
|
|
100631
|
+
[DeviceType.Fan]: FAN_LOOK,
|
|
98416
100632
|
[DeviceType.MediaPlayer]: MEDIA_PLAYER_LOOK,
|
|
98417
|
-
[DeviceType.AlarmPanel]:
|
|
98418
|
-
[DeviceType.Control]:
|
|
98419
|
-
[DeviceType.Presence]:
|
|
98420
|
-
[DeviceType.Weather]:
|
|
98421
|
-
[DeviceType.Vacuum]:
|
|
98422
|
-
[DeviceType.LawnMower]:
|
|
100633
|
+
[DeviceType.AlarmPanel]: ALARM_LOOK,
|
|
100634
|
+
[DeviceType.Control]: CONTROL_LOOK,
|
|
100635
|
+
[DeviceType.Presence]: PRESENCE_LOOK,
|
|
100636
|
+
[DeviceType.Weather]: WEATHER_LOOK,
|
|
100637
|
+
[DeviceType.Vacuum]: VACUUM_LOOK,
|
|
100638
|
+
[DeviceType.LawnMower]: MOWER_LOOK,
|
|
98423
100639
|
[DeviceType.Container]: HERO_LOOK_DEFAULT,
|
|
98424
|
-
[DeviceType.Image]:
|
|
98425
|
-
[DeviceType.PetFeeder]:
|
|
98426
|
-
[DeviceType.PetFountain]:
|
|
100640
|
+
[DeviceType.Image]: IMAGE_LOOK,
|
|
100641
|
+
[DeviceType.PetFeeder]: FEEDER_LOOK,
|
|
100642
|
+
[DeviceType.PetFountain]: FOUNTAIN_LOOK,
|
|
98427
100643
|
[DeviceType.Dishwasher]: DISHWASHER_LOOK,
|
|
98428
100644
|
[DeviceType.Washer]: WASHER_LOOK,
|
|
98429
100645
|
[DeviceType.Heater]: HEATER_LOOK,
|
|
@@ -98435,12 +100651,12 @@ var HERO_LOOK_BY_ROLE = {
|
|
|
98435
100651
|
[DeviceRole.Siren]: "inherit",
|
|
98436
100652
|
[DeviceRole.Floodlight]: "inherit",
|
|
98437
100653
|
[DeviceRole.Spotlight]: "inherit",
|
|
98438
|
-
[DeviceRole.PirSensor]:
|
|
100654
|
+
[DeviceRole.PirSensor]: MOTION_LOOK,
|
|
98439
100655
|
[DeviceRole.Chime]: "inherit",
|
|
98440
100656
|
[DeviceRole.Autotrack]: "inherit",
|
|
98441
100657
|
[DeviceRole.Nightvision]: "inherit",
|
|
98442
100658
|
[DeviceRole.PrivacyMask]: "inherit",
|
|
98443
|
-
[DeviceRole.Doorbell]:
|
|
100659
|
+
[DeviceRole.Doorbell]: DOORBELL_LOOK,
|
|
98444
100660
|
[DeviceRole.CoverBlind]: "inherit",
|
|
98445
100661
|
[DeviceRole.CoverShutter]: "inherit",
|
|
98446
100662
|
[DeviceRole.CoverAwning]: "inherit",
|
|
@@ -98451,21 +100667,21 @@ var HERO_LOOK_BY_ROLE = {
|
|
|
98451
100667
|
[DeviceRole.CoverWindow]: "inherit",
|
|
98452
100668
|
[DeviceRole.BinaryHelper]: "inherit",
|
|
98453
100669
|
[DeviceRole.Outlet]: "inherit",
|
|
98454
|
-
[DeviceRole.MotionSensor]:
|
|
100670
|
+
[DeviceRole.MotionSensor]: MOTION_LOOK,
|
|
98455
100671
|
[DeviceRole.ContactSensor]: "inherit",
|
|
98456
100672
|
[DeviceRole.LeakSensor]: LEAK_LOOK,
|
|
98457
100673
|
[DeviceRole.SmokeSensor]: SMOKE_LOOK,
|
|
98458
|
-
[DeviceRole.COSensor]:
|
|
98459
|
-
[DeviceRole.GasSensor]:
|
|
98460
|
-
[DeviceRole.TamperSensor]:
|
|
98461
|
-
[DeviceRole.VibrationSensor]:
|
|
100674
|
+
[DeviceRole.COSensor]: CO_LOOK,
|
|
100675
|
+
[DeviceRole.GasSensor]: GAS_LOOK,
|
|
100676
|
+
[DeviceRole.TamperSensor]: TAMPER_LOOK,
|
|
100677
|
+
[DeviceRole.VibrationSensor]: VIBRATION_LOOK,
|
|
98462
100678
|
[DeviceRole.ConnectivitySensor]: "inherit",
|
|
98463
100679
|
[DeviceRole.SoundSensor]: "inherit",
|
|
98464
100680
|
[DeviceRole.BinarySensor]: "inherit",
|
|
98465
|
-
[DeviceRole.TemperatureSensor]:
|
|
98466
|
-
[DeviceRole.HumiditySensor]:
|
|
98467
|
-
[DeviceRole.AmbientLightSensor]:
|
|
98468
|
-
[DeviceRole.PressureSensor]:
|
|
100681
|
+
[DeviceRole.TemperatureSensor]: TEMPERATURE_LOOK,
|
|
100682
|
+
[DeviceRole.HumiditySensor]: HUMIDITY_LOOK,
|
|
100683
|
+
[DeviceRole.AmbientLightSensor]: LIGHT_SENSOR_LOOK,
|
|
100684
|
+
[DeviceRole.PressureSensor]: READING_SENSOR_LOOK,
|
|
98469
100685
|
[DeviceRole.WindSensor]: "inherit",
|
|
98470
100686
|
[DeviceRole.RainSensor]: "inherit",
|
|
98471
100687
|
[DeviceRole.UvSensor]: "inherit",
|
|
@@ -98475,7 +100691,7 @@ var HERO_LOOK_BY_ROLE = {
|
|
|
98475
100691
|
[DeviceRole.EnergySensor]: "inherit",
|
|
98476
100692
|
[DeviceRole.VoltageSensor]: "inherit",
|
|
98477
100693
|
[DeviceRole.CurrentSensor]: "inherit",
|
|
98478
|
-
[DeviceRole.AirQualitySensor]:
|
|
100694
|
+
[DeviceRole.AirQualitySensor]: AIR_QUALITY_LOOK,
|
|
98479
100695
|
[DeviceRole.BatterySensor]: "inherit",
|
|
98480
100696
|
[DeviceRole.NumericSensor]: "inherit",
|
|
98481
100697
|
[DeviceRole.EnumSensor]: "inherit",
|
|
@@ -98497,14 +100713,25 @@ function isDeviceType(type) {
|
|
|
98497
100713
|
function isDeviceRole(role) {
|
|
98498
100714
|
return Object.values(DeviceRole).includes(role);
|
|
98499
100715
|
}
|
|
98500
|
-
/**
|
|
98501
|
-
|
|
100716
|
+
/**
|
|
100717
|
+
* The look of a (role, type) pair, for a state. Role beats type beats the generic default.
|
|
100718
|
+
* A climate device that is on draws its MODE (`mode` is the scene's); a role never loses to it.
|
|
100719
|
+
*/
|
|
100720
|
+
function resolveHeroLook(role, type, state, mode = null) {
|
|
98502
100721
|
const byRole = role !== null && isDeviceRole(role) ? HERO_LOOK_BY_ROLE[role] : void 0;
|
|
98503
100722
|
if (byRole !== void 0 && byRole !== "inherit") return byRole[state];
|
|
100723
|
+
if (mode !== null && (state === "on" || state === "running") && MODE_LOOK_TYPES.includes(type)) {
|
|
100724
|
+
const byMode = HERO_MODE_LOOK[mode];
|
|
100725
|
+
if (byMode !== null) return byMode;
|
|
100726
|
+
}
|
|
98504
100727
|
return ((isDeviceType(type) ? HERO_LOOK_BY_TYPE[type] : void 0) ?? HERO_LOOK_DEFAULT)[state];
|
|
98505
100728
|
}
|
|
98506
100729
|
/** The media player's offer outranks a bound switch: the player's own state is the device's. */
|
|
98507
|
-
var OWN_POWER_SOURCE_ORDER = [
|
|
100730
|
+
var OWN_POWER_SOURCE_ORDER = [
|
|
100731
|
+
"media-player",
|
|
100732
|
+
"climate-control",
|
|
100733
|
+
"switch"
|
|
100734
|
+
];
|
|
98508
100735
|
function resolveOwnPower(offers) {
|
|
98509
100736
|
for (const source of OWN_POWER_SOURCE_ORDER) {
|
|
98510
100737
|
const offer = offers.find((o) => o.source === source);
|
|
@@ -98526,9 +100753,41 @@ function resolveOwnPower(offers) {
|
|
|
98526
100753
|
var STATE_SOURCE_ORDER = [
|
|
98527
100754
|
"media-player",
|
|
98528
100755
|
"dishwasher",
|
|
100756
|
+
"lock-control",
|
|
100757
|
+
"alarm-panel",
|
|
100758
|
+
"vacuum-control",
|
|
100759
|
+
"lawn-mower-control",
|
|
100760
|
+
"fan-control",
|
|
100761
|
+
"pet-feeder",
|
|
100762
|
+
"pet-fountain",
|
|
100763
|
+
"automation-control",
|
|
100764
|
+
"script-runner",
|
|
100765
|
+
"event-emitter",
|
|
98529
100766
|
"running-state",
|
|
98530
100767
|
"switch",
|
|
98531
|
-
"contact"
|
|
100768
|
+
"contact",
|
|
100769
|
+
"group-active",
|
|
100770
|
+
"cover",
|
|
100771
|
+
"valve",
|
|
100772
|
+
"humidifier",
|
|
100773
|
+
"brightness",
|
|
100774
|
+
"smoke",
|
|
100775
|
+
"flood",
|
|
100776
|
+
"gas",
|
|
100777
|
+
"tamper",
|
|
100778
|
+
"vibration",
|
|
100779
|
+
"doorbell",
|
|
100780
|
+
"motion",
|
|
100781
|
+
"presence",
|
|
100782
|
+
"update",
|
|
100783
|
+
"weather",
|
|
100784
|
+
"image",
|
|
100785
|
+
"control",
|
|
100786
|
+
"meter",
|
|
100787
|
+
"binary",
|
|
100788
|
+
"button",
|
|
100789
|
+
"climate-control",
|
|
100790
|
+
"sensor"
|
|
98532
100791
|
];
|
|
98533
100792
|
var STATE_TEXT = {
|
|
98534
100793
|
on: t("On", "Acceso"),
|
|
@@ -98541,6 +100800,10 @@ var STATE_TEXT = {
|
|
|
98541
100800
|
unknown: t("Unknown", "Sconosciuto")
|
|
98542
100801
|
};
|
|
98543
100802
|
function pickReading(readings) {
|
|
100803
|
+
for (const source of STATE_SOURCE_ORDER) {
|
|
100804
|
+
const alarm = readings.find((r) => r.source === source && r.state === "alert");
|
|
100805
|
+
if (alarm !== void 0) return alarm;
|
|
100806
|
+
}
|
|
98544
100807
|
for (const source of STATE_SOURCE_ORDER) {
|
|
98545
100808
|
const found = readings.find((r) => r.source === source && r.state !== "unknown");
|
|
98546
100809
|
if (found !== void 0) return found;
|
|
@@ -98555,21 +100818,25 @@ function runningOf(input) {
|
|
|
98555
100818
|
function stateOf(input, readings) {
|
|
98556
100819
|
if (!input.device.online) return {
|
|
98557
100820
|
state: "offline",
|
|
98558
|
-
assumed: false
|
|
100821
|
+
assumed: false,
|
|
100822
|
+
title: STATE_TEXT.offline
|
|
98559
100823
|
};
|
|
98560
100824
|
const picked = pickReading(readings);
|
|
98561
100825
|
if (picked === null) return {
|
|
98562
100826
|
state: "unknown",
|
|
98563
|
-
assumed: false
|
|
100827
|
+
assumed: false,
|
|
100828
|
+
title: STATE_TEXT.unknown
|
|
98564
100829
|
};
|
|
98565
100830
|
const switchOff = readings.some((r) => r.source === "switch" && r.state === "off");
|
|
98566
100831
|
if (picked.source === "running-state" && picked.state === "idle" && switchOff) return {
|
|
98567
100832
|
state: "off",
|
|
98568
|
-
assumed: false
|
|
100833
|
+
assumed: false,
|
|
100834
|
+
title: STATE_TEXT.off
|
|
98569
100835
|
};
|
|
98570
100836
|
return {
|
|
98571
100837
|
state: picked.state,
|
|
98572
|
-
assumed: picked.assumed
|
|
100838
|
+
assumed: picked.assumed,
|
|
100839
|
+
title: picked.title ?? STATE_TEXT[picked.state]
|
|
98573
100840
|
};
|
|
98574
100841
|
}
|
|
98575
100842
|
function provenanceOf(cap, fragment) {
|
|
@@ -98618,15 +100885,17 @@ function buildHeroModel(input) {
|
|
|
98618
100885
|
features: input.features,
|
|
98619
100886
|
now: input.now,
|
|
98620
100887
|
running: runningOf(input),
|
|
98621
|
-
remoteCommands: input.remoteCommands
|
|
100888
|
+
remoteCommands: input.remoteCommands,
|
|
100889
|
+
caps: input.caps
|
|
98622
100890
|
};
|
|
98623
100891
|
const contributed = HERO_CAP_CONTRIBUTIONS.filter((c) => input.caps.includes(c.cap)).map((c) => ({
|
|
98624
100892
|
cap: c.cap,
|
|
98625
100893
|
fragment: c.contribute(input.slices[c.cap], ctx)
|
|
98626
100894
|
}));
|
|
98627
100895
|
const fragments = contributed.map((c) => c.fragment);
|
|
98628
|
-
const { state, assumed } = stateOf(input, fragments.flatMap((f) => f.reading === void 0 ? [] : [f.reading]));
|
|
98629
|
-
const
|
|
100896
|
+
const { state, assumed, title } = stateOf(input, fragments.flatMap((f) => f.reading === void 0 ? [] : [f.reading]));
|
|
100897
|
+
const scene = sceneOf(device.role, device.type, fragments);
|
|
100898
|
+
const look = resolveHeroLook(device.role, device.type, state, scene.mode);
|
|
98630
100899
|
const artworkUrl = fragments.find((f) => f.artworkUrl !== void 0)?.artworkUrl;
|
|
98631
100900
|
const background = artworkUrl === void 0 || state === "offline" ? {
|
|
98632
100901
|
kind: "state",
|
|
@@ -98650,7 +100919,8 @@ function buildHeroModel(input) {
|
|
|
98650
100919
|
const powerSupply = fragments.find((f) => f.powerSupply !== void 0)?.powerSupply ?? null;
|
|
98651
100920
|
const remote = fragments.find((f) => f.remote !== void 0)?.remote ?? null;
|
|
98652
100921
|
const badges = fragments.flatMap((f) => f.badges ?? []);
|
|
98653
|
-
const
|
|
100922
|
+
const headline = state === "offline" || state === "unknown" ? void 0 : fragments.find((f) => f.title !== void 0)?.title;
|
|
100923
|
+
const facts = fragments.flatMap((f) => f.facts ?? []).filter((f) => headline === void 0 || f.text.en !== headline.en);
|
|
98654
100924
|
const sideTiles = {
|
|
98655
100925
|
left: tilesOf(fragments, "left"),
|
|
98656
100926
|
right: tilesOf(fragments, "right")
|
|
@@ -98672,10 +100942,10 @@ function buildHeroModel(input) {
|
|
|
98672
100942
|
stateAssumed: assumed,
|
|
98673
100943
|
look,
|
|
98674
100944
|
background,
|
|
98675
|
-
scene
|
|
100945
|
+
scene,
|
|
98676
100946
|
facts,
|
|
98677
100947
|
sideTiles,
|
|
98678
|
-
title:
|
|
100948
|
+
title: headline ?? title,
|
|
98679
100949
|
badges,
|
|
98680
100950
|
remote,
|
|
98681
100951
|
consumables: fragments.find((f) => f.consumables !== void 0)?.consumables ?? null,
|
|
@@ -112225,7 +114495,7 @@ Object.freeze({
|
|
|
112225
114495
|
});
|
|
112226
114496
|
/**
|
|
112227
114497
|
* Per-cap runtime-state policy, projected from every `*.cap.ts` that declares
|
|
112228
|
-
* `runtimeState`. 81 caps:
|
|
114498
|
+
* `runtimeState`. 81 caps: 41 `restored`, 40 `session`.
|
|
112229
114499
|
*
|
|
112230
114500
|
* A cap absent from this map has no runtime-state slice at all. A cap PRESENT
|
|
112231
114501
|
* with `durability: 'session'` has one and has decided not to keep it.
|
|
@@ -112272,8 +114542,9 @@ var RUNTIME_STATE_POLICY = {
|
|
|
112272
114542
|
volatileFields: ["lastChangedAt"]
|
|
112273
114543
|
},
|
|
112274
114544
|
"climate-control": {
|
|
112275
|
-
durability: "
|
|
112276
|
-
volatileFields: []
|
|
114545
|
+
durability: "restored",
|
|
114546
|
+
volatileFields: [],
|
|
114547
|
+
restoredFields: ["lastActiveMode"]
|
|
112277
114548
|
},
|
|
112278
114549
|
"color": {
|
|
112279
114550
|
durability: "session",
|
|
@@ -112325,7 +114596,7 @@ var RUNTIME_STATE_POLICY = {
|
|
|
112325
114596
|
},
|
|
112326
114597
|
"enum-sensor": {
|
|
112327
114598
|
durability: "restored",
|
|
112328
|
-
volatileFields: ["lastFetchedAt"]
|
|
114599
|
+
volatileFields: ["lastFetchedAt", "timestamp"]
|
|
112329
114600
|
},
|
|
112330
114601
|
"event-emitter": {
|
|
112331
114602
|
durability: "session",
|
|
@@ -112536,8 +114807,9 @@ var RUNTIME_STATE_POLICY = {
|
|
|
112536
114807
|
volatileFields: ["lastChangedAt"]
|
|
112537
114808
|
},
|
|
112538
114809
|
"water-heater": {
|
|
112539
|
-
durability: "
|
|
112540
|
-
volatileFields: []
|
|
114810
|
+
durability: "restored",
|
|
114811
|
+
volatileFields: [],
|
|
114812
|
+
restoredFields: ["lastActiveMode"]
|
|
112541
114813
|
},
|
|
112542
114814
|
"weather": {
|
|
112543
114815
|
durability: "session",
|