Ultimately you are moving from a state based Rules engine to an event based Rules engine and the two work just differently enough that I don’t think you will be able to just write a script to convert from one to the other. But OH is an EVENT based engine, not a CHANGE based engine.
OH supports:
- updates (an Item received a new value but the value is not necessarily different from the current value)
- commands (an Item is being told to go do something)
- changes (an Item changed state)
- channel trigger (some 2.x version bindings support Channels that directly trigger a Rule, e.g. Astro binding triggers a Rule at sunrise through a Channel trigger)
- time based trigger (a certain time of day, in Rules DSL (the default Rules Engine) this is a cron expression)
- system trigger (OH startup, shutdown)
In the new Rules Engine with the new MQTT binding David is working on, we can also trigger Rules based on MQTT messages directly.
The new Rules Engine is Experimental and has basically no documentation yet. I’ve started some User’s Guides here. I believe what David is proposing is that you can mimic a state machine by creating rules with a When...
but only if...
action
that correspond to your existing state machine.
What would probably be easiest would be to click together a Rule by hand then look at the resultant JSON file. then you can write a script to convert your state machine Rules to JSON rules.
But this is an “abuse” because OH Rules are not designed like a state machine. They are designed as “When this event happens (again, event, not necessarily change) run this program.” As such your 4000+ state machine Rules would probably be <400 OH rules, if you rewrote them in the way OH is designed to work.