bizikle
(joseba arrieta)
June 17, 2021, 2:46pm
1
Hello:
Ia have some problems with my openhabian rules.
I have two conditions for moving my blinds but only one of them works.
One is luminescence (>350), ad it works well, but second (< 20.0) condition doesn’t work.
Can any one help me?
This is my rule
rule “control persianas”
when
Item ZWaveNode003ZW100Multisensor6_SensorLuminance changed
then
if (ZWaveNode003ZW100Multisensor6_SensorLuminance.state > 350)
{if (ZWaveNode011ZW100Multisensor6_SensorTemperature.state > 20.0)
{ZWaveNode008FGR223RollerShutter3_BlindsControl.sendCommand(0)
Thread::sleep(20000)
ZWaveNode009FGR223RollerShutter3_BlindsControl.sendCommand(0)}
else
{ZWaveNode009FGR223RollerShutter3_BlindsControl.sendCommand(100)
Thread::sleep(20000)
ZWaveNode008FGR223RollerShutter3_BlindsControl.sendCommand(100)}
}
else
{if (ZWaveNode011ZW100Multisensor6_SensorTemperature.state > 20.0)
{ZWaveNode008FGR223RollerShutter3_BlindsControl.sendCommand(100)
Thread::sleep(20000)
ZWaveNode009FGR223RollerShutter3_BlindsControl.sendCommand(100)}
else
{ZWaveNode009FGR223RollerShutter3_BlindsControl.sendCommand(0)
Thread::sleep(20000)
ZWaveNode008FGR223RollerShutter3_BlindsControl.sendCommand(0)}
}
end
rlkoshak
(Rich Koshak)
June 17, 2021, 3:28pm
2
Please use code fences. The code is really hard to read without it.
```
code goes here
```
You have 20 second sleeps in this rule and the tag indicates you are on OH 2. If your sensor reports more often then once every 20 seconds you will quickly run out of rule threads and no rules will be able to run. Sleeps are a really bad idea in OH 2 rules.
Beyond that I need to see the code indented to even begin to comment.
I’ve moved this to the correct category. The Development category is for discussions about the development of OH itself, not the development of rules.
bizikle
(joseba arrieta)
June 17, 2021, 3:39pm
3
sorry I am just a beginner
1 Like
rossko57
(Rossko57)
June 17, 2021, 4:16pm
4
Maybe your zwave Item states have units of measurement. Always worth logging out what you are comparing, when a comparison doesn’t do what you expect.
Both IF conditions are
if (ZWaveNode011ZW100Multisensor6_SensorTemperature.state > 20.0)
So if the first one is TRUE, it won’t check the second one. If the first one is FALSE, the second one is also FALSE as both check if the temperature is higher than 20.
bizikle
(joseba arrieta)
June 18, 2021, 7:32pm
6
but once if it has checked luminescence I order to check temperature one, after the other
bizikle
(joseba arrieta)
June 18, 2021, 7:50pm
7
somebody know where can I see the logs of rules?
rossko57
(Rossko57)
June 18, 2021, 7:54pm
8
Look at other examples. You write statements into your rule, to produce logs with the message of your choice.
Example
logInfo("test", "My Item state is " + ZWaveNode003ZW100Multisensor6_SensorLuminance.state.toString)
The output appears in your openhab.log
(where you should already have looked to see if your rule has runtime syntax errors).
bizikle
(joseba arrieta)
June 19, 2021, 1:10pm
10
Thanks for your help, I have solved it
when
Item ZWaveNode003ZW100Multisensor6_SensorLuminance changed
then
logInfo("test", "luz exterior " + ZWaveNode003ZW100Multisensor6_SensorLuminance.state.toString)
logInfo("test", "temp interior " + ZWaveNode011ZW100Multisensor6_SensorTemperature.state.toString)
var Number delta = (ZWaveNode011ZW100Multisensor6_SensorTemperature.state as Number).doubleValue
if (ZWaveNode003ZW100Multisensor6_SensorLuminance.state > 350)
{if (delta > 25)
{ZWaveNode008FGR223RollerShutter3_BlindsControl.sendCommand(0)
Thread::sleep(20000)
ZWaveNode009FGR223RollerShutter3_BlindsControl.sendCommand(0)}
else
{ZWaveNode009FGR223RollerShutter3_BlindsControl.sendCommand(100)
Thread::sleep(20000)
ZWaveNode008FGR223RollerShutter3_BlindsControl.sendCommand(100)}
}
else
{if (delta > 25)
{ZWaveNode008FGR223RollerShutter3_BlindsControl.sendCommand(100)
Thread::sleep(20000)
ZWaveNode009FGR223RollerShutter3_BlindsControl.sendCommand(100)}
else
{ZWaveNode009FGR223RollerShutter3_BlindsControl.sendCommand(0)
Thread::sleep(20000)
ZWaveNode008FGR223RollerShutter3_BlindsControl.sendCommand(0)}
}
end
bizikle
(joseba arrieta)
June 17, 2021, 3:36pm
11
sorry i am just a beginner
system
(system)
Closed
July 29, 2021, 7:36am
12
This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.