Device tracker (Fritz! integration): detect new devices

I would like to build a notification automation as soon as a new device is connected to the network.

  • But: how can I detect new devices?
  • How should the trigger look like?

I will manage the rest myself :slightly_smiling_face:

(background: I can already collect the number of device tracker entities using {{ states.device_tracker | list | length }} and use an increment as trigger, BUT I also want to tell in the notification which device (entity/device name) is new… so how exactly do I get to the new device?)

I couldn’t find a solution for this, only one very old topic based on the Unifi integration (Unifi Device Tracker - Notification of New Device).

      - platform: event
        id: "state"
        event_type: entity_registry_updated
        event_data:
          action: create

You can access the properties of the new device through

trigger.event.data.entity_id

That’d probably the solution. But as I’m not used to the event platform:

  1. Wouldn’t this trigger every new entity? How can I restrict (filter) this to the Fritz! integration (maybe integration_entities('fritz')?)?

  2. Will this still be possible with HA 2022.2 (2022.2: Let's start streamlining! - Home Assistant) ? As I understand new entities are not created automatically anymore.

Didn’t happen for me yet.

Edit: oh wait, if have this condition set in the automation as well:

    - "{{trigger.event.data.entity_id.startswith('device_tracker')}}"