We already have built-in functionality to indicate the device's online/offline status.
Just need a little configuration for it.
Configure your application version for the EPL service like on the screen above.
It means that you will have the 'turn' and 'turn_ts' endpoint metadata fields that will be automatically updated on endpoint connect/disconnect.
Also, you will have the time series with the name 'ep-online' and be able to see the endpoint connectivity history events via the EPTS service.