How to setup custom email notification for an alarm

Victor Butler5 years ago

Hello Anton,

I need your advice about the following issue I cannot find the answer for:

I have setup a custom Alarm via computed attributes for Device Plug/Unplug even like so:

Description: Alarm: Device Unplugged
Attribute: Alarm
Expression: (io252 || io252 === 0) ? (io252 === 0 ? "Alarm: Device Plugged" : io252 == 1 ? "Alarm: Device Unplugged" : null) : null
Type: String

Image here:
Custom Alarm

Having created this computed attribute, the alarm is recorded in the position table and can be seen in the events reports.

The question, however, is how do I get this alarm to be also sent as email notification?

Thank you!

Anton Tananaev5 years ago

You would need to register the new alarm type in the web app or back-end.

Victor Butler5 years ago

Hi Anton,

Thank you for the reply! The back-end path is clear -> edit the source code and compile the server files again, which is something I'd rather avoid.

How do I do this via the web app? Tried searching all over the forum as well as the traccar documentation but no answer unfortunately...

Thank you in advance!

Victor Butler5 years ago

Hello Anton,

Any update on this please? If too time consuming to explain, is there any documentation how to register new alarm type via web app?

Alternatively, would it be possible to add this as functionality in any of the next releases, i.e. to have the possibility to add new alarm similar to adding new notifications?

Thank you!

Anton Tananaev5 years ago

Unfortunately there is no documentation for it. You would have to study the source code.

Dejan Gambin5 years ago

Hi Victor, Anton

I am pretty newbie in traccar and have a similar requirement - I have Teltonika GPS tracker with a digital input connected to a float switch. I should send email (sms can be sent by device directly) when this input (reported as di1 attribute) goes to 1. I have managed to do everything but would be nice to have a custom alarm type for this. Victor, did you manage to solve this?

thanks very much

regards, dejan

jangrewe4 years ago

Uhm, would't it be sufficient to just create a Computed "Alarm" Attribute with the Expression event == 252 && io252 == 0 ? "powerCut" : null, and then enable notifications for "Power Cut" alarms?
The secret ingredient is returning the exact alarm key that the "Power Cut" alarm would trigger on, and that's powerCut.

I happen to be setting up a Teltonika device at the moment, and that uses io252, so i guess that's exactly what you're looking for?

PS: event == 252 && io252 == 1 ? "powerRestored" : null

jangrewe4 years ago

Too late to edit the post, but the correct order would have been (with additional fluff to silence some errors sometimes):

event ? (event == 252 && io252 == 1 ? "powerCut" : null) : null
event ? (event == 252 && io252 == 0 ? "powerRestored" : null) : null

corva year ago

Hi all,
Sorry to resurrect an ancient post but I'm having the exact same issue (setting an email alarm on device unplugging with Teltonika).

You originally posted the expression (io252 || io252 === 0) ? (io252 === 0 ? "Alarm: Device Plugged" : io252 == 1 ? "Alarm: Device Unplugged" : null) : null which I believe is invalid since JEXL doesn't have triple equals?

I'm wondering if anyone tried jangrewe's solution?

br04 months ago

Maybe try this
ioX == 0 ? "text" : (ioX == 1 ? "text" : null)