Ask for a solution


I want the fan to turn on at 26 degrees.
(sonoff3 is the fan name)

Find out the state of your Item. Is it 26 or 26 degrees? Degrees what?

Please post text not screenshots where possible, using code fences.

1 Like

Is it a 26 degree angle? 26 degrees Kelvin? 26 degrees Fahrenheit?
You need to show some effort.

See especially #1, #4, #6, #8, #10, #12, #13. We cannot help without proper, easy to read information.

How to ask a good question / Help Us Help You - Tutorials & Examples - openHAB Community

1 Like

26 degrees Celsius
sorry I’m not good at English

It’s not about the language, it is about the state of the Item.

If that is really your Item state, then it must be a String type Item and you would not be able to compare without extracting the number.

I don’t think that is the actual Item state, though?

1 Like

26 degrees Celsius.
#1 I would like to specify that when the thermometer reaches 26 degrees Celsius, it will automatically turn on the fan.
(sorry I’m not good at English.)


Can you write a pattern as an example for me?

#12 says to use code fences You are not going to get many people squinting at a screenshot.

First welcome to openHAB

It seams you are having an issue with the format of the data that you are trying to compere.

You probably need to define quantity type like stated in Manual :slight_smile:

Since its your first post and you state your English is not the best and I am in a good mood I will help

image
Pain in ass to copy past click on the image then copy paste your code inbetween and you will get

rule "rule name"
when
    Item HomeTemp_Temp changed 
then
    if (receivedCommand.state > 26|°C ) HOME_SONOFF3.sendCommand(ON)
end

Much easer to look at on your phone on the train and can help easer.

Use Implicit Variables inside the Execution Block

Use logging to try and tell you what is happening like

rule "rule name"
when
    Item HomeTemp_Temp changed 
then
    logInfo("House temp Changed to ", receivedCommand.state)
    if (receivedCommand.state > 26|°C ) {
        HOME_SONOFF3.sendCommand(ON)
        logInfo("Fan", "Turned on")
    }
end
2 Likes


my items

This isn’t going to work, there is no command when this rule is triggered.

The Item appears to be just a Number type, not a Number:Temperature, so there should be no units involved here.

rule "my rule name"
when
    Item HomeTemp_Temp changed 
then
    logInfo("test", "House temp Changed to " + HomeTemp_Temp.state)
    if (HomeTemp_Temp.state > 26) {
        HOME_SONOFF3.sendCommand(ON)
        logInfo("Fan", "Turned on")
    } else {
        logInfo("test", "House temp not more than 26")
    }
end

and look in your openhab.log

Rules can be a bit a bit funny about treating states as numbers, you may need to spell it out
if (HomeTemp_Temp.state as Number > 26) {

1 Like

I’m not good at code at all.
Could you write code a command to set a timer to turn on the lights at 5pm?

Thank you very much, the code you wrote works. :tada: :tada: :tada: