NEWS
[New Adapter] statechart - build state machines graphically
-
Hi everyone,
I'd like to introduce my adapter ioBroker.statechart and I'm looking for testers before it goes into the beta repository.
Many automations are really state machines: the light is on or off, the heating is in comfort, eco or window open mode, the washing machine is running or done. In scripts or Blockly this quickly spreads over many triggers, helper variables and timers. With this adapter you draw such logic as a statechart directly in the admin: states as boxes, transitions as arrows with conditions. The adapter executes the chart exactly as it is drawn.

Example alarm system (available as a template when you create a chart): In Disarmed, the chart waits to be armed, or arms itself at 11 pm if no window is open. An open window is reported. Armed contains the substates Exit delay (30 s), Monitoring, Entry delay (20 s) and Alarm. Door, window or motion for at least 2 s trigger it, motion not during night mode. In the alarm, two parallel regions run: the Siren goes silent after 3 minutes, the Notification sends a reminder every 10 minutes. Pressing the panic button three times triggers the alarm immediately. Disarming ends everything, whatever substate the chart is in.
Highlights
- Nested and parallel states,
entry/during/exitactions, transitions asevent[condition]{action} - Temporal logic like
after(5, min),every, counting button presses,at("22:30")orat("sunset", -30) - Inputs and outputs are any ioBroker states, your own JavaScript functions in function blocks
- Live view with active states and values, history, and a simulation with fast-forward, breakpoints and single steps, without switching anything
- Checks while editing, templates for new charts, restore former versions, import/export


Installation
Until the adapter is in the beta repository, install the released version from npm: Admin → Adapters → Install from custom URL → tab Custom →
iobroker.statechart(or on the console:iobroker url iobroker.statechart). Then add an instance of State Machine.Requirements: Node.js 22, js-controller ≥ 6.0.11, admin ≥ 7.6.20
Docs: Getting started · Reference
Feedback
I'm especially interested in whether you can get started without prior knowledge, and which of your automations fit well or badly into a chart. Please report bugs as an issue on GitHub, questions and ideas here in the thread.
This is an early version, the format of the charts may still change until 1.0. Please don't rely on it blindly for critical things like an alarm system or heating in winter yet.
Looking forward to your feedback!
- Nested and parallel states,
-
@Igge nice work, the simulation with fast-forward and breakpoints is something we have been missing for logic in ioBroker.
One question: how are the actions and function blocks executed at runtime? Directly in the adapter process or in some kind of sandbox (vm)? If a user writes an endless loop or throws an exception in a
duringaction, what happens to the other charts and to the adapter?Once you have the first feedback from testers, create a PR in ioBroker.repositories to add it to the latest repository. The repository checker will tell you what still has to be fixed before that.
Following notes:
- It would be cool, that theme of ioBroker (dark/light) would be supported
- It would be useful to see in the description to condition the example with Variable

-
Hi Bluefox,
thanks for the question and the notes!
How code runs today (0.5.x): conditions, actions and function blocks run in the adapter process, in a separate JavaScript context per chart (Node.js
vm) withoutrequireorprocess, with a time limit of 1 second and inside a try/catch. An exception is logged as a warning and the chart continues, other charts are not affected. An endless loop is aborted after 1 second, but since all charts share one process, the whole adapter is blocked for that second, and aduringaction would do that again on every wakeup. Code in Promise callbacks escapes both protections. It is no security sandbox, just like the JavaScript adapter.Planned for the next version:
- A chart whose code exceeds the time limit is stopped, with an error in the log. Fix it and start it again with ▶.
- Promise callbacks get the same time limit, their exceptions are caught.
- A chart which writes states far more often than plausible (e.g. a feedback loop) is stopped as well.
Your notes: both good points, I'll include them in the next release:
- The editor will follow the dark/light theme of ioBroker.
- The explanation of the condition field will get an example with a variable.
-
Note
This is an english version of Topic https://forum.iobroker.net/topic/85834/test-adapter-statechart-v0.5.1-grafische-zustandsautomaten addressed to non german speakers. Whoever speak german is welcome to use the german section.
Hey! Du scheinst an dieser Unterhaltung interessiert zu sein, hast aber noch kein Konto.
Hast du es satt, bei jedem Besuch durch die gleichen Beiträge zu scrollen? Wenn du dich für ein Konto anmeldest, kommst du immer genau dorthin zurück, wo du zuvor warst, und kannst dich über neue Antworten benachrichtigen lassen (entweder per E-Mail oder Push-Benachrichtigung). Du kannst auch Lesezeichen speichern und Beiträge positiv bewerten, um anderen Community-Mitgliedern deine Wertschätzung zu zeigen.
Mit deinem Input könnte dieser Beitrag noch besser werden 💗
Registrieren Anmelden