Get Notified of New Devices on Your Network

I used to have an automation that would notify me if a new (previously unseen) device joined my home network. When the device_tracker_new_device event was removed at some point, this automation stopped working.

I have a new automation working that I thought I would share. In my searches to replace this automation I found a number of people in the same boat.

The new automation watches the entity_registry for changes through the entity_registry_updated event and has a condition to only notify me of the domain of the trigger is device_tracker.

I use the Unifi Controller integration to provide my device tracker information and haven’t tested with any of the other device_tracker components.

  - alias: "Send notification of new network device"
    initial_state: true
    trigger:
      - platform: event
        event_type: entity_registry_updated
    condition:
      - condition: template
        value_template: "{{trigger.event.data.entity_id.split('.')[0] == 'device_tracker' }}"
    action:
      - service: notify.mobile_app_adams_iphone
        data_template:
          title: "Home Assistant Detected a New Network Device"
          message: "{{ trigger.event.data.entity_id }} was added to the device_tracker registry"

Note that this automation will trigger when you add or delete a device from the unifi controller. I rarely delete anything from my controller so the false positives aren’t an issue for me.

Many thanks to the folks over on the discord server for helping me with the templates.

11 Likes

This is beautiful, thanks. That would have taken me a week to piece together.

1 Like

Adding event_data: create to the trigger should make it report only added devices (as in this answer)

This is so useful, thank you!

The bit from @giancarlo.s should be:

event_data:
  action: create
2 Likes