[SOLVED] Trying to set up If Then with Outdoor Temperature

Unfortunately the latter. See How to use code fences. It looks like you are trying to use

'``

You need to use

```

Do not name variables the same as your Item name.

Why not trigger when WC_PWS_Temperature changes?

You never set currentTemperature to anything. Where is it supposed to get it’s value? Presumably what you want is the state of WC_PWS_Temperature. But you’ve overridden that name in the Rule by redefining it as a variable.

Finally, WC_PWS_Temperature is a Number:Temperature meaning it has a Unit of Measurement so using it in a Rule is a little different. See Textual Rules | openHAB and scroll down to the QuantityTypes section.

rule "Control lamp by temp"
when
    Item WC_PWS_Temperature changed
then
    if(WC_PWS_Temperature.state > 33|°F) {
        OfficeDeskLight.sendCommand(OFF)
    }
    else if (WC_PWS_Temperature.state < 30|°F) {
        OfficeDeskLight.sendCommand(ON)
    }
end

Assuming my guess is correct and OP is using °F, this Rule will turn on a light when the temperature is below freezing which could be a handy indicator if you need to do something special in that situation. Though I really expect this is the equivalent of “hello world”; something simple to figure out how to write Rules.

1 Like