kiosko-plugin-homeassistant 0.2.1 → 0.2.2

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # kiosko-plugin-homeassistant
2
2
 
3
- Home Assistant on the panel, live over its WebSocket API: any entity in big with its history, lists of entities, and what needs you at home (doors left open, low batteries, leaks, the alarm).
3
+ Home Assistant on the panel, live over its WebSocket API: any entity in big with its history, lists of entities, what needs you at home (doors left open, low batteries, leaks, the alarm) and your cameras' latest pictures.
4
4
 
5
5
  A plugin for [Kiosko](https://github.com/kiosko-lcd/kiosko), the widget mosaic for small USB LCD panels.
6
6
 
@@ -88,6 +88,27 @@ Uses: `homeassistant/states`.
88
88
  | `batteryWarn` | number | `20` | Battery warning at |
89
89
  | `batteryAlert` | number | `10` | Battery alert at |
90
90
 
91
+ ### Camera — `homeassistant/camera`
92
+
93
+ The latest picture of a Home Assistant camera (Blink, Reolink, ONVIF…), refreshed every minute, with how old it is; with a motion sensor, a red mark while it sees someone, and it can take over its tile. A still, not live video.
94
+
95
+ ![Camera](docs/camera.png)
96
+
97
+ Uses: `homeassistant/states`.
98
+
99
+ The picture is read from Home Assistant's camera proxy with the camera's own short-lived token (the one in its `entity_picture`, renewed by Home Assistant every few minutes): your long-lived token stays in the source. What the picture is depends on the camera: a fresh still for one that streams; for a battery camera like **Blink**, the last thumbnail it took (on motion, or when asked with Home Assistant's `blink.trigger_camera`), so the age tells how old it is. "Keep the tile while urgent" is off by default: turn it on to have the camera take over its tile while its motion sensor is on.
100
+
101
+ | Option | Type | Default | |
102
+ |---|---|---|---|
103
+ | `entity` | string | `""` | Camera. Its id in Home Assistant: camera.something. |
104
+ | `name` | string | `""` | Name. Empty = the name in Home Assistant. |
105
+ | `showName` | boolean | `true` | Show the name |
106
+ | `showAge` | boolean | `true` | Show how old the picture is. Since the picture last changed. A battery camera (Blink) only takes a new one on motion or when asked. |
107
+ | `motion` | string | `""` | Motion sensor. Empty = binary_sensor.<camera>_motion if there is one (Blink names them so). |
108
+ | `fit` | `cover` \| `contain` | `"cover"` | Fit |
109
+ | `keep` | `center` \| `top` \| `bottom` | `"center"` | Keep in view. What filling crops last: the sky or the ground. |
110
+ | `dim` | number | `0` | Darken. Keeps a bright picture from outshining everything else. |
111
+
91
112
  ## Data sources
92
113
 
93
114
  ### Home Assistant — `homeassistant/states`
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { createRequire as __pluginRequire } from 'node:module'; const require = __pluginRequire(import.meta.url);
2
2
 
3
3
  // src/index.ts
4
- import { defineSource, definePlugin, defineWidget, drawEmpty, listLayout, listOptions, t } from "@kiosko/sdk";
4
+ import { defineSource, definePlugin, defineWidget as defineWidget2, drawEmpty, listLayout, listOptions, t as t2 } from "@kiosko/sdk";
5
5
 
6
6
  // src/ha.ts
7
7
  import { matchFilter, filterPatterns } from "@kiosko/sdk";
@@ -31,8 +31,15 @@ function compact(s) {
31
31
  if (action) e.action = action;
32
32
  const battery = num(a.battery_level) ?? num(a.battery);
33
33
  if (battery !== void 0) e.battery = battery;
34
+ const picture = str(a.entity_picture);
35
+ if (picture && (e.domain === "camera" || e.domain === "image")) e.picture = picture;
34
36
  return e;
35
37
  }
38
+ function httpBase(address) {
39
+ let a = address.trim().replace(/\/+$/, "").replace(/\/api\/websocket$/, "");
40
+ if (!/^[a-z]+:\/\//i.test(a)) a = `http://${a}`;
41
+ return a.replace(/^ws(s?):\/\//i, (_, s) => `http${s}://`);
42
+ }
36
43
  function websocketUrl(address) {
37
44
  let a = address.trim().replace(/\/+$/, "");
38
45
  if (!/^[a-z]+:\/\//i.test(a)) a = `http://${a}`;
@@ -154,8 +161,8 @@ var DANGER = /* @__PURE__ */ new Set(["smoke", "gas", "carbon_monoxide", "moistu
154
161
  var TROUBLE = /* @__PURE__ */ new Set(["problem", "tamper", "battery", "cold", "heat"]);
155
162
  var DEVICE_DOMAINS = /* @__PURE__ */ new Set(["sensor", "binary_sensor", "light", "switch", "lock", "cover", "climate", "fan", "media_player", "vacuum", "camera", "alarm_control_panel", "water_heater", "humidifier", "valve", "siren", "device_tracker"]);
156
163
  function stateText(e, ctx, decimals = -1) {
157
- const { t: t2 } = ctx;
158
- if (e.state === "unavailable" || e.state === "unknown") return t2(WORDS[e.state]);
164
+ const { t: t3 } = ctx;
165
+ if (e.state === "unavailable" || e.state === "unknown") return t3(WORDS[e.state]);
159
166
  if (e.deviceClass === "timestamp") {
160
167
  const at = Date.parse(e.state);
161
168
  if (Number.isFinite(at)) return at <= ctx.now ? ctx.fmt.ago(at) : ctx.fmt.time(at);
@@ -164,16 +171,16 @@ function stateText(e, ctx, decimals = -1) {
164
171
  if (n !== void 0 && e.domain !== "binary_sensor") return withUnit(formatNumber(n, ctx.locale, decimals), e.unit);
165
172
  if (e.domain === "binary_sensor") {
166
173
  const words = BINARY[e.deviceClass ?? ""] ?? on_off(WORDS.on, WORDS.off);
167
- if (e.state === "on" || e.state === "off") return t2(words[e.state]);
174
+ if (e.state === "on" || e.state === "off") return t3(words[e.state]);
168
175
  }
169
176
  if (e.domain === "climate" && e.current !== void 0) {
170
177
  const temp = withUnit(formatNumber(e.current, ctx.locale, decimals), e.unit ?? "\xB0");
171
- return e.action && e.action !== "idle" && e.action !== "off" ? `${temp} \xB7 ${t2(WORDS[e.action] ?? { en: e.action })}` : temp;
178
+ return e.action && e.action !== "idle" && e.action !== "off" ? `${temp} \xB7 ${t3(WORDS[e.action] ?? { en: e.action })}` : temp;
172
179
  }
173
- if (e.domain === "update") return t2(e.state === "on" ? BINARY.update.on : BINARY.update.off);
180
+ if (e.domain === "update") return t3(e.state === "on" ? BINARY.update.on : BINARY.update.off);
174
181
  if ((e.domain === "person" || e.domain === "device_tracker") && !WORDS[e.state]) return e.state;
175
182
  const w = WORDS[e.state];
176
- if (w) return t2(w);
183
+ if (w) return t3(w);
177
184
  const plain = e.state.replace(/_/g, " ");
178
185
  return plain.charAt(0).toUpperCase() + plain.slice(1);
179
186
  }
@@ -361,8 +368,8 @@ function parseHistory(rows) {
361
368
  const out = [];
362
369
  for (const r of rows) {
363
370
  const s = r?.s ?? r?.state;
364
- const t2 = num(r?.lu) ?? num(r?.lc);
365
- const at = t2 !== void 0 ? t2 * 1e3 : Date.parse(String(r?.last_changed ?? r?.last_updated ?? ""));
371
+ const t3 = num(r?.lu) ?? num(r?.lc);
372
+ const at = t3 !== void 0 ? t3 * 1e3 : Date.parse(String(r?.last_changed ?? r?.last_updated ?? ""));
366
373
  const value = numericState({ state: String(s) });
367
374
  if (value !== void 0 && Number.isFinite(at)) out.push({ at, value });
368
375
  }
@@ -387,6 +394,8 @@ function demoHome(now, locale = "en") {
387
394
  { id: "binary_sensor.balcony_door", name: n("Balcony door", "Puerta del balc\xF3n"), state: "on", deviceClass: "door", changedAt: ago(42 * min) },
388
395
  { id: "binary_sensor.front_door", name: n("Front door", "Puerta de entrada"), state: "off", deviceClass: "door", changedAt: ago(95 * min) },
389
396
  { id: "binary_sensor.kitchen_window", name: n("Kitchen window", "Ventana cocina"), state: "off", deviceClass: "window", changedAt: ago(5 * 36e5) },
397
+ { id: "camera.porch", name: n("Porch", "Porche"), state: "idle", picture: "/api/camera_proxy/camera.porch?token=demo", changedAt: ago(3 * 36e5) },
398
+ { id: "binary_sensor.porch_motion", name: n("Porch motion", "Movimiento porche"), state: "off", deviceClass: "motion", changedAt: ago(12 * min) },
390
399
  { id: "binary_sensor.hallway_motion", name: n("Hallway motion", "Movimiento pasillo"), state: "on", deviceClass: "motion", changedAt: ago(1 * min) },
391
400
  { id: "binary_sensor.washing_machine_leak", name: n("Washing machine leak", "Fuga lavadora"), state: "off", deviceClass: "moisture", changedAt: ago(26 * 36e5) },
392
401
  { id: "lock.front_door", name: n("Front door lock", "Cerradura entrada"), state: "locked", changedAt: ago(95 * min) },
@@ -420,7 +429,7 @@ function demoHome(now, locale = "en") {
420
429
  const e = entities2[id];
421
430
  e.state = String(Math.round(last * (e.unit === "W" ? 1 : 10)) / (e.unit === "W" ? 1 : 10));
422
431
  }
423
- return { state: "ok", version: "2026.11.1", entities: entities2, history };
432
+ return { state: "ok", version: "2026.11.1", base: "http://homeassistant.local:8123", entities: entities2, history };
424
433
  }
425
434
 
426
435
  // src/connection.ts
@@ -472,6 +481,7 @@ function connect(o, emit, deps = {}) {
472
481
  ...error ? { error } : {},
473
482
  ...since !== void 0 ? { since } : {},
474
483
  ...version ? { version } : {},
484
+ base: httpBase(o.url),
475
485
  entities: Object.fromEntries(entities2),
476
486
  history
477
487
  });
@@ -644,12 +654,12 @@ function connect(o, emit, deps = {}) {
644
654
  }
645
655
  if (!stopped) retryTimer = timers.setTimeout(open, ms);
646
656
  };
647
- const drop = (why) => {
657
+ const drop = (why2) => {
648
658
  if (stopped) return;
649
659
  const wasUp = status === "ok";
650
660
  if (status !== "error") {
651
661
  status = entities2.size ? "offline" : "error";
652
- error = why;
662
+ error = why2;
653
663
  since ??= timers.now();
654
664
  }
655
665
  if (wasUp || status === "error") changed(true);
@@ -1505,8 +1515,238 @@ function renderClimate(g, ctx, e, box) {
1505
1515
  }
1506
1516
  }
1507
1517
 
1508
- // src/index.ts
1518
+ // src/camera.ts
1519
+ import { createHash } from "node:crypto";
1520
+ import { defineWidget, t } from "@kiosko/sdk";
1509
1521
  var SOURCE = "homeassistant/states";
1522
+ var dataOf = (sources) => sources[SOURCE];
1523
+ var seen = /* @__PURE__ */ new Map();
1524
+ function pictureChangedAt(camera2, bytes, now) {
1525
+ const hash = createHash("sha1").update(bytes).digest("hex");
1526
+ const last = seen.get(camera2);
1527
+ if (last?.hash === hash) return last.at;
1528
+ seen.set(camera2, { hash, at: now });
1529
+ return now;
1530
+ }
1531
+ function motionOf(entities2, camera2, chosen) {
1532
+ if (chosen) return entities2[chosen];
1533
+ const auto = `binary_sensor.${camera2.split(".")[1] ?? ""}_motion`;
1534
+ return entities2[auto];
1535
+ }
1536
+ function placePicture(box, w, h, fit2, fy) {
1537
+ const s = fit2 === "cover" ? Math.max(box.w / w, box.h / h) : Math.min(box.w / w, box.h / h);
1538
+ const dw = w * s, dh = h * s;
1539
+ return { x: box.x + (box.w - dw) / 2, y: box.y + (box.h - dh) * fy, w: dw, h: dh };
1540
+ }
1541
+ var KEEP = { top: 0, center: 0.5, bottom: 1 };
1542
+ var camera = defineWidget({
1543
+ id: "camera",
1544
+ name: { en: "Camera", es: "C\xE1mara" },
1545
+ description: {
1546
+ en: "The latest picture of a Home Assistant camera (Blink, Reolink, ONVIF\u2026), refreshed every minute, with how old it is; with a motion sensor, a red mark while it sees someone, and it can take over its tile. A still, not live video.",
1547
+ es: "La \xFAltima imagen de una c\xE1mara de Home Assistant (Blink, Reolink, ONVIF\u2026), refrescada cada minuto, con su antig\xFCedad; con un sensor de movimiento, una marca roja mientras ve a alguien, y puede quedarse con su tesela. Una foto, no v\xEDdeo en directo."
1548
+ },
1549
+ icon: "cctv",
1550
+ category: "media",
1551
+ tags: ["home assistant", "camera", "blink", "security"],
1552
+ chrome: "bare",
1553
+ size: { min: { w: 120, h: 80 }, preferred: { w: 400, h: 260 } },
1554
+ sources: [SOURCE],
1555
+ options: t.object({
1556
+ entity: t.string({
1557
+ choices: { source: SOURCE, list: "cameras" },
1558
+ placeholder: "camera.porch",
1559
+ label: { en: "Camera", es: "C\xE1mara" },
1560
+ help: { en: "Its id in Home Assistant: camera.something.", es: "Su id en Home Assistant: camera.algo." }
1561
+ }),
1562
+ name: t.string({ label: { en: "Name", es: "Nombre" }, help: { en: "Empty = the name in Home Assistant.", es: "Vac\xEDo = el nombre en Home Assistant." } }),
1563
+ showName: t.boolean({ default: true, label: { en: "Show the name", es: "Mostrar el nombre" } }),
1564
+ showAge: t.boolean({ default: true, label: { en: "Show how old the picture is", es: "Mostrar la antig\xFCedad de la imagen" }, help: { en: "Since the picture last changed. A battery camera (Blink) only takes a new one on motion or when asked.", es: "Desde que cambi\xF3 la imagen por \xFAltima vez. Una c\xE1mara de bater\xEDa (Blink) solo hace otra con movimiento o cuando se le pide." } }),
1565
+ motion: t.string({
1566
+ choices: { source: SOURCE, list: "motion" },
1567
+ placeholder: "binary_sensor.porch_motion",
1568
+ label: { en: "Motion sensor", es: "Sensor de movimiento" },
1569
+ help: { en: "Empty = binary_sensor.<camera>_motion if there is one (Blink names them so).", es: "Vac\xEDo = binary_sensor.<c\xE1mara>_motion si existe (Blink los llama as\xED)." }
1570
+ }),
1571
+ fit: t.enum(["cover", "contain"], { label: { en: "Fit", es: "Ajuste" }, labels: { cover: { en: "Fill (crop)", es: "Llenar (recorta)" }, contain: { en: "Whole picture", es: "Imagen entera" } } }),
1572
+ keep: t.enum(["center", "top", "bottom"], {
1573
+ advanced: true,
1574
+ label: { en: "Keep in view", es: "Mantener a la vista" },
1575
+ labels: { center: { en: "The centre", es: "El centro" }, top: { en: "The top", es: "La parte de arriba" }, bottom: { en: "The bottom", es: "La parte de abajo" } },
1576
+ help: { en: "What filling crops last: the sky or the ground.", es: "Lo \xFAltimo que recorta al llenar: el cielo o el suelo." }
1577
+ }),
1578
+ dim: t.integer({ default: 0, min: 0, max: 90, step: 5, unit: "%", slider: true, advanced: true, label: { en: "Darken", es: "Oscurecer" }, help: { en: "Keeps a bright picture from outshining everything else.", es: "Para que una imagen clara no deslumbre al resto." } })
1579
+ }),
1580
+ intervalMs: 6e4,
1581
+ // Until the connection has the camera, look again soon: the first picture shouldn't wait a minute.
1582
+ intervalOf: ({ data }) => !data || data.state === "waiting" ? 5e3 : void 0,
1583
+ timeoutMs: 3e4,
1584
+ async fetch({ options, sources, canvas, signal }) {
1585
+ if (!options.entity) return { state: "pick" };
1586
+ const d = dataOf(sources);
1587
+ if (!d || !d.base || !Object.keys(d.entities).length) return { state: "waiting" };
1588
+ const e = d.entities[options.entity];
1589
+ if (!e) return { state: "missing" };
1590
+ if (!e.picture) return { state: "nopicture" };
1591
+ const res = await fetch(d.base + e.picture, { signal });
1592
+ if (!res.ok) throw new Error(`Home Assistant answered HTTP ${res.status} for ${options.entity}`);
1593
+ const bytes = new Uint8Array(await res.arrayBuffer());
1594
+ return { state: "ok", img: await canvas.loadImage(Buffer.from(bytes)), changedAt: pictureChangedAt(options.entity, bytes, Date.now()) };
1595
+ },
1596
+ redraw: "minute",
1597
+ urgent: ({ options, sources }) => {
1598
+ const d = dataOf(sources);
1599
+ return d?.state === "ok" && !!options.entity && motionOf(d.entities, options.entity, options.motion)?.state === "on";
1600
+ },
1601
+ // Off by default: a camera's tile is for looking, not for interrupting. The user turns it on.
1602
+ takeOver: false,
1603
+ render(g, ctx) {
1604
+ const { options, sources, data, theme, t: tr } = ctx;
1605
+ const { box } = ctx;
1606
+ const d = dataOf(sources);
1607
+ const e = d?.entities[options.entity];
1608
+ g.fillStyle = theme.colors.surface;
1609
+ g.fillRect(box.x, box.y, box.w, box.h);
1610
+ const pad = Math.round(Math.min(16, box.h * 0.08));
1611
+ const inner = { x: box.x + pad, y: box.y + pad, w: box.w - pad * 2, h: box.h - pad * 2 };
1612
+ if (!data?.img && !data?.demo) {
1613
+ const [text, hint] = why(d, data, options.entity, tr);
1614
+ return drawMessage(g, inner, ctx, text, hint);
1615
+ }
1616
+ g.save();
1617
+ g.beginPath();
1618
+ g.rect(box.x, box.y, box.w, box.h);
1619
+ g.clip();
1620
+ if (data.demo) drawScene(g, box);
1621
+ else {
1622
+ const at = placePicture(box, data.img.width, data.img.height, options.fit, KEEP[options.keep]);
1623
+ g.drawImage(data.img, at.x, at.y, at.w, at.h);
1624
+ }
1625
+ if (options.dim > 0) {
1626
+ g.fillStyle = `rgba(0,0,0,${options.dim / 100})`;
1627
+ g.fillRect(box.x, box.y, box.w, box.h);
1628
+ }
1629
+ const stale = !d || d.state !== "ok" || e?.state === "unavailable";
1630
+ if (stale) {
1631
+ g.fillStyle = "rgba(0,0,0,0.45)";
1632
+ g.fillRect(box.x, box.y, box.w, box.h);
1633
+ }
1634
+ g.restore();
1635
+ const motion = d && e ? motionOf(d.entities, e.id, options.motion) : void 0;
1636
+ overlay(g, ctx, {
1637
+ name: options.showName ? options.name || e?.name || options.entity : "",
1638
+ age: options.showAge && data.changedAt ? ctx.fmt.ago(data.changedAt) : "",
1639
+ motion: motion?.state === "on",
1640
+ stale: stale ? e?.state === "unavailable" ? tr({ en: "camera unavailable", es: "c\xE1mara no disponible" }) : tr({ en: "offline", es: "sin conexi\xF3n" }) : ""
1641
+ });
1642
+ },
1643
+ demo: ({ now, locale }) => ({
1644
+ sources: { [SOURCE]: demoHome(now, locale) },
1645
+ data: { state: "ok", demo: true, changedAt: now - 4 * 6e4 },
1646
+ options: { entity: "camera.porch" }
1647
+ })
1648
+ });
1649
+ function why(d, data, entity2, tr) {
1650
+ if (d?.state === "unconfigured") return [tr({ en: "Home Assistant not set up", es: "Home Assistant sin configurar" }), tr({ en: "Set its address and a token in Settings \u2192 Data sources", es: "Pon su direcci\xF3n y un token en Ajustes \u2192 Fuentes de datos" })];
1651
+ if (!entity2 || data?.state === "pick") return [tr({ en: "Choose a camera", es: "Elige una c\xE1mara" }), tr({ en: "In the inspector: one of your Home Assistant cameras, e.g. camera.porch", es: "En el inspector: una de las c\xE1maras de tu Home Assistant, p. ej. camera.porch" })];
1652
+ if (d?.state === "error" && !Object.keys(d.entities).length) return [tr({ en: "Home Assistant unreachable", es: "Home Assistant no responde" }), d.error];
1653
+ if (data?.state === "missing") return [tr({ en: "Camera not found", es: "C\xE1mara no encontrada" }), entity2];
1654
+ if (data?.state === "nopicture") return [tr({ en: "This camera has no picture", es: "Esta c\xE1mara no tiene imagen" }), tr({ en: "It may be off, or not a camera", es: "Puede que est\xE9 apagada, o que no sea una c\xE1mara" })];
1655
+ return [tr({ en: "Waiting for the camera\u2026", es: "Esperando a la c\xE1mara\u2026" })];
1656
+ }
1657
+ function overlay(g, ctx, o) {
1658
+ const { box, theme, kit } = ctx;
1659
+ const { fonts, colors } = theme;
1660
+ const s = Math.max(11, Math.round(Math.min(22, box.h * 0.085, box.w * 0.05)));
1661
+ const pad = Math.round(s * 0.7);
1662
+ if (o.name || o.age) {
1663
+ const h = s * 2.6;
1664
+ const shade = g.createLinearGradient(0, box.y + box.h - h, 0, box.y + box.h);
1665
+ shade.addColorStop(0, "rgba(0,0,0,0)");
1666
+ shade.addColorStop(1, "rgba(0,0,0,0.72)");
1667
+ g.fillStyle = shade;
1668
+ g.fillRect(box.x, box.y + box.h - h, box.w, h);
1669
+ const base = box.y + box.h - pad;
1670
+ const ageO = { size: Math.round(s * 0.8), family: fonts.sans, color: "rgba(255,255,255,0.75)", align: "right" };
1671
+ const ageW = o.age ? kit.measureTracked(g, o.age, ageO) + pad : 0;
1672
+ if (o.age) kit.drawTracked(g, o.age, box.x + box.w - pad, base, ageO);
1673
+ if (o.name) {
1674
+ const nameO = { size: s, family: fonts.sansBold, color: "#fff" };
1675
+ kit.drawTracked(g, kit.truncate(g, o.name, box.w - pad * 2 - ageW, nameO), box.x + pad, base, nameO);
1676
+ }
1677
+ }
1678
+ let x = box.x + pad;
1679
+ const pill = (text, color, dot) => {
1680
+ const ps = Math.round(s * 0.8);
1681
+ const tw = kit.measureTracked(g, text, { size: ps, family: fonts.sansBold });
1682
+ const h = ps * 1.7, w = tw + ps * (dot ? 2.4 : 1.4);
1683
+ const y = box.y + pad;
1684
+ g.fillStyle = "rgba(0,0,0,0.6)";
1685
+ g.beginPath();
1686
+ g.roundRect(x, y, w, h, h / 2);
1687
+ g.fill();
1688
+ if (dot) {
1689
+ g.fillStyle = color;
1690
+ g.beginPath();
1691
+ g.arc(x + ps * 0.85, y + h / 2, ps * 0.32, 0, Math.PI * 2);
1692
+ g.fill();
1693
+ }
1694
+ kit.drawTracked(g, text, x + ps * (dot ? 1.55 : 0.7), y + h / 2 + ps * 0.36, { size: ps, family: fonts.sansBold, color: dot ? "#fff" : color });
1695
+ x += w + ps * 0.5;
1696
+ };
1697
+ if (o.motion) {
1698
+ pill(ctx.t({ en: "Motion", es: "Movimiento" }), colors.alert, true);
1699
+ g.strokeStyle = colors.alert;
1700
+ g.lineWidth = Math.max(2, Math.round(s * 0.18));
1701
+ g.strokeRect(box.x + g.lineWidth / 2, box.y + g.lineWidth / 2, box.w - g.lineWidth, box.h - g.lineWidth);
1702
+ }
1703
+ if (o.stale) pill(o.stale, colors.warn, false);
1704
+ }
1705
+ function drawScene(g, b) {
1706
+ const sky = g.createLinearGradient(0, b.y, 0, b.y + b.h);
1707
+ sky.addColorStop(0, "#1d2a44");
1708
+ sky.addColorStop(0.55, "#3b4a63");
1709
+ sky.addColorStop(1, "#2a2622");
1710
+ g.fillStyle = sky;
1711
+ g.fillRect(b.x, b.y, b.w, b.h);
1712
+ const floor = b.y + b.h * 0.78;
1713
+ g.fillStyle = "#5b5148";
1714
+ g.fillRect(b.x, b.y + b.h * 0.18, b.w, floor - b.y - b.h * 0.18);
1715
+ g.fillStyle = "#3a332d";
1716
+ g.fillRect(b.x, floor, b.w, b.y + b.h - floor);
1717
+ const dw = b.w * 0.2, dh = b.h * 0.5, dx = b.x + b.w * 0.42, dy = floor - dh;
1718
+ const glow = g.createRadialGradient(dx + dw / 2, dy - b.h * 0.04, 2, dx + dw / 2, dy - b.h * 0.04, b.w * 0.35);
1719
+ glow.addColorStop(0, "rgba(255,214,150,0.55)");
1720
+ glow.addColorStop(1, "rgba(255,214,150,0)");
1721
+ g.fillStyle = glow;
1722
+ g.fillRect(b.x, b.y, b.w, b.h);
1723
+ g.fillStyle = "#2b2018";
1724
+ g.fillRect(dx, dy, dw, dh);
1725
+ g.fillStyle = "#6e4a2f";
1726
+ g.fillRect(dx + dw * 0.08, dy + dh * 0.05, dw * 0.84, dh * 0.95);
1727
+ g.fillStyle = "#d9b26a";
1728
+ g.beginPath();
1729
+ g.arc(dx + dw * 0.78, dy + dh * 0.55, Math.max(1.5, dw * 0.04), 0, Math.PI * 2);
1730
+ g.fill();
1731
+ g.fillStyle = "#ffe2a8";
1732
+ g.fillRect(dx + dw / 2 - dw * 0.08, dy - b.h * 0.07, dw * 0.16, b.h * 0.04);
1733
+ g.fillStyle = "#2f4a33";
1734
+ g.beginPath();
1735
+ g.ellipse(b.x + b.w * 0.24, floor - b.h * 0.12, b.w * 0.05, b.h * 0.11, 0, 0, Math.PI * 2);
1736
+ g.fill();
1737
+ g.fillStyle = "#4a3b30";
1738
+ g.fillRect(b.x + b.w * 0.205, floor - b.h * 0.05, b.w * 0.07, b.h * 0.06);
1739
+ g.fillStyle = "#2a2420";
1740
+ g.fillRect(dx - dw * 0.05, floor + b.h * 0.02, dw * 1.1, b.h * 0.05);
1741
+ const v = g.createRadialGradient(b.x + b.w / 2, b.y + b.h / 2, Math.min(b.w, b.h) * 0.3, b.x + b.w / 2, b.y + b.h / 2, Math.max(b.w, b.h) * 0.75);
1742
+ v.addColorStop(0, "rgba(0,0,0,0)");
1743
+ v.addColorStop(1, "rgba(0,0,0,0.5)");
1744
+ g.fillStyle = v;
1745
+ g.fillRect(b.x, b.y, b.w, b.h);
1746
+ }
1747
+
1748
+ // src/index.ts
1749
+ var SOURCE2 = "homeassistant/states";
1510
1750
  var states = defineSource({
1511
1751
  id: "states",
1512
1752
  name: { en: "Home Assistant", es: "Home Assistant" },
@@ -1514,15 +1754,15 @@ var states = defineSource({
1514
1754
  en: "The states of your Home Assistant entities, live over its WebSocket API (a change shows at once), and the last day of the numeric sensors for the history bars.",
1515
1755
  es: "Los estados de las entidades de tu Home Assistant, en directo por su API WebSocket (un cambio se ve al momento), y el \xFAltimo d\xEDa de los sensores num\xE9ricos para las barras de hist\xF3rico."
1516
1756
  },
1517
- options: t.object({
1518
- url: t.string({
1757
+ options: t2.object({
1758
+ url: t2.string({
1519
1759
  format: "url",
1520
1760
  risk: "network",
1521
1761
  placeholder: "http://homeassistant.local:8123",
1522
1762
  label: { en: "Home Assistant address", es: "Direcci\xF3n de Home Assistant" },
1523
1763
  help: { en: "The one you open in the browser, e.g. http://homeassistant.local:8123 or https://home.example.com.", es: "La que abres en el navegador, p. ej. http://homeassistant.local:8123 o https://casa.example.com." }
1524
1764
  }),
1525
- token: t.string({
1765
+ token: t2.string({
1526
1766
  secret: true,
1527
1767
  label: { en: "Long-lived access token", es: "Token de acceso de larga duraci\xF3n" },
1528
1768
  help: {
@@ -1530,16 +1770,16 @@ var states = defineSource({
1530
1770
  es: "En Home Assistant: tu perfil \u2192 Seguridad \u2192 Tokens de acceso de larga duraci\xF3n \u2192 Crear token. Basta un usuario que no sea administrador."
1531
1771
  }
1532
1772
  }),
1533
- entities: t.filter({
1773
+ entities: t2.filter({
1534
1774
  label: { en: "Entities to read", es: "Entidades que leer" },
1535
1775
  help: { en: "Empty = all. Ids or names, with * and !: sensor.*, binary_sensor.*, lock.*, !sensor.*_linkquality.", es: "Vac\xEDo = todas. Ids o nombres, con * y !: sensor.*, binary_sensor.*, lock.*, !sensor.*_linkquality." }
1536
1776
  }),
1537
- history: t.filter({
1777
+ history: t2.filter({
1538
1778
  advanced: true,
1539
1779
  label: { en: "Entities with history", es: "Entidades con hist\xF3rico" },
1540
1780
  help: { en: "Numeric sensors whose last day is kept for the history bars. Empty = every one with a unit.", es: "Sensores num\xE9ricos de los que se guarda el \xFAltimo d\xEDa para las barras de hist\xF3rico. Vac\xEDo = todos los que tienen unidad." }
1541
1781
  }),
1542
- maxHistory: t.integer({
1782
+ maxHistory: t2.integer({
1543
1783
  default: 100,
1544
1784
  min: 0,
1545
1785
  max: 1e3,
@@ -1552,11 +1792,14 @@ var states = defineSource({
1552
1792
  demo: ({ now, locale }) => demoHome(now, locale),
1553
1793
  // Every entity it reads, by name, grouped by domain: for the entity field and the filters.
1554
1794
  choices: {
1555
- entities: (d) => Object.values(d?.entities ?? {}).sort((a, b) => a.domain.localeCompare(b.domain) || a.name.localeCompare(b.name)).map((e) => ({ value: e.id, label: e.name, group: e.domain }))
1795
+ entities: (d) => Object.values(d?.entities ?? {}).sort((a, b) => a.domain.localeCompare(b.domain) || a.name.localeCompare(b.name)).map((e) => ({ value: e.id, label: e.name, group: e.domain })),
1796
+ // The cameras, for the camera widget; and the motion sensors to go with them.
1797
+ cameras: (d) => Object.values(d?.entities ?? {}).filter((e) => e.picture).sort((a, b) => a.name.localeCompare(b.name)).map((e) => ({ value: e.id, label: e.name, group: e.domain })),
1798
+ motion: (d) => Object.values(d?.entities ?? {}).filter((e) => e.domain === "binary_sensor" && ["motion", "occupancy", "presence"].includes(e.deviceClass ?? "")).sort((a, b) => a.name.localeCompare(b.name)).map((e) => ({ value: e.id, label: e.name }))
1556
1799
  }
1557
1800
  });
1558
- var dataOf = (sources) => sources[SOURCE];
1559
- var demo = ({ now, locale }) => ({ sources: { [SOURCE]: demoHome(now, locale) } });
1801
+ var dataOf2 = (sources) => sources[SOURCE2];
1802
+ var demo = ({ now, locale }) => ({ sources: { [SOURCE2]: demoHome(now, locale) } });
1560
1803
  function frame(g, box, ctx, data) {
1561
1804
  if (!data) return null;
1562
1805
  const tr = ctx.t;
@@ -1581,10 +1824,10 @@ function frame(g, box, ctx, data) {
1581
1824
  }
1582
1825
  var live = (d) => !!d && (d.state === "ok" || d.state === "offline" || d.state === "error" && Object.keys(d.entities).length > 0);
1583
1826
  var batteryFields = () => ({
1584
- batteryWarn: t.integer({ default: 20, min: 0, max: 100, unit: "%", advanced: true, label: { en: "Battery warning at", es: "Bater\xEDa en aviso desde" } }),
1585
- batteryAlert: t.integer({ default: 10, min: 0, max: 100, unit: "%", advanced: true, label: { en: "Battery alert at", es: "Bater\xEDa en alerta desde" } })
1827
+ batteryWarn: t2.integer({ default: 20, min: 0, max: 100, unit: "%", advanced: true, label: { en: "Battery warning at", es: "Bater\xEDa en aviso desde" } }),
1828
+ batteryAlert: t2.integer({ default: 10, min: 0, max: 100, unit: "%", advanced: true, label: { en: "Battery alert at", es: "Bater\xEDa en alerta desde" } })
1586
1829
  });
1587
- var entity = defineWidget({
1830
+ var entity = defineWidget2({
1588
1831
  id: "entity",
1589
1832
  name: { en: "Entity", es: "Entidad" },
1590
1833
  description: {
@@ -1595,35 +1838,35 @@ var entity = defineWidget({
1595
1838
  category: "info",
1596
1839
  tags: ["home assistant", "smart home", "sensor"],
1597
1840
  size: { min: { w: 140, h: 80 }, preferred: { w: 320, h: 200 } },
1598
- sources: [SOURCE],
1599
- options: t.object({
1600
- entity: t.string({
1601
- choices: { source: SOURCE, list: "entities" },
1841
+ sources: [SOURCE2],
1842
+ options: t2.object({
1843
+ entity: t2.string({
1844
+ choices: { source: SOURCE2, list: "entities" },
1602
1845
  placeholder: "sensor.living_room_temperature",
1603
1846
  label: { en: "Entity", es: "Entidad" },
1604
1847
  help: { en: "Its id, as in Home Assistant \u2192 Settings \u2192 Devices & services \u2192 Entities.", es: "Su id, como en Home Assistant \u2192 Ajustes \u2192 Dispositivos y servicios \u2192 Entidades." }
1605
1848
  }),
1606
- name: t.string({ label: { en: "Name", es: "Nombre" }, help: { en: "Empty = the name in Home Assistant.", es: "Vac\xEDo = el nombre en Home Assistant." } }),
1607
- showName: t.boolean({ default: true, label: { en: "Show the name", es: "Mostrar el nombre" } }),
1608
- showHistory: t.boolean({ default: true, label: { en: "Show the history", es: "Mostrar el hist\xF3rico" }, help: { en: "Numeric sensors only, when the source keeps their history.", es: "Solo sensores num\xE9ricos cuyo hist\xF3rico guarda la fuente." } }),
1609
- historyMs: t.duration({ default: 24 * 36e5, min: 36e5, max: 24 * 36e5, label: { en: "History span", es: "Periodo del hist\xF3rico" } }),
1610
- decimals: t.integer({ default: -1, min: -1, max: 4, advanced: true, label: { en: "Decimals", es: "Decimales" }, help: { en: "-1 = automatic: fewer as the number grows.", es: "-1 = autom\xE1tico: menos cuanto mayor es el n\xFAmero." } }),
1611
- thresholds: t.enum(["off", "above", "below"], {
1849
+ name: t2.string({ label: { en: "Name", es: "Nombre" }, help: { en: "Empty = the name in Home Assistant.", es: "Vac\xEDo = el nombre en Home Assistant." } }),
1850
+ showName: t2.boolean({ default: true, label: { en: "Show the name", es: "Mostrar el nombre" } }),
1851
+ showHistory: t2.boolean({ default: true, label: { en: "Show the history", es: "Mostrar el hist\xF3rico" }, help: { en: "Numeric sensors only, when the source keeps their history.", es: "Solo sensores num\xE9ricos cuyo hist\xF3rico guarda la fuente." } }),
1852
+ historyMs: t2.duration({ default: 24 * 36e5, min: 36e5, max: 24 * 36e5, label: { en: "History span", es: "Periodo del hist\xF3rico" } }),
1853
+ decimals: t2.integer({ default: -1, min: -1, max: 4, advanced: true, label: { en: "Decimals", es: "Decimales" }, help: { en: "-1 = automatic: fewer as the number grows.", es: "-1 = autom\xE1tico: menos cuanto mayor es el n\xFAmero." } }),
1854
+ thresholds: t2.enum(["off", "above", "below"], {
1612
1855
  default: "off",
1613
1856
  label: { en: "Thresholds", es: "Umbrales" },
1614
1857
  labels: { off: { en: "Off", es: "No" }, above: { en: "Warn above", es: "Avisar por encima" }, below: { en: "Warn below", es: "Avisar por debajo" } }
1615
1858
  }),
1616
- warn: t.number({ default: 0, min: -1e6, max: 1e6, label: { en: "Warning (amber) at", es: "Aviso (\xE1mbar) en" } }),
1617
- alert: t.number({ default: 0, min: -1e6, max: 1e6, label: { en: "Alert (red) at", es: "Alerta (rojo) en" }, help: { en: "Red, and the widget keeps its tile.", es: "Rojo, y el widget se queda con su tesela." } })
1859
+ warn: t2.number({ default: 0, min: -1e6, max: 1e6, label: { en: "Warning (amber) at", es: "Aviso (\xE1mbar) en" } }),
1860
+ alert: t2.number({ default: 0, min: -1e6, max: 1e6, label: { en: "Alert (red) at", es: "Alerta (rojo) en" }, help: { en: "Red, and the widget keeps its tile.", es: "Rojo, y el widget se queda con su tesela." } })
1618
1861
  }),
1619
1862
  redraw: "minute",
1620
1863
  urgent: ({ options, sources }) => {
1621
- const e = dataOf(sources)?.entities[options.entity];
1622
- return !!e && dataOf(sources)?.state === "ok" && thresholdLevel(e, options) === "alert";
1864
+ const e = dataOf2(sources)?.entities[options.entity];
1865
+ return !!e && dataOf2(sources)?.state === "ok" && thresholdLevel(e, options) === "alert";
1623
1866
  },
1624
1867
  render(g, ctx) {
1625
1868
  const { options, sources, t: tr } = ctx;
1626
- const data = dataOf(sources);
1869
+ const data = dataOf2(sources);
1627
1870
  const box = frame(g, ctx.box, ctx, data);
1628
1871
  if (!box || !data) return;
1629
1872
  if (!options.entity) return drawMessage(g, box, ctx, tr({ en: "Choose an entity", es: "Elige una entidad" }), tr({ en: "Its id in the inspector, e.g. sensor.living_room_temperature", es: "Su id en el inspector, p. ej. sensor.living_room_temperature" }));
@@ -1632,7 +1875,7 @@ var entity = defineWidget({
1632
1875
  },
1633
1876
  demo: ({ now, locale }) => ({ ...demo({ now, locale }), options: { entity: "sensor.living_room_temperature" } })
1634
1877
  });
1635
- var entities = defineWidget({
1878
+ var entities = defineWidget2({
1636
1879
  id: "entities",
1637
1880
  name: { en: "Entities", es: "Entidades" },
1638
1881
  description: {
@@ -1643,27 +1886,27 @@ var entities = defineWidget({
1643
1886
  category: "info",
1644
1887
  tags: ["home assistant", "smart home"],
1645
1888
  size: { min: { w: 220, h: 90 }, preferred: { w: 480, h: 260 } },
1646
- sources: [SOURCE],
1647
- options: t.object({
1889
+ sources: [SOURCE2],
1890
+ options: t2.object({
1648
1891
  ...listOptions({ layouts: ["one-line", "detailed"] }),
1649
- entities: t.filter({
1650
- choices: { source: SOURCE, list: "entities" },
1892
+ entities: t2.filter({
1893
+ choices: { source: SOURCE2, list: "entities" },
1651
1894
  label: { en: "Entities", es: "Entidades" },
1652
1895
  help: { en: "Ids or names, in the order to list them: sensor.*_temperature, light.*, *kitchen*, !light.porch. Empty = all.", es: "Ids o nombres, en el orden en que listarlas: sensor.*_temperature, light.*, *cocina*, !light.porch. Vac\xEDo = todas." }
1653
1896
  }),
1654
- hideOff: t.boolean({ label: { en: "Only what is on, open or wrong", es: "Solo lo encendido, abierto o con problemas" }, help: { en: "Leaves out what is off or closed. Numbers always stay.", es: "Deja fuera lo apagado o cerrado. Los n\xFAmeros se quedan siempre." } }),
1655
- hideUnavailable: t.boolean({ label: { en: "Hide unavailable entities", es: "Ocultar las entidades no disponibles" } }),
1656
- decimals: t.integer({ default: -1, min: -1, max: 4, advanced: true, label: { en: "Decimals", es: "Decimales" }, help: { en: "-1 = automatic.", es: "-1 = autom\xE1tico." } }),
1897
+ hideOff: t2.boolean({ label: { en: "Only what is on, open or wrong", es: "Solo lo encendido, abierto o con problemas" }, help: { en: "Leaves out what is off or closed. Numbers always stay.", es: "Deja fuera lo apagado o cerrado. Los n\xFAmeros se quedan siempre." } }),
1898
+ hideUnavailable: t2.boolean({ label: { en: "Hide unavailable entities", es: "Ocultar las entidades no disponibles" } }),
1899
+ decimals: t2.integer({ default: -1, min: -1, max: 4, advanced: true, label: { en: "Decimals", es: "Decimales" }, help: { en: "-1 = automatic.", es: "-1 = autom\xE1tico." } }),
1657
1900
  ...batteryFields()
1658
1901
  }),
1659
1902
  redraw: "minute",
1660
1903
  empty: ({ options, sources }) => {
1661
- const d = dataOf(sources);
1904
+ const d = dataOf2(sources);
1662
1905
  return live(d) && !listed(d, options).length;
1663
1906
  },
1664
1907
  render(g, ctx) {
1665
1908
  const { options, sources, theme, fmt, t: tr } = ctx;
1666
- const data = dataOf(sources);
1909
+ const data = dataOf2(sources);
1667
1910
  const box = frame(g, ctx.box, ctx, data);
1668
1911
  if (!box || !data) return;
1669
1912
  const list = listed(data, options);
@@ -1702,7 +1945,7 @@ function entityRow(e, level, ctx, decimals) {
1702
1945
  function listed(data, o) {
1703
1946
  return pick(data.entities, o.entities).map((e) => ({ e, level: levelOf(e, o) })).filter(({ e, level }) => !(o.hideUnavailable && level === "na") && !(o.hideOff && level === "off" && numericState(e) === void 0));
1704
1947
  }
1705
- var attention = defineWidget({
1948
+ var attention = defineWidget2({
1706
1949
  id: "attention",
1707
1950
  name: { en: "Home: needs you", es: "Casa: te necesita" },
1708
1951
  description: {
@@ -1713,35 +1956,35 @@ var attention = defineWidget({
1713
1956
  category: "info",
1714
1957
  tags: ["home assistant", "smart home", "alerts"],
1715
1958
  size: { min: { w: 220, h: 90 }, preferred: { w: 480, h: 220 } },
1716
- sources: [SOURCE],
1717
- options: t.object({
1959
+ sources: [SOURCE2],
1960
+ options: t2.object({
1718
1961
  ...listOptions({ layouts: ["one-line", "detailed"] }),
1719
- entities: t.filter({ choices: { source: SOURCE, list: "entities" }, label: { en: "Entities", es: "Entidades" }, help: { en: "Empty = all. Leave out the ones that are fine open with !: !binary_sensor.patio_door.", es: "Vac\xEDo = todas. Deja fuera con ! las que pueden estar abiertas: !binary_sensor.patio_door." } }),
1720
- includeOpenings: t.boolean({ default: true, label: { en: "Doors, windows and locks", es: "Puertas, ventanas y cerraduras" }, help: { en: "Open doors, windows, garage doors and gates; unlocked locks.", es: "Puertas, ventanas, garajes y cancelas abiertas; cerraduras sin cerrar." } }),
1721
- openMs: t.duration({ default: 0, label: { en: "Open for at least", es: "Abierta al menos" }, help: { en: "A door counts once it has been open this long. 0 = at once.", es: "Una puerta cuenta cuando lleva abierta este tiempo. 0 = al momento." } }),
1722
- includeBatteries: t.boolean({ default: true, label: { en: "Low batteries", es: "Bater\xEDas bajas" } }),
1723
- includeProblems: t.boolean({ default: true, label: { en: "Problems", es: "Problemas" }, help: { en: "Problem and tamper sensors, lost connections, a vacuum in error.", es: "Sensores de problema y manipulaci\xF3n, conexiones perdidas, un robot aspirador en error." } }),
1724
- includeUnavailable: t.boolean({ label: { en: "Unavailable devices", es: "Dispositivos no disponibles" } }),
1725
- includeUpdates: t.boolean({ label: { en: "Updates available", es: "Actualizaciones disponibles" } }),
1962
+ entities: t2.filter({ choices: { source: SOURCE2, list: "entities" }, label: { en: "Entities", es: "Entidades" }, help: { en: "Empty = all. Leave out the ones that are fine open with !: !binary_sensor.patio_door.", es: "Vac\xEDo = todas. Deja fuera con ! las que pueden estar abiertas: !binary_sensor.patio_door." } }),
1963
+ includeOpenings: t2.boolean({ default: true, label: { en: "Doors, windows and locks", es: "Puertas, ventanas y cerraduras" }, help: { en: "Open doors, windows, garage doors and gates; unlocked locks.", es: "Puertas, ventanas, garajes y cancelas abiertas; cerraduras sin cerrar." } }),
1964
+ openMs: t2.duration({ default: 0, label: { en: "Open for at least", es: "Abierta al menos" }, help: { en: "A door counts once it has been open this long. 0 = at once.", es: "Una puerta cuenta cuando lleva abierta este tiempo. 0 = al momento." } }),
1965
+ includeBatteries: t2.boolean({ default: true, label: { en: "Low batteries", es: "Bater\xEDas bajas" } }),
1966
+ includeProblems: t2.boolean({ default: true, label: { en: "Problems", es: "Problemas" }, help: { en: "Problem and tamper sensors, lost connections, a vacuum in error.", es: "Sensores de problema y manipulaci\xF3n, conexiones perdidas, un robot aspirador en error." } }),
1967
+ includeUnavailable: t2.boolean({ label: { en: "Unavailable devices", es: "Dispositivos no disponibles" } }),
1968
+ includeUpdates: t2.boolean({ label: { en: "Updates available", es: "Actualizaciones disponibles" } }),
1726
1969
  ...batteryFields()
1727
1970
  }),
1728
1971
  hideWhenEmpty: true,
1729
1972
  redraw: "minute",
1730
1973
  urgent: ({ options, sources, now }) => {
1731
- const d = dataOf(sources);
1974
+ const d = dataOf2(sources);
1732
1975
  return d?.state === "ok" && notices(d.entities, options, now).some((n) => n.kind === "danger");
1733
1976
  },
1734
1977
  idle: ({ options, sources, now }) => {
1735
- const d = dataOf(sources);
1978
+ const d = dataOf2(sources);
1736
1979
  return !live(d) || !notices(d.entities, options, now).length;
1737
1980
  },
1738
1981
  empty: ({ options, sources, now }) => {
1739
- const d = dataOf(sources);
1982
+ const d = dataOf2(sources);
1740
1983
  return live(d) && !notices(d.entities, options, now).length;
1741
1984
  },
1742
1985
  render(g, ctx) {
1743
1986
  const { options, sources, theme, fmt, now, t: tr } = ctx;
1744
- const data = dataOf(sources);
1987
+ const data = dataOf2(sources);
1745
1988
  const box = frame(g, ctx.box, ctx, data);
1746
1989
  if (!box || !data) return;
1747
1990
  const list = notices(data.entities, options, now);
@@ -1773,15 +2016,15 @@ var attention = defineWidget({
1773
2016
  var index_default = definePlugin({
1774
2017
  id: "homeassistant",
1775
2018
  name: { en: "Home Assistant", es: "Home Assistant" },
1776
- version: "0.2.1",
2019
+ version: "0.2.2",
1777
2020
  sdk: "^0.2.0",
1778
2021
  permissions: { network: ["user"] },
1779
2022
  description: {
1780
- en: "Home Assistant on the panel, live over its WebSocket API: any entity in big with its history, lists of entities, and what needs you at home (doors left open, low batteries, leaks, the alarm).",
1781
- es: "Home Assistant en el panel, en directo por su API WebSocket: cualquier entidad en grande con su hist\xF3rico, listas de entidades y lo que te necesita en casa (puertas abiertas, bater\xEDas bajas, fugas, la alarma)."
2023
+ en: "Home Assistant on the panel, live over its WebSocket API: any entity in big with its history, lists of entities, what needs you at home (doors left open, low batteries, leaks, the alarm) and your cameras' latest pictures.",
2024
+ es: "Home Assistant en el panel, en directo por su API WebSocket: cualquier entidad en grande con su hist\xF3rico, listas de entidades, lo que te necesita en casa (puertas abiertas, bater\xEDas bajas, fugas, la alarma) y la \xFAltima imagen de tus c\xE1maras."
1782
2025
  },
1783
2026
  icon: "house",
1784
- widgets: [entity, entities, attention],
2027
+ widgets: [entity, entities, attention, camera],
1785
2028
  sources: [states]
1786
2029
  });
1787
2030
  export {
@@ -1798,6 +2041,7 @@ export {
1798
2041
  attention,
1799
2042
  autoDecimals,
1800
2043
  batteryLevel,
2044
+ camera,
1801
2045
  compact,
1802
2046
  connect,
1803
2047
  curveScale,
@@ -1816,18 +2060,22 @@ export {
1816
2060
  entities,
1817
2061
  entity,
1818
2062
  formatNumber,
2063
+ httpBase,
1819
2064
  iconFor,
1820
2065
  isNumber,
1821
2066
  isTemperature,
1822
2067
  levelColor,
1823
2068
  levelOf,
1824
2069
  matchEntity,
2070
+ motionOf,
1825
2071
  noticeOf,
1826
2072
  notices,
1827
2073
  numericState,
1828
2074
  parseHistory,
1829
2075
  parsePath,
1830
2076
  pick,
2077
+ pictureChangedAt,
2078
+ placePicture,
1831
2079
  renderEntity,
1832
2080
  stateColor,
1833
2081
  stateText,
Binary file
@@ -6,10 +6,10 @@
6
6
  "en": "Home Assistant",
7
7
  "es": "Home Assistant"
8
8
  },
9
- "version": "0.2.1",
9
+ "version": "0.2.2",
10
10
  "description": {
11
- "en": "Home Assistant on the panel, live over its WebSocket API: any entity in big with its history, lists of entities, and what needs you at home (doors left open, low batteries, leaks, the alarm).",
12
- "es": "Home Assistant en el panel, en directo por su API WebSocket: cualquier entidad en grande con su histórico, listas de entidades y lo que te necesita en casa (puertas abiertas, baterías bajas, fugas, la alarma)."
11
+ "en": "Home Assistant on the panel, live over its WebSocket API: any entity in big with its history, lists of entities, what needs you at home (doors left open, low batteries, leaks, the alarm) and your cameras' latest pictures.",
12
+ "es": "Home Assistant en el panel, en directo por su API WebSocket: cualquier entidad en grande con su histórico, listas de entidades, lo que te necesita en casa (puertas abiertas, baterías bajas, fugas, la alarma) y la última imagen de tus cámaras."
13
13
  },
14
14
  "author": "Loksly",
15
15
  "license": "MIT",
@@ -27,13 +27,17 @@
27
27
  "es"
28
28
  ],
29
29
  "categories": [
30
- "info"
30
+ "info",
31
+ "media"
31
32
  ],
32
33
  "tags": [
33
34
  "home assistant",
34
35
  "smart home",
35
36
  "sensor",
36
- "alerts"
37
+ "alerts",
38
+ "camera",
39
+ "blink",
40
+ "security"
37
41
  ],
38
42
  "permissions": {
39
43
  "network": [
@@ -731,6 +735,226 @@
731
735
  "screenshot": "docs/attention.png",
732
736
  "animated": false,
733
737
  "urgent": true
738
+ },
739
+ {
740
+ "type": "homeassistant/camera",
741
+ "name": {
742
+ "en": "Camera",
743
+ "es": "Cámara"
744
+ },
745
+ "description": {
746
+ "en": "The latest picture of a Home Assistant camera (Blink, Reolink, ONVIF…), refreshed every minute, with how old it is; with a motion sensor, a red mark while it sees someone, and it can take over its tile. A still, not live video.",
747
+ "es": "La última imagen de una cámara de Home Assistant (Blink, Reolink, ONVIF…), refrescada cada minuto, con su antigüedad; con un sensor de movimiento, una marca roja mientras ve a alguien, y puede quedarse con su tesela. Una foto, no vídeo en directo."
748
+ },
749
+ "icon": "cctv",
750
+ "category": "media",
751
+ "tags": [
752
+ "home assistant",
753
+ "camera",
754
+ "blink",
755
+ "security"
756
+ ],
757
+ "size": {
758
+ "min": {
759
+ "w": 120,
760
+ "h": 80
761
+ },
762
+ "preferred": {
763
+ "w": 400,
764
+ "h": 260
765
+ }
766
+ },
767
+ "chrome": "bare",
768
+ "sources": [
769
+ "homeassistant/states"
770
+ ],
771
+ "options": {
772
+ "default": {
773
+ "entity": "",
774
+ "name": "",
775
+ "showName": true,
776
+ "showAge": true,
777
+ "motion": "",
778
+ "fit": "cover",
779
+ "keep": "center",
780
+ "dim": 0
781
+ },
782
+ "x-ui": {},
783
+ "type": "object",
784
+ "properties": {
785
+ "entity": {
786
+ "title": "Camera",
787
+ "description": "Its id in Home Assistant: camera.something.",
788
+ "default": "",
789
+ "x-ui": {
790
+ "label": {
791
+ "en": "Camera",
792
+ "es": "Cámara"
793
+ },
794
+ "help": {
795
+ "en": "Its id in Home Assistant: camera.something.",
796
+ "es": "Su id en Home Assistant: camera.algo."
797
+ },
798
+ "placeholder": "camera.porch",
799
+ "choices": {
800
+ "source": "homeassistant/states",
801
+ "list": "cameras"
802
+ }
803
+ },
804
+ "type": "string"
805
+ },
806
+ "name": {
807
+ "title": "Name",
808
+ "description": "Empty = the name in Home Assistant.",
809
+ "default": "",
810
+ "x-ui": {
811
+ "label": {
812
+ "en": "Name",
813
+ "es": "Nombre"
814
+ },
815
+ "help": {
816
+ "en": "Empty = the name in Home Assistant.",
817
+ "es": "Vacío = el nombre en Home Assistant."
818
+ }
819
+ },
820
+ "type": "string"
821
+ },
822
+ "showName": {
823
+ "title": "Show the name",
824
+ "default": true,
825
+ "x-ui": {
826
+ "label": {
827
+ "en": "Show the name",
828
+ "es": "Mostrar el nombre"
829
+ }
830
+ },
831
+ "type": "boolean"
832
+ },
833
+ "showAge": {
834
+ "title": "Show how old the picture is",
835
+ "description": "Since the picture last changed. A battery camera (Blink) only takes a new one on motion or when asked.",
836
+ "default": true,
837
+ "x-ui": {
838
+ "label": {
839
+ "en": "Show how old the picture is",
840
+ "es": "Mostrar la antigüedad de la imagen"
841
+ },
842
+ "help": {
843
+ "en": "Since the picture last changed. A battery camera (Blink) only takes a new one on motion or when asked.",
844
+ "es": "Desde que cambió la imagen por última vez. Una cámara de batería (Blink) solo hace otra con movimiento o cuando se le pide."
845
+ }
846
+ },
847
+ "type": "boolean"
848
+ },
849
+ "motion": {
850
+ "title": "Motion sensor",
851
+ "description": "Empty = binary_sensor.<camera>_motion if there is one (Blink names them so).",
852
+ "default": "",
853
+ "x-ui": {
854
+ "label": {
855
+ "en": "Motion sensor",
856
+ "es": "Sensor de movimiento"
857
+ },
858
+ "help": {
859
+ "en": "Empty = binary_sensor.<camera>_motion if there is one (Blink names them so).",
860
+ "es": "Vacío = binary_sensor.<cámara>_motion si existe (Blink los llama así)."
861
+ },
862
+ "placeholder": "binary_sensor.porch_motion",
863
+ "choices": {
864
+ "source": "homeassistant/states",
865
+ "list": "motion"
866
+ }
867
+ },
868
+ "type": "string"
869
+ },
870
+ "fit": {
871
+ "title": "Fit",
872
+ "default": "cover",
873
+ "x-ui": {
874
+ "label": {
875
+ "en": "Fit",
876
+ "es": "Ajuste"
877
+ },
878
+ "labels": {
879
+ "cover": {
880
+ "en": "Fill (crop)",
881
+ "es": "Llenar (recorta)"
882
+ },
883
+ "contain": {
884
+ "en": "Whole picture",
885
+ "es": "Imagen entera"
886
+ }
887
+ }
888
+ },
889
+ "type": "string",
890
+ "enum": [
891
+ "cover",
892
+ "contain"
893
+ ]
894
+ },
895
+ "keep": {
896
+ "title": "Keep in view",
897
+ "description": "What filling crops last: the sky or the ground.",
898
+ "default": "center",
899
+ "x-ui": {
900
+ "label": {
901
+ "en": "Keep in view",
902
+ "es": "Mantener a la vista"
903
+ },
904
+ "help": {
905
+ "en": "What filling crops last: the sky or the ground.",
906
+ "es": "Lo último que recorta al llenar: el cielo o el suelo."
907
+ },
908
+ "advanced": true,
909
+ "labels": {
910
+ "center": {
911
+ "en": "The centre",
912
+ "es": "El centro"
913
+ },
914
+ "top": {
915
+ "en": "The top",
916
+ "es": "La parte de arriba"
917
+ },
918
+ "bottom": {
919
+ "en": "The bottom",
920
+ "es": "La parte de abajo"
921
+ }
922
+ }
923
+ },
924
+ "type": "string",
925
+ "enum": [
926
+ "center",
927
+ "top",
928
+ "bottom"
929
+ ]
930
+ },
931
+ "dim": {
932
+ "title": "Darken",
933
+ "description": "Keeps a bright picture from outshining everything else.",
934
+ "default": 0,
935
+ "x-ui": {
936
+ "label": {
937
+ "en": "Darken",
938
+ "es": "Oscurecer"
939
+ },
940
+ "help": {
941
+ "en": "Keeps a bright picture from outshining everything else.",
942
+ "es": "Para que una imagen clara no deslumbre al resto."
943
+ },
944
+ "advanced": true,
945
+ "unit": "%",
946
+ "step": 5,
947
+ "slider": true
948
+ },
949
+ "type": "integer",
950
+ "minimum": 0,
951
+ "maximum": 90
952
+ }
953
+ }
954
+ },
955
+ "screenshot": "docs/camera.png",
956
+ "animated": false,
957
+ "urgent": true
734
958
  }
735
959
  ],
736
960
  "sources": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kiosko-plugin-homeassistant",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Home Assistant on the panel, live over its WebSocket API: any entity in big with its history, lists of entities, and what needs you at home (doors left open, low batteries, leaks, the alarm).",
5
5
  "type": "module",
6
6
  "license": "MIT",