Connect Esper to Openhab

Hello guys :slight_smile:
I know that Openhab has its own rule engine but for a student project I have to use Esper to define rules for my Openhab system.


@watou proposed to use an MQTT Broker to connect Openhab to an Esper Engine to share the occuring sate updates among them. Could anybody explain how this could work in detail?
How can I β€œtranslate” state updates from Openhab to Event-Objects that can be processed by Esper?

(My Openhab Installation runs on a Raspberry Pi)

What about using jython scripting to connect. https://github.com/OH-Jython-Scripters/openhab2-jython/blob/master/Script%20Examples/esper_example.py

1 Like

Great idea thank you!
I tried installing jython like it’s described here but the example scripts are not working:

Do you have any idea what’s the problem?

Which version of OH are you using?

I’m using 2.3.0

I upgarded to 2.4.0~M5-1 the hello_world.py does work now but the esper_example.py still throws the same error as shown above :frowning:

There have been a fair number of changes to Jython, and I don’t believe that esper has been updated to reflect that. I am not in a situation where I can troubleshoot this. @5iver might have some ideas?

Are you loading the Esper component script? The docs have been rewritten, and things are being shifted around in the repo. The Esper package and examples didn’t quite fit in anywhere, so it was archived. See if this info helps. There is also a PR to restructure the repo, which will provide a better way of storing/communicating this sort of JSR223-Jython example code.

Let us know if you can get it working. In reading through it, nothing stood out as needing to be updated to use the updates in the ESH automation API, but I’ve never used the code. Glad you got the hello_world.py script running (hello)!

Thanks for the advice :slightly_smiling_face: Yes I’m loading the Esper component script.
I used the files from the newest Repo and structured my directories in the following way:

/etc/openhab2/
β”œβ”€β”€β”€automation
β”‚ β”œβ”€β”€β”€jsr223
β”‚ β”‚ β”œβ”€β”€β”€000_core
β”‚ β”‚ β”‚ β”‚ 000_startup_delay.py
β”‚ β”‚ β”‚ β”‚
β”‚ β”‚ β”‚ └───components
β”‚ β”‚ β”‚ 100_DirectoryTrigger.py
β”‚ β”‚ β”‚ 100_OsgiEventTrigger.py
β”‚ β”‚ β”‚ 100_ShutdownTrigger.py
β”‚ β”‚ β”‚ 100_StartupTrigger.py
β”‚ β”‚ β”‚ 200_JythonBindingInfoProvider.py
β”‚ β”‚ β”‚ 200_JythonExtensionProvider.py
β”‚ β”‚ β”‚ 200_JythonItemProvider.py
β”‚ β”‚ β”‚ 200_JythonThingProvider.py
β”‚ β”‚ β”‚ 200_JythonThingTypeProvider.py
β”‚ β”‚ β”‚ 200_JythonTransform.py
β”‚ β”‚ β”‚
β”‚ β”‚ └───community
β”‚ β”‚ └───esper
β”‚ β”‚ β”‚ esper_example.py
β”‚ β”‚ β”‚
β”‚ β”‚ └───components
β”‚ β”‚ 000_Esper.py
β”‚ β”‚
β”‚ β”œβ”€β”€β”€jython
β”‚ β”‚ jython-standalone-2.7.0.jar
β”‚ β”‚
β”‚ └───lib
β”‚ └───python
β”‚ β”‚ configuration.py
β”‚ β”‚
β”‚ β”œβ”€β”€β”€community
β”‚ β”‚ β”‚ init.py
β”‚ β”‚ β”‚
β”‚ β”‚ └───esper
β”‚ β”‚ β”‚ example0.py
β”‚ β”‚ β”‚ example2.py
β”‚ β”‚ β”‚ example3.epl
β”‚ β”‚ β”‚ example3.py
β”‚ β”‚ β”‚ init.py
β”‚ β”‚ β”‚
β”‚ β”‚ └───java
β”‚ β”‚ antlr-runtime-4.5.3.jar
β”‚ β”‚ cglib-nodep-3.2.4.jar
β”‚ β”‚ esper-6.1.0.jar
β”‚ β”‚ log4j-1.2.17.jar
β”‚ β”‚ log4j.properties
β”‚ β”‚ slf4j-api-1.7.21.jar
β”‚ β”‚ slf4j-log4j12-1.7.21.jar
β”‚ β”‚ init.py
β”‚ β”‚
β”‚ β”œβ”€β”€β”€core
β”‚ β”‚ β”‚ actions.py
β”‚ β”‚ β”‚ date.py
β”‚ β”‚ β”‚ items.py
β”‚ β”‚ β”‚ jsr223.py
β”‚ β”‚ β”‚ log.py
β”‚ β”‚ β”‚ rules.py
β”‚ β”‚ β”‚ testing.py
β”‚ β”‚ β”‚ triggers.py
β”‚ β”‚ β”‚ init.py
β”‚ β”‚ β”‚
β”‚ β”‚ └───osgi
β”‚ β”‚ events.py
β”‚ β”‚ init.py
β”‚ β”‚
β”‚ └───personal
β”‚ init.py

Now I’m getting this error:

:persevere:

It looks like I screwed up the first import in esper_example.py when I moved it to the community package. This was from openhab import esper before I touched it. Change…

from community import esper

to…

from core import esper

Let’s see if that works any better for you.

Now I’m getting the error from my first post again (that the eventtype or class β€œItemStateUpdate” was not found) :see_no_evil: