I recently (4 days ago ) manually migrated medium sized smarthome installation (1200+items, 200 things) from openhab 2.5 to 3.3.
One of the thing (of many, but I will try to limit them to one per post ) is strange behaviour, which did not happen on 2.5, and even on 3.3 happens around 1% situations, leading me to an unproven yet conclusion of some kind of race condition in rule code.
Description:
Due to the oscillation of hardware temperature sensor measurement, which happens randomly around once per hour, a sensor shows 60k+ celsius temperature for very short timespan. To avoid it, I use proxy pattern.
Error:
YET, 1 in 100 of such erroneous fluctuation, the very same rule (unchanged) misfires, and the target item (guarded by the rule) is actually being updated to 60k :-o
My hypothesis:
race condition: source item changes between rule being fired, and internal if.
Questions to community and reason for this post:
- Is my hypothesis correct, (although AFAIR values shall not change within one rule invocation, hence it shall NOT be possible).
- If not correct, why it happens?
- Workarounds suggested → although quite obvious: change internal if command. Any better (performance wise) solutions?
Rule definition:
rule "rulUPDRknxKITCheaterTemperatureProxy"
when Item knxKITCheaterTemperatureSOURCE received update
then
if (( knxKITCheaterTemperatureSOURCE.state as DecimalType) < 1000.0 ) {
knxKITCheaterTemperature.postUpdate( knxKITCheaterTemperatureSOURCE.state)
}
end
Items definition:
Number knxKITCheaterTemperature "Kitchen temp. [%.1f )C]" <temperature> (geqKITCheater,groPersistHeatData,varHOMEvalue_TemperatureAVG,varHOMEvalue_TemperatureMIN,groAlarmTemperature) ["CurrentTemperature"]
Number knxKITCheaterTemperatureSOURCE "Kitchen temp. [%.1f )C]" <temperature> { channel="knx:device:bridge:generic:knxKITCheaterTemperature" }
Logs from race condition (some comments to the logs below):
2022-10-14 09:10:24.881 Item 'knxKITCheaterTemperatureSOURCE' changed from 21.16 to 670760.96
2022-10-14 09:10:24.888 Item 'varHOMEvalue_TemperatureAVG' changed from 21.476666666666667 to 111811.443333333333334 through knxKITCheaterTemperature
2022-10-14 09:10:24.891 Item 'knxKITCheaterTemperature' changed from 21.16 to 670760.96
2022-10-14 09:10:34.810 Item 'knxKITCheaterTemperatureSOURCE' changed from 670760.96 to 21.22
2022-10-14 09:10:34.821 Item 'varHOMEvalue_TemperatureAVG' changed from 111811.443333333333334 to 21.486666666666667 through knxKITCheaterTemperature
2022-10-14 09:10:34.823 Item 'knxKITCheaterTemperature' changed from 670760.96 to 21.22
a. nothing relevant happens before, and after above excerpt
b. some of the log lines, while varying 0.00x seconds, are actually swapped (for example second line .888 SHALL be AFTER third one .891, but it is not) - this is one of the openhab logging bugs, not related to the situation