Notification for Bad Logins

I had an automation that would notify my phone when a bad username or password was entered on the HA login web page but it no longer works (“Last triggered” was in March, 2023). It was using the following trigger:

trigger:
  - platform: state
    entity_id:
      - persistent_notification.httplogin

I found some older references to this using persistent_notification.http_login, but that doesn’t seem to work either. The only references to “persistent_notification” in Developer Tools are for ‘create’, ‘dismiss’ and ‘dismiss_all’, so I’m assuming this is deprecated? Is there another method folks are using now? I do see the failed logins on the Notifications side bar.

Take this one . It works,


alias: Failed Login I Push
description: ""
trigger:
  - platform: persistent_notification
    update_type: added
condition:
  - >
    {% set message = trigger.notification.message %} {{'Too many login attempts'
    in message or
      'invalid authentication' in message or 'login attempt' in message}}
action:
  - service: notify.mobile_app_iphone
    data:
      title: |
        {% set title = trigger.notification.title %} ⚠️Ha Main: {{title}}⚠️
      message: >
        {% set message = trigger.notification.message %} {% set now =
        now().strftime('%d %b: %X') %} {% if 'Too many login attempts' in
        message %}
         Login notification: {{now}}: {{message}}
        {% elif 'invalid authentication' in message or 'login attempt' in
        message %}
          Login notification: {{now}}: {{message}}
          Track offending ip on http://www.ip-tracker.org/locator/ip-lookup.php?ip={{message.split('from ')[1]}}
        {% else %}
          Login notification other: {{now}}: {{message}}
        {% endif %}

Thx @Mariusthvdb

3 Likes

sourced from Heads up: 2023.6 longer has persistent notifications in states: what to do? - #95 by Mariusthvdb

where you can reduce on those new persistent notifications too

1 Like

Right….

Thx for source!!!

Thanks!
I remember seeing the comments about persistent notifications but didn’t relate it to my automation. It’s working again!