Cannot post update to item; Saving timer persistence for notifications

Which JavaScript? The ECMAScript 5.1 that comes with openHAB or the JS Scripting add-on that provides ECMAScript 11. If the former, I recommend using the latter, especially if you are just getting started. This looks like ECMAScript 5.1 which is not well documented.

Rules DSL does a lot of magic in the background. In fact, the Item does not have a postUpdate nor a sendCommand method. In ECMAScript 5.1, you have to use the actions (note the actions require Strings as the two arguments.

events.postUpdate("Telegram_Last_Notification", new DateTimeType().toString());

In ECMAScript 11, a lot of work was done to make the interaction with the openHAB API simpler and behave more like “pure” JavaScript instead of a mix of JS and Java (in the above, events and DateTimeType are both Java, not JavaScript). Posting an update there would be

var lastUpdateItem = items.getItem("Telegram_Last_Notification");
lastUpdateItem.postUpdate(time.toZDT().toString());

See the docs for the add-on for full details. JavaScript Scripting - Automation | openHAB

There might be other and simpler approaches. For example, you could use the follow Profile to update the timestamp on your DateTime Item when the Channel that reports the state of the door changes state.

You could use a local variable that persists across the runs of the rule. In ECMAScript 5.1

    this.lastRun = (this.lastRun === undefined) ? null : this.lastRun;
    ...
    this.lastRun = new DateTimeType();

In ECMAScript 11 there is a cache which exists outside of the rule and can be used to share data between scripts.

cache.put("lastRun", new DateTimeType());
cache.get("lastRun");

You could have a Switch Item with an expire. When you send the Telegram command the Switch to ON. Expire will turn it OFF after the configured time. Then you just need to check to see if that Switch is ON or OFF to determine whether to send the telegram.

You can use Debounce to only forward the OPEN/CLOSED to another proxy Item after it remains OPEN/CLOSED for a certain amount of time.

If you are using the newer JS Scripting add-on, you can install libraries. I’ve an openhab-rules-tools library you can install using npm that includes a rate_limit class. This class lets you set a time between events such that if another event happens too soon, it’s ignore.