Rule with if and average value

in the rule I have this if:

val avg = ModbusPVPower850_ValueasNumber.averageSince(now.minusMinutes(5))
if (avg < 2500) {  

Problem is, that this isn’t working
if I will do only this without if:


it’s working, so problem must be in if declaration, but don’t know which

I suppose you could use logInfo() to find out what avg is - might there be a unit as part of it?

ok, let me chek later, now I don’t have a access to the terminal.

ok, I found it :

val PV_average = ModbusPVPower850_ValueasNumber.averageSince(now.minusMinutes(5)) as Number

now it works