Intruder alert!

Just a simple but effective automation which notifies me whenever someone tries to login to my HASS and enters a faulty password. Can be usefull when you’re exposed to the internet.

The only component which has to be enabled for this to work is Pushbullet.

configuration.yaml:

notify:
  - name: Pushbullet
    platform: pushbullet
    api_key: !secret pushbullet_api_key

Get your api key here: https://www.pushbullet.com/#settings/account

Automation:

- alias: "Send notification upon failed login attempt"
  trigger:
    - platform: state
      entity_id: persistent_notification.httplogin
  condition:
    - condition: template
      value_template: "{{ trigger.to_state.state != off }}"
  action:
    - service: notify.pushbullet
      data_template:
        title: "Failed Home Assistant login attempt!"
        message: "{{ trigger.to_state.state }}"
        data:
          url: http://www.ip-tracker.org/locator/ip-lookup.php?ip={{ states.persistent_notification.httplogin.state.split ("from ") [1]}}

Result:
Instant notification upon false login:

Takes you right to the IP-Tracker page:

You can extend this notification with all the bells and whistles you like, especially when intercepting the notification with Tasker (Android only). Enjoy.

16 Likes

Nice integration.

Can’t seem to make it work, it creates the notification but doesn’t send to pushbullet.

Thanks for the idea that I stole (if you don’t mind :wink: to adapt to send a text message instead of a Pushbullet notification !! It uses Free Mobile API to send the text message but easily adaptable for other SMS system I guess :wink: You need to get Free Mobile API already setup in HA to get this working !

    - alias: "Send notification upon failed login attempt"
  trigger:
    - platform: state
      entity_id: persistent_notification.httplogin
  condition:
    - condition: template
      value_template: "{{ trigger.to_state.state != off }}"
  action:
    - service: notify.free_mobile
      data_template:
        title: "Failed Home Assistant login attempt!"
        target: '012345678'     <- to replace with your Free Mobile french phone number
        message: "{{ trigger.to_state.state }}from{{ states.persistent_notification.httplogin.state.split}}"

and here is text message received on phone (not sure from what is coming the garbage after message but doesn’t matter !!

2 Likes

Nice idea Bob, I’ll give it a go this weekend :slight_smile:

1 Like

Thanks @Bob_NL

I noticed the persistent_notification entity recently and was thinking of doing the same. Been too busy sorting WiFi bulbs out :smiley:

I edited the action slightly as I use Telegram Bot for most stuff:

- alias: Send notification upon failed login attempt
  trigger:
    - platform: state
      entity_id: persistent_notification.httplogin
  condition:
    - condition: template
      value_template: "{{ trigger.to_state.state != off }}"
  action:
    - service: telegram_bot.send_message
      data_template:
        target: !secret chat_id_telegram_mike
        title: '*Failed Home Assistant login attempt!*'
        message: '{{ trigger.to_state.state }} http://www.ip-tracker.org/locator/ip-lookup.php?ip={{ states.persistent_notification.httplogin.state.split ("from ") [1]}}'  

Haven’t figure out how to pass the URL as a separate line / link, not sure if it’s possible with Telegram but this works OK.

Thanks again! :slight_smile:

1 Like

That is exactly the reason I use Pushbullet for this automation, I also use Telegram for all my other notifications :slight_smile:

1 Like

Does this only work for French numbers?

Did you setup the Pushbullet platform correctly? Can you send a message from the dev-tool for example?

change to this:

  action:
    - service: notify.free_mobile
      data_template:
        title: "Failed Home Assistant login attempt!"
        target: '012345678'     <- to replace with your Free Mobile french phone number
        message: "{{ trigger.to_state.state }}"

Yes, Pushbullet is working for other notifications.

Very nice friend Bob. Thank you

1 Like

@Bob_NL unhappy yes and you have to be a customer of Free Mobile and you can only send sms to your own number (to avoid any spams or abuse !!)

@Bob_NL thanks for the trick, message is now perfect on my phone :slight_smile:

1 Like

Than it has to be a syntax error. Can you post your automation?

My Pushbullet component stopped working with a recent HA update :disappointed:

That issue should have been fixed.

I can confirm that Pushbullet notifications are working fine in 0.51.2 here

Awesome idea, thx bro! :smiley:

1 Like

Hi Bob. Nice idea and I copied it into my configuration. It works, at least the detection works. But because I’ve set up a SSL reverse proxy through my Synology NAS, it detects only the internal IP address of my Synology.

Does anybody has a solution for this problem, or is it simply not possible to resolve the external IP address through a SSL reverse proxy ?

You’re right! I had to update the trigger per the giant warning about homeassistant_start (https://home-assistant.io/docs/automation/trigger/). Thanks for getting that back on my radar, that has been annoying.