kiosko-plugin-homeassistant 0.2.5 → 0.3.0

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
@@ -161,7 +161,7 @@ Uses: `homeassistant/states`.
161
161
 
162
162
  ### Home Assistant — `homeassistant/states`
163
163
 
164
- 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. Options are set once in Kiosko → Settings → Data sources.
164
+ 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. Options are set in Kiosko → Settings → Data sources.
165
165
 
166
166
  | Option | Type | Default | |
167
167
  |---|---|---|---|
@@ -171,6 +171,10 @@ The states of your Home Assistant entities, live over its WebSocket API (a chang
171
171
  | `history` | list | `[]` | Entities with history. Numeric sensors whose last day is kept for the history bars. Empty = every one with a unit. |
172
172
  | `maxHistory` | number | `100` | Most entities with history. Each costs a day of five-minute averages in memory (about 300 numbers). 0 = no history. |
173
173
 
174
+ ### Several homes
175
+
176
+ With Kiosko 0.2.12 and later the source can have **profiles**: named configurations, each with its own address, token and entity filters, say «Flat» for `http://homeassistant.local:8123` and «Village» for `https://pueblo.example.com`. Each profile keeps its own live connection to its Home Assistant (one WebSocket each, connected while a tile uses it), and each tile picks its profile in the inspector (**Source profile**; **New profile…** makes one from the tile), where the entity, camera, player and people pickers list that home's entities. Two homes may have entities with the same id (`camera.front_door` in both): each tile still shows its own home's picture, cover and photos. Settings → Data sources shows the profiles as tabs. A tile with no profile reads the source's own options, as before; with older Kiosko versions there is one home.
177
+
174
178
  ## Development
175
179
 
176
180
  ```sh
package/dist/index.js CHANGED
@@ -101,6 +101,7 @@ function compact(s) {
101
101
  }
102
102
  return e;
103
103
  }
104
+ var homeKey = (d, id) => `${d.base ?? ""} ${id}`;
104
105
  function httpBase(address) {
105
106
  let a = address.trim().replace(/\/+$/, "").replace(/\/api\/websocket$/, "");
106
107
  if (!/^[a-z]+:\/\//i.test(a)) a = `http://${a}`;
@@ -1764,7 +1765,7 @@ var camera = defineWidget({
1764
1765
  const bytes = await readPicture(d.base, e.picture, signal);
1765
1766
  const now = Date.now();
1766
1767
  const lively = motionOf(d.entities, e.id, options.motion)?.state === "on" || ringing(options.doorbell ? d.entities[options.doorbell] : void 0, now);
1767
- return { state: "ok", img: await canvas.loadImage(Buffer.from(bytes)), changedAt: pictureChangedAt(options.entity, bytes, now), ...lively ? { lively } : {} };
1768
+ return { state: "ok", img: await canvas.loadImage(Buffer.from(bytes)), changedAt: pictureChangedAt(homeKey(d, options.entity), bytes, now), ...lively ? { lively } : {} };
1768
1769
  },
1769
1770
  redraw: "minute",
1770
1771
  urgent: ({ options, sources, now }) => {
@@ -2177,10 +2178,10 @@ var media = defineWidget3({
2177
2178
  const e = d ? pickPlayer(d.entities, options.entity) : void 0;
2178
2179
  if (!d?.base || !e?.picture || !options.showCover) return {};
2179
2180
  const key = e.picture.split("?")[0] + "|" + e.media?.title + "|" + e.media?.album;
2180
- const hit = covers.get(e.id);
2181
+ const hit = covers.get(homeKey(d, e.id));
2181
2182
  if (hit?.key === key) return { cover: hit.img, coverOf: key };
2182
2183
  const img = await canvas.loadImage(Buffer.from(await readPicture(d.base, e.picture, signal)));
2183
- covers.set(e.id, { key, img });
2184
+ covers.set(homeKey(d, e.id), { key, img });
2184
2185
  return { cover: img, coverOf: key };
2185
2186
  },
2186
2187
  redraw: ({ options, sources }) => {
@@ -2344,7 +2345,7 @@ var people = defineWidget4({
2344
2345
  if (!d?.base) return out;
2345
2346
  for (const e of peopleOf(d, options.people)) {
2346
2347
  if (!e.photo) continue;
2347
- const key = e.photo.split("?")[0];
2348
+ const key = homeKey(d, e.photo.split("?")[0]);
2348
2349
  try {
2349
2350
  let img = photos.get(key);
2350
2351
  if (!img) {
@@ -2477,6 +2478,9 @@ var states = defineSource({
2477
2478
  }),
2478
2479
  watch: (ctx, emit) => connect({ url: ctx.options.url, token: ctx.options.token, entities: ctx.options.entities, history: ctx.options.history, maxHistory: ctx.options.maxHistory }, emit, { signal: ctx.signal, log: ctx.log }),
2479
2480
  demo: ({ now, locale }) => demoHome(now, locale),
2481
+ // Several homes (a flat and a village house), each with its address, token and own connection: Kiosko 0.2.12
2482
+ // and later; older ones ignore it. Kiosko calls `watch` once per profile, so each gets its own WebSocket.
2483
+ ...{ profiles: true },
2480
2484
  // Every entity it reads, by name, grouped by domain: for the entity field and the filters.
2481
2485
  choices: {
2482
2486
  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 })),
@@ -2718,7 +2722,7 @@ var attention = defineWidget5({
2718
2722
  var index_default = definePlugin({
2719
2723
  id: "homeassistant",
2720
2724
  name: { en: "Home Assistant", es: "Home Assistant", de: "Home Assistant", "zh-Hant": "Home Assistant", "zh-Hans": "Home Assistant" },
2721
- version: "0.2.5",
2725
+ version: "0.3.0",
2722
2726
  languages: ["en", "es", "de", "zh-Hant", "zh-Hans"],
2723
2727
  sdk: "^0.2.0",
2724
2728
  permissions: { network: ["user"] },
@@ -2778,6 +2782,7 @@ export {
2778
2782
  formatPower,
2779
2783
  historyHas,
2780
2784
  historyValues,
2785
+ homeKey,
2781
2786
  homeToday,
2782
2787
  httpBase,
2783
2788
  iconFor,
@@ -9,7 +9,7 @@
9
9
  "zh-Hant": "Home Assistant",
10
10
  "zh-Hans": "Home Assistant"
11
11
  },
12
- "version": "0.2.5",
12
+ "version": "0.3.0",
13
13
  "description": {
14
14
  "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), your cameras (with the doorbell), the energy flow, what's playing and who is home.",
15
15
  "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), tus cámaras (con el timbre), el flujo de energía, lo que suena y quién está en casa.",
@@ -17,7 +17,7 @@
17
17
  "zh-Hant": "在面板上顯示 Home Assistant,透過其 WebSocket API 即時更新:以大字顯示任一實體及其歷史、實體清單、家中需要你處理的事(沒關的門、電量低的電池、漏水、警報)、你的攝影機(含門鈴)、能源流向、正在播放的內容,以及誰在家。",
18
18
  "zh-Hans": "在副屏上显示 Home Assistant,通过其 WebSocket API 实时更新:以大字显示任一实体及其历史、实体列表、家里需要你处理的事(没关的门、电量低的电池、漏水、警报)、你的摄像头(含门铃)、能源流向、正在播放的内容,以及谁在家。"
19
19
  },
20
- "author": "Loksly",
20
+ "author": "Loksly <info@kioskolcd.dev> (https://kioskolcd.dev)",
21
21
  "license": "MIT",
22
22
  "homepage": "https://github.com/kiosko-lcd/kiosko-plugin-homeassistant#readme",
23
23
  "repository": "https://github.com/kiosko-lcd/kiosko-plugin-homeassistant.git",
@@ -1725,6 +1725,7 @@
1725
1725
  "zh-Hans": "你的 Home Assistant 实体状态,通过其 WebSocket API 实时获取(变化会立即显示),以及数值传感器最近一天的数据,用于历史柱状图。"
1726
1726
  },
1727
1727
  "polled": false,
1728
+ "profiles": true,
1728
1729
  "options": {
1729
1730
  "default": {
1730
1731
  "url": "",
@@ -1878,5 +1879,9 @@
1878
1879
  }
1879
1880
  ],
1880
1881
  "interludes": [],
1881
- "templates": []
1882
+ "templates": [],
1883
+ "support": {
1884
+ "issues": "https://github.com/kiosko-lcd/kiosko-plugin-homeassistant/issues",
1885
+ "docs": "https://github.com/kiosko-lcd/kiosko-plugin-homeassistant#readme"
1886
+ }
1882
1887
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kiosko-plugin-homeassistant",
3
- "version": "0.2.5",
3
+ "version": "0.3.0",
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",