How to know if a device is moving or stopped?

exaucaea year 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 Tananaeva year ago

There's a property on the device object.

exaucaea year ago

motion?

Anton Tananaeva year ago

Is that a device property?

exaucaea year ago

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

exaucaea year 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 Tananaeva year ago

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

exaucaea year 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 Tananaeva year ago

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

exaucaea year ago

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

Anton Tananaeva year ago

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

exaucaea year 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 Tananaeva year 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.