I have upgraded to OH3 and most things have gone fine, including using the new time library in rules but I have a problem that I can’t find a solution to.
The rule below is used to close my roofblinds when the sun shines through them onto the worktop in the kitchen. The rule is triggered each time the Astro binding updates the sun position and it first checks whether the sun is in the position where it shines through the roof window, then it checks is the sun is out (using the solar panels as a proxy for intensity) and finally it checks if the blinds are open.
It worked fine in OH2 but now, it doesn’t pass the first condition, wherever the sun is.
// Roof blind rules
// Declare variable for auto closed flag
var AutoClosed = 0
// Rules
rule Sunshine
when Item Azimuth received update
then
logWarn("rules.sunshire", "Rule triggered by azimuth update. Azimuth is: "+Azimuth.state.toString)
if ((Azimuth.state > 110) && (Azimuth.state <206)) { // If sun is overhead
logWarn("rules.sunshine", "Azimuth in range. Solar power is: "+Solar_average.state.toString)
if (Solar_average.state > 1600) { // Close the blinds if the sun is bright
logWarn("rules.sunshine", "Solar power in range. Blind position is: "+RoofBlinds.state.toString)
if (RoofBlinds.state == 100) { // If the blind is open
AutoClosed = 1 // Set flag because the blind was closed automatically by this rule
sendCommand(RoofBlinds, DOWN) // and close the blind
}
}
if (Solar_average.state <700 && AutoClosed == 1 && RoofBlinds.state != 100) { // Open the blinds in the sun is dim and they were closed automat$
sendCommand(RoofBlinds, UP)
AutoClosed = 0
}
}
if (Azimuth.state > 206 && AutoClosed == 1) { // Open blinds if sun is no longer overhead and they were closed automatically
sendCommand(RoofBlinds, UP)
AutoClosed = 0
}
end
This is what appears in the log:
2021-02-27 11:12:23.681 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'Solar_average' received command 2268
2021-02-27 11:15:41.295 [WARN ] [hab.core.model.script.rules.sunshire] - Rule triggered by azimuth update. Azimuth is: 162.96620351644566 °
2021-02-27 11:15:41.307 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Azimuth' changed from 160.21833952726723 ° to 162.96620351644566 °
2021-02-27 11:17:23.637 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'Solar_average' received command 2268
2021-02-27 11:22:23.581 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'Solar_average' received command 2268
2021-02-27 11:25:41.304 [WARN ] [hab.core.model.script.rules.sunshire] - Rule triggered by azimuth update. Azimuth is: 165.74079577034144 °
2021-02-27 11:25:41.315 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Azimuth' changed from 162.96620351644566 ° to 165.74079577034144 °
2021-02-27 11:27:23.527 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'Solar_average' received command 2256
2021-02-27 11:27:23.534 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Solar_average' changed from 2268.0 W to 2256.0 W
2021-02-27 11:32:23.485 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'Solar_average' received command 2244
2021-02-27 11:32:23.495 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Solar_average' changed from 2256.0 W to 2244.0 W
2021-02-27 11:35:41.292 [WARN ] [hab.core.model.script.rules.sunshire] - Rule triggered by azimuth update. Azimuth is: 168.53843769558236 °
2021-02-27 11:35:41.301 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Azimuth' changed from 165.74079577034144 ° to 168.53843769558236 °
2021-02-27 11:37:23.431 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'Solar_average' received command 2256
2021-02-27 11:37:23.454 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Solar_average' changed from 2244.0 W to 2256.0 W
2021-02-27 11:42:23.995 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'Solar_average' received command 2244
2021-02-27 11:42:24.027 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Solar_average' changed from 2256.0 W to 2244.0 W
2021-02-27 11:45:41.420 [WARN ] [hab.core.model.script.rules.sunshire] - Rule triggered by azimuth update. Azimuth is: 171.35506087356174 °
2021-02-27 11:45:41.463 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Azimuth' changed from 168.53843769558236 ° to 171.35506087356174 °
RoofBlinds is 100 throughout.
So the rule is triggered but despite the values of the items being within the range of the if statement, the rules don’t work.
I’m guessing something has changed with the evaluation of numeric items that’s making them not work with the if statements but I don’t know what it is. I have the same problem with similar rules including those where the first condition has no logical operator (so I don’t think it’s a problem with the && operator).
Any ideas gratefully recieved/investigated.
Openhabian on RPi3
OH3.0.0