What to know if supervisor is connected to Balena cloud

I would like to get the connection status of the Balena Supervisor with the cloud, I saw a mechanism called RESIN_SUPERVISOR_CONNECTIVITY_CHECK, is there a way to query the connectivity check status of the Supervisor?

Thanks in advance

You could get the device model for the UUID you’d like from the API. See https://www.balena.io/docs/reference/api/overview/#constructing-api-calls

I think that there should be a field api_heartbeat_state on the device model which indicates if the device has been talking to the API as expected. Does this cover your use case?

Are you talking about something like:
curl -qs -X GET “https://api.balena-cloud.com/v5/device?$filter=uuid%20eq%20’$UUID’
-H “Content-Type: application/json”
-H “Authorization: Bearer $token” | jq -r ‘.d[0] | “(.api_heartbeat_state) (.last_connectivity_event)”’

Seems as a status from Balena Cloud? I need a mechanism that can run on my device to validate if my device is connected to the cloud, is that the right mechanism?

Hi, yes that will work. You can also optionally simplify your request to https://api.balena-cloud.com/v5/device($UUID). You can look at is_connected_to_vpn and api_heartbeat_state to determine connectivity to the VPN and API respectively. There is a little more detail on this here https://www.balena.io/docs/learn/manage/device-statuses/. As per your example, you could also look at last_connectivity_event and last_vpn_event to derive this information for yourself, but using is_connected_to_vpn is true and api_heartbeat_state is “online” should be sufficient.

Thanks I will try that as soon as possible.