Raspberry pi running V2.2 and working in VScode
Im trying to set up a strategy were I require setpoints to have a deadband between them ie not the same number and one needs to always be above the other, and not the inverse.
I was going to write a whole long list of if else statements to see if one setpoints was within range of another but the problem there is that if say im raising the lower setpoint but the upper setpoint is first in the if statement, that will always get caught first. If the outcome of that statement is to drop the lower setpoint, I would get stuck because the rule would drop the setpoint as I raise it to its limit, whereas dropping the upper setpoint would continually force the lower setpoint down.
Hope that makes sense.
Anyway, I was instead going to grab the last updated item in the group then apply the logic to the relevant setpoint. But I cant seem to get the last item.
Heres the items I added the SUM option just to try to see if the rule would pick it up as opposed to only having it set as a group with no other parameters.
Group:Number:SUM gSetpoints
Number Heating_OnTemp_Occupied "Heating_Setpoint Occupied ON [%.1f'C]" (gSetpoints)
Number Heating_OffTemp_Occupied "Heating_Setpoint Occupied OFF [%.1f'C]" (gSetpoints)
Number Heating_OnTemp_Reduced "Heating_Setpoint Reduced ON [%.1f'C]" (gSetpoints)
Number Heating_OffTemp_Reduced "Heating_Setpoint Reduced OFF [%.1f'C]" (gSetpoints)
Number Heating_OnTemp_Unoccupied "Heating_Setpoint Unoccupied ON [%.1f'C]" (gSetpoints)
Number Heating_OffTemp_Unoccupied "Heating_Setpoint Unoccupied OFF [%.1f'C]" (gSetpoints)
Number Heating_OnTemp_Setback "Heating_Setpoint Base ON [%.1f'C]" (gSetpoints)
Number Heating_OffTemp_Setback "Heating_Setpoint Base OFF [%.1f'C]" (gSetpoints)
Heres the rule
rule "Setpoint Offset"
when
Item gSetpoints received update
then
//maintain 0.5degC gap betwen setpoints
//if(Heating_OnTemp_Occupied.state as Number > (Heating_OffTemp_Occupied.state as Number - 0.5)){
// Heating_OffTemp_Occupied.sendCommand((Heating_OnTemp_Occupied.state as Number + 0.5))
//}
Thread::sleep(150)
val lastupdate = gSetpoints.members.sortBy[lastUpdate].last
logInfo("Setpoint changed","Last setpoint changed - "+lastupdate.name)
end
The commented out lines was the start of the if else way of doing it.
in the karaf console, I can see the item being updated, and this is reflected on the sitemap.
But I cant see the group being updated as the rule doesnt appear to fire.
I did see in the console that the rules file was ‘empty or not parsed correctly’ but I dont understand this, I see it every now and then for various rules files which continue to work fine.
I tried adding a also at the start of the rule before anything else but still no sign of it.
Not sure if im missing something.
Thanks