iobroker.faikout 0.2.0 → 0.2.1
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 +21 -23
- package/io-package.json +14 -14
- package/lib/fields.js +7 -4
- package/main.js +203 -1
- package/package.json +3 -3
- package/widgets/faikout/js/faikout.js +2 -2
package/README.md
CHANGED
|
@@ -121,12 +121,12 @@ the device cards. Lovelace, however, converts the keys of `common.states` to num
|
|
|
121
121
|
climate entity; with text keys this gives `NaN` and the command is lost. Use the numeric twins in
|
|
122
122
|
`<device>.control.*` for such tools:
|
|
123
123
|
|
|
124
|
-
| State | Role | Values
|
|
125
|
-
| ----------- | --------------------------- |
|
|
126
|
-
| `modeNum` | `level.mode.airconditioner` | 0 off, 1 heat_cool, 2 cool, 3 heat, 4 dry, 5 fan_only
|
|
127
|
-
| `fanNum` | `level.mode.fan` | 0 auto, 1 night, 2 low, 3 lowMedium, 4 medium, 5 mediumHigh, 6 high
|
|
128
|
-
| `swingNum` | `level.mode.swing` | 0 off, 1 on, 2 vertical, 3 horizontal, 4 both, 5 comfort
|
|
129
|
-
| `presetNum` | `level.mode` | 0 home, 1 eco, 2 boost
|
|
124
|
+
| State | Role | Values |
|
|
125
|
+
| ----------- | --------------------------- | ----------------------------------------------------------------------------- |
|
|
126
|
+
| `modeNum` | `level.mode.airconditioner` | 0 off, 1 heat_cool, 2 cool, 3 heat, 4 dry, 5 fan_only |
|
|
127
|
+
| `fanNum` | `level.mode.fan` | 0 auto, 1 night, 2 low, 3 lowMedium, 4 medium, 5 mediumHigh, 6 high |
|
|
128
|
+
| `swingNum` | `level.mode.swing` | 0 off, 1 on, 2 vertical, 3 horizontal, 4 both, 5 comfort, 6 horizontalComfort |
|
|
129
|
+
| `presetNum` | `level.mode` | 0 home, 1 eco, 2 boost |
|
|
130
130
|
|
|
131
131
|
The roles let the type detector find them as part of an air conditioner. Writing `2`, `"2"` or the label
|
|
132
132
|
`"cool"` to `modeNum` sends one command `cool` to the module; `modeNum` and `mode` are both set with
|
|
@@ -146,6 +146,21 @@ one detail page per unit with controls, energy history and a phone view. They us
|
|
|
146
146
|
Placeholder for the next version (at the beginning of the line):
|
|
147
147
|
### **WORK IN PROGRESS**
|
|
148
148
|
-->
|
|
149
|
+
### 0.2.1 (2026-11-19)
|
|
150
|
+
- `control.swing` / `swingNum`: new value `H+C` (`horizontalComfort`, number 6) for comfort mode with
|
|
151
|
+
horizontal swing. Comfort is a mode of the vertical louvres; the swing selector (e.g. in Lovelace) can now
|
|
152
|
+
combine it with horizontal swing. Needs Faikout firmware with `H+C` support; older firmware reports `C`
|
|
153
|
+
during comfort and treats a written `H+C` as `off`.
|
|
154
|
+
- Renamed modules (issue #6): after changing the hostname of a module, the adapter kept the old name in memory
|
|
155
|
+
until the next restart and, once its objects were deleted, logged `State "...consumption..." has no existing
|
|
156
|
+
object` every hour. The module is now recognised by its hardware ID (`info.id`): the old name is no longer
|
|
157
|
+
updated, its consumption counters (today, month, JSON series) continue under the new name, and its objects
|
|
158
|
+
stay untouched until you delete them (SmarthomeElektroniker)
|
|
159
|
+
- Deleted objects are noticed while the adapter runs: a deleted device is dropped, a deleted state or branch is
|
|
160
|
+
created again before the next write; states are no longer written to objects that do not exist
|
|
161
|
+
(SmarthomeElektroniker)
|
|
162
|
+
- Dev dependency `@iobroker/testing` 6.3.2 (SmarthomeElektroniker)
|
|
163
|
+
|
|
149
164
|
### 0.2.0 (2026-11-13)
|
|
150
165
|
- Numeric twins of the text control states: `control.modeNum`, `fanNum`, `swingNum` and `presetNum` with
|
|
151
166
|
`common.states` (`{0: "off", 1: "heat_cool", ...}`) and the roles `level.mode.airconditioner`,
|
|
@@ -183,23 +198,6 @@ one detail page per unit with controls, energy history and a phone view. They us
|
|
|
183
198
|
cannot set CSS custom properties with `.css()`, so it always stayed blue.
|
|
184
199
|
- New: vis templates (`vis-templates/`) – overview, detail page per unit, energy and phone view.
|
|
185
200
|
|
|
186
|
-
### 0.0.17
|
|
187
|
-
- Fixed units of `status.comp` and `status.fanfreq`: the module sends Hz by default and rpm only with `ha.comprpm`/`ha.fanrpm`.
|
|
188
|
-
The adapter now takes the unit from the module's Home Assistant discovery (a fractional fan value is always Hz),
|
|
189
|
-
sets it on the state and remembers it per device. The VIS widgets show the unit of the state.
|
|
190
|
-
- All fields the module can report are described: new `status.action` (with `no.hvacaction` off), `status.loopback`,
|
|
191
|
-
`status.bletemp`/`blehum`/`blebat`, `info.dma`, `info.restart`, `info.ipv6`, `info.secureboot`, `info.nvsecryption`.
|
|
192
|
-
`dma` and `restart` were created as unknown fields under `status.*` up to 0.0.16 and are moved to `info.*` on start.
|
|
193
|
-
- New tab "Module settings" in the instance configuration: which settings the faikout module needs for the complete set of
|
|
194
|
-
data points (all eleven languages). Same table in the README.
|
|
195
|
-
- Warning in the log when a module is connected without `ha.enable`.
|
|
196
|
-
|
|
197
|
-
### 0.0.16
|
|
198
|
-
- Release notes in `io-package.json` trimmed to seven entries and translated into all languages (repository checker E1032/E1144).
|
|
199
|
-
|
|
200
|
-
### 0.0.15
|
|
201
|
-
- The MQTT broker's shutdown timeout uses the adapter's `setTimeout` (repository checker E5005).
|
|
202
|
-
|
|
203
201
|
[Older changelog entries can be found here](CHANGELOG_OLD.md)
|
|
204
202
|
|
|
205
203
|
## Trademark and relationship to the hardware project
|
package/io-package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"common": {
|
|
3
3
|
"name": "faikout",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.1",
|
|
5
5
|
"titleLang": {
|
|
6
6
|
"en": "Faikout",
|
|
7
7
|
"de": "Faikout",
|
|
@@ -71,6 +71,19 @@
|
|
|
71
71
|
}
|
|
72
72
|
],
|
|
73
73
|
"news": {
|
|
74
|
+
"0.2.1": {
|
|
75
|
+
"en": "Renamed modules are recognised by their hardware ID: no more writes to deleted objects, consumption counters continue under the new name (issue #6); deleted objects are noticed at runtime; new swing value H+C (comfort with horizontal swing)",
|
|
76
|
+
"de": "Umbenannte Module werden an ihrer Hardware-ID erkannt: keine Schreibzugriffe mehr auf gelöschte Objekte, Verbrauchszähler laufen unter dem neuen Namen weiter (Issue #6); gelöschte Objekte werden zur Laufzeit erkannt; neuer Schwenkwert H+C (Komfort mit waagerechtem Schwenken)",
|
|
77
|
+
"ru": "Переименованные модули распознаются по аппаратному ID: больше нет записи в удалённые объекты, счётчики потребления продолжаются под новым именем (issue #6); удалённые объекты обнаруживаются во время работы; новое значение качания H+C (комфорт с горизонтальным качанием)",
|
|
78
|
+
"pt": "Módulos renomeados são reconhecidos pelo ID de hardware: sem gravações em objetos excluídos, os contadores de consumo continuam com o novo nome (issue #6); objetos excluídos são detectados em execução; novo valor de oscilação H+C (conforto com oscilação horizontal)",
|
|
79
|
+
"nl": "Hernoemde modules worden herkend aan hun hardware-ID: geen schrijfacties meer naar verwijderde objecten, verbruikstellers lopen door onder de nieuwe naam (issue #6); verwijderde objecten worden tijdens het draaien opgemerkt; nieuwe zwenkwaarde H+C (comfort met horizontaal zwenken)",
|
|
80
|
+
"fr": "Les modules renommés sont reconnus par leur ID matériel : plus d'écriture vers des objets supprimés, les compteurs de consommation continuent sous le nouveau nom (issue #6) ; les objets supprimés sont détectés en cours d'exécution ; nouvelle valeur d'oscillation H+C (confort avec oscillation horizontale)",
|
|
81
|
+
"it": "I moduli rinominati vengono riconosciuti dall'ID hardware: nessuna scrittura su oggetti eliminati, i contatori di consumo proseguono con il nuovo nome (issue #6); gli oggetti eliminati vengono rilevati durante l'esecuzione; nuovo valore di oscillazione H+C (comfort con oscillazione orizzontale)",
|
|
82
|
+
"es": "Los módulos renombrados se reconocen por su ID de hardware: ya no se escribe en objetos eliminados, los contadores de consumo continúan con el nuevo nombre (issue #6); los objetos eliminados se detectan en ejecución; nuevo valor de oscilación H+C (confort con oscilación horizontal)",
|
|
83
|
+
"pl": "Moduły o zmienionej nazwie są rozpoznawane po identyfikatorze sprzętowym: brak zapisów do usuniętych obiektów, liczniki zużycia działają dalej pod nową nazwą (issue #6); usunięte obiekty są wykrywane w trakcie działania; nowa wartość nachylenia H+C (komfort z poziomym ruchem)",
|
|
84
|
+
"uk": "Перейменовані модулі розпізнаються за апаратним ID: більше немає запису у видалені об'єкти, лічильники споживання продовжуються під новою назвою (issue #6); видалені об'єкти виявляються під час роботи; нове значення гойдання H+C (комфорт із горизонтальним гойданням)",
|
|
85
|
+
"zh-cn": "重命名的模块通过硬件 ID 识别:不再写入已删除的对象,用电计数器在新名称下继续(issue #6);运行时可识别已删除的对象;新的摆风值 H+C(舒适模式加水平摆风)"
|
|
86
|
+
},
|
|
74
87
|
"0.2.0": {
|
|
75
88
|
"en": "Numeric twins of the text control states (modeNum, fanNum, swingNum, presetNum) with level.mode roles for Lovelace and the type detector; one command per write, ack only with the module confirmation",
|
|
76
89
|
"de": "Zahl-Datenpunkte neben den Text-Steuerfeldern (modeNum, fanNum, swingNum, presetNum) mit level.mode-Rollen für Lovelace und den Type-Detector; ein Befehl pro Schreibvorgang, ack erst mit der Bestätigung des Moduls",
|
|
@@ -148,19 +161,6 @@
|
|
|
148
161
|
"pl": "Informacje o wydaniu skrócone do siedmiu wpisów i przetłumaczone (kontrola repozytorium E1032/E1144)",
|
|
149
162
|
"uk": "Примітки до випуску скорочено до семи записів і перекладено (перевірка репозиторію E1032/E1144)",
|
|
150
163
|
"zh-cn": "发行说明精简为七条并已翻译(仓库检查 E1032/E1144)"
|
|
151
|
-
},
|
|
152
|
-
"0.0.15": {
|
|
153
|
-
"en": "Shutdown timeout of the MQTT broker uses the adapter timer (checker E5005)",
|
|
154
|
-
"de": "Abschalt-Zeitlimit des MQTT-Brokers nutzt den Adapter-Zeitgeber (Checker E5005)",
|
|
155
|
-
"ru": "Тайм-аут остановки MQTT-брокера использует таймер адаптера (проверка E5005)",
|
|
156
|
-
"pt": "O tempo limite de encerramento do broker MQTT usa o temporizador do adaptador (verificação E5005)",
|
|
157
|
-
"nl": "Afsluittime-out van de MQTT-broker gebruikt de timer van de adapter (controle E5005)",
|
|
158
|
-
"fr": "Le délai d'arrêt du broker MQTT utilise le minuteur de l'adaptateur (contrôle E5005)",
|
|
159
|
-
"it": "Il timeout di arresto del broker MQTT usa il timer dell'adattatore (controllo E5005)",
|
|
160
|
-
"es": "El tiempo de espera de cierre del broker MQTT usa el temporizador del adaptador (comprobación E5005)",
|
|
161
|
-
"pl": "Limit czasu zamykania brokera MQTT korzysta z timera adaptera (kontrola E5005)",
|
|
162
|
-
"uk": "Тайм-аут зупинки MQTT-брокера використовує таймер адаптера (перевірка E5005)",
|
|
163
|
-
"zh-cn": "MQTT 代理的关闭超时使用适配器计时器(检查 E5005)"
|
|
164
164
|
}
|
|
165
165
|
},
|
|
166
166
|
"restartAdapters": [
|
package/lib/fields.js
CHANGED
|
@@ -87,9 +87,11 @@ const FELDER = {
|
|
|
87
87
|
states: liste(FAN_MODES),
|
|
88
88
|
name: { en: 'Fan speed', de: 'Lüfterstufe' },
|
|
89
89
|
},
|
|
90
|
-
// ACHTUNG: `swing` kennt
|
|
91
|
-
// off|on, das Geraet selbst sendet aber H, V, H+V (beide Achsen)
|
|
92
|
-
//
|
|
90
|
+
// ACHTUNG: `swing` kennt sieben Werte, nicht nur off/on. Die HA-Discovery meldet zwar nur
|
|
91
|
+
// off|on, das Geraet selbst sendet aber H, V, H+V (beide Achsen), C (Komfortbetrieb) und
|
|
92
|
+
// H+C (waagerecht schwenken plus Komfort, ab der Firmware mit SWING_HCOMFORT) -
|
|
93
|
+
// siehe SWING_* in Faikout.c. Komfort ist eine Betriebsart der senkrechten Lamellen;
|
|
94
|
+
// aeltere Firmware meldet waehrend Komfort immer C, auch wenn waagerecht geschwenkt wird. Am Wohnzimmer-Geraet stand live "V"; mit einer Liste aus
|
|
93
95
|
// nur off/on waere das im VIS ein unbekannter Zustand gewesen.
|
|
94
96
|
swing: {
|
|
95
97
|
kanal: 'control',
|
|
@@ -103,6 +105,7 @@ const FELDER = {
|
|
|
103
105
|
H: 'horizontal',
|
|
104
106
|
'H+V': 'both',
|
|
105
107
|
C: 'comfort',
|
|
108
|
+
'H+C': 'horizontalComfort',
|
|
106
109
|
},
|
|
107
110
|
name: { en: 'Swing', de: 'Luftverteilung' },
|
|
108
111
|
},
|
|
@@ -598,7 +601,7 @@ const ZAHL_ZWILLINGE = {
|
|
|
598
601
|
name: { en: 'Fan speed (number)', de: 'Lüfterstufe (Zahl)' },
|
|
599
602
|
},
|
|
600
603
|
swing: {
|
|
601
|
-
werte: ['off', 'on', 'V', 'H', 'H+V', 'C'],
|
|
604
|
+
werte: ['off', 'on', 'V', 'H', 'H+V', 'C', 'H+C'],
|
|
602
605
|
role: 'level.mode.swing',
|
|
603
606
|
name: { en: 'Swing (number)', de: 'Luftverteilung (Zahl)' },
|
|
604
607
|
},
|
package/main.js
CHANGED
|
@@ -132,6 +132,7 @@ class Faikout extends utils.Adapter {
|
|
|
132
132
|
|
|
133
133
|
this.on('ready', this.onReady.bind(this));
|
|
134
134
|
this.on('stateChange', this.onStateChange.bind(this));
|
|
135
|
+
this.on('objectChange', this.onObjectChange.bind(this));
|
|
135
136
|
this.on('unload', this.onUnload.bind(this));
|
|
136
137
|
}
|
|
137
138
|
|
|
@@ -141,6 +142,9 @@ class Faikout extends utils.Adapter {
|
|
|
141
142
|
await this.setState('info.connection', { val: false, ack: true });
|
|
142
143
|
await this.verbrauchUmziehen();
|
|
143
144
|
await this.objekteAbgleichen();
|
|
145
|
+
// Geloeschte Objekte mitbekommen (Issue #6): sonst schreibt der Adapter weiter in einen
|
|
146
|
+
// Zweig, den er fuer angelegt haelt - "State ... has no existing object".
|
|
147
|
+
await this.subscribeObjectsAsync('*');
|
|
144
148
|
|
|
145
149
|
const port = Number(this.config.port) || 1888;
|
|
146
150
|
this.broker = new FaikoutBroker({
|
|
@@ -186,8 +190,17 @@ class Faikout extends utils.Adapter {
|
|
|
186
190
|
}
|
|
187
191
|
|
|
188
192
|
async stundenwechsel() {
|
|
189
|
-
|
|
193
|
+
// Kopie: geraetVergessen() nimmt waehrend der Schleife Eintraege heraus.
|
|
194
|
+
for (const [id, g] of [...this.geraete]) {
|
|
195
|
+
// Issue #6: Ein umbenanntes Modul blieb bis zum Neustart als Geist in this.geraete, und
|
|
196
|
+
// jede volle Stunde gingen setState-Aufrufe auf die vom Nutzer geloeschten Objekte.
|
|
197
|
+
if (!(await this.geraetNochDa(id, g))) {
|
|
198
|
+
continue;
|
|
199
|
+
}
|
|
190
200
|
for (const z of ZAEHLER) {
|
|
201
|
+
if (this.geraete.get(id) !== g) {
|
|
202
|
+
break; // inzwischen geloescht oder umbenannt
|
|
203
|
+
}
|
|
191
204
|
const ergebnis = verbrauch.pruefen(g.zaehler[z.feld], new Date());
|
|
192
205
|
if (!ergebnis.werte) {
|
|
193
206
|
continue;
|
|
@@ -463,6 +476,12 @@ class Faikout extends utils.Adapter {
|
|
|
463
476
|
const alt = await this.getObjectAsync(id);
|
|
464
477
|
g = {
|
|
465
478
|
name: geraetName,
|
|
479
|
+
// Geraeteobjekt gab es vor diesem Lauf nicht - Kandidat fuer die Uebernahme der
|
|
480
|
+
// Zaehler eines umbenannten Moduls (siehe modulIdPruefen()).
|
|
481
|
+
neu: !alt,
|
|
482
|
+
// Hardware-ID des Moduls (Feld `id`, die MAC ohne Doppelpunkte). Erst gesetzt, wenn
|
|
483
|
+
// sie in diesem Lauf gemeldet und gegen die anderen Geraete geprueft wurde.
|
|
484
|
+
modulId: null,
|
|
466
485
|
angelegt: new Set(),
|
|
467
486
|
feuchteEcht: !!(alt && alt.native && alt.native.feuchteEcht),
|
|
468
487
|
// Die Zaehlerstaende muessen den Adapter-Neustart ueberleben, sonst faengt
|
|
@@ -493,6 +512,11 @@ class Faikout extends utils.Adapter {
|
|
|
493
512
|
// Der Name kann sich aendern, wenn der Hostname im Modul umgestellt wird.
|
|
494
513
|
g.name = geraetName;
|
|
495
514
|
|
|
515
|
+
// Hardware-ID: erkennt ein umbenanntes Modul, bevor die Zaehler verarbeitet werden.
|
|
516
|
+
if (typeof daten.id === 'string' && daten.id && g.modulId !== daten.id) {
|
|
517
|
+
await this.modulIdPruefen(id, g, daten.id);
|
|
518
|
+
}
|
|
519
|
+
|
|
496
520
|
for (const [feld, wert] of Object.entries(daten)) {
|
|
497
521
|
if (wert === null || wert === undefined) {
|
|
498
522
|
continue;
|
|
@@ -863,11 +887,189 @@ class Faikout extends utils.Adapter {
|
|
|
863
887
|
}
|
|
864
888
|
|
|
865
889
|
async zaehlerstandSichern(id, g) {
|
|
890
|
+
// Nie ein geloeschtes Geraeteobjekt per extendObject als Rumpf wiederbeleben (Issue #6).
|
|
891
|
+
if (!(await this.geraetNochDa(id, g))) {
|
|
892
|
+
return;
|
|
893
|
+
}
|
|
866
894
|
g.gesichert = Date.now();
|
|
867
895
|
g.zaehlerGeaendert = false;
|
|
868
896
|
await this.extendObject(id, { native: { zaehler: g.zaehler } });
|
|
869
897
|
}
|
|
870
898
|
|
|
899
|
+
// ---------------------------------------------------------------- Umbenennen und Loeschen (Issue #6)
|
|
900
|
+
|
|
901
|
+
/**
|
|
902
|
+
* Ist das Geraet noch im Speicher UND sein Geraeteobjekt noch vorhanden? Fehlt das Objekt (vom
|
|
903
|
+
* Nutzer geloescht), wird das Geraet vergessen. Meldet sich das Modul weiter, entsteht es mit
|
|
904
|
+
* der naechsten Nachricht vollstaendig neu.
|
|
905
|
+
*
|
|
906
|
+
* @param {string} id Objekt-ID des Geraets
|
|
907
|
+
* @param {object} g gemerkter Zustand des Geraets
|
|
908
|
+
* @returns {Promise<boolean>} true, wenn weitergeschrieben werden darf
|
|
909
|
+
*/
|
|
910
|
+
async geraetNochDa(id, g) {
|
|
911
|
+
if (this.geraete.get(id) !== g) {
|
|
912
|
+
return false;
|
|
913
|
+
}
|
|
914
|
+
if (await this.getObjectAsync(id)) {
|
|
915
|
+
return true;
|
|
916
|
+
}
|
|
917
|
+
this.geraetVergessen(id, 'its objects were deleted');
|
|
918
|
+
return false;
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
/**
|
|
922
|
+
* Nimmt ein Geraet aus allen Speichern des laufenden Adapters, die am Geraet bzw. seinem Namen
|
|
923
|
+
* haengen. Die Einheiten (this.einheiten) bleiben: sie stammen aus der Discovery, die nicht
|
|
924
|
+
* wiederholt wird, und schaden ohne Geraet nicht.
|
|
925
|
+
*
|
|
926
|
+
* @param {string} id Objekt-ID des Geraets
|
|
927
|
+
* @param {string} grund Grund fuers Log
|
|
928
|
+
*/
|
|
929
|
+
geraetVergessen(id, grund) {
|
|
930
|
+
const g = this.geraete.get(id);
|
|
931
|
+
if (!g) {
|
|
932
|
+
return;
|
|
933
|
+
}
|
|
934
|
+
this.geraete.delete(id);
|
|
935
|
+
const praefix = `${id}.`;
|
|
936
|
+
for (const speicher of [this.geschrieben, this.reihenStunde]) {
|
|
937
|
+
for (const schluessel of [...speicher.keys()]) {
|
|
938
|
+
if (schluessel.startsWith(praefix)) {
|
|
939
|
+
speicher.delete(schluessel);
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
this.haWarnung.delete(g.name);
|
|
944
|
+
this.abgelehntWarnung.delete(g.name);
|
|
945
|
+
this.log.info(`"${g.name}" (${this.namespace}.${id}) is no longer updated: ${grund}.`);
|
|
946
|
+
this.verbindungPruefen();
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
/**
|
|
950
|
+
* Ein Objekt im eigenen Namensraum wurde geloescht. Alles, was der Adapter darueber im Speicher
|
|
951
|
+
* hat, muss weg - sonst haelt er den Datenpunkt fuer angelegt und schreibt per setState auf ein
|
|
952
|
+
* Objekt, das es nicht mehr gibt. Ist es das Geraeteobjekt selbst, wird das Geraet vergessen.
|
|
953
|
+
*
|
|
954
|
+
* @param {string} volleId Objekt-ID mit Namensraum
|
|
955
|
+
* @param {ioBroker.Object | null | undefined} obj neues Objekt, null/undefined beim Loeschen
|
|
956
|
+
*/
|
|
957
|
+
onObjectChange(volleId, obj) {
|
|
958
|
+
if (obj || !volleId.startsWith(`${this.namespace}.`)) {
|
|
959
|
+
return;
|
|
960
|
+
}
|
|
961
|
+
const id = volleId.slice(this.namespace.length + 1);
|
|
962
|
+
const geraetId = id.split('.')[0];
|
|
963
|
+
const g = this.geraete.get(geraetId);
|
|
964
|
+
if (!g) {
|
|
965
|
+
return;
|
|
966
|
+
}
|
|
967
|
+
if (id === geraetId) {
|
|
968
|
+
this.geraetVergessen(geraetId, 'its objects were deleted');
|
|
969
|
+
return;
|
|
970
|
+
}
|
|
971
|
+
this.geschrieben.delete(id);
|
|
972
|
+
this.reihenStunde.delete(id);
|
|
973
|
+
// Den Eintrag selbst, alles darunter und die Zweige darueber (consumption.total steht fuer
|
|
974
|
+
// den ganzen Zweig) - fehlt einer seiner Datenpunkte, wird der Zweig neu angelegt.
|
|
975
|
+
for (const a of [...g.angelegt]) {
|
|
976
|
+
if (a === id || a.startsWith(`${id}.`) || id.startsWith(`${a}.`)) {
|
|
977
|
+
g.angelegt.delete(a);
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
/**
|
|
983
|
+
* Prueft die Hardware-ID eines Moduls gegen die anderen Geraete. Der Objektbaum haengt am
|
|
984
|
+
* Hostnamen; wird der im Modul umgestellt, meldet sich dasselbe Modul unter neuem Namen.
|
|
985
|
+
* Bis 0.2.0 lief das alte Geraet dann im Speicher weiter (Issue #6).
|
|
986
|
+
*
|
|
987
|
+
* Ein anderes Geraet mit derselben ID ist der fruehere Name dieses Moduls. Es wird vergessen und
|
|
988
|
+
* im Objekt als umbenannt markiert (native.renamedTo), damit es nicht bei jedem Start erneut
|
|
989
|
+
* auffaellt; seine Objekte und Verlaufsdaten bleiben unangetastet - loeschen kann sie der Nutzer.
|
|
990
|
+
* Die Zaehlerstaende (Basis fuer heute, Monat und die JSON-Reihen) werden uebernommen, wenn das
|
|
991
|
+
* Geraet unter dem neuen Namen noch keine eigene Geschichte hat: Geraeteobjekt in diesem Lauf
|
|
992
|
+
* neu angelegt, noch kein Zaehlerstand, oder selbst frueher als umbenannt markiert (Modul hat
|
|
993
|
+
* seinen alten Namen zurueck). Sonst bleiben die eigenen Zaehler - nichts wird ueberschrieben.
|
|
994
|
+
*
|
|
995
|
+
* @param {string} id Objekt-ID des Geraets
|
|
996
|
+
* @param {object} g gemerkter Zustand des Geraets
|
|
997
|
+
* @param {string} modulId gemeldete Hardware-ID
|
|
998
|
+
*/
|
|
999
|
+
async modulIdPruefen(id, g, modulId) {
|
|
1000
|
+
g.modulId = modulId;
|
|
1001
|
+
const eigen = await this.getObjectAsync(id);
|
|
1002
|
+
const eigenNative = (eigen && eigen.native) || {};
|
|
1003
|
+
const ohneGeschichte = g.neu || !Object.keys(g.zaehler).length || !!eigenNative.renamedTo;
|
|
1004
|
+
|
|
1005
|
+
// aid -> {name, zaehler, objekt}
|
|
1006
|
+
const frueher = new Map();
|
|
1007
|
+
// Im Speicher: das Modul lief in diesem Lauf schon unter dem alten Namen.
|
|
1008
|
+
for (const [aid, ag] of this.geraete) {
|
|
1009
|
+
if (aid !== id && ag.modulId === modulId) {
|
|
1010
|
+
frueher.set(aid, { name: ag.name, zaehler: ag.zaehler, objekt: false });
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
// Im Objektbaum: alter Name aus einem frueheren Lauf. native.modulId gibt es erst nach 0.2.0, davor
|
|
1014
|
+
// steht die ID nur im Datenpunkt info.id.
|
|
1015
|
+
try {
|
|
1016
|
+
for (const geraet of await this.getDevicesAsync()) {
|
|
1017
|
+
const aid = geraet._id.slice(this.namespace.length + 1);
|
|
1018
|
+
const n = geraet.native || {};
|
|
1019
|
+
if (aid === id || n.renamedTo) {
|
|
1020
|
+
continue;
|
|
1021
|
+
}
|
|
1022
|
+
let gleich = n.modulId === modulId;
|
|
1023
|
+
if (!gleich && !n.modulId) {
|
|
1024
|
+
const st = await this.getStateAsync(`${aid}.info.id`);
|
|
1025
|
+
gleich = !!st && st.val === modulId;
|
|
1026
|
+
}
|
|
1027
|
+
if (!gleich) {
|
|
1028
|
+
continue;
|
|
1029
|
+
}
|
|
1030
|
+
const bekannt = frueher.get(aid);
|
|
1031
|
+
frueher.set(aid, {
|
|
1032
|
+
name: bekannt ? bekannt.name : n.faikoutName || aid,
|
|
1033
|
+
// Speicherstand ist aktueller als der zuletzt gesicherte im Objekt.
|
|
1034
|
+
zaehler: bekannt ? bekannt.zaehler : n.zaehler || null,
|
|
1035
|
+
objekt: true,
|
|
1036
|
+
});
|
|
1037
|
+
}
|
|
1038
|
+
} catch (e) {
|
|
1039
|
+
this.log.debug(`Device lookup for module ${modulId} skipped: ${e.message}`);
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
let uebernommen = null;
|
|
1043
|
+
for (const [aid, alt] of frueher) {
|
|
1044
|
+
this.geraetVergessen(aid, `module ${modulId} now reports as "${g.name}"`);
|
|
1045
|
+
if (alt.objekt) {
|
|
1046
|
+
await this.extendObject(aid, { native: { modulId, renamedTo: id } });
|
|
1047
|
+
}
|
|
1048
|
+
const hatZaehler = alt.zaehler && Object.keys(alt.zaehler).length;
|
|
1049
|
+
if (ohneGeschichte && hatZaehler && !uebernommen) {
|
|
1050
|
+
g.zaehler = JSON.parse(JSON.stringify(alt.zaehler));
|
|
1051
|
+
uebernommen = alt.name;
|
|
1052
|
+
}
|
|
1053
|
+
const zusatz = uebernommen === alt.name ? 'Consumption counters taken over. ' : '';
|
|
1054
|
+
this.log.info(
|
|
1055
|
+
`"${g.name}": module ${modulId} was known as "${alt.name}" (${this.namespace}.${aid}). ${zusatz}The old objects are no longer updated and can be deleted.`,
|
|
1056
|
+
);
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1059
|
+
const native = { modulId };
|
|
1060
|
+
if (eigenNative.renamedTo) {
|
|
1061
|
+
native.renamedTo = null;
|
|
1062
|
+
}
|
|
1063
|
+
if (uebernommen) {
|
|
1064
|
+
native.zaehler = g.zaehler;
|
|
1065
|
+
g.gesichert = Date.now();
|
|
1066
|
+
g.zaehlerGeaendert = false;
|
|
1067
|
+
}
|
|
1068
|
+
if (eigen && (eigenNative.modulId !== modulId || eigenNative.renamedTo || uebernommen)) {
|
|
1069
|
+
await this.extendObject(id, { native });
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
|
|
871
1073
|
async objektAnlegen(geraetId, def, feld, stateId, einheit = def.unit) {
|
|
872
1074
|
await this.extendObject(`${geraetId}.${def.kanal}`, {
|
|
873
1075
|
type: 'channel',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "iobroker.faikout",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Connect Daikin air conditioners with a faikout module locally via MQTT.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Immanuel",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@alcalzone/release-script-plugin-manual-review": "^5.2.0",
|
|
39
39
|
"@iobroker/adapter-dev": "^1.5.0",
|
|
40
40
|
"@iobroker/eslint-config": "^2.3.4",
|
|
41
|
-
"@iobroker/testing": "^6.3.
|
|
41
|
+
"@iobroker/testing": "^6.3.2",
|
|
42
42
|
"@tsconfig/node22": "^22.0.6",
|
|
43
43
|
"@types/node": "^22.18.11",
|
|
44
44
|
"mqtt": "^5.15.2",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"test:integration": "mocha test/integration --exit",
|
|
59
59
|
"test": "npm run test:package && npm run test:unit",
|
|
60
60
|
"lint": "eslint .",
|
|
61
|
-
"test:unit": "mocha test/verbrauch test/broker test/namen test/einheiten test/abgelehnt test/schreiblast test/devicemanager test/zahlundtext --exit",
|
|
61
|
+
"test:unit": "mocha test/verbrauch test/broker test/namen test/einheiten test/abgelehnt test/schreiblast test/devicemanager test/zahlundtext test/umbenennen --exit",
|
|
62
62
|
"release": "release-script"
|
|
63
63
|
}
|
|
64
64
|
}
|
|
@@ -697,7 +697,7 @@ vis.binds.faikout = {
|
|
|
697
697
|
.on('click', function () {
|
|
698
698
|
var alt = ctx.wert(z.feld);
|
|
699
699
|
// `swing` ist eine Liste (off/on), alle anderen sind Schalter.
|
|
700
|
-
// `swing` kennt off/on/V/H/H+V/C (SWING_* in Faikout.c). Umgeschaltet wird nur
|
|
700
|
+
// `swing` kennt off/on/V/H/H+V/C/H+C (SWING_* in Faikout.c). Umgeschaltet wird nur
|
|
701
701
|
// zwischen aus und ein; die Achsen setzt man ueber swingv/swingh.
|
|
702
702
|
if (z.feld === 'control.swing') vis.setValue(ctx.oid(z.feld), alt === 'off' ? 'on' : 'off');
|
|
703
703
|
else vis.setValue(ctx.oid(z.feld), !alt);
|
|
@@ -1102,7 +1102,7 @@ vis.binds.faikout = {
|
|
|
1102
1102
|
.html(b.SYM[z.sym] + (mitText ? '<span>' + z.name + '</span>' : ''))
|
|
1103
1103
|
.on('click', function () {
|
|
1104
1104
|
var alt = ctx.wert(z.feld);
|
|
1105
|
-
// `swing` kennt off/on/V/H/H+V/C (SWING_* in Faikout.c). Umgeschaltet wird nur
|
|
1105
|
+
// `swing` kennt off/on/V/H/H+V/C/H+C (SWING_* in Faikout.c). Umgeschaltet wird nur
|
|
1106
1106
|
// zwischen aus und ein; die Achsen setzt man ueber swingv/swingh.
|
|
1107
1107
|
if (z.feld === 'control.swing') vis.setValue(ctx.oid(z.feld), alt === 'off' ? 'on' : 'off');
|
|
1108
1108
|
else vis.setValue(ctx.oid(z.feld), !alt);
|