I would like to control my rollershutters depending on the luminance + a switch for disable the automatic control + a switch for wind protection.
My rule looks currently as shown below. Unfortunately it doesnt work.
If I use the rule with only 2 if conditions in the script block, then it works.
Is there a limitation on openhab, or do I have to define the rule in a different way?
Any help is very much apreciated.
rule “sensorgesteuerte Beschattung Sued EG”
when
Item kueche_luminance received command
then
if ((kueche_luminance.state >4500) && (Wind.state==OFF) && (Automatik_aus.state==OFF)) {
sendCommand(Essen,25)
sendCommand(Kueche2,25)
Add some logIfo statements to check the state of your tests items in the if statement BEFORE the if statement
Change the trigger to changed
Change the sendCommand actions into item methods
rule “sensorgesteuerte Beschattung Sued EG”
when
Item kueche_luminance changed
then
logInfo("kueche_luminance", kueche_luminance.state.toString)
logInfo("Wind", Wind.state.toString)
logInfo("Automatik_aus", Automatik_aus.state.toString)
if ((kueche_luminance.state > 4500) && (Wind.state == OFF) && (Automatik_aus.state == OFF)) {
Essen.sendCommand(25)
Kueche.sendCommand(25)
}
end
You need to accomodate with Xtend rules languages. It has got its rough edges and we all had to learn ourselves…the parser is telling you right where the error in your code is.
It’s good practice to use constants instead of literal numbers such as
val Number luminance_threshold = 4500
global to the rules file and to then use luminance_threshold everywhere you used to use the literal number 4500 before.
Hi, I need again your help. I changed the code as follows, but the rule does not fire …
when
Time cron “0 * 6-17 ? * MON-SUN” or
Item kueche_luminance changed
then
var Lux_Grenzwert_Kueche = Lux_Grenzwert_Sonnenschutz_Kueche.state as DecimalType
var Temp_Grenzwert_Sommer = Aussentemp_Grenzwert_Sonnenschutz_Sued.state as DecimalType
if (((Wind.state) !=1) && ((Beschattungsautomatik.state)==1) && ((kueche_luminance.state) >Lux_Grenzwert_Kueche)) {
Essen.sendCommand (25)
Kueche2.sendCommand (25)
}
if ((Wind.state !=1) && (Beschattungsautomatik.state==1) && ((kueche_luminance.state) >Lux_Grenzwert_Kueche) && (Multi1_temp.state as Number >Temp_Grenzwert_Sommer)) {
Can someone help me with the code?
I added the relevant items and setpoint item in the sitemap for the Grenzwert…
The logs still bring the same result as before…
First of all use the methods… sendCommand(Kueche1, 100) will be Kueche1.sendCommand(100)
The second point:
you are using the same states PLUS another one for the second if-clause. I would try to use the one with the most states as first and then go further with else-if-statements…
That means, first check if wind, automatic, luminance and tempeature are in the used case, if not (= else if) do the next check…
The third point:
if you have the states of Wind and Beschattungsautomatik both set to NULL, something is not initialized correctly… I think you will have a wind sensor and a switch for the Beschattungsautomatik. If not, you should set-up one in your System…