Timescale rules (CEP) possible?

Hello,
I’m new to openHAB and wanted to ask if rules are possible that include a timescale and event count. Sometimes they are referred to as “Complex Event Processing” (CEP).

For example:
When the lamp is switched to ON/OFF 3 times within 10 seconds - fire an special event.
or:
When the motion sensor A was triggered 100 times within the last hour and motion sensor B was triggered 30 % less - fire an event.

Can you think of even more complex rules that are possible?

There’s currently no direct support for it. However, if enough people were interested we could create a binding for the Esper CEP engine that could receive and publish openHAB bus events.

1 Like

Or use the MQTT event bus binding to publish all state updates to the Esper engine, and subscribe to MQTT topics for its results. If an MQTT broker stood between the CEP engine and openHAB, the implementation would probably be simpler than writing openHAB-specific code. Just a thought…

2 Likes

The openHAB rules are Turing Complete so it is possible to write rules that behave like this using Timers and Items or local variables for the counts.

I think @watou’s solution would be the easiest near term.

1 Like