Need assistance with custom device attributes in Traccar notification template

Hamzaa month ago

Hi there,

I'm currently facing an issue while customizing the notification template for Traccar. My aim is to incorporate a custom device attribute, specifically contact2, alongside the default contact attribute in the notification template. However, despite trying a couple of different approaches, I'm unable to get the contact2 attribute to display correctly.

Here's the modified template snippet I'm using:

Contact: #if($device.contact && $device.contact.trim().length() > 0)$device.contact #else Not found #end (working)

Contact2: #if($device.attributes.containsKey("contact2") && $device.attributes.get("contact2").trim().length() > 0)$device.attributes.get("contact2") #else Not found #end

Contact2: #if($device.contact2 && $device.contact2.trim().length() > 0)$device.contact2 #else Not found #end

As you can see, the contact is working as expected, but the contact2 attribute isn't displaying properly using either of the methods I've tried.

I'd greatly appreciate any assistance or suggestions on how to properly access and display custom device attributes in Traccar notification templates. Thank you in advance for your help!

Best regards,

Anton Tananaeva month ago

Have you tried $device.getString("contact2")?

Hamzaa month ago

Thank you its working