iobroker.statechart 0.1.1 → 0.2.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 +130 -21
- package/admin/build/tab.js +132 -130
- package/admin/statechart.png +0 -0
- package/build/lib/chart-codegen.js +338 -0
- package/build/lib/chart-codegen.js.map +7 -0
- package/build/lib/chart-helpers.js +90 -0
- package/build/lib/chart-helpers.js.map +7 -0
- package/build/lib/chart-model.js +353 -0
- package/build/lib/chart-model.js.map +7 -0
- package/build/lib/chart-runtime.js +876 -0
- package/build/lib/chart-runtime.js.map +7 -0
- package/build/lib/chart-structure.js +101 -0
- package/build/lib/chart-structure.js.map +7 -0
- package/build/lib/chart-validation.js +303 -0
- package/build/lib/chart-validation.js.map +7 -0
- package/build/main.js +342 -0
- package/build/main.js.map +7 -0
- package/io-package.json +14 -1
- package/package.json +20 -17
- package/lib/adapter-config.d.ts +0 -19
- package/lib/chart-codegen.js +0 -436
- package/lib/chart-codegen.test.js +0 -132
- package/lib/chart-helpers.js +0 -74
- package/lib/chart-helpers.test.js +0 -38
- package/lib/chart-model.js +0 -577
- package/lib/chart-model.test.js +0 -189
- package/lib/chart-runtime.js +0 -797
- package/lib/chart-runtime.test.js +0 -699
- package/lib/chart-structure.js +0 -106
- package/lib/chart-validation.js +0 -328
- package/lib/chart-validation.test.js +0 -149
- package/main.js +0 -279
package/README.md
CHANGED
|
@@ -30,13 +30,14 @@ actions, timers and function blocks are drawn in the ioBroker admin and executed
|
|
|
30
30
|
- Timers: `after(5, sec)`
|
|
31
31
|
- Function blocks with your own JavaScript functions, usable in all conditions and actions
|
|
32
32
|
- Inputs and outputs mapped to any ioBroker states
|
|
33
|
-
- Live view: the active state is highlighted in the editor
|
|
33
|
+
- Live view: the active state is highlighted in the editor, the current values of the variables are shown, taken
|
|
34
|
+
transitions light up, and a history shows when which transition was taken and why
|
|
34
35
|
- Code editor with syntax highlighting, error checking (e.g. unknown variables) and completion
|
|
35
36
|
- Several independent charts per instance
|
|
36
37
|
- Import and export of charts as JSON files
|
|
37
38
|
- Comments on states, transitions and function blocks, and notes on the canvas
|
|
38
39
|
- Per input: wake up on every update or only on changes, filter by ack, debounce
|
|
39
|
-
- Helper functions: setState, setStateDelayed, sendTo, isTimeBetween, isDaytime, astroTime
|
|
40
|
+
- Helper functions: setState, setStateDelayed, sendTo, isTimeBetween, isDaytime, astroTime, change detection (hasChanged...)
|
|
40
41
|
- Undo/redo (Ctrl+Z, Ctrl+Y), copy/cut/paste of states and function blocks (Ctrl+C, Ctrl+X, Ctrl+V), also between charts, and a warning about unsaved changes
|
|
41
42
|
- **Show code**: the JavaScript generated from the chart, showing exactly how the adapter executes it
|
|
42
43
|
|
|
@@ -66,7 +67,10 @@ Requirements: Node.js 22 or newer, js-controller 6.0.11 or newer, admin 7.6.17 o
|
|
|
66
67
|
- **Local**: only exists inside the chart, with an initial value
|
|
67
68
|
4. Add states with **Add state**. The state marked with the dot and arrow is the initial state
|
|
68
69
|
(can be changed in the properties of a state).
|
|
69
|
-
5. Draw transitions by dragging from the border of a state to another state (or to itself).
|
|
70
|
+
5. Draw transitions by dragging from the border of a state to another state (or to itself). The arrows start and
|
|
71
|
+
end where the states face each other and follow them when they are moved. To fix an end at another place,
|
|
72
|
+
select the transition and drag the round grip at the end along the border (double click: automatic again). To
|
|
73
|
+
move a transition to another state, drop the grip on that state: its label and all other properties are kept.
|
|
70
74
|
6. Select a state or transition (or double click it) to edit its actions or label on the right.
|
|
71
75
|
7. Click **Save**. New charts are paused: start the chart with ▶ in the chart list. After saving, the adapter
|
|
72
76
|
restarts a running chart immediately.
|
|
@@ -156,11 +160,21 @@ In conditions, actions and function blocks:
|
|
|
156
160
|
| `isTimeBetween("22:00", "06:00")` | true if the current time is in the range, also over midnight |
|
|
157
161
|
| `isDaytime()` | true between sunrise and sunset |
|
|
158
162
|
| `astroTime("sunset", offsetMinutes)` | time of an astro event today as `Date`: `sunrise`, `sunset`, `dawn`, `dusk`, `solarNoon`, ... |
|
|
163
|
+
| `hasChanged(variable)` | true if the variable has changed, see below |
|
|
164
|
+
| `hasChangedFrom(variable, value)` | true if the variable has changed and its previous value was `value` |
|
|
165
|
+
| `hasChangedTo(variable, value)` | true if the variable has changed to `value`, e.g. `hasChangedTo(button, true)` for a rising edge |
|
|
159
166
|
|
|
160
167
|
`isDaytime()` and `astroTime()` use the location of the ioBroker system settings. To read other states, add
|
|
161
168
|
them as inputs: their variables are always up to date and wake up the chart. Time based functions do not wake up
|
|
162
169
|
the chart by themselves, they are evaluated when it wakes up.
|
|
163
170
|
|
|
171
|
+
**Change detection** works like in Stateflow: it compares the value of the variable at the start of the current
|
|
172
|
+
wakeup with its value at the start of the previous wakeup. Inputs, outputs and locals can be checked. An update
|
|
173
|
+
with the same value is no change, neither is a wakeup by another input or a timer, so `[hasChangedTo(button, true)]`
|
|
174
|
+
is only true once per press of the button. On the wakeup after the start nothing has changed yet. A change of a
|
|
175
|
+
local by an action is seen on the next wakeup, also in a super step. Objects and arrays are compared by their
|
|
176
|
+
contents.
|
|
177
|
+
|
|
164
178
|
### Function blocks
|
|
165
179
|
|
|
166
180
|
**Add function** creates a block for your own JavaScript. It is executed once when the chart starts,
|
|
@@ -186,6 +200,22 @@ Transition label: `[tooWarm(temperature)]{heating = false;}`
|
|
|
186
200
|
Comments and notes have no influence on the execution. They are included in the generated code and in exported
|
|
187
201
|
files, and changing them does not prevent restoring the state after a restart.
|
|
188
202
|
|
|
203
|
+
### Watching a running chart
|
|
204
|
+
|
|
205
|
+
While a chart runs, the editor shows what it does:
|
|
206
|
+
|
|
207
|
+
- The **active states** have a green border.
|
|
208
|
+
- **Live values** (panel at the top left of the canvas, switched on and off with the last icon in the toolbar):
|
|
209
|
+
the current values of all variables. They are also shown below each variable in the tab **Variables**.
|
|
210
|
+
- A **transition lights up** for a moment when the chart takes it.
|
|
211
|
+
- The tab **History** lists the starts of the chart and the transitions taken, newest first: when, from which state
|
|
212
|
+
to which, triggered by which input or by a timer (`after`), and which states were active afterwards. Click a
|
|
213
|
+
transition to select it in the chart. The adapter keeps the last 200 events, also when the editor is closed and
|
|
214
|
+
after a restart. **Clear history** removes them.
|
|
215
|
+
|
|
216
|
+
The live values and the history come from the running chart, so they refer to the saved chart, not to unsaved
|
|
217
|
+
changes in the editor.
|
|
218
|
+
|
|
189
219
|
### Import and export
|
|
190
220
|
|
|
191
221
|
- **Export chart** (last icon in the toolbar of the editor) saves the chart as JSON file, including unsaved changes.
|
|
@@ -205,6 +235,8 @@ For every chart, the adapter creates below `statechart.<instance>.charts.<chart>
|
|
|
205
235
|
| `activeState` | Name of the active state, nested states as `Parent.Child` |
|
|
206
236
|
| `activeStateIds` | IDs of all active states as JSON |
|
|
207
237
|
| `snapshot` | Stored state of the chart (active states, when they were entered, locals), see below |
|
|
238
|
+
| `values` | Current values of all variables as JSON, `{}` if the chart does not run |
|
|
239
|
+
| `history` | The last 200 events (starts and transitions taken) as JSON. Writing it without ack clears it |
|
|
208
240
|
|
|
209
241
|
The chart itself is stored in the object `statechart.<instance>.charts.<chart>`.
|
|
210
242
|
|
|
@@ -213,6 +245,8 @@ The chart itself is stored in the object `statechart.<instance>.charts.<chart>`.
|
|
|
213
245
|
After a restart of the adapter or of ioBroker, every chart continues in the states which were active
|
|
214
246
|
before, with its local variables. The entry actions are not executed again, and timers continue with
|
|
215
247
|
their remaining time. A timer which expired while the adapter was stopped is taken right after the start.
|
|
248
|
+
Like after every start, the chart then wakes up once, so changes of the inputs during the stop are
|
|
249
|
+
noticed.
|
|
216
250
|
|
|
217
251
|
The chart starts in its initial state instead if it was changed meanwhile (positions in the editor do not
|
|
218
252
|
count), after saving it in the editor, after pausing it, and if the option **Restore the state after a
|
|
@@ -221,7 +255,14 @@ restart** in the chart properties is switched off. Variables declared in functio
|
|
|
221
255
|
### Execution model and differences to other statechart tools
|
|
222
256
|
|
|
223
257
|
- The adapter uses [XState](https://stately.ai/docs/xstate) to execute the charts.
|
|
224
|
-
- Every change of an input wakes up the chart once
|
|
258
|
+
- Every change of an input wakes up the chart once, as well as an expiring `after(...)` and the start of the chart
|
|
259
|
+
(also after restoring it). Transitions without event, e.g. without label, are checked on every wakeup, so they
|
|
260
|
+
are taken right after the start if their condition is true.
|
|
261
|
+
- By default, only one transition is taken per wakeup, a following one waits for the next wakeup. With the
|
|
262
|
+
chart option **Take transitions until none is valid (super step)**, the chart is checked again right after a
|
|
263
|
+
transition, until no transition is valid anymore, like the super step semantics of Stateflow. The event of an
|
|
264
|
+
input only counts for the first transition of a wakeup, during actions may run several times. To protect against
|
|
265
|
+
loops, at most 100 transitions are taken per wakeup, then a warning is logged.
|
|
225
266
|
- `{action}` is executed while the transition is taken, i.e. after `exit` of the old and before `entry` of
|
|
226
267
|
the new state. A separate condition action and `/action` are not supported (yet).
|
|
227
268
|
- Transitions are selected like in Stateflow (outer before inner, see above), XState only executes them.
|
|
@@ -257,13 +298,14 @@ Adapter ausgeführt.
|
|
|
257
298
|
- Timer: `after(5, sec)`
|
|
258
299
|
- Funktionsblöcke mit eigenen JavaScript-Funktionen, nutzbar in allen Bedingungen und Aktionen
|
|
259
300
|
- Eingänge und Ausgänge, die mit beliebigen ioBroker-Datenpunkten verbunden sind
|
|
260
|
-
- Live-Ansicht: Der aktive Zustand wird im Editor hervorgehoben
|
|
301
|
+
- Live-Ansicht: Der aktive Zustand wird im Editor hervorgehoben, die aktuellen Werte der Variablen werden angezeigt,
|
|
302
|
+
genommene Übergänge leuchten auf, und ein Verlauf zeigt, wann welcher Übergang genommen wurde und warum
|
|
261
303
|
- Code-Editor mit Syntax-Hervorhebung, Fehlerprüfung (z.B. unbekannte Variablen) und Autovervollständigung
|
|
262
304
|
- Mehrere unabhängige Charts pro Instanz
|
|
263
305
|
- Import und Export von Charts als JSON-Dateien
|
|
264
306
|
- Kommentare zu Zuständen, Übergängen und Funktionsblöcken sowie Notizen auf der Zeichenfläche
|
|
265
307
|
- Pro Eingang: Aufwecken bei jeder Aktualisierung oder nur bei Änderung, Filter nach ack, Entprellen
|
|
266
|
-
- Hilfsfunktionen: setState, setStateDelayed, sendTo, isTimeBetween, isDaytime, astroTime
|
|
308
|
+
- Hilfsfunktionen: setState, setStateDelayed, sendTo, isTimeBetween, isDaytime, astroTime, Änderungserkennung (hasChanged...)
|
|
267
309
|
- Rückgängig/Wiederholen (Strg+Z, Strg+Y), Kopieren/Ausschneiden/Einfügen von Zuständen und Funktionsblöcken (Strg+C, Strg+X, Strg+V), auch zwischen Charts, und eine Warnung bei ungespeicherten Änderungen
|
|
268
310
|
- **Code anzeigen**: das aus dem Chart generierte JavaScript, das genau zeigt, wie der Adapter es ausführt
|
|
269
311
|
|
|
@@ -293,7 +335,11 @@ Voraussetzungen: Node.js 22 oder neuer, js-controller 6.0.11 oder neuer, Admin 7
|
|
|
293
335
|
- **Lokal**: gibt es nur im Chart, mit einem Startwert
|
|
294
336
|
4. Mit **Zustand hinzufügen** Zustände anlegen. Der Zustand mit Punkt und Pfeil ist der Startzustand
|
|
295
337
|
(änderbar in den Eigenschaften eines Zustands).
|
|
296
|
-
5. Übergänge zeichnen: vom Rand eines Zustands zu einem anderen Zustand (oder zu sich selbst) ziehen.
|
|
338
|
+
5. Übergänge zeichnen: vom Rand eines Zustands zu einem anderen Zustand (oder zu sich selbst) ziehen. Die Pfeile
|
|
339
|
+
beginnen und enden dort, wo sich die Zustände gegenüberliegen, und folgen ihnen beim Verschieben. Um ein Ende
|
|
340
|
+
an einer anderen Stelle festzulegen, den Übergang auswählen und den runden Griff am Ende am Rand entlang ziehen
|
|
341
|
+
(Doppelklick: wieder automatisch). Um einen Übergang an einen anderen Zustand umzuhängen, den Griff auf diesen
|
|
342
|
+
Zustand ziehen: Beschriftung und alle anderen Eigenschaften bleiben erhalten.
|
|
297
343
|
6. Einen Zustand oder Übergang anklicken (oder doppelklicken), um rechts seine Aktionen bzw. seine
|
|
298
344
|
Beschriftung zu bearbeiten.
|
|
299
345
|
7. **Speichern** klicken. Neue Charts sind angehalten: Starte das Chart mit ▶ in der Chart-Liste. Nach dem
|
|
@@ -386,11 +432,21 @@ In Bedingungen, Aktionen und Funktionsblöcken:
|
|
|
386
432
|
| `isTimeBetween("22:00", "06:00")` | wahr, wenn die aktuelle Uhrzeit im Bereich liegt, auch über Mitternacht |
|
|
387
433
|
| `isDaytime()` | wahr zwischen Sonnenaufgang und Sonnenuntergang |
|
|
388
434
|
| `astroTime("sunset", minuten)` | Zeitpunkt eines Astro-Ereignisses heute als `Date`: `sunrise`, `sunset`, `dawn`, `dusk`, `solarNoon`, ... |
|
|
435
|
+
| `hasChanged(variable)` | wahr, wenn sich die Variable geändert hat, siehe unten |
|
|
436
|
+
| `hasChangedFrom(variable, wert)` | wahr, wenn sich die Variable geändert hat und vorher `wert` war |
|
|
437
|
+
| `hasChangedTo(variable, wert)` | wahr, wenn sich die Variable auf `wert` geändert hat, z.B. `hasChangedTo(taster, true)` für eine steigende Flanke |
|
|
389
438
|
|
|
390
439
|
`isDaytime()` und `astroTime()` nutzen den Standort aus den ioBroker-Systemeinstellungen. Andere Datenpunkte liest
|
|
391
440
|
man über Eingänge: Ihre Variablen sind immer aktuell und wecken das Chart. Zeitabhängige Funktionen wecken das
|
|
392
441
|
Chart nicht von selbst, sie werden beim Aufwecken ausgewertet.
|
|
393
442
|
|
|
443
|
+
Die **Änderungserkennung** funktioniert wie in Stateflow: Sie vergleicht den Wert der Variablen zu Beginn des
|
|
444
|
+
aktuellen Aufweckens mit ihrem Wert zu Beginn des vorherigen. Eingänge, Ausgänge und lokale Variablen lassen sich
|
|
445
|
+
prüfen. Eine Aktualisierung mit demselben Wert ist keine Änderung, ebenso wenig ein Aufwecken durch einen anderen
|
|
446
|
+
Eingang oder einen Timer. `[hasChangedTo(taster, true)]` ist also nur einmal pro Tastendruck wahr. Beim Aufwecken
|
|
447
|
+
nach dem Start hat sich noch nichts geändert. Ändert eine Aktion eine lokale Variable, sieht man das erst beim
|
|
448
|
+
nächsten Aufwecken, auch im Super-Step. Objekte und Arrays werden nach ihrem Inhalt verglichen.
|
|
449
|
+
|
|
394
450
|
### Funktionsblöcke
|
|
395
451
|
|
|
396
452
|
**Funktion hinzufügen** legt einen Block für eigenes JavaScript an. Er wird beim Start des Charts
|
|
@@ -418,6 +474,22 @@ Beschriftung eines Übergangs: `[zuWarm(temperatur)]{heizung = false;}`
|
|
|
418
474
|
Kommentare und Notizen haben keinen Einfluss auf die Ausführung. Sie stehen im generierten Code und in exportierten
|
|
419
475
|
Dateien, und wenn sie sich ändern, wird der Zustand nach einem Neustart trotzdem wiederhergestellt.
|
|
420
476
|
|
|
477
|
+
### Ein laufendes Chart beobachten
|
|
478
|
+
|
|
479
|
+
Während ein Chart läuft, zeigt der Editor, was es tut:
|
|
480
|
+
|
|
481
|
+
- Die **aktiven Zustände** haben einen grünen Rahmen.
|
|
482
|
+
- **Live-Werte** (Tafel oben links auf der Zeichenfläche, ein- und ausgeschaltet mit dem letzten Symbol der
|
|
483
|
+
Werkzeugleiste): die aktuellen Werte aller Variablen. Sie stehen auch unter jeder Variable im Reiter **Variablen**.
|
|
484
|
+
- Ein **Übergang leuchtet kurz auf**, wenn das Chart ihn nimmt.
|
|
485
|
+
- Der Reiter **Verlauf** listet die Starts des Charts und die genommenen Übergänge, der neueste zuerst: wann, von
|
|
486
|
+
welchem Zustand zu welchem, ausgelöst durch welchen Eingang oder einen Timer (`after`), und welche Zustände danach
|
|
487
|
+
aktiv waren. Ein Klick auf einen Übergang wählt ihn im Chart aus. Der Adapter behält die letzten 200 Ereignisse,
|
|
488
|
+
auch bei geschlossenem Editor und über einen Neustart hinweg. **Verlauf leeren** löscht sie.
|
|
489
|
+
|
|
490
|
+
Live-Werte und Verlauf kommen vom laufenden Chart. Sie beziehen sich also auf das gespeicherte Chart, nicht auf
|
|
491
|
+
ungespeicherte Änderungen im Editor.
|
|
492
|
+
|
|
421
493
|
### Import und Export
|
|
422
494
|
|
|
423
495
|
- **Chart exportieren** (letztes Symbol in der Werkzeugleiste des Editors) speichert das Chart als JSON-Datei, mit
|
|
@@ -439,6 +511,8 @@ Für jedes Chart legt der Adapter unter `statechart.<instanz>.charts.<chart>` an
|
|
|
439
511
|
| `activeState` | Name des aktiven Zustands, verschachtelte Zustände als `Eltern.Kind` |
|
|
440
512
|
| `activeStateIds` | IDs aller aktiven Zustände als JSON |
|
|
441
513
|
| `snapshot` | Gespeicherter Zustand des Charts (aktive Zustände, wann sie betreten wurden, lokale Variablen), siehe unten |
|
|
514
|
+
| `values` | Aktuelle Werte aller Variablen als JSON, `{}` wenn das Chart nicht läuft |
|
|
515
|
+
| `history` | Die letzten 200 Ereignisse (Starts und genommene Übergänge) als JSON. Schreiben ohne ack leert ihn |
|
|
442
516
|
|
|
443
517
|
Das Chart selbst ist im Objekt `statechart.<instanz>.charts.<chart>` gespeichert.
|
|
444
518
|
|
|
@@ -447,7 +521,8 @@ Das Chart selbst ist im Objekt `statechart.<instanz>.charts.<chart>` gespeichert
|
|
|
447
521
|
Nach einem Neustart des Adapters oder von ioBroker macht jedes Chart in den Zuständen weiter, die
|
|
448
522
|
vorher aktiv waren, mit seinen lokalen Variablen. Die entry-Aktionen laufen nicht noch einmal, und Timer
|
|
449
523
|
laufen mit ihrer Restzeit weiter. Ein Timer, der abgelaufen ist, während der Adapter gestoppt war, greift
|
|
450
|
-
gleich nach dem Start.
|
|
524
|
+
gleich nach dem Start. Wie nach jedem Start wacht das Chart dann einmal auf, so werden Änderungen der
|
|
525
|
+
Eingänge während des Stopps bemerkt.
|
|
451
526
|
|
|
452
527
|
Im Startzustand beginnt das Chart stattdessen, wenn es zwischendurch geändert wurde (Positionen im
|
|
453
528
|
Editor zählen nicht), nach dem Speichern im Editor, nach dem Anhalten und wenn die Option **Zustand nach
|
|
@@ -457,7 +532,14 @@ Funktionsblöcken deklariert sind, werden nicht wiederhergestellt.
|
|
|
457
532
|
### Ausführung und Unterschiede zu anderen Statechart-Werkzeugen
|
|
458
533
|
|
|
459
534
|
- Der Adapter führt die Charts mit [XState](https://stately.ai/docs/xstate) aus.
|
|
460
|
-
- Jede Änderung eines Eingangs weckt das Chart einmal auf
|
|
535
|
+
- Jede Änderung eines Eingangs weckt das Chart einmal auf, ebenso ein ablaufendes `after(...)` und der Start des
|
|
536
|
+
Charts (auch nach dem Wiederherstellen). Übergänge ohne Event, z.B. ohne Beschriftung, werden bei jedem Aufwecken
|
|
537
|
+
geprüft und greifen deshalb direkt nach dem Start, wenn ihre Bedingung wahr ist.
|
|
538
|
+
- Standardmäßig wird pro Aufwecken nur ein Übergang genommen, ein folgender wartet auf das nächste Aufwecken. Mit der
|
|
539
|
+
Chart-Option **Weiterschalten, bis kein Übergang mehr gilt (Super-Step)** wird das Chart nach einem Übergang sofort
|
|
540
|
+
erneut geprüft, bis kein Übergang mehr gilt, wie bei der Super-Step-Semantik von Stateflow. Das Event eines
|
|
541
|
+
Eingangs zählt nur für den ersten Übergang eines Aufweckens, during-Aktionen können mehrmals laufen. Zum Schutz vor
|
|
542
|
+
Schleifen werden pro Aufwecken höchstens 100 Übergänge genommen, danach wird eine Warnung geloggt.
|
|
461
543
|
- `{aktion}` wird während des Übergangs ausgeführt, also nach `exit` des alten und vor `entry` des
|
|
462
544
|
neuen Zustands. Eine eigene Condition Action und `/aktion` werden (noch) nicht unterstützt.
|
|
463
545
|
- Übergänge werden wie bei Stateflow ausgewählt (außen vor innen, siehe oben), XState führt sie nur aus.
|
|
@@ -480,35 +562,51 @@ Funktionsblöcken deklariert sind, werden nicht wiederhergestellt.
|
|
|
480
562
|
|
|
481
563
|
```bash
|
|
482
564
|
npm install
|
|
483
|
-
npm run build # build the admin tab
|
|
565
|
+
npm run build # build the adapter (src/ to build/) and the admin tab
|
|
484
566
|
npm run dev-server setup # once: local ioBroker test instance in .dev-server/
|
|
485
|
-
npm run dev-server watch # run it, admin on http://127.0.0.1:8081
|
|
567
|
+
npm run dev-server watch # run it, admin on http://127.0.0.1:8081/, rebuilds the adapter on changes
|
|
486
568
|
npm run upload:tab # in a second terminal: upload the tab into the test instance
|
|
487
569
|
```
|
|
488
570
|
|
|
571
|
+
The adapter and the editor are written in TypeScript. The editor imports the chart model, the validation
|
|
572
|
+
and the code generator directly from `src/lib/`, so they are shared by both.
|
|
573
|
+
|
|
489
574
|
| Script | Description |
|
|
490
575
|
|---|---|
|
|
491
576
|
| `dev-server` | Runs [`dev-server`](https://github.com/ioBroker/dev-server) with the given command. Before, it applies the patches in `patches/`: the dev-server uses `wmic.exe` to find the adapter process, which no longer exists in Windows 11 25H2 |
|
|
492
|
-
| `build` / `watch` | Build the
|
|
577
|
+
| `build` / `watch` | Build the adapter (`src` to `build`) and the tab (`admin/src` to `admin/build`), with type check |
|
|
578
|
+
| `build:ts` / `watch:ts` | Build only the adapter |
|
|
579
|
+
| `build:react` / `watch:react` | Build only the tab |
|
|
493
580
|
| `upload:tab` | Build the tab and write the admin files into the running dev-server instance (works while `dev-server watch` runs) |
|
|
494
|
-
| `test` | Unit tests (`
|
|
495
|
-
| `check` | Type check of the adapter
|
|
581
|
+
| `test` | Unit tests (`src/**/*.test.ts`) and package tests |
|
|
582
|
+
| `check` | Type check of the adapter and the tab |
|
|
496
583
|
| `lint` | ESLint |
|
|
497
584
|
| `translate` | Translate the texts of the adapter |
|
|
498
585
|
| `release` | Create a new release |
|
|
499
586
|
|
|
500
587
|
After changes of `io-package.json`, run `npm run dev-server upload` and restart `npm run dev-server watch`.
|
|
501
588
|
|
|
502
|
-
**The built tab (`admin/build`)
|
|
503
|
-
After changes in `admin/src`, run `npm run build` and commit `
|
|
504
|
-
`check-
|
|
589
|
+
**The built adapter (`build`) and tab (`admin/build`) are committed**, because installations from GitHub do
|
|
590
|
+
not run a build. After changes in `src` or `admin/src`, run `npm run build` and commit `build` and
|
|
591
|
+
`admin/build` as well. The workflow job `check-build` fails if they are outdated. The source maps are not
|
|
592
|
+
committed.
|
|
593
|
+
|
|
594
|
+
**Dependabot** proposes updates monthly. Patch updates (and minor updates of development dependencies) are
|
|
595
|
+
merged automatically when the checks pass, which are required for `main`. Dependabot cannot rebuild the
|
|
596
|
+
committed build, so `check-build` does not compare it in Dependabot pull requests. Instead, after every push to
|
|
597
|
+
`main`, it rebuilds `build` and `admin/build` and commits them if they changed. The workflows need the secret
|
|
598
|
+
`AUTO_MERGE_TOKEN`, a fine-grained personal access token for this repository with the permissions
|
|
599
|
+
"Contents" and "Pull requests" (read and write). Major updates of MUI, React and
|
|
600
|
+
`@types/node` are ignored: `@iobroker/adapter-react-v5` requires MUI 6 and React 18, and the adapter supports
|
|
601
|
+
Node.js 22.
|
|
505
602
|
|
|
506
603
|
| Path | Content |
|
|
507
604
|
|---|---|
|
|
508
|
-
| `main.
|
|
509
|
-
| `lib/chart-model.
|
|
510
|
-
| `lib/chart-runtime.
|
|
511
|
-
| `lib/chart-validation.
|
|
605
|
+
| `src/main.ts` | Adapter: loads the charts, subscribes the inputs, restarts a chart when it is saved |
|
|
606
|
+
| `src/lib/chart-model.ts` | Chart model (shared by adapter and editor) and parser of the transition labels |
|
|
607
|
+
| `src/lib/chart-runtime.ts` | Execution of a chart with XState |
|
|
608
|
+
| `src/lib/chart-validation.ts` | Checks of conditions, actions and function blocks |
|
|
609
|
+
| `src/lib/chart-codegen.ts` | Code shown by "Show code" in the editor |
|
|
512
610
|
| `admin/src/` | Editor (React, React Flow, CodeMirror) |
|
|
513
611
|
| `admin/jsonConfig.json` | Instance settings |
|
|
514
612
|
|
|
@@ -522,6 +620,17 @@ with, endorsed or sponsored by The MathWorks, Inc.
|
|
|
522
620
|
Placeholder for the next version (at the beginning of the line):
|
|
523
621
|
### **WORK IN PROGRESS**
|
|
524
622
|
-->
|
|
623
|
+
### 0.2.0 (2026-11-01)
|
|
624
|
+
* (Igge) the adapter and the editor are written in TypeScript now, no changes of the behavior
|
|
625
|
+
* (Igge) live values of the variables in the editor
|
|
626
|
+
* (Igge) taken transitions light up in the editor
|
|
627
|
+
* (Igge) history of the starts and the transitions taken (tab "History", state `charts.<chart>.history`)
|
|
628
|
+
* (Igge) a chart wakes up once right after the start, so transitions without label are taken without waiting for a change of an input
|
|
629
|
+
* (Igge) chart option "super step": take transitions until none is valid anymore
|
|
630
|
+
* (Igge) the arrows of transitions start and end where the states face each other (floating edges), their ends can be dragged along the border of the states or onto another state to move the transition there
|
|
631
|
+
* (Igge) change detection: `hasChanged`, `hasChangedFrom` and `hasChangedTo`, e.g. `hasChangedTo(button, true)` for edges
|
|
632
|
+
* (Igge) suncalc 2: `isDaytime()` is true all day during the midnight sun, `astroTime()` reports events which do not happen on a day (polar regions)
|
|
633
|
+
|
|
525
634
|
### 0.1.1 (2026-10-25)
|
|
526
635
|
* (Igge) renamed from "state-machine" to "statechart", because npm does not accept the old name (too similar to an existing package)
|
|
527
636
|
|