That’s probably expected behavior unless this Item is changing at least twice per 20 seconds. If there’s only one result over the time period, averageSince returns null because you can’t calculate an average with only one value.
I suspect that you don’t have at least two values in the database until you expand the time to 45 seconds.
Unrelated note, there are some alternative ways to generate interval.
var interval = time.toZDT().minusSeconds(20);
var interval = time.toZDT(-20000);
var interval = time.toZDT('PT-20s');
var interval = time.toZDT(time.Duration.ofSeconds(-20));
toZDT() will take almost anything you can think of that represents a time or a duration and converts it to a ZonedDateTime. See Working with Date Times in JS Scripting (ECMAScript 11).