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 !!!

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.

1 Like

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