Quick thoughts on Python and the next-generation rule engine

Tags: #<Tag:0x00007f6182afc590>

It works really well, and with the helper libraries it’s easier than Rules DSL for anyone with a degree of programming knowledge. I’d also say easier for someone learning to program - start with one of the millions of python tutorials out there, and then progress onto openhab/NGRE.

I should have moved over sooner - and anyone else prevaricating should take the leap (given present circumstances mean many of us have more time than we did before…).

Many thanks to all the developers!

3 Likes

Couldn’t agree more, converting my rules from DSL to Jython was actually not at all as much work as I feared. I did have some experience with python so I had an advantage but I also agree that you will probably get more out of learning basic python than spending time on learning the DSL syntax.

Indeed many thanks to all those contributing to OpenHAB! :partying_face:

2 Likes

You are me interested now. Was there a particular guide you started with?

1 Like

The beta bundle from @5iver (here and then following the tips and examples here

I know some basic python, and the examples were easily enough to get me going.

Check out Udemy, they have many courses to choose from. It’s not free (around $10) but you get support from the instructor when needed.

No I’m fine with Python. I thought you mentioned some guides examples of setting up python for openHAB to use it for the rules

@dan12345. Thanks, yeah that’s what I was after

1 Like

Sorry misunderstood.

You may like this post as well.

1 Like

Possibly these guides could be promoted better - I had no idea how easy it was until I stumbled into them.

1 Like

Which guides are you referring to? If there is something missing from the helper library docs, please let me know in the forum or preferably as an issue or PR. The official docs are due for an update, but automation will be going through some changes in OH 3.0 that will also need documenting.

Perhaps a pinned post on the form saying something like “Try NGRE python - it’s now really easy and you will probably like it”?

1 Like

That’s the message I’ve been trying to get out for a couple years now! :smile:

I like the idea of a sticky. We’d need a moderator to buy into it and a good post. When/if the Jython addon and now a separate helper library addon are merged, I’ll definitely be putting out a post, so that one would be a good candidate.

2 Likes

Another quick thought: the new rule engine is much faster.

I’m surprised at this - I have openHAB running on a ridiculously overpowered media PC (i5) and I’m not sure why simple rules should have held up Rules DSL - but they did.

Example: I have a hard button attached to a sonoff device. That triggers a rule which makes a sound and does a thing. Under Rules DSL, there was a noticeable lag between the button pressing and the sound playing - perhaps half a second. Now there is no gap at all.

There are many benefits to using the new rule engine and scripted automation with Jython vs the old rule engine and the rules DSL. Performance is definitely one of them!

1 Like

Here’s another benefit. Under Rules DSL I’d often have stalled threads sucking up CPU time. The problem seemed to be bugs in executeCommand but I was never able to identify them or fix them.

Under Jython all that goes away.

Really, anyone with even basic python skills should move all their rules to Jython yesterday.

I’m getting boring now and will shut up.

1 Like

Haha. Nothing wrong with making a point so positively, Dan.

I have no experience with Python, so I’ve bookmarked a bunch of resources for the eventual move to NGR. Posts like this one reinforce the benefits of doing so.

From a change-management perspective, I think the tricky part will be assisting new users who will be told they should use NGR going forward, but find old posts in the community with examples that are coded in DSL. So the more people who move early, the better we’ll be able to assist newcomers starting from scratch!

Hi - just upgraded to openHAB 2.5.5 Release Build and wondered if I should still use the JAR you linked to, or if it’s now been merged?

thanks,

Dan