Odd issue with a Heater rule and timers

Heater.sendCommand(transform("MAP", "mapfile.map", "HeaterOn")

It worked ok in previous rules with just Heater.sendCommand(“HeaterOff”) though?

Ok, I don’t know the broadlink binding
Does it automatically transform the commands through the map file?

Yes, you just reference the name inside the .map file, HeaterOn, HeaterOff etc…

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