HTML5 push notification to desktop with TTL


Is there a way to set the TTL of a message when sent to the browser?
I use these for notifications about things happening (duh …) when working on my desktop. I only want to show them the moment they happen. Currently if my browser is closed, all messages are queued. So when I open browser/start the machine the next day, I get burried by notifications.

Is there a way to prevent this? I have used different values for the ttl …

title: "notif"
message: "with ttl 0"
  ttl: 0

How do you want to prevent it?
Not sending any messages or what do you mean?

Yeah interesting thread , I am facing the same issue…
When I turn on my laptop/chromebook, all past notifications that are being send, without laptop on, are indeed queud, so lots of popups :wink:

Yes I see that as well…

That’s what a TTL is for ?

That is not how I see it.
The docs just say so notifications by default are delivered only when phone is awake.
I can’t see that it says truncating messages.

But if that is what you want then I believe this is the wrong method.

Look at the browser mod it can detect if a device is on or off and use that as condition when you send the message.

Using browsermod is a workaround yes, but my wife and i are logged in on quite some machines (2x work, 2x home), this will get quite cumbersome to maintain.
Also, I prefer to use as less custom components as possible.

TTL is exactly what is need: the time the message is allowed to live. If it cannot be received within the specified TTL, the message should be discarded (as e.g. with PushOver)

Just wanted to share my solution as I was also struggling to find a way to achieve sending HTML5 web notifications, but preventing them queuing up and being bombarded when my laptop was turned on the following day.


alias: Time Sensitive Web Notification
description: Sends a web notification and dismisses after a short period of time
    description: Id of the message which is used to auto dismiss the message (optional)
    example: hall_light_on
    default: time_sensitive_{{ range(1, 99999) | random }}
    description: The title of the notification
    example: State change
    required: true
    description: The message content
    example: The light is on!
    required: true
  - service: notify.web
      title: "{{ title }}"
      message: "{{ message }}"
        tag: "{{ tag }}"
  - delay:
      hours: 0
      minutes: 0
      seconds: 10
      milliseconds: 0
  - service: html5.dismiss
        tag: "{{ tag }}"
icon: mdi:bell-alert-outline
mode: parallel

Usage in Automations:

  - service: script.turn_on
      entity_id: script.time_sensitive_web_notification
        title: Doorbell
        message: There is someone at the door.
        icon: /static/icons/favicon-192x192.png
        tag: doorbell

Now I receive the notification instantly. After 10 seconds it is removed. If my PC is off or browser is closed I don’t receive the notification. And when I turn on the PC and open the browser, I still don’t see the notification. :slightly_smiling_face:

1 Like