New device tracked automation non longer works

used this automation from the beginnings, but as of a few iterations in HA it doesn’t do its job anylonger. Apparently the backend got changed tracking new devices, but can anyone explain how to get this back to work?
Isn’t the event created any longer? Is another event to be tracked?


- alias: 'New Device Tracked'
  id: 'New Device Tracked'
  trigger:
    platform: event
    event_type: device_tracker_new_device
  condition: []
  action:
    service: persistent_notification.create
    data_template:
      title: 'New device tracked'
      message: >
        New Device Tracked: {{trigger.event.data.host_name}}
          ({{trigger.event.data.entity_id}}) 
        mac-address: {{trigger.event.data.mac}}

I think there have been a few posts about this, but I can’t find an answer yet, so please forgive if this a repost…
thanks

As far as I can tell the feature to fire that event is still present in the code. Of course it only applies to “legacy” style device_tracker's, and only when they weren’t already listed in known_devices.yaml.

thanks for chiming in Phil.
well, yes, that’s what I was hoping indeed. It is my nmap device_tracker that should notice new network attached devices.

You mean nmap_tracker? AFAIK that’s still a legacy tracker, so it should.

well, I was daft.

It does still work, tested just now with a new device. Its just that the persistent notification isn’t created in a dedicated card any more, but in the sidebar…

thanks for conforming :wink:

@chemelli fixed this and we’ve come up with:

  - alias: New device registered
    id: New device registered
    mode: queued
    trigger:
      platform: event
      event_type: entity_registry_updated
      event_data:
        action: create
    condition: >
      {{trigger.event.data.entity_id.startswith('device_tracker')}}
    action:
      - variables:
          entity: >
            {{trigger.event.data.entity_id}}
      - service: system_log.write
        data:
          message: >
            New device registrered: {{state_attr(entity,'friendly_name')}}
          level: warning
          logger: homeassistant.components.device_tracker
      - service: persistent_notification.create
        data:
          title: >
            New device registered: {{state_attr(entity,'friendly_name')}}
          message: >
            Entity: {{entity}}
            Host: {{state_attr(entity,'host_name')}}
            Ip: {{state_attr(entity,'ip')}}
            Mac-address: {{state_attr(entity,'mac')}}
            Full data: {{trigger.event.data}}

which writes a entry in the log and a persistent notification.

2 Likes

It didn’t works for me. I didn’t get host and IP.

yep, depending on the device_tracker, that can happen. if the new device does not contain that info, at wont be able to add that to the output.