# Rule with if and average value

in the rule I have this if:

``````val avg = ModbusPVPower850_ValueasNumber.averageSince(now.minusMinutes(5))

if (avg < 2500) {
Relay_2_status.postUpdate(avg.toString)
}
``````

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

``````
Relay_2_status.postUpdate(avg.toString)

``````

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