You can achive this using API shared in this forum.
Use device state API and create alerts on status object. Staus 1 is online and 0 means offline.
status