To make use of persisted states inside scripts and rules, a few useful extensions have been defined on items. Note that these extensions are only available to be applied to Items. They are not generally available for use in Scripts or Rules.
Found this sentence in the docs and I feel like it has to do with this, but I don’t really understand it. At first it says it is only for scripts and rules and at the end it says they are not availabale in scripts and rules.
What does “applied to items” mean? How can I use it in a widget?
All it means is that there is no general feature like lastUpdate(someTable, some PersistenceService)
the persistence extensions only extend Item objects like myItem.lastUpdate()
You cannot.
The features are available on the Item objects inside openHAB i.e. in rules and scripts, where the Java Item object is available to you.
The Java Item ibject is not available in your browser.
As a rule of thumb, if you want to display anything in your UI you will need to get it into an Item state.
In this case, you might create a new DateTime Item and have a rule update that from the other Item lastUpdate that you are interested in.
uid: widget_now_to_then
tags: []
props:
parameters:
- description: Title
label: Title
name: title
required: true
type: TEXT
- context: item
description: The DateTime item to show
label: DateTime item
name: item
required: true
type: TEXT
parameterGroups: []
timestamp: Oct 30, 2022, 12:58:59 AM
component: f7-card
config:
content: =dayjs().to(dayjs(items[props.item].state))
title: =props.title