# Alert on communication loss

**URL:** <https://forums.losant.com/t/alert-on-communication-loss/820>\
**Category:** Help\
**Created:** [March 21, 2018, 6:36pm UTC](https://forums.losant.com/t/alert-on-communication-loss/820 "2018-03-21T18:36:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![David\_Agard](https://avatars.discourse-cdn.com/v4/letter/d/e5b9ba/32.png) [@David\_Agard](https://forums.losant.com/u/David_Agard)\
**Post date:** [March 21, 2018, 6:36pm UTC](https://forums.losant.com/t/alert-on-communication-loss/820/1 "2018-03-21T18:36:49Z")

</div>

Is there a way to trigger a workflow alert or make a change in a dashboard color if communication is lost for more than a defined time?

---

<div class="post-metadata">

**Author:** ![Erin\_Thompson](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/erin_thompson/32/501_2.png) [@Erin\_Thompson](https://forums.losant.com/u/Erin_Thompson)\
**Post date:** [March 21, 2018, 7:24pm UTC](https://forums.losant.com/t/alert-on-communication-loss/820/2 "2018-03-21T19:24:16Z")

</div>

Hi David,

The easiest way to trigger an alert on a workflow if a device is inactive and continuously sending state would be to use the [Device Inactivity Node](https://docs.losant.com/workflows/triggers/on-inactivity/), and then use either an email, sms, etc. to alert people that need to be alerted. If it is not continuously reporting state then I would use a [Device On Connect Trigger](https://docs.losant.com/workflows/triggers/on-connect/) and [Device On Disconnect Trigger](https://docs.losant.com/workflows/triggers/on-disconnect/). Each time one of these triggers occurs I would [insert a row into a data table](https://docs.losant.com/workflows/data/table-insert-row/). I would then have a 3rd trigger of a [Timer Trigger](https://docs.losant.com/workflows/triggers/timer/) that will fire as frequently as you would like to check to see if the device has disconnected and if so what is the difference between now and the last disconnect time.

As far as the dashboard goes, assuming that you know the time of the last time the device communicated to Losant, you can use an [Indicator Block](https://docs.losant.com/dashboards/indicator/) on the dashboard. You can then add a condition that would be `{{subtract (formatDate undefined ‘x’) time}} > 5000` such that the formatData undefined ‘x’ resolves to the current time now, and subtracts the variable time, which is the last time the device reported. The result of the difference will be in milliseconds. Then you can add make the block a different color and add some kind of warning label to it.

Hope that helps.  
Erin

---

<div class="post-metadata">

**Author:** ![David\_Agard](https://avatars.discourse-cdn.com/v4/letter/d/e5b9ba/32.png) [@David\_Agard](https://forums.losant.com/u/David_Agard)\
**Post date:** [March 22, 2018, 5:37pm UTC](https://forums.losant.com/t/alert-on-communication-loss/820/3 "2018-03-22T17:37:15Z")

</div>

Hi Erin  
Thanks for this. I’ll try the workflow. Sorry for the naive question, but for the Dashboard do I have to explicitly define ‘x’? {{(formatDate undefined ‘x’)}} does not resolve into a value when I try to display it in an indicator block, while {{time}} does. Thanks

---

<div class="post-metadata">

**Author:** ![Erin\_Thompson](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/erin_thompson/32/501_2.png) [@Erin\_Thompson](https://forums.losant.com/u/Erin_Thompson)\
**Post date:** [March 22, 2018, 6:16pm UTC](https://forums.losant.com/t/alert-on-communication-loss/820/4 "2018-03-22T18:16:31Z")

</div>

I believe it’s the extra `()`. This `{{formatDate undefined 'x'}}` should be resolving to the time in milliseconds. If you wanted to display the current time in a human readable format you can do `{{formatDate undefined}}`. The parentheses are required when wrapping `{{formatDate undefined 'x'}}` into a subtract helper, like `{{subtract (formatDate undefined ‘x’) time}}`.

Thanks,  
Erin

---

<div class="post-metadata">

**Author:** ![David\_Agard](https://avatars.discourse-cdn.com/v4/letter/d/e5b9ba/32.png) [@David\_Agard](https://forums.losant.com/u/David_Agard)\
**Post date:** [March 22, 2018, 8:16pm UTC](https://forums.losant.com/t/alert-on-communication-loss/820/5 "2018-03-22T20:16:05Z")

</div>

Erin. Perfect - thanks so much David
