Rule MQTT temperature > Tradfrii Switch

Hello.

I want to build a rule so that Tradfrii Switch triggered using MQTT temperature measurement.

Unfortunately I don’t know completely how to set the rule triggered by MQTT

I want to control the temperature in my boiler.
If the water temperature is equal or higher than 59 degrees Celsius - the Tradfrii switch should turn off

and

If the water temperature is equal or lower than 50 degrees Celsius - the Tradfrii switch should turn on

Snippets of my configuration are below:

.things

    Bridge mqtt:broker:HomeMqttBroker [
        host="10.10.102.200",
        port="1883",
        secure=false,
        username="name",
        password="password",
        clientID="openhab"
]
{
    Thing topic myBasementEsp32
    {
        Channels:
            Type number : Temperature [stateTopic="basement/hotwater", refresh=5 ]
    }
}

.items

// MQTT
// READ

Number HotWaterTemperature {channel="mqtt:topic:HomeMqttBroker:myBasementEsp32:Temperature"}

.rules ???
I built up reading posts and documentation

rule "Hot water pump off"
when
    Item HotWaterTemperature changed
    ???
then
    if (ControlOutlet5.state == ON)
    ControlOutlet1.sendCommand(OFF)
end

rule "Hot water pump off"
when
    Item HotWaterTemperature changed
    ???
then
    if (ControlOutlet5.state == ON)
    ControlOutlet1.sendCommand(OFF)
end

Unfortunately, I do not know how to set temperatures that interest me?

Thank you in advance for any help

I’d do the following

You need to use {} for if statements.
You can change it to one rule.
The sleep for 500ms makes sure you read the latest value from the temperature.

rule "Hot water pump rule"
when
    Item HotWaterTemperature changed
then
    Thread::sleep(500)
    if (HotWaterTemperature.state > 50 && ControlOutlet5.state == ON) {
        ControlOutlet1.sendCommand(OFF)
    }
    else if (HotWaterTemperature.state < 30 && ControlOutlet5.state == ON) {
        ControlOutlet1.sendCommand(ON)
    }
end

Now that you showed me this - everything is very simple and obvious !!! However, without your help he would not do it alone.

Thank you very much

Uh, it’s just changed, you know that because it’s the rule trigger condition.
No need to wait here, just take that delay out.

OK - thanks