I’m developing an Angular/NodeJS UI for my OH2 install and am using OH2’s REST add-on for the data. Using the REST url http://XXX.XXX.XXX.XXX:8080/rest/items and sorting by tags I can fetch all motion sensors for example. But, there is no field from the OH2 REST for the time/date last triggered. What is the best way to add the DateTime last triggered field into the REST response?
I am not 100% sure but maybe one possible solution would be to have an event in NodeJS which is triggered by a state change at http://<IP_ADDRESS>:8080/rest/items/<ITEM_NAME>/state. Once this state change occurs then the current time could be logged https://usefulangle.com/post/187/nodejs-get-date-time
How this event would be listening for this state change though without multiple calls to the API I would not be entirely sure on. Possibly it could be called every set number of minutes if the exact time of the trigger is not required to give a rough approximation of time.
Am I missing something here, is there some property of an Item for “last”? What does it represent, last update, last change?
When I use the REST UI and GET an item, like a motion sensor, there is no field “last” or any field that has a date.
Right. So what you are asking is not about REST, its about adding some new property to the fundamental Item used in openHAB core. You can’t get what isn’t currently there.