[SOLVED] Rule executed only partially

Hi guys,

I’m quite new to OH. I tried searching for similar issue with no luck.

I have successfully setup OH with DS18 temperature sensor, which I can see with proper values. But this rules doesn’t seem to be working properly - it’s acting as the condition is always met even when the temperature is under the defined value.


rule "Temperature relay test"
        Item Temp1 changed
        val t1=Temp1.state as Number
        if (t1 > 22) {
                logInfo("TEST", "Relay ON")

          else {
          logInfo("TEST", "Relay OFF")


2019-12-19 13:40:43.050 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'home.rules'
2019-12-19 13:40:53.365 [INFO ] [.eclipse.smarthome.model.script.TEST] - Relay ON
2019-12-19 13:41:02.368 [INFO ] [.eclipse.smarthome.model.script.TEST] - Relay ON                                                                                                                              2019-12-19 13:41:13.252 [INFO ] [.eclipse.smarthome.model.script.TEST] - Relay ON                                                                                                                              2019-12-19 13:41:24.201 [INFO ] [.eclipse.smarthome.model.script.TEST] - Relay ON                                                                                                                              2019-12-19 13:41:35.094 [INFO ] [.eclipse.smarthome.model.script.TEST] - Relay ON                                                                                                                              2019-12-19 13:41:46.046 [INFO ] [.eclipse.smarthome.model.script.TEST] - Relay ON  

Is there something I overlooked? Running on the latest stable 2.5 oh, java 1.8.0_222 in RPi Zero W

Many thanks!

Your variable t1 looks important here. Is there some reason you don’t logInfo it’s value, so that you can find out what you’re dealing with?

I’ll take a wild guess that this is similar

Thank you! You were right. Once I added the t1 into the log, it hit me. Of course that was the issue… Once I changed the Temp1 to number only it is working. Thanks!

That’s a bodge. You can write your rules to deal with temperatures with units.