How the last connect for the devices work? Do we also have a way to know when was the device disconnected?

Hi,

We have a use case where we want to track the last connect and last disconnect for a device to losant.

As of now we were using the connectionTime string that we get by default on the device as the last connect and we were manually storing the timestamp for disconnect everytime the disconnect node was triggered on the workflow but the timestamps that we have gathered are a bit confusing?

Most of the time its the same value for both. Is there a clear way to know when was the last time the device established a connection and when it got disconnected?

Thanks,

@Suroor_Wijdan,

Would you be able to tell me more about (or share a screenshot of) the workflow that is setting these values?

In the Disconnect Trigger, the connectedAt field is the time that the device last connected, and the time value would be the time that the device disconnect.

we were manually storing the timestamp for disconnect every time the disconnect node was triggered on the workflow

Could you share the configuration of the node you are using to store this data?

I ran a simple test with a standalone device and our Device Simulator and this workflow:

image

Here are the two payloads:

The connectedAt key in the disconnect payload shows the same time as the time field of the connect payload. The disconnect time is the time field in the disconnect payload.

Please let me know if this helps or if you need more clarification. Including the information above would be a great help.

Thank you,
Heath

Not sure where this left off… how to retrieve a last connected timestamp if any, aside from the device connect disconnect trigger?

Like if polling connection status in a resource job, would you use Losant API, Device: Get [and some reference to ‘disconnectedAt’ in REST schema]?

Thanks

Using the Device: Get Node, you can select the “Include Connection Status” option. This returns the current connection status and the time it entered that status.

So if the device is currently connected, this will provide you the timestamp for when it connected.

If the device is disconnected and you want to know the last time it connected, I recommend using the “Get Log Entries” API endpoint:

This is the endpoint used to retrieve the connection log that appears in the Losant portal. This API endpoint will return all historical connect/disconnect events over a maximum time period of 6 months.

1 Like