How to implement logic engine

Hi,

i am running an OH2 Installation in my new build Home as extension to the KNX bus. Actually i use it to use the alexa binding, persistance and visualization and some extended logic-rules.
My House has a fairly complex Design with at least 24 rollershutters and two blinds on top of a glass roof. The geometry is also a little bit complex. To cut a long story short: - I need more regulation and control over the complete envoirmential systems in the house than a standard solution can do.
My target for this upcoming summer is to develop a logic engine that can control the Sun-Protection. In the next steps i would like to integrate more details like heating, active cooling and ventilation.

What i would like to ask is - what is the best way to implement these engine? I think it is to comlex to build this als rules? Should it be a thing? Or Should i implement the main Logic as rules and develop the more complex calculations in JAVA objects?

thanks in advance

Have you had a look at node-red
In particular the blind controller node

I use these nodes in combination with the openhab2 nodes to control my blinds very effectively. I only have 4 blinds (So far) but it works perfectly.

The intended way for creating logical “connections” between different sensors and actuators is rules (either the textual rules or the new and still experimental graphical rule engine).

What makes you think that such would to complex?

the first reason is that the Rules DSL is not an full featured programming language - it works great if you have the typical connection thigs “when A happens, check for B and C and execute D”. But if you try to implement more complex applications its hard to maintain. At least i am missing the possibility to simpulate and test my application in a way i need it. I have implemented the logic for my blinds in JAVA and build a testing environment around it simulate the movement of the sun around my house and export the results as CSV Data for testing.
It would be great if i could implement my logic functions in java and use them in the rules engine, sadly it seems to be impossible to import external .jars in these rules.

you should definitely use node-red, that’s what you need. it can be installed via openhabian-config / optional components.

thanks for the tip with node-red, i did not catch what it is when vincent mentioned it! Installation with openhabian-config helps a lot to get started. What a powerful tool! I have to investigate further if i will use it, but it seems promising…

Sadly the blindcontroller is not able to set the blade angle of my blinds as far as i can see. This is what i have invested most of my time until now, so at least i could do this myself in js.

Hi, with the danger of being accused of “marketing”, I am now in the process of taking my own medicine: I work with a tool called CDP Studio, which is a full blown industrial control system development platform. I run all the logic in CDP and connect to the OH eventbus by MQTT. So far this looks very promising, as long as you are prepared to do the functional blocks in C++, relatively easy as there is a lot of autogenerated code. The runtime applications may be deployed on Windows or Linux, and it runs on anything from RPi and up.

As for logic there is practically no limit, for the normal stuff there is state machines, PID regulator, etc… And if you would like to build a dedicated “master control panel” in your control room; there is a full vector based GUI design tool in the package.

CDP Studio is free for hobby/non-commercial use - i.e. we provide licenses. If this is of interest, I could elaborate further, and also share the basic setup I already have in place.

Have a look here: cdpstudio.com and https://cdpstudio.com/getstarted/