If you break down the error it becomes apparent what the problem is.
TypeError:: Something is not of a type that histroicState understands. That means something you are passing to historicState isn’t of a type that is understood. Since the only thing you are passing to historicState is local_timestamp_yesterday, that is not of an understandable type.
So what types are acceptable? Reading on we see a list of “overloads” which is the list of different ways you can call historicState:
In this case the error is coming from below the JS Scripting helper library level but the clue is still there. It wants a ZonedDateTime. In truth everything in openHAB wants a ZonedDateTime. There is basically no reason to use Date, epoch, or any of the myriad of other ways to represent date times because you will have to convert it to a ZonedDateTime eventually.
And even if a ZonedDateTime were not required, that one line of code is really complicated. Here are some much easier to read and understand options:
var local_timestamp_yesterday = time.toZDT().minusDays(1); // yesterday, same time as now
var local_timestamp_yesterday = time.toZDT('23:59:59').minusDays(1); // yesteday at one second before midnight
var local_timestamp_yesterday = time.toZDT().minusDays(1).withHour(23).withMinute(59).withSecond(59).withNano(0); // yesteday at one second before midnight
Do you have the latest version of the openhab library installed? openhab-js has it’s own release schedule independent of OH’s release cycle. What you find in the docs, and especially in the reference docs is the latest which may include things not yet available in the library that ships with the add-on.