Boolean & Persistence / Cannot reference the field 'Power' before it is defined

Hi,

im trying to refactoring my rules a little bit

so i want to do the following:

var boolean isPowerLastHour = (Power.maximumSince(now.minusHours(1), “influxdb”).state >= (minPower))

and in he rule:

if (isPowerLastHour  {
                    // do some stuff
}

Power is an ITEM.

Now i receive this message:

Cannot reference the field 'Power' before it is defined

best regards

Are you trying to define that outside of any rule?
It wouldn’t work the way you want, even if it worked. It would be evaluated once only at xxx.rules file load time.

Hi,

its inside a rule but i found that i‘ve to put it „deeper“ in the rule. I also have a function in that rule. So i put it in die function. Now the message is gone.

best regards