Odd issue with a Heater rule and timers

Do the sent command appear in the log?

Nothings in the log. The only events the sensor is showing are those that relate to motion

The rule as it stands is:


    
rule "FibaroEye1 Temperature Controlled Gas Heater turns on when Temp is below 1                                                                                                               7°C. Turns off when temp is above 20°C"
when
    Item FibaroEye1Temp received update
then
    logInfo("FibaroEye1Temp","Temperature Update = {}",FibaroEye1Temp.state)
    var bHeat = 1
    if (now.getMonthOfYear < 6 || now.getMonthOfYear > 8 ) {
        logInfo("FibaroEye1Temp","stop heating, Month = {}",now.getMonthOfYear)
        bHeat = 0
    }
    if (now.getHourOfDay < 6 || now.getHourOfDay > 8 ) {
        logInfo("FibaroEye1Temp","stop heating, Hour = {}",now.getHourOfDay)
        bHeat = 0
    }
    if (now.getHourOfDay < 7 && now.getDayOfWeek > 5 ) {
        logInfo("FibaroEye1Temp","stop heating, Hour = {} and DoW = {}",now.getH                                                                                                               ourOfDay,now.getDayOfWeek)
        bHeat = 0
    }
    val currentTemp = FibaroEye1Temp.state as Number
    if (currentTemp > 20) {
        logInfo("FibaroEye1Temp", "Living Room Temp above 20°C, Turning off Heat                                                                                                               er")
        bHeat = 0
    }
    if(bHeat == 1) {
        if (currentTemp < 17)
            logInfo("FibaroEye1Temp","Living Room Temp below 17°C, Turning on He                                                                                                               ater")
        else
            bHeat = -1             // do nothing
    }
    logInfo("FibaroEye1Temp","Desired state = {}",bHeat)
    if (bHeat==1 && Heater.state.toString != "ON") Heater.sendCommand("HeaterOn"                                                                                                               )
    if (bHeat==0 && Heater.state.toString != "OFF") Heater.sendCommand("HeaterOf                                                                                                               f")
end

Does it not even show the first logInfo?

No sir :confused:

Then your rule file has a problem
Edit it and save. What does the log show?


22:39:46.714 [INFO ] [del.core.internal.ModelRepositoryImpl] - Refreshing model 'comfort.rules'

Well, your rule is not as I posted it. You have lots of spaces in it, that’s not ok! Which editor do you use?

Edit: Please consider to shorten the rule name. Even if you can use a whole paragraph as a title, four words should suffice. “switch heater by temperature”

1 Like

nano
I dont see any spaces?

OK

I shortened the name

rule "FibaroEye1 Temperature Controlled Gas Heater"
when
    Item FibaroEye1Temp received update
then
    logInfo("FibaroEye1Temp","Temperature Update = {}",FibaroEye1Temp.state)
    var bHeat = 1
    if (now.getMonthOfYear < 6 || now.getMonthOfYear > 8 ) {
        logInfo("FibaroEye1Temp","stop heating, Month = {}",now.getMonthOfYear)
        bHeat = 0
    }
    if (now.getHourOfDay < 6 || now.getHourOfDay > 8 ) {
        logInfo("FibaroEye1Temp","stop heating, Hour = {}",now.getHourOfDay)
        bHeat = 0
    }
    if (now.getHourOfDay < 7 && now.getDayOfWeek > 5 ) {
        logInfo("FibaroEye1Temp","stop heating, Hour = {} and DoW = {}",now.getHourOfDay,now.getDayOfWeek)
        bHeat = 0
    }
    val currentTemp = FibaroEye1Temp.state as Number
    if (currentTemp > 20) {
        logInfo("FibaroEye1Temp", "Living Room Temp above 20°C, Turning off Heater")
        bHeat = 0
    }
    if(bHeat == 1) {
        if (currentTemp < 17)
            logInfo("FibaroEye1Temp","Living Room Temp below 17°C, Turning on Heater")
        else
            bHeat = -1             // do nothing
    }
    logInfo("FibaroEye1Temp","Desired state = {}",bHeat)
    if (bHeat==1 && Heater.state.toString != "ON") Heater.sendCommand("HeaterOn")
    if (bHeat==0 && Heater.state.toString != "OFF") Heater.sendCommand("HeaterOff")
end



Consider there may be a problem in a preceding rule that messes up following e.g. mismatched brackets.

VSCode editor is good for catching that kind of thing.

Proceeding rule? Where?

In your xxx.rules file, preceeding = some rule coming before the one in question, that might have mismatched () or “” and so on, that prevents following rules being recognised properly.

I’m assuming we are still looking for the problem that the first logInfo in the the rule is not found in your log i.e. the rule never triggers.

So, this rule actually works fine to turn OFF the heater, but it never turns on :stuck_out_tongue:

So ive watched the logs, the rule has to be incorrect.


2018-08-23 07:24:39.447 [INFO ] [marthome.model.script.FibaroEye1Temp] - Temperature Update = 20.1
2018-08-23 07:24:39.457 [INFO ] [marthome.model.script.FibaroEye1Temp] - Desired state = -1
2018-08-23 07:26:04.696 [INFO ] [rthome.model.script.FibaroEye1Motion] - Eye1 Timer rescheduled for 2 minutes
2018-08-23 07:28:04.703 [INFO ] [rthome.model.script.FibaroEye1Motion] - Eye1 No Motion Detected! Turning OFF Living Room Lights
2018-08-23 08:09:42.204 [INFO ] [marthome.model.script.FibaroEye1Temp] - Temperature Update = 21.2
2018-08-23 08:09:42.217 [INFO ] [marthome.model.script.FibaroEye1Temp] - Desired state = -1
2018-08-23 08:39:45.789 [INFO ] [marthome.model.script.FibaroEye1Temp] - Temperature Update = 19.9
2018-08-23 08:39:45.797 [INFO ] [marthome.model.script.FibaroEye1Temp] - Desired state = -1
2018-08-23 08:54:46.514 [INFO ] [marthome.model.script.FibaroEye1Temp] - Temperature Update = 18.5
2018-08-23 08:54:46.520 [INFO ] [marthome.model.script.FibaroEye1Temp] - Desired state = -1
2018-08-23 09:24:54.023 [INFO ] [marthome.model.script.FibaroEye1Temp] - Temperature Update = 17.2
2018-08-23 09:24:54.028 [INFO ] [marthome.model.script.FibaroEye1Temp] - Stop Heating, Hour = 9
2018-08-23 09:24:54.033 [INFO ] [marthome.model.script.FibaroEye1Temp] - Desired state = 0

This says to me, at 7.24.39, the Temp update was 20.1

The revised temps in the rule, it should have turned on because it wasnt above 22


    }
    val currentTemp = FibaroEye1Temp.state as Number
    if (currentTemp > 22) {
        logInfo("FibaroEye1Temp", "Living Room Temp above 22°C, Turning off Heater")
        bHeat = 0
    }
    if(bHeat == 1) {
        if (currentTemp < 17)
            logInfo("FibaroEye1Temp","Living Room Temp below 17°C, Turning on Heater")
        else
            bHeat = -1             // do nothing
    }

Instead, it set the desired state to -1 which if I read correctly means it didnt match any of the IF statements until the final one, where it does nothing., right?

Um, the rule turns ON the heater when temp is less than 17. It turns OFF when above 22.
When temp is between 17 - 22 it does not change; if it’s ON it stays ON, if it’s OFF it stays OFF

turned off i mean.

anyway, some thing is wrong because its also turning off in the evening , when the rule is only meant to take effect in the morning :slight_smile:

I think ill go back to my old rule, it wasnt temp based but it work! Thanks anyway Udo!

The rule as written is will allow heater-ON only during summer weekend mornings. It actually turns on only when temp below 17.

It turns OFF the heater anytime the temp is above 22 (which seems like a good idea)

Thanks rossko57 :slight_smile:
Thats an issue then!

lol

Its meant to turn on during the week DAY, summer (your side, but winter my side)

Below 17 is fine, but today it didnt turn on and its 15 degrees inside, or was :wink:

Turning off above 22 any time is cool.

Hum, i didn’t spend much time analyzing the season/day stuff 
 just as well, as I didn’t even think hemispheres :frowning:
But you can do that, you know what you want and the logic isn’t hard to follow. If bHeat gets set to zero, this rule will never turn the heater on.