The idea is to save to a new Item, the timestamp of the last sent notification. When the rule fires off, load this timestamp and compare to current time. If the difference is greater than 10s, send notification and update the time. If less than 10s, do nothing.
I first created a new Item, ‘Telegram_Last_Notification’ of type DateTime. There’s also a rule that triggers when any of the doors’ state change to run a script. In that script, I’m trying to follow the documentation, which indicates I can do the following, but this doesn’t work:
// Get last time we sent telegram message var lastUpdateItem = itemRegistry.getItem("Telegram_Last_Notification"); <-- works log.info("LAST UPDATE: " + lastUpdateItem.lastUpdate); <-- works // Update item and store "now" as the latest message sent lastUpdateItem.postUpdate(new DateTimeType()); <-- does not work // TypeError: lastUpdateItem.postUpdate is not a function in <eval> at line number 1
Any ideas on why postUpdate doesn’t exist on this Item object?