Trying to detect specific out of hours events

Kevin Hartina month ago

I have a situation where I need to detect a ignitionOn event between 6pm and 6am and subsequently send an email.

I can do this fairly easily with a php script that runs via a cron job, but was wondering if it can be done inside traccar server using Computed Attributes and Notifications.

Anton Tananaeva month ago

You can create an alarm if you see ignition value between those hours using computed attributes.

Kevin Hartina month ago

Is there any code samples

Anton Tananaeva month ago

There are some examples in the documentation, but obviously not exactly this thing.

Andresa month ago

Hi @kevinhartin, did you manage to create the calculated attribute with hours?

Adriano Mirandaa month ago

Hello guys,

Just wanted to share a possible solution. I’m using a Teltonika device, which sends event == 239 when the ignition is turned on. Here’s the computed attribute expression I tested:

event && event == 239 && (fixTime.getHours() >= 18 || fixTime.getHours() < 6) ? 'powerOn' : null

You can then create your notification based on the "powerOn" alarm.

Let me know if this helps! :)