<solved>Help with rule for heating or humidifier


(stuart harvey) #1

Just a bit of help please with a rule to turn on and off with a set-point please

Item

Number Humidity_SP “Hallway”

Item

Switch dehumidifier “dehumidifier” (LR,gLight)
{ mqtt=">[broker:cmnd/sonoff1-d/POWER:command:*:default],
<[broker:stat/sonoff1-d/POWER:state:default]" }
Number dehumidifier_RSSI “dehumidifier: RSSI [%d %%]” (gRSSI)
{ mqtt="<[broker:tele/sonoff1-d/STATE:state:JSONPATH($.Wifi.RSSI)]" }

Rule

rule “dehumidifier”
when
Item GF_House_humidity changed
then
if Item (GF_House_humidity >= (Humidity_SP+1)){
dehumidifier.sendCommand(OFF)
} else {
if (GF_House_humidity < (Humidity_SP-1))
dehumidifier.sendCommand(OFF)
}
end

Error log [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'humidifier.rules' has errors, therefore ignoring it: [5,7]: extraneous input 'Item' expecting '('

==> /var/log/openhab2/events.log <==

Hope this is better after edit


(Miika Jukka) #2

I’ll just leave it here: How to ask a good question / Help Us Help You


(SiHui) #3

Delete Item and proceed to the next error, there will probably some more.
A good starting point is:
https://www.openhab.org/docs/configuration/rules-dsl.html and
https://www.openhab.org/docs/configuration/editors.html#openhab-vs-code-extension


(CM6.5 H102) #4

It’s almost Christmas.:grinning:
@stuart22 Try this rule and see if it works the way you like. I’m not sure about the dehumidifier sendCommand OFF in both if and else if statements but you can adjust to fit your needs.

rule "dehumidifier"
when
Item GF_House_humidity changed
then
    var Number house_hum = GF_House_humidity.state as Number
    var Number hum_setpoint = Humidity_SP.state as Number
    val Number offset = 1
if(house_hum >= (hum_setpoint + offset)){
    dehumidifier.sendCommand(OFF)
} 
else if(house_hum < (hum_setpoint - offset)){
dehumidifier.sendCommand(OFF)
}
end

(stuart harvey) #5

Thank you so much i have been trying to get that working for a few days i was reading all the rules i could my mistake turning both off one should have been ON changed it and it works great
couldn’t see any examples of this but can use for turning heating on and off the same way
is there a page with some simple rule examples apart from https://www.openhab.org/docs/configuration/rules-dsl.html as this goes a bit to in depth for the beginners


(CM6.5 H102) #6

Here’s a great topic that has several links and examples (more examples in the links).

I would also like to say thanks for marking the topic as solved.:+1:

Have a Great Holiday Season.


(stuart harvey) #7

Merry Christmas to all