Difficulties with Null Values average since

Hi,

I am having difficulties with averageSince with some suggested null value, that is not there. Openhab thinks tmp_count is null even though I just logged it otherwise…

my rule:

var tmp_count = EG_AZ_PRAESENZ.averageSince(now.minusSeconds(60*3))
logInfo("bewegungsmelder.rules", "EG_AZ Average Since: "+ tmp_count)
if (tmp_count !== null ) {
        tmp_count = Math.min(Math.max(tmp_count*20, 1.0), 10.0)

my output:

2022-02-01 08:47:34.943 [INFO ] [e.model.script.bewegungsmelder.rules] - EG_AZ Average Since: 0.4915571139833297
2022-02-01 08:47:34.944 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'bewegungsmelder-5' failed: An error occurred during the script execution: Could not invoke method: java.lang.Math.max(double,double) on instance: null in bewegungsmelder
``

The issue was that I had to convert the .averageSince() part to a double value (doubleValue())

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.