Hi all,
I am running openHabian 2.3 on a RPI3. There are some rules running on it but after more or less a day the rules stop executing. All other functions are unchanged although the sitemap doesn’t update ‘live’ anymore, just when one refreshes the page itself states show their current status.
I did some debugging and found that my awning/rollershutter rule is the troublemaker of them all.
// zon berekening en uitvoering
rule "Auto Zon"
when
Item zonBerekening received command
then
val logName = "zon"
val int Lux_Gemiddelde = 20
val float Lux_drempel_achter_middel_start = 20000.0
val float Lux_drempel_achter_hoog_start = 40000.0
val float Lux_drempel_voor_middel_start = 20000.0
val float Lux_drempel_voor_hoog_start = 40000.0
var boolean schaduw_ochtend_hoog_oud = false
var boolean schaduw_ochtend_middel_oud = false
var boolean schaduw_middag_hoog_oud = false
var boolean schaduw_middag_middel_oud = false
logInfo(logName, "Rule -Auto zon- triggered")
drempel_achter_middel.postUpdate(Lux_drempel_achter_middel_start)
drempel_achter_hoog.postUpdate(Lux_drempel_achter_hoog_start)
drempel_voor_middel.postUpdate(Lux_drempel_voor_middel_start)
drempel_voor_hoog.postUpdate(Lux_drempel_voor_hoog_start)
avgLuxAchter.postUpdate(luxAchter.averageSince(now.minusMinutes(Lux_Gemiddelde), "mysql"))
// avgLuxVoor.postUpdate(luxVoor.averageSince(now.minusMinutes(Lux_Gemiddelde), "mysql"))
var stand_ochtend = ""
// var stand_middag = ""
var Number A = (sunAzi.state as DecimalType)
var Number E = (sunEle.state as DecimalType)
var boolean schaduw_ochtend_middel = (A < 150) && (avgLuxAchter.state as DecimalType > drempel_achter_middel.state as DecimalType)
var boolean schaduw_ochtend_hoog = (A < 150) && (avgLuxAchter.state as DecimalType > drempel_achter_hoog.state as DecimalType)
// var boolean schaduw_middag_middel = (A > 160) && ((avgLuxVoor.state > drempel_voor_middel.state as DecimalType)
// var boolean schaduw_middag_hoog = (A > 160) && (avgLuxVoor.state > drempel_voor_hoog.state as DecimalType)
// Rolluiken achter
if(schaduw_ochtend_hoog) {
stand_ochtend = "DOWN"
}
else if(schaduw_ochtend_middel) {
stand_ochtend = "85"
}
else {
stand_ochtend = "UP"
}
/*
// Rolluiken Voor
if(schaduw_middag_hoog) {
stand_middag = "DOWN"
}
else if(schaduw_middag_middel) {
stand_middag = "85"
}
else {
stand_middag = "UP"
}
*/
// Zet zonnescherm
if((schaduw_ochtend_hoog || schaduw_ochtend_middel) && autoZbw.state < 4) {
if(autoZbw.state < 3) {
if(E < 35 || A < 97) {
zonneschermBenedenWoonkamer.sendCommand(DOWN)
}
else if(A < 118) {
zonneschermBenedenWoonkamer.sendCommand(66)
}
else {
zonneschermBenedenWoonkamer.sendCommand(33)
}
}
else {
zonneschermBenedenWoonkamer.sendCommand(DOWN)
}
}
else if(!schaduw_ochtend_hoog && !schaduw_ochtend_middel && (schaduw_ochtend_hoog_oud || schaduw_ochtend_middel_oud) && autoZbw.state == 0) {
zonneschermBenedenWoonkamer.sendCommand(UP)
}
// Zet rolluiken achter
val autoAchter = gZonAchterAuto.members.filter[ a | a.state < 4 && a.state != 1 ]
autoAchter.forEach[ a |
val rsNachtA = gAchterNacht.members.findFirst[ na | na.name == a.name + "_nacht" ]
if(rsNachtA.state == OnOffType::OFF) {
(a.name + "_shutter").sendCommand(stand_ochtend)
}
]
/* // Zet rolluiken voor
val autoVoor = gZonVoorAuto.members.filter[ v | v.state < 4 && v.state != 1 ]
logInfo(logName, "There are " + autoVoor.size + " shutters voor in auto-mode")
autoVoor.forEach[ v |
logInfo(logName, "It is " + v.name + " turn to check for nightmode")
val rsNachtV = gVoorNacht.members.findFirst[ nv | nv.name == v.name + "_nacht" ]
if(rsNachtV.state == OnOffType::OFF) {
(v.name + "_shutter").sendCommand(stand_middag)
logInfo(logName, "Item " + v.name + "_shutter received command")
}
]
*/
schaduw_ochtend_hoog_oud = schaduw_ochtend_hoog
schaduw_ochtend_middel_oud = schaduw_ochtend_middel
// schaduw_middag_hoog_oud = schaduw_middag_hoog
// schaduw_middag_middel_oud = schaduw_middag_middel
end
Now, you might wonder why so much is commented out. This is just because my luxsensor for the front of the house (Dutch word: voor) is not in yet so there is no item to connect to.
After slowly releasing parts of my rule I found that this line:
avgLuxAchter.postUpdate(luxAchter.averageSince(now.minusMinutes(Lux_Gemiddelde), "mysql"))
makes the system stop after a while. I saw in another topic that the mysql persistence made someones rule stop so I now changed to jdbc instead. Since this morning it is running with this new persistence so the results aren’t in yet but I was wondering if my rules is fundamentally wrong in the first place?
None of my rule make use of thread::sleep. No error in the log. CPU usage as expected (low).
Best regards