iobroker.lovelace 4.1.1 → 4.1.4

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
@@ -473,6 +473,17 @@ After that checkout modified version in `./build` folder. Then.
473
473
  PLACEHOLDER for next version:
474
474
  ### **WORK IN PROGRESS**
475
475
  -->
476
+ ### 4.1.4 (2024-02-10)
477
+ * (Garfonso) improved fix: lamp icons now turn gray on switch off.
478
+
479
+ ### 4.1.3 (2024-02-10)
480
+ * (Garfonso) prevent warning for browser_mod/recall_id service call
481
+ * (Garfonso) fix: lamp icons now turn gray on switch off.
482
+ * (Garfonso) fix: notifications via sendTo work again.
483
+
484
+ ### 4.1.2 (2024-01-09)
485
+ * (Garfonso) fix: time in timestamp display
486
+
476
487
  ### 4.1.1 (2024-01-02)
477
488
  * (Garfonso) changed: determining user id
478
489
  * (Garfosno) changed: history attributes handling
@@ -482,18 +493,6 @@ After that checkout modified version in `./build` folder. Then.
482
493
  ### 4.1.0 (2023-12-18)
483
494
  * (Garfons) add an option to show users on login screen (off by default)
484
495
 
485
- ### 4.0.12 (2023-12-15)
486
- * (Garfonso) fix lint errors
487
-
488
- ### 4.0.11 (2023-12-15)
489
- * (Garfonso) updated dependencies
490
-
491
- ### 4.0.10 (2023-12-15)
492
- * (Garfonso) brought back shopping list. Now also supports shopping/todo lists from manual entities.
493
- * (Garfonso) fix: browser console errors
494
- * (Garfonso) fix: login & authorization
495
- * (Garfonso) added: user images & names on login screen
496
-
497
496
  ## License
498
497
 
499
498
  Copyright 2019-2024, bluefox <dogafox@gmail.com>
package/io-package.json CHANGED
@@ -1,8 +1,29 @@
1
1
  {
2
2
  "common": {
3
3
  "name": "lovelace",
4
- "version": "4.1.1",
4
+ "version": "4.1.4",
5
5
  "news": {
6
+ "4.1.4": {
7
+ "en": "improved fix: lamp icons now turn gray on switch off.",
8
+ "de": "verbesserter fix: lampensymbole werden nun grau beim ausschalten."
9
+ },
10
+ "4.1.3": {
11
+ "en": "prevent warning for browser_mod/recall_id service call\nfix: lamp icons now turn gray on switch off.\nfix: notifications via sendTo work again.",
12
+ "de": "Verhindere warnung für browser_mod/recall_id service call\nfix: Lampensymbole werden nun grau beim ausschalten.\nfix: Benachrichtigung mittels sendTo funktionieren wieder."
13
+ },
14
+ "4.1.2": {
15
+ "en": "fix: time in timestamp display",
16
+ "de": "fix: zeit im zeitstempel-display",
17
+ "ru": "фиксация: время дисплея",
18
+ "pt": "correção: tempo em exibição do timestamp",
19
+ "nl": "fix: tijd in tijdstempelweergave",
20
+ "fr": "correction : temps dans l'affichage de l'horodatage",
21
+ "it": "correzione: tempo in visualizzazione timestamp",
22
+ "es": "fijación: tiempo en la pantalla de tiempo",
23
+ "pl": "fix: czas wyświetlania znacznika czasu",
24
+ "uk": "виправити: час в часовому режимі відображення",
25
+ "zh-cn": "修正:时间戳显示的时间"
26
+ },
6
27
  "4.1.1": {
7
28
  "en": "changed: determining user id\nchanged: history attributes handling\nadded: handle browser_mod/recall_id service call.\nchanged: all states are strings!",
8
29
  "de": "geändert: bestimmung der benutzer-id\ngeändert: historie für attribute\nhinzugefügt: handle browser_mod/recall_id service call.\ngeändert: alle zustände sind strings!"
@@ -36,18 +57,6 @@
36
57
  "pl": "zależności aktualizacji",
37
58
  "uk": "оновлені залежності",
38
59
  "zh-cn": "二. 最新依赖"
39
- },
40
- "4.0.10": {
41
- "en": "brought back shopping list. Now also supports shopping/todo lists from manual entities.\nfix: browser console errors\nfix: login & authorization\nadded: user images & names on login screen",
42
- "de": "Einkaufsliste funktioniert wieder. Zusätzliche Shopping/Todo-Listen können als manuellen Entities angelegt werden.\nfix: browser fehler\nfix: anmeldung & autorisierung\nhinzugefügt: benutzerbilder & namen auf login-bildschirm"
43
- },
44
- "4.0.9": {
45
- "en": "fixed: timestamp in legacy history data",
46
- "de": "fixed: zeitstempel in alten History daten"
47
- },
48
- "4.0.8": {
49
- "en": "re-add legacy history for custom cards",
50
- "de": "re-add die alten history methoden für benutzerdefinierte karten"
51
60
  }
52
61
  },
53
62
  "title": "Visualization with Lovelace-UI",
@@ -166,6 +175,60 @@
166
175
  "agree",
167
176
  "cancel"
168
177
  ]
178
+ },
179
+ {
180
+ "condition": {
181
+ "operand": "and",
182
+ "rules": [
183
+ "oldVersion<=3.0.0",
184
+ "newVersion>=4.0.0"
185
+ ]
186
+ },
187
+ "title": {
188
+ "en": "Visualisation Update",
189
+ "de": "Aktualisierung der Visualisierung",
190
+ "ru": "Обновление визуализации",
191
+ "pt": "Atualização da visualização",
192
+ "nl": "Visualisatie Update",
193
+ "fr": "Mise à jour de la visualisation",
194
+ "it": "Aggiornamento della visualizzazione",
195
+ "es": "Actualización de Visualización",
196
+ "pl": "Visualizacja",
197
+ "uk": "Оновлення візуалізації",
198
+ "zh-cn": "更新"
199
+ },
200
+ "text": {
201
+ "en": "The update to version 4.x will change the frontend version from 20221026.0 to 20231208.2. This implies many months of Lovelace development in a single update. You will likely need to update or fix your themes and custom cards. Make sure to review your visualization after this update. Seek help in the forum or Discord if needed.",
202
+ "de": "Das Update auf Version 4.x wird die Frontend Version von 20221026.0 auf 20231208.2 ändern. Dies bedeutet 10 Monate Entwicklung von Lovelace in einem Update. Sie müssen wahrscheinlich Ihre Themen und benutzerdefinierten Karten aktualisieren oder reparieren. Achten Sie darauf, Ihre Visualisierung nach diesem Update zu überprüfen. Fragen Sie im Forum oder Discord nach Hilfe.",
203
+ "ru": "Обновление до версии 4.x изменит версию интерфейса с 20221026.0 на 20231208.2. Это означает многомесячную разработку Lovelace в рамках одного обновления. Вам, вероятно, придется обновить или исправить свои темы и пользовательские карты. Обязательно проверьте свою визуализацию после этого обновления. Задавайте вопросы на форуме или в Discord, если вам нужна помощь.",
204
+ "pt": "A atualização para a versão 4.x irá alterar a versão do frontend de 20221026.0 para 20231208.2. Isso significa muitos meses de desenvolvimento do Lovelace em uma única atualização. Você provavelmente precisará atualizar ou corrigir seus temas e cartões personalizados. Certifique-se de verificar sua visualização após esta atualização. Procure ajuda no fórum ou no Discord, se necessário.",
205
+ "nl": "De update naar versie 4.x zal de frontend-versie veranderen van 20221026.0 naar 20231208.2. Dit betekent vele maanden ontwikkeling van Lovelace in één update. Waarschijnlijk moet u uw thema's en aangepaste kaarten bijwerken of herstellen. Controleer na deze update uw visualisatie. Vraag om hulp op het forum of Discord indien nodig.",
206
+ "fr": "La mise à jour vers la version 4.x changera la version du frontend de 20221026.0 à 20231208.2. Cela signifie plusieurs mois de développement de Lovelace en une seule mise à jour. Vous devrez probablement mettre à jour ou réparer vos thèmes et cartes personnalisées. Assurez-vous de vérifier votre visualisation après cette mise à jour. Demandez de l'aide sur le forum ou sur Discord si nécessaire.",
207
+ "it": "L'aggiornamento alla versione 4.x cambierà la versione del frontend da 20221026.0 a 20231208.2. Ciò significa molti mesi di sviluppo di Lovelace in un singolo aggiornamento. Probabilmente sarà necessario aggiornare o correggere i temi e le carte personalizzate. Assicurati di controllare la tua visualizzazione dopo questo aggiornamento. Chiedi aiuto sul forum o su Discord se necessario.",
208
+ "es": "La actualización a la versión 4.x cambiará la versión del frontend de 20221026.0 a 20231208.2. Esto significa muchos meses de desarrollo de Lovelace en una sola actualización. Probablemente necesitarás actualizar o corregir tus temas y tarjetas personalizadas. Asegúrate de revisar tu visualización después de esta actualización. Busca ayuda en el foro o en Discord si es necesario.",
209
+ "pl": "Aktualizacja do wersji 4.x zmieni wersję frontendu z 20221026.0 na 20231208.2. Oznacza to wiele miesięcy rozwoju Lovelace w jednej aktualizacji. Prawdopodobnie będziesz musiał zaktualizować lub naprawić swoje motywy i niestandardowe karty. Upewnij się, że sprawdzisz swoją wizualizację po tej aktualizacji. Szukaj pomocy na forum lub Discord, jeśli to konieczne.",
210
+ "uk": "Оновлення до версії 4.x змінить версію фронтенду з 20221026.0 на 20231208.2. Це означає багато місяців розробки Lovelace у одному оновленні. Ймовірно, вам доведеться оновити або виправити свої теми та власні картки. Переконайтеся, що після цього оновлення ви переглянете свою візуалізацію. Звертайтеся за допомогою на форумі або в Discord, якщо потрібно.",
211
+ "zh-cn": "升级到4.x版本将把前端版本从20221026.0更改为20231208.2。这意味着在一个更新中进行了数月的Lovelace开发。您可能需要更新或修复您的主题和自定义卡片。请确保在此更新后检查您的可视化。如有需要,请在论坛或Discord上寻求帮助。"
212
+ },
213
+ "link": "https://forum.iobroker.net/topic/59435/test-lovelace-4-x/408?_=1705695186248",
214
+ "level": "warn",
215
+ "linkText": {
216
+ "en": "A few issues with themes were already discussed here.",
217
+ "de": "Hier wurden bereits einige Themen diskutiert.",
218
+ "ru": "Здесь уже обсуждались несколько вопросов с темами.",
219
+ "pt": "Algumas questões com temas já foram discutidas aqui.",
220
+ "nl": "Een paar problemen met ze werden hier al besproken.",
221
+ "fr": "Quelques questions avec des thèmes ont déjà été discutées ici.",
222
+ "it": "Sono già state discusse alcune questioni con temi.",
223
+ "es": "Algunos temas con temas ya se discutieron aquí.",
224
+ "pl": "Omawiano tam kilka tematów.",
225
+ "uk": "Тут вже обговорювалися кілька питань з темами.",
226
+ "zh-cn": "这里已经讨论了几个专题的问题。."
227
+ },
228
+ "buttons": [
229
+ "agree",
230
+ "cancel"
231
+ ]
169
232
  }
170
233
  ],
171
234
  "dependencies": [
@@ -63,9 +63,10 @@ exports.iobState2EntityState = function (entity, val, attribute) {
63
63
  //convert to date string
64
64
  const date = new Date(val);
65
65
  let dateStr = date.toDateString();
66
- if (attribute === 'timestamp') {
66
+ if (entity.attributes.device_class === 'timestamp') {
67
67
  dateStr = date.toISOString();
68
68
  }
69
+ console.log('Sending', dateStr, '-', typeof dateStr);
69
70
  return dateStr === 'Invalid Date' ? 'unknown' : dateStr;
70
71
  } else if (type === 'lock') {
71
72
  return val ? 'unlocked' : 'locked';
@@ -42,8 +42,38 @@ const SUPPORT_EFFECT = 4;
42
42
  //const SUPPORT_FLASH = 8;
43
43
  //const SUPPORT_TRANSITION = 32;
44
44
 
45
+ const attributesToNullOnOff = ['color_mode', 'brightness', 'color_temp', 'hs_color', 'rgb_color', 'rgbw_color', 'xy_color', 'effect'];
46
+
45
47
  function _lightAdvancedAddState(states, objects, entity) {
46
48
  const getState = states.stateRead;
49
+
50
+ //for advanced lights, clear attributes, so frontend doesn't still show them.
51
+ entity.context.STATE.storedValues = {};
52
+ entity.context.STATE.getParser = (entity, attr, state) => {
53
+ if (!state) {
54
+ state = {val: null};
55
+ }
56
+ const oldState = entity.state;
57
+ entity.state = state.val ? 'on' : 'off';
58
+ if (!state.val && oldState === 'on') {
59
+ for (const attr of attributesToNullOnOff) {
60
+ if (entity.attributes[attr] !== undefined) {
61
+ entity.context.STATE.storedValues[attr] = entity.attributes[attr];
62
+ entity.attributes[attr] = null;
63
+ }
64
+ }
65
+ adapterData.log.debug(`Stored old values for next switch on: ${JSON.stringify(entity.context.STATE.storedValues)}`);
66
+ }
67
+ if (state.val && oldState !== 'on') {
68
+ for (const attr of attributesToNullOnOff) {
69
+ if (entity.attributes[attr] === null) { //make sure the attribute was not yet read from somewhere else
70
+ entity.attributes[attr] = entity.context.STATE.storedValues[attr];
71
+ }
72
+ }
73
+ adapterData.log.debug(`Restored old values from previous switch off: ${JSON.stringify(entity.context.STATE.storedValues)}`);
74
+ }
75
+ };
76
+
47
77
  //prevent zigbee 'available' to become getId:
48
78
  if (getState && getState.startsWith('zigbee.') && (getState.endsWith('.available') || getState.endsWith('.device_query'))) {
49
79
  entity.context.STATE.getId = states.state;
@@ -5,6 +5,7 @@ module.exports = {
5
5
  iobID2entity: {}, //find entities (array) by ioBroker-object id.
6
6
  entityId2Entity: {}, //find entity by entity_id.
7
7
  adapter: {}, //adapter object
8
+ server: {}, //lovelace-web server object
8
9
  log: {}, //log object
9
10
  lang: 'en', //configured language
10
11
  words: {}, //translation via words.json
@@ -323,7 +323,7 @@ class BrowserModModule {
323
323
  // console.log('Incoming browser_mod message:');
324
324
  // console.dir(message, {depth: null});
325
325
 
326
- if (!message.browserID) {
326
+ if (!message.browserID && method !== 'recall_id') {
327
327
  this.adapter.log.warn('No browser ID in browser_mod request: ' + JSON.stringify(message));
328
328
  return;
329
329
  }
@@ -154,14 +154,16 @@ class LogbookModule {
154
154
  this.sendLogbookResponse(ws, message.id, startTime, endTime, results, true);
155
155
  setTimeout(() => this.sendLogbookResponse(ws, message.id, startTime, endTime, []), 300);
156
156
  //keep subscription and id:
157
- const subscription = ws._subscribes.logbook.find(entry => entry.id === Number(message.id));
158
- if (subscription) {
159
- subscription.idsToWatch = subscription.idsToWatch.concat(idsToWatch);
160
- } else {
161
- ws._subscribes.logbook.push({
162
- id: Number(message.id),
163
- idsToWatch: idsToWatch
164
- });
157
+ if (ws._subscribes.logbook) {
158
+ const subscription = ws._subscribes.logbook.find(entry => entry.id === Number(message.id));
159
+ if (subscription) {
160
+ subscription.idsToWatch = subscription.idsToWatch.concat(idsToWatch);
161
+ } else {
162
+ ws._subscribes.logbook.push({
163
+ id: Number(message.id),
164
+ idsToWatch: idsToWatch
165
+ });
166
+ }
165
167
  }
166
168
  } catch (e) {
167
169
  this.adapter.log.error('Could not create logbook answer: ' + e.stack);
package/lib/server.js CHANGED
@@ -135,6 +135,7 @@ class WebServer {
135
135
  entityData.adapter = this.adapter;
136
136
  entityData.log = this.adapter.log;
137
137
  entityData.words = this.words;
138
+ entityData.server = this;
138
139
 
139
140
  this._subscribed = [];
140
141
  this._server = options.server;
@@ -807,26 +808,7 @@ class WebServer {
807
808
  return; //nothing happened -> do not notify UI.
808
809
  }
809
810
 
810
- const t = {
811
- type: 'event',
812
- event: {
813
- a: {
814
- },
815
- event_type: 'subscribe_entities',
816
- origin: 'LOCAL',
817
- time_fired: (state ? state.ts : Date.now()) / 1000
818
- }
819
- };
820
- t.event.a[entity.entity_id] = this._getShortEntity(entity);
821
-
822
- this._wss && this._wss.clients.forEach(ws => {
823
- if (ws._subscribes && ws._subscribes.subscribe_entities) {
824
- ws._subscribes.subscribe_entities.forEach(id => {
825
- t.id = id;
826
- ws.send(JSON.stringify(t));
827
- });
828
- }
829
- });
811
+ this.updateEntityInFrontend(entity, state);
830
812
 
831
813
  });
832
814
  }
@@ -839,6 +821,28 @@ class WebServer {
839
821
  }
840
822
  }
841
823
 
824
+ updateEntityInFrontend(entity, state) {
825
+ const t = {
826
+ type: 'event',
827
+ event: {
828
+ a: {},
829
+ event_type: 'subscribe_entities',
830
+ origin: 'LOCAL',
831
+ time_fired: (state ? state.ts : Date.now()) / 1000
832
+ }
833
+ };
834
+ t.event.a[entity.entity_id] = this._getShortEntity(entity);
835
+
836
+ this._wss && this._wss.clients.forEach(ws => {
837
+ if (ws._subscribes && ws._subscribes.subscribe_entities) {
838
+ ws._subscribes.subscribe_entities.forEach(id => {
839
+ t.id = id;
840
+ ws.send(JSON.stringify(t));
841
+ });
842
+ }
843
+ });
844
+ }
845
+
842
846
  // ------------------------------- END OF CONVERTERS ---------------------------------------- //
843
847
 
844
848
  async _processIobState(ids, objects, id, roomName, funcName, result, forcedEntityId) {
package/main.js CHANGED
@@ -62,7 +62,8 @@ function startAdapter(options) {
62
62
  if (obj.command === 'browse') {
63
63
  obj.callback && adapter.sendTo(obj.from, obj.command, adapter.apiServer.getHassStates(), obj.callback);
64
64
  } else if (obj.command === 'send') {
65
- adapter.apiServer.addNotification(obj.message).then(list =>
65
+ //*cough*
66
+ adapter.apiServer.onStateChange(adapter.namespace + '.notifications.add', {val: obj.message, ack: false}).then(list =>
66
67
  obj.callback && adapter.sendTo(obj.from, obj.command, list, obj.callback));
67
68
  } else if (obj.command === 'checkIdForDuplicates') {
68
69
  if (obj.callback) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iobroker.lovelace",
3
- "version": "4.1.1",
3
+ "version": "4.1.4",
4
4
  "description": "With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI",
5
5
  "author": {
6
6
  "name": "bluefox",
@@ -20,7 +20,7 @@
20
20
  },
21
21
  "dependencies": {
22
22
  "@iobroker/adapter-core": "^3.0.4",
23
- "axios": "^1.6.3",
23
+ "axios": "^1.6.7",
24
24
  "body-parser": "^1.20.2",
25
25
  "express": "^4.18.2",
26
26
  "iobroker.type-detector": "^3.0.5",
@@ -46,7 +46,7 @@
46
46
  "@types/mocha": "^10.0.6",
47
47
  "@types/node": "^16.18.69 < 17",
48
48
  "@types/proxyquire": "^1.3.31",
49
- "@types/sinon": "^17.0.2",
49
+ "@types/sinon": "^17.0.3",
50
50
  "@types/sinon-chai": "^3.2.12",
51
51
  "chai": "^4.3.10",
52
52
  "chai-as-promised": "^7.1.1",