There were changes in how openhab-js handles the persistence functions recently.
When you go to the OH Docs, pay attention to the version you are looking at. In the upper left you will see “Stable (3.4.1)” and “Latest (4.0.0)”. You are running 3.4.1 so you must be sure to look at the docs for that version where you will see that in 3.4.1, previousState returns just a string.
Ah so I see, I was reading topics of 2021 and earlier about previousState().state ext so I thought this was already available in JS but I was probably looking at DSL based topics. Thanks!
I’ve solved my issue on 3.4.1 by directly using the previousState() of the PersistenceExtensions. I then get a full item returned. I will use this until 4 becomes stable.
var PersistenceExtensions = Java.type('org.openhab.core.persistence.extensions.PersistenceExtensions');
var previousState = PersistenceExtensions.previousState(Duco_Ventilatie_Trigger.rawItem, true);