How to know if a device is moving or stopped?

exaucae2 years ago

I know that traccar fires an event for deviceMoving and deviceStopped. Is there any other way to know that without using these events? I long for any useful property or perhaps a computed attribute

Anton Tananaev2 years ago

There's a property on the device object.

exaucae2 years ago

motion?

Anton Tananaev2 years ago

Is that a device property?

exaucae2 years ago

Oh no, that a position attribute. Could you give me the property name, please?

exaucae2 years ago

If you'refering to device status ( online, offline, unknown), I'd be curious to know if it answer my request.

A device can be online but stopped or online and moving. At least, that's my assumption. That's why I was leaning onto the position motion attribute. Let me know if I'm mistaken.

Anton Tananaev2 years ago

I'm obviously not referring to the device status. What properties do you see on the device?

exaucae2 years ago

the device has this schema:

{
  "id": 0,
  "name": "string",
  "uniqueId": "string",
  "status": "string",
  "disabled": true,
  "lastUpdate": "2019-08-24T14:15:22Z",
  "positionId": 0,
  "groupId": 0,
  "phone": "string",
  "model": "string",
  "contact": "string",
  "category": "string",
  "attributes": {}
}
Anton Tananaev2 years ago

I think you forgot to provide any context. Where do you want to get it? Web? API? Backend?

exaucae2 years ago

Oh, sure.From Backend or API. Whatever works between those two.

Anton Tananaev2 years ago

On the backend you should have more properties. Check again.

exaucae2 years ago

One of motionStreak or motionState should be the relevant one.

Now that I think of it, I was definitely operating from API. I don't have control on the other sides of our Traccar instance.
I now understand why those properties were missing from my previous messages: they are ignored by Jackson serialization.

Is there any chance API returns them? If not, I'm open to alternatives: like reading motion state attribute from latest position

Anton Tananaev2 years ago

The API doesn't return them. Alternative is using the motion attribute from position, but note that it's a bit different from the events. Events are generated when motion value is constant for minimum duration.

exaucaea year ago

I'll use that alternative, thanks.