My roller rules

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

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.

sorry I am just a beginner

1 Like

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.

but once if it has checked luminescence I order to check temperature one, after the other

somebody know where can I see the logs of rules?

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).

Thank you

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

sorry i am just a beginner

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.