[SOLVED] Problem with rules if

openhab2
Tags: #<Tag:0x00007fe06616f528>

(Grzegorz Janocha) #1

Hello ALL,
I have been using OpenHAB for several years but I used it only for the presentation of my home,
For some time I have been trying to go with the whole control to control from the OpenHAB level and here I have a problem,
I wrote a few rules that work for me but I also wanted to write rules with numerical conditions and unfortunately they do not work, despite the fact that they work well
Example of a working rule:
rule “CH pump - ON control”
when
Time cron “0 0/5 * 1/1 *? *” Or // every 5 minutes
Item piec changed
then
// logInfo (“CH pump”, “CH pump operation check”)
// logInfo (“CO”, “TempMinCO:” + TempMinCO.state)
// logInfo (“CO”, “TempMinWieca:” + tempMinPieca.state)
// logInfo (“CO”, “Outdoor Temp:” + TempZew.state)
if (Temperature.state <TempTrend.state && furnace.state> = tempMinPieca.state && TempZew.state <= TempMinCO.state) {
pompaCO.sendCommand (ON)
logInfo (“Pump CO”, “Pump CO ON”)
}
else {
pompaCO.sendCommand (OFF)
logInfo (“Pump CO”, “Pump CO OFF”)
}
end
and here the rule that does not work

rule “Switching off the central heating pump at low furnace temperature”
when
Item piec changed
then
logInfo (“PumpCO”, “Furnace temperature:” + furnace)
if (piec.state <TempMinCO.state) {
pompaCO.sendCommand (OFF)
logInfo (“Pump CO”, “Pump CO OFF”)
}
end


(Cyril Jaquier) #2

Log the values (using logInfo) of piec.state and TempMinCO.state right at the beginning of the rule and see if this is the expected values.


(Mark) #3

First, when you post rules, code fences are really helpful for readability.

rule “Switching off the central heating pump at low furnace temperature”
when
    Item piec changed
then
    logInfo (“PumpCO”, “Furnace temperature:” + furnace)
    if (piec.state <TempMinCO.state) {
        pompaCO.sendCommand (OFF)
        logInfo (“Pump CO”, “Pump CO OFF”)
    }
end

How exactly is the rule “not working”? Are you seeing any errors in the log? If so, can you post them?

Is furnace an item or a variable? If an item, it should be furnace.state

How is piec defined? Number?


(Josar) #4

or has to be lowercase, imho.


(Grzegorz Janocha) #5

hi,
piec is Number

> Number 	piec					"Piec [%.2f °C]"				<fire>			(garaz)									{mqtt="<[openhabian:/Kotlownia/Piec/T:state:default]"}//{mqtt="<[openhabian:dom/PiecT:state:default]"}

I know that the rule is run, but it never enters the “if” condition, the OFF command is not issued, and logInfo is not published
The variables I have displayed and are valid


(Jürgen Baginski) #6

Confirm you get the first logInfo (“Furnace temperature”)?
In this case the second logInfo will not show if/because piec.state is never lower then TempminCO.state


(Grzegorz Janocha) #7

He shows me the first infoLog and I know that the variable “piec” is smaller than TempminCO,
When I am at home I will try to display data logs.


(Grzegorz Janocha) #8

Thank you all for help, I have mistaken variable.


(Vincent Regaud) #9

Good, can you post the working code, please, for the community to see.
Thanks


(Grzegorz Janocha) #10

I’m sorry, I did not have time to insert the code`

rule "Wylaczenie pompy CO przy niskiej temp. pieca"
when
	Item piec changed
then
	logInfo("PompaCO", "Temperatura pieca: " + piec.state)
	logInfo("PompaCO", "Temperatura min CO: " + tempMinPieca.state)
	if (piec.state < tempMinPieca.state)	{
		pompaCO.sendCommand(OFF)
		logInfo("PompaCO", "Pompa CO OFF od pieca")
	}
end

`