"send a notification" with message body from item state

OpenHAB 3.4.4 in docker on x86/64 Linux

I’m able to send notifications to my phone (OpenHAB app) from a UI defined rule, but I can’t figure out how include the item state in the body of the message!

The item is a string item defined in an .items file like so:
String Notification_Leif "Notification (Leif)" <none>

I need to know what to put here, for it to send the item state.

There are no examples provided in the UI.

I found some related topics, such as this and this and this but neither example worked – the only notification message I get is exactly what I put in, verbatim.

Is it possible to do this with an UI rule or do I have to write a file based rule?

Appreciate any advice.

I don’t think this is possible yet. The simple UI rules are pretty limited. The notification action only supports static messages. If you need more, such as referencing the state of an Item, you’ll have to use an inline script. In 3.4.4 I don’t remember if Blockly has a Notification block or not. If not you’ll have to use code. With JS Scripting it will look something like

actions.NotificationAction.sendNotification("romeo@montague.org", "Balcony door is " + items.MyDoor.state);

Thanks Rich,

A bunch of forum searching later (finding other posts of yours) I got it to work with a file based JS rule, after installing the JS scripting add-on.

OpenHAB is shockingly comprehensive.

Thanks again!