i use a rule here for automatic close and open rollershutters.
Talking about the open after the sun is gone.
the original code is like that:
if (Rolloautomatik_zielwert.state == Integer::parseInt(i.state.toString())) {
it compares the real position of the rollershutter with the settet position like 70
my rollershutter (shelly2.5) does not exact reach this position, it stop -2 or +2 (68 up to 72) due to
tolerances during the movement.
But not my opening rule will not trigger because it´s not on the settet position.
I want to put some “tolerrance” in to the rule, but therefore my knowledge is not enough.
it try a couple of thing but no trigger of the rule
the last i tested was this:
If you look at your logic, it boils down to if ( (x=< y) && (x>= y) )
both those things cannot be true at the same time, so the && (and) is never satisfied.
My Goal is:
After other parts of the rule send my shutter to for example 70, it reaches its position at 72
(reportet via mqtt)
If the rule wants to open the shutter later, the rule check the position of the shutter.
If its not exact there (70) the rule wont open the shutter, because perhaps it is moved in the meantime
manually (close it complete or open it).
Now it want that the rule “thinks” while the shutter is at -2 (68) or +2 (72) it also at its right position close to 70.
Hoppyfully this works.
You have all the working parts available. And, Or, Greater, Less, Add offset, Subtract offset.
It’s up to you to assemble them into the logical condition that you want.
So in words, that condition is -
some Item state is more than a target (less a little)
and at the same time
some Item state is less than a target (plus a little)
which is a way of saying, the item state is close to the target.
Sounds like the wrong condition to me? Wouldn’t you want - if the Item state is not close to the target, do something
so give me another try:
My Shading Rule does the following:
If the Azimuth of the Sun is in the right angle (i can set this), the Rule sends the value that it set in “Rolloautomatik_zielwert” to my Rollershutter Actor with Mqtt (its a Shelly 2.5)
This “Rolloautomatik_zielwert” can be any value from 0 up 100. 0=open, 100=closed.
So for the Shading i use a value of 70.
Later the day if the Elevation of the Sun is in the right angle (i can set this), the Rule sends a 0 to open the Shutter.
But before the rule checks the position of the shutter: is it at “Rolloautomatik_zielwert” 70 ?.
Because probably somebody opened it or closed it manually. This avoids usless moving of the Shutter.
No coming to my problem:
If the Shelly receives the command close to “Rolloautomatik_zielwert” thats 70, it stops most of the time at 71 or 72. This comes from Tolerances.
But now my opening rule wont open, because is comparing the “Rolloautomatik_zielwert” with the real State of the Shutter i think its “==” part in the rule:
if (Rolloautomatik_zielwert.state == Integer::parseInt(i.state.toString())) {
So now i want to change the rule due to: “Open also if the position is “Rolloautomatik_zielwert” but in the range of -3 or +3”
if((Rolloautomatik_Sued_zielwert.state as Number).intValue <= (i.state as Number).intValue +3 && (Rolloautomatik_Sued_zielwert.state as Number).intValue >= (i.state as Number).intValue- 3) {