Issues with automation for new devices sent to Prowl

Hi. I have just started using HA and am liking it a lot. I have setup a notifier using prowl and am using nmap to detect devices.
I created an automation to fire when new devices are detected, using the event device_tracker_new_device but instead of just stating a new device was detected, I want to send the mac and friendly_name of the device in the message as well.
Can anyone help me with this?

Thank you

My current automation is below.

  - alias: notify.prowl
    data:
      message: 'New Device Detected:'
      title: New Device
    service: notify.prowl
  alias: Notify_When_New_Device_Detected
  condition: []
  id: '1504526752440'
  trigger:
  - event_data: {}
    event_type: device_tracker_new_device
    platform: event

Can you make sure you use code blocks and syntax highlighting when pasting your code?
From what you posted I can’t figure out how it’s formatted
also if this not an extract but your full automation, you may want to check https://home-assistant.io/getting-started/automation/ as you’re missing your automation trigger

Hi lolouk44

Apologies for the formatting error :frowning: I have fixed it now and have also included the missing trigger part.

If you look at the line below, I want to have the mac address and the friendly name of the newly detected device as well

“message: 'New Device Detected:”

No need to apologize, just need to learn :slight_smile:
your automation isn’t formatted correctly. A couple of things to bear in mind:

  • Yaml is very strict with indentation,
  • automations need to be structured into:
    • Trigger: what you need to monitor
    • Conditions (optional)
    • action: what you want done.

example:

automation:
  - alias: Check sensor value and show notification
    trigger:
      platform: numeric_state
      entity_id: sensor.random_sensor
      above: 10
    action:
      service: persistent_notification.create
      data:
        message: "Sensor value greater than 10"

now for your actual request, I’m not sure how that can be achieved. an automation i normally triggered by checking the state of an entity (platform: state)
Unless you know the name of the entity, you can’t trigger an automation, and as you’re looking for new devices, you won’t know the name of the entity, bit of a catch 22…

You could try and run an automation every minute and use a condition to check if you have a new device, but I don’t (yet) know of nmap works and what the component returns…
I’m also not aware of being able to do a comparison against a list of known entities…
I’m thinking about a for loop but that’s a bit beyond my capabilities at this stage. Maybe someone else can help?

draft thoughts of how it might look like:

automation_notify_when_new_device_detected:
  - alias: Notify When New Device Detected
    trigger:
      platform: time
      minutes: '/1'
      seconds: 00
    condition:
      - condition: template
        value_template: 'using a for loop of some kind to go through all nmap devices and maybe check when they were created and have the condition to be true if created time was less than 5 sec ago? I don't think we can retrieve the created time though'
    action:
      service: notify.PROWL_NOTIFIER_NAME_SET_IN_CONFIG
      data_template:
        message: | 
          New device detected:
          MAC Address: {{states.sensor.lolo_to_home.state}}
          Friendly Name: {{states.sensor.lolo_to_home.state}}