Catching Connection Error in node-red-dashboard

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:

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


(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'});

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?

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)

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