HaveIBeenPwned Alert Automation

Hey all,

I’ve been working a bit more on my automations recently and I was kinda bugged by my haveibeenpwned automations. Essentially i use a crapload of e-mailadresses (i won’t bore you with the details).

So I have two problems:

  • I have to do automation for each one of them (my templating skills suck)
  • I cant get the breach attribute out due to a space in the attribute name

Config example:
- platform: haveibeenpwned
- [email protected]
- [email protected]

  - platform: trend
        entity_id: sensor.breaches_test1examplecom
        entity_id: sensor.breaches_test2examplecom

    name: E-mail breaches
    view: no
      - sensor.breaches_test1examplecom
      - sensor.breaches_test2examplecom
    name: Email Breaches Increment
    view: no
      - binary_sensor.mailbreach_increase_test1examplecom
      - binary_sensor.mailbreach_increase_test2examplecom

  - alias: Notify - Emailbreach
    id: '12983124012012'
    - platform: state
      entity_id: group.emailbreachesincrement
      to: 'on'
    condition: []
    - service: script.notify_engine
        title: 'Security issue:'
        message: "Email address {{states.sensor.breaches_<<<emailaddress>>>.attributes.friendly_name}} has been found in a compromised database: {{states.sensor.breaches_<<<emailaddress>>>.attributes.breach <<<last number>>>}}."
        who: 'everyone'

I think you are overcomplicating this quite a bit, mine is at the bottom of this package…

link removed

1 Like

I like your idea and the simplicity,
on the other hand, you always would ahve to adjust your script after there is a new breach detected. A lazy programmer is a good programmer :wink:

I guess my other question is answered: space in a attribute name means you have to use the underscore.

I’ll have to change like a billion passwords for each email address anyway, changing the number to 1 for the affected address is not that much extra work tbh :stuck_out_tongue_winking_eye:

Anyone else having trouble with this sensor on 0.67.0?

2018-04-15 15:51:00 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up platform haveibeenpwned Traceback (most recent call last): File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 82, in async_setup SLOW_SETUP_MAX_WAIT, loop=hass.loop) File "/usr/lib/python3.6/asyncio/tasks.py", line 358, in wait_for return fut.result() File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run result = self.fn(*self.args, **self.kwargs) File "/usr/lib/python3.6/site-packages/homeassistant/components/sensor/haveibeenpwned.py", line 53, in setup_platform sensor.update_nothrottle() File "/usr/lib/python3.6/site-packages/homeassistant/components/sensor/haveibeenpwned.py", line 116, in update_nothrottle self.schedule_update_ha_state() File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 294, in schedule_update_ha_state self.hass.add_job(self.async_update_ha_state(force_refresh)) AttributeError: 'NoneType' object has no attribute 'add_job'

Hi mf,

I did nearly the same as you but per e-mailadres (lots of copy paste work).

  - alias: Security - Email breach
    initial_state: on
      - platform: numeric_state
          - !secret sensor_email_cf
          - !secret sensor_email_hass
        above: 0
      - platform: numeric_state
        entity_id: !secret sensor_email_ls
        above: 1
      service: notify.mf
        message: "Warning - HaveIbeenPwned detected {{ trigger.to_state.attributes.friendly_name }}"

The only thing i dont understand is:
{{ trigger.to_state.attributes.friendly_name }}"
It doenst work by just adding it. Can you explain the extra steps to get it working? Or should it just work?

Yeah, should just dump the friendly_name for the sensor that triggered the automation in to the text, no magic.

Not sure why it wouldn’t be working for you.

I presume you’re testing by changing the logic of the trigger, rather than manually triggering it? Obviously the latter won’t have anything to put in the template.

I change the state to 1 to test it. The message works but it doesn’t show te name…

Ill just keep them separate for now. Going to do a clean install next month. Maby my version of HA doesnt work.

Thanks anyways!

1 Like

What format do you have in your secrets file for: “haveibeenpwned_email” (as referenced in the sensor definition)
I assume it is multiple entities? (please change the actual addresses)

link removed