# Catching Connection Error in node-red-dashboard

**URL:** <https://discourse.nodered.org/t/catching-connection-error-in-node-red-dashboard/34773>\
**Category:** Dashboard\
**Created:** [25 October 2020 11:03 UTC](https://discourse.nodered.org/t/catching-connection-error-in-node-red-dashboard/34773 "2020-10-25T11:03:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lizzardguki](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/lizzardguki/32/103637_2.png) [@lizzardguki](https://discourse.nodered.org/u/lizzardguki)\
**Post date:** [25 October 2020 11:03 UTC](https://discourse.nodered.org/t/catching-connection-error-in-node-red-dashboard/34773/1 "2020-10-25T11:03:56Z")

</div>

I am working on a start/stop system for couple of pumps that are communicating via Home Assistant...

So i have a onhold/onrelease button for turning pump on / off in ui template node:

```auto
<div class="pump1">
   <md-button> Pump1</md-button>
</div>

<script>

(function($scope) {
    
$('.pump1').on('touchstart mousedown', function(e) {
    e.preventDefault(); //prevent default behavior
   $scope.send({"payload" : { "service":'turn_on'} , "topic": 'switch.pump1'});
});

$('.pump1').on('touchend mouseup', function(e) {
    e.preventDefault(); //prevent default behavior
    $scope.send({"payload" : { "service":'turn_off'} , "topic": 'switch.pump1'});
});
    
})(scope);
</script>

```

And i am worried about the following situation:

1. I press down the button.
2. For some reason the device lost connectivity
3. the payload.service ('turn\_off') is not sent, and the pump keeps running.

How could i catch any connectivity error, and there for send the second (payload.service ('turn\_off')) message?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [25 October 2020 11:11 UTC](https://discourse.nodered.org/t/catching-connection-error-in-node-red-dashboard/34773/2 "2020-10-25T11:11:56Z")

</div>

First thoughts are dont rely on a dashboard for physical automation.

However, some thoughts on how you might contain your current situation...

- Use separate start and stop buttons
- have a fall back in your flow that auto switches off after MAX time (a fall back in-case no STOP signal is sent) (clue use a trigger node)
- use visual feedback indicators that are sent to the dashboard AFTER the command has been sent to the pump (better still feedback actual pump running status if you have it)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [8 November 2020 11:11 UTC](https://discourse.nodered.org/t/catching-connection-error-in-node-red-dashboard/34773/3 "2020-11-08T11:11:57Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
