i have been using Oh1 for quite a while now, and went to OH2. Doing so i had to realize, that most of my rules arent working properly. It looks like something is blocking them for some reason.
For example i have this simple one:
import org.openhab.model.script.actions.*
// Global Variables
rule "Jalousien_Fernsehmodus"
when
Item Fernsehmodus changed
then
if ((Fernsehmodus.state == ON)) {
sendCommand(Jalousie6, 85)
sendCommand(Jalousie7, 85)
sendCommand(Jalousie8, 70)
postUpdate(Fernsehmodus, OFF)
}
end
It sometimes works, sometimes it doesnt. When it doesnt, the log just tells me, that the switch has changed. Thats it. When it works, i get the right statements of the Jalousie Items getting a new state.
I also went to disable all my rules one by one. Thought i had it, because i left some disabled, and everything went fine. Then the next day, nothing working anymore…
Do you have any idea what might block my rules from working?
(Have it running on a Small Intel Quadcore with 4 GB of Rams, most of the time its on 5-10% usage when i look into Top)
I think that in OH2 you don’t need to include any import statements in your rules.
Also, try something like:
rule "Jalousien_Fernsehmodus"
when
Item Fernsehmodus changed from OFF to ON
logInfo("MyRule","Fernsehmodus switched to ON !")
then
Jalousie6.sendCommand(85)
Jalousie7.sendCommand(85)
Jalousie8.sendCommand(70)
Fernsehmodus.postUpdate(OFF)
logInfo("MyRule","Fernsehmodus Commands done !")
end
Ps: logInfo lines are optional and for debugging purposes. You will find the output in openhab.log.
I tried it out, but it didnt really work unfortunately.
The first loginfo in your rule gave me an error, so i excluded it. The rule still didnt work then.
What i dont understand is, that my rule seemed to be allright too, because once every week i can use it normally. But most of the time it just doesnt work.
Log just says:
2017-05-04 00:46:44.704 [ItemCommandEvent ] - Item ‘Fernsehmodus’ received command ON
2017-05-04 00:46:44.706 [ItemStateChangedEvent ] - Fernsehmodus changed from OFF to ON
Yeah, I think that the logInfo doesn’t work in the “when” section… only in the “then” (not sure about this).
Try to send a command to the item “Fernsehmodus” instead of updating its status in OH2.
rule "Jalousien_Fernsehmodus"
when
Item Fernsehmodus changed from OFF to ON
then
Jalousie6.sendCommand(85)
Jalousie7.sendCommand(85)
Jalousie8.sendCommand(70)
Fernsehmodus.sendCommand(OFF)
logInfo("MyRule","Fernsehmodus Commands done !")
end
Does the rule fire up correctly and does it send the commands to the Jalousie items?
no, still not working. Its like something is blocking the ruleengine from doing anything. After several restarts and disabling of rules and changing of items, i sometimes get it to work for a while, and then its back off. But its not like i would find any logic, when it works and when not.
Thats the strange thing, this is just an example rule, but these problems appear with all my rules, and all of them worked fine in oh1…