Thanks @abyss,
It was a path in the right direction. As the first calendar app I tested this ics was not showing what you showed on your screenshot, but as soon as this was imported into other calendar apps, it showed that.
Unfortunately after implementing the same day on DTSTART and DTEND but different time, it still triggered a geofence event out of schedule.
This is the new ics (notice the DTEND is 2315):
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//example.com//ical//EN
BEGIN:VEVENT
UID:a337@example.com
SEQUENCE:0
DTSTAMP:20180526T232036Z
DTSTART:20180526T223000Z
DTEND:20180526T231500Z
RRULE:FREQ=DAILY;BYDAY=SA
SUMMARY:Lugar 3
DESCRIPTION:Lugar 3
END:VEVENT
END:VCALENDAR
Relevant events row (notice the serverTime is 2323 which is outside the calendar schedule):
Name |Value |
----------|-------------------|
id |5712 |
type |geofenceEnter |
servertime|2018-05-26 23:23:33|
deviceid |8 |
positionid|16271 |
geofenceid|9 |
attributes|{} |
Relevant positions row:
Name |Value
----------|---------------------------------------
id |16271
protocol |watch
deviceid |8
servertime|2018-05-26 23:23:33
devicetime|2018-05-26 23:12:09
fixtime |2018-05-26 23:12:09
valid |true
latitude |00.000000
longitude |00.000000
altitude |0
speed |0.539957
course |293.38
Anton, you have green light to prepare the logging.
@Percy Server still works correctly, it analyzes fixTime
23:12 and it is in interval 23:00 - 23:15
@abyss,
Thank you for the info. So this means I can get a "late" event from the device, even after the calendar interval is over, correct?
This is kind of confusing for our use case, as we expect events to be generated as they happen, not delayed. I know that probably for some reason the device send this fixTime after the fact, but there should be a setting to "normalize" event generation to be within the calendar interval.
Again, I appreciate the help. Anton prepared an extra logging. As we run all our tests, if there is another reported anomaly on the event generation - I'll forward this to Anton.
Thanks guys, I really appreciate your help. Once we get a Java person on our team, expect many pull requests back to the Traccar community, to give back to you guys.
Anton,
After some tests, I see that we are missing an use case: being able to generate an event for: geofenceOutside. By all the tests performed, a geofenceEnter and geofenceExit are only emitted when there are two consecutive valid positions inside and outside the geofence, or outside then inside. Which is good if you know that the device will enter the geofence at some point. But this doesn't work on the scenario that we have a device that could enter this geofence, but is not mandatory, but still I want to get notified if the device is not inside that geofence as soon as the geofence schedule is in effect.
Also, I see a geofenceInside event - that could be used in the case the geofenceEnter is not emitted, because the device suddenly reported a position inside the geofence, (and not a consecutive outside, then inside position - that geofenceEnter requires)
Here is the scenario: having a device, that may or may not enter a geofence. But I want to be notified if the device is outside the geofence on the given time period set by the calendar assigned to the geofence. Or the device suddenly appears inside the geofence (but no consecutive outside then inside positions are registered)
Want me to open a new issue for this enhancement?
How can you help me with this?
You can create a feature request if you want. Currently the was it works is you get notification only when you cross the border.
Yes, I know. My tests revealed that - notifications are emitted only when crossing the border of the geofence, and I need to get a "geofenceOutside" and "geofenceInside" like I described above too.
I'll create a feature request.
Hi Percy!
"I simulate a geofenceEnter / geofenceExit"
That's exactly what we need: How do you simulate programmatically a geofence enter/leave event (preferably in Node or otherwise)?
Hi Percy!
"I simulate a geofenceEnter / geofenceExit"
That's exactly what we need: How do you simulate programmatically a geofence enter/leave event (preferably in Node or otherwise)?
I want for example some vehicles not to be used over the weekend. It makes no sense to let someone drive it through a geofence to stop the engine then or I have a bunch of vehicles stalled around the border of the fence. I'd rather not even start the vehicle during these off-days/time frames.
So, as soon as a person tries to start the device, I receive a Power ON event which would let me fake a geofence event to evaluate driver, group, device and if the time of attempted start is out of the valid range, the power is turned off again. No harm, no foul. They will have to check other vehicles that allow usage during this timeframe.
I looked at checkMoment() but not being a Java person, even less a iCal person I don't understand it. I also don't know how to call a java function from Node.
public boolean checkMoment(Date date) {
if (calendar != null) {
Period period = new Period(new DateTime(date), new Dur(0, 0, 0, 0));
Predicate<CalendarComponent> periodRule = new PeriodRule<>(period);
Filter<CalendarComponent> filter = new Filter<>(new Predicate[] {periodRule}, Filter.MATCH_ANY);
Collection<CalendarComponent> events = filter.filter(calendar.getComponents(CalendarComponent.VEVENT));
if (events != null && !events.isEmpty()) {
return true;
}
}
return false;
}
If I can however trigger a fake fence event, everything falls into place. I looked and searched and did not find an api call (which would be the best solution: .../api/valid_geofence_event?device=xxx&driver=xxx&geovenceid=xxx where driver or group or device where I could derive the driver even if they are hidden in a group. I would receive a true or false if the driver or device are within or outside the iCal periods)
This calendar ics is passed from another connected app I'm working with to the Traccar API along with a geofence creation.
The geofences are generally 1 or 2 days a week recurring for 1 hour or less.
I tested this ics with a calendar app I use and it was imported successfully and correctly. But as you pointed, it is not always parsed the same way everywhere.
But, yeah you are right - I'm going to import it into more apps to check it. I know whatever works for ical4j should work. If this doesn't work, I'll use your paid support as I'm on a dead end with this issue so far.