In my current installation of OpenHAB 4.3.3 I a have a grain bin in which I have a low level detector installed. When a low level alarm clears (after I refill the bin) I capture the date in a DateTime item (Bin Filled). However just before this occurs, I would like to move that date that is currently captured in that item into a “Bin Previously Filled” DateTime item, so I can see the interval between fillings. I am having difficulty in creating the rule to move this value. I’ve been trying to treat the value as a string but OpenHAB isn’t at all happy with that:
Script execution of rule with UID 'BinMonitoring-11' failed: Could not cast Bin_Filled (Type=DateTimeItem, State=2025-03-02T00:00:00.000-0600, Label=Bin Last Filled, Category=calendar, Tags=[Point], Groups=[Yard_Equipment]) to void; line...
There is a level probe that will turn “OFF” on a low level and “ON” when the alarm clears (the bin is refilled):
rule "11 Bin Last Filled"
when
Item Bin11_Level changed to ON
then
Bin11_FilledPrevious.postUpdate(Bin11_Filled as MyDateTimeItem)
Bin11_Filled.postUpdate(new DateTimeType())
end
I’ve been through multiple permutations of this; as I mentioned I’d tried to treat this as a string (unsuccessfully, and I’ve overwritten the original) and after studying Java time notations eventually moved to the attempt shown. Again the goal is to get the date from the DateTime item Bin11_Filled moved to the DateTime item Bin11_FilledPrevious, then write the new fill date to Bin11_Filled.
rule "11 Bin Last Filled"
when
Item Bin11_Level changed to ON
then
Bin11_FilledPrevious.postUpdate(Bin11_Filled.state as DateTimeType)
Bin11_Filled.postUpdate(new DateTimeType())
end