Include content of an item in notification

Hello,
unfortunately I can’t find anything in the vastness of the WWW and also here in the forum not really a simple explanation, so I have to ask.

Is it possible to display the value of an item in a notification? For example, I track the price of gasoline at my gas station and of course I want to know what the current price is in the notification.

I think about the DSL rule interface this will not be possible but about a code rule or a script maybe? Unfortunately, I can’t find a good simple explanation anywhere if and how this works.

As an example:
Notification content: Diesel 1,79€ → after next update → Diesel 1,84€

Thanks already

Yes, it is possible.

I am using DSL rules.

sendNotification("me@example.com", "Today it will be " + Weather_home_Temperature_Max_today.state + "!")

To add a value to a string you just add + myItem.state to the string.

You can send ephemeral notifications as @christoph_wempe demonstrated. You’ll get a new notification every time the price changes.

But if you are after a constant always there notification then no, there is no way to do that.

@christoph_wempe , thx i will try this.

I do similar but only show the price in the UI and do not get a notification, as the price is changing frequently.

In addition you can use persistence and calculate e.g. last x days average (I do last 7 days) and compare current price with the average. By this you know if it’s currently cheap or expensive and you can better see trends

A big thank you to you @christoph_wempe , you made my day. Works perfectly.

Hello,
I have a new question. How can I send an icon in the message? The message structure is clear to me but if I put a comma after sendNotification(“me@example.com”, "Today it will be " + Weather_home_Temperature_Max_today.state + “!”, “icon”), and select the “icon”, sending the whole message does not work anymore.
What am I doing wrong?
I have also tried with SendExtendedNotification but no success.

Translated with DeepL Translate: The world's most accurate translator (free version)

Did not know you could define an icon.
But you are right according to the documentation.

But it looks like you need to define a severity, too.

I guess these are possible values for this: