First of all I would like to ensure rlkoshak and Max_G that I strongly respect knowledge, experience and all the effort of rlkoshak and also other members of this community. I have often used the hints in other threads (where I have not participated) and the hints and pieces of code helped me a lot. With all the respect it does not mean that I would blindly implement something without thinking. And asking, arguing, discussing various approaches does not mean I do not respect the other opinion. Maybe I do not understand it sufficiently, maybe it is in different situation… If you feel offended that I’m not willing to listen to you then I apologize because it was not my intention and I have never thought of you and/or your hints like this.
Now to the practical points 
Persistence If I would be starting today I would do it differently, at that time I was starting with openhab and whole automation. It has taken me lot of effort to understand the basic principles of OH, rules, api, sensors, arduino, radios, HW… and I need really the most primitive system to keep variable values, for this reason I re-invented the wheel, in fact at that time I was not knowing that the wheel is already invented.
Sleeps and locks For many reasons (starting by variables race conditions and finishing by relay currents…) it was big benefit in my setup to serialize all (almost) rules that can move the rollershutter (price for this is slower reaction to commands, but time is not important for my use case). This in turn can easily use all available execution threads as rlkoshak correctly mentioned. To prevent this if rule is going to trigger multiple rules that might result in rollershutter movement it starts them only if the lock is open (this is the loop with delay inside), because of race conditions this results in max 2 execution threads (little bit simplified, but it is not that important to go into deep details, was tested for more than 300 motors control and worked perfectly) occupied by rules that can move rollershutter and this threads are serialized by locks.
Result are long running rules (I was not aware this causes problems to OH as I have not experienced problems with this until now) but keeping still threads free for manually triggered rules, that can even ‘overtake’ the automated rules.
Numbers with(out) decimal places
Rule is here:
rule "South SLD"
// 0:Sunshine 1:Light 2:Dark
when
Item S_light_southffxINRAW changed
then
logInfo("Light", "Light changed input is " + S_light_southffxSLD.state + "/" + S_light_southffxINRAW.state)
if ( S_light_southffxDarkTreshold.state == NULL ) { S_light_southffxDarkTreshold.postUpdate(sensor_default_dark) }
if ( S_light_southffxSunshineTreshold.state == NULL ) { S_light_southffxSunshineTreshold.postUpdate(sensor_default_sunshine) }
if ( S_light_southffxHysteresis.state == NULL ) { S_light_southffxHysteresis.postUpdate(sensor_default_hyst) }
if ( S_light_southffxSLD.state == NULL ) {
if ( (S_light_southffxINRAW.state as Number) <= (S_light_southffxDarkTreshold.state as Number) ) { S_light_southffxSLD.sendCommand (2) }
else if ( (S_light_southffxINRAW.state as Number) <= (S_light_southffxSunshineTreshold.state as Number) ) { S_light_southffxSLD.sendCommand (1) }
else if ( (S_light_southffxINRAW.state as Number) > (S_light_southffxSunshineTreshold.state as Number) ) { S_light_southffxSLD.sendCommand (0) }
}
else {
if ( (S_light_southffxSLD.state as Number) == 0 ) {
if ( (S_light_southffxINRAW.state as Number) <= (S_light_southffxDarkTreshold.state as Number) ) { S_light_southffxSLD.sendCommand (2) }
else if ( (S_light_southffxINRAW.state as Number) <= ((S_light_southffxSunshineTreshold.state as Number) - (S_light_southffxHysteresis.state as Number)) ) { S_light_southffxSLD.sendCommand (1) }
}
if ( (S_light_southffxSLD.state as Number) == 1 ) {
if ( (S_light_southffxINRAW.state as Number) >= ((S_light_southffxSunshineTreshold.state as Number) + (S_light_southffxHysteresis.state as Number)) ) { S_light_southffxSLD.sendCommand (0) }
else if ( (S_light_southffxINRAW.state as Number) <= ((S_light_southffxDarkTreshold.state as Number) - (S_light_southffxHysteresis.state as Number)) ) { S_light_southffxSLD.sendCommand (2) }
}
if ( (S_light_southffxSLD.state as Number) == 2 ) {
if ( (S_light_southffxINRAW.state as Number) >= (S_light_southffxSunshineTreshold.state as Number) ) { S_light_southffxSLD.sendCommand (0) }
else if ( (S_light_southffxINRAW.state as Number) >= ((S_light_southffxDarkTreshold.state as Number) + (S_light_southffxHysteresis.state as Number)) ) { S_light_southffxSLD.sendCommand (1) }
}
}
end
The value of S_light_southffxINRAW
is changed by API from C code as the C code is receiving data from arduinos that measure light intensity and after it is checked and validated it is submitted to openhab and openhab by rule above prepares cleaned value of S_light_southffxSLD
. Depending on the change it might trigger rollershutter movement.
This is code scheduled to refactor, because with this approach each sensor would require own rule (not ideal), for this reason the RAW variables will be in group and if member of group will be changed the corresponding ‘cleaned’ variable will be updated. After refactor rain sensors + north and east light sensors will be connected.
Exec whitelist Sorry my mistake, not in GIT, forgot to add, now I’m not at my development machine, but will fix.
START Yes we should ge one by one and correct start is good start, as soon as I move the OH3 to development area (made change too fast and my OH3 has now HDMI turned off, wifi off and live IP address = need to change IP but without monitor and network
) I will post fresh log with all the details as mentioned by rlkoshak . In live is currently OH2 back.
Thanks for the help and hope to have some news by next week (this week I have very intensive work in my real work and not sufficient time for my hobby).