Disable or hide notifications?

Is there a way to disable notifications of failed login attempts, or alternately, is there a way to hide ALL notifications from certain users? Background:

The wall-mounted tablet in my kitchen uses Fully Kiosk and a regular (not admin) user. This tablet, for whatever reason, regularly generates login failures. Those failures generate notifications, and those notifications generate the little red dot on the hamburger menu in the upper left corner.

Since no one seems to have a solution for why the login failures happen, the next best thing is to suppress the notifications so the little red dot doesn’t show up. Might seem trivial, but it really bothers my OCD, and I just HAVE to click on it every time I walk by that display and see the notification - and it’s always the same nonsense. It’s turning into the boy who cried wolf, and really annoying the life out of me. Moreover, I’d like to prevent having a big red dot screaming to my guests “click this configuration bar!!”

Any ideas or assistance would be greatly appreciated.

1 Like

Here’s an automation that dismisses notifications based on notification_id.

Hmm, tried it myself and it seems this doesn’t work anymore. :neutral_face:
Sorry

It looks like there is no event fired on this notification. :thinking:
Don’t know if this is a bug or intended.

This should work:

automation:
  - alias: persistent_notification_dismiss_http_login
    trigger:
      - platform: event
        event_type: state_changed
        event_data:
          entity_id: persistent_notification.http_login
          old_state: null
    condition:
      - condition: template
        value_template: >
          {{ 'hostname_or_ip' in trigger.event.data.new_state.attributes.message }}
    action:
      - service: persistent_notification.dismiss
        data:
          notification_id: http_login

In the condition you can filter for only certain clients.

2 Likes

Thank you for that. I finally just had a few minutes free, and implemented this automation. I’ll let you know if it doesn’t get the job done, but following it in theory, it looks good to me!

Thank you again for the assist. :slight_smile:

edit: Haven’t seen any of those notifications since adding this automation. Seeing as they used to show up multiple times a day, I’m going to call this fixed. Thanks again, @VDRainer !!!

Hi, I’ve been having the same issue with irritating notifications and looking for a way to stop them.

I’m quite new to Home Assistant - do I just copy paste your code into /config/automations.yaml:

automation:
  - alias: persistent_notification_dismiss_http_login
    trigger:
      - platform: event
        event_type: state_changed
        event_data:
          entity_id: persistent_notification.http_login
          old_state: null
    condition:
      - condition: template
        value_template: >
          {{ 'hostname_or_ip' in trigger.event.data.new_state.attributes.message }}
    action:
      - service: persistent_notification.dismiss
        data:
          notification_id: http_login

Or do I need to change it in someway? Like do I need to add the individual IPs that are causing the notification issues in the code? Thanks!

No, you can’t just copy/paste it in… The first line of the code is only used at the beginning of the file. The author included it in the example so you’d know what it was.

Next, you need an id. Then, you can copy in the rest of the code - except you’ll need to edit the ‘hostname_or_ip’ part to whatever the offending value is in your environment.

Check your existing automations file for examples, that’s honestly the best way to learn. That’s how I did it.

2 Likes

The above code worked until a recent update. Has anyone else noticed that the code has stopped being able to dismiss these notifications?

Anyone have a fix?

Persistent notifications are no longer stored in the state machine. This means that we no longer create an entity for each persistent notification.

If you used these entities in, for example, automations, scripts, or templates, you won’t be able to use these anymore.
2023.6: Network storage, favorite light colors, new integrations dashboard - Home Assistant

Because of this, the entity persistent_notification.http_login no longer exists.

I listened for all events with * in developer-tools/event, but found nothing. Alternative is to use system_log

automation:
  - alias: persistent_notification_dismiss_http_login
    trigger:
      - platform: event
        event_type: system_log_event
        event_data:
          name: homeassistant.components.http.ban
          level: WARNING
    condition: "{{ trigger.event.data.message is defined }}"
    action:
      - service: persistent_notification.dismiss
        data:
          notification_id: http-login

configuration.yaml

http:
  ip_ban_enabled: True
  login_attempts_threshold: 3
logger:
  default: error #critical
  logs:
    homeassistant.components.http.ban: warning
system_log:
  fire_event: true
  max_entries: 50

Note: that http_login has changed to http-login

NOTIFICATION_ID_BAN: Final = "ip-ban"
NOTIFICATION_ID_LOGIN: Final = "http-login"

ban.py

1 Like

In the 2023.7 release tomorrow, there will be also a new persistent_notification trigger that can handle these notifications.

This will work in 2023.7 and newer:

  - alias: persistent_notification_dismiss_http_login
    trigger:
      - platform: persistent_notification
        update_type:
          - added
    condition:
      - condition: template
        value_template: >
          {{ 'hostname or ip' in trigger.notification.message }}
    action:
      - service: persistent_notification.dismiss
        data:
          notification_id: http-login
4 Likes

Also, I’d like to add:
I’m using kiosk mode (GitHub - NemesisRE/kiosk-mode: 🙈 Hides the Home Assistant header and/or sidebar, available in HACS) and thanks to the very prompt reaction to my feature request (thank you very much, @elchininet), it now supports hiding the notifications at all.

1 Like