I do apologize in advance as I know there are several topics about this subject but I can’t seem to find an answer to my (fairly) trivial problem I’m having.
I have the below rule defined but am getting an error on multiplication (*) symbol saying it cannot be resolved.
The Energy_Cost is defined as a Thing:number. I have also tried it as a string but get further errors.
val minute = now.getHour() * 60 + now.getMinute()
rule "Energy Cost"
when
Item Energy_Watts changed
then
var cost = Energy_Watts.state instanceof Number
var Number OFFrate = 0.0074
var Number ONrate = 0.0152
var Number MIDrate = 0.0102
//Off-Peak from 7AM to 7PM
if (minute > 1140 || minute < 420) {
Energy_Cost = cost * OFFrate
}
//On-Peak from 11AM to 5PM
if (minute > 660 || minute < 1020) {
Energy_Cost = cost * ONrate
}
//Other times are MidPeak (7AM to 11AM & 5PM to 7PM)
else {
Energy_Cost = cost * MIDrate
}
end
I have also tried changing the Energy_Watts.state to as Number and other ways but keep getting the error.
This variable (Energy_Watts) is also defined as a number.
I know it has something to do with trying my variable types but can’t seem to figure out where I’m going wrong.
Anyone have any ideas?
Thank you kindly