Ok,
First of all, please use the code fences when publishing code
You rules is:
rule "Oppvask"
when
Item OppvaskProgramStatus changed
then
logDebug("Oppvask","Rule running!")
if (OppvaskProgramStatus is "Off") {
KjokkenPanel.postUpdate("Huset")
logDebug("Oppvask","HUSET chosen")
}
else {
KjokkenPanel.postupdate("HusOppvask")
logDebug("Oppvask","Oppvask chosen")
}
end
Which is untidy, use indents:
To see message in the log use logInfo if your logging is not set to debug.
Use ==
, is
is NOT a keywork.
Put a space after commas, it makes the code easier to read.
The state of an item can be obtained with .state
. Putting just the name of the item refers to the item object itself.
Add a logInfo
line to check the value of OppvaskProgramStatus
.
Add a check if the value is NULL and do nothing in that case.
rule "Oppvask"
when
Item OppvaskProgramStatus changed
then
logInfo("Oppvask", "Rule running!")
logInfo("Oppvask", "Status is: " + OppvaskProgramStatus.state.toString)
if (OppvaskProgramStatus.state == NULL) return; //Do nothing if changed to NULL
if (OppvaskProgramStatus.state == "Off") {
KjokkenPanel.postUpdate("Huset")
logInfo("Oppvask", "HUSET chosen")
}
else {
KjokkenPanel.postUpdate("HusOppvask")
logInfo("Oppvask", "Oppvask chosen")
}
end