well changed the rule to this instead and works with no error
//val openTime = new DateTimeType(LastBoxOpen.state.toString)
val openTime = (LastBoxOpen.state as DateTimeType).zonedDateTime.toInstant.toEpochMilli
///val motionTime = new DateTimeType(LastBoxBuzz.state.toString)
val motionTime = (LastBoxBuzz.state as DateTimeType).zonedDateTime.toInstant.toEpochMilli
//if (openTime.isBefore(motionTime)) {tally = (tally + 60)}
if (openTime < motionTime) {tally = (tally + 60)}
//if (openTime.isAfter(motionTime)) {tally = (tally - 5)}
that was my old version before rud and rich helped me in this thread
which I used to develop this rule example