Trying to detect specific out of hours events

Kevin Hartin11 days 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 Tananaev11 days ago

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

Kevin Hartin11 days ago

Is there any code samples

Anton Tananaev11 days ago

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

Andres9 days ago

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

Adriano Miranda4 days 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! :)