Button operation in node red

Hello everyone

I'm trying to make an application with node red and ctrlx that uses the dashboard 
to control the opening and closing of a door,
But I don't know how to reset the signal so I can do it continuously, any help? Thank you very much to everyone.
Best reply by CodeShepherd

As far as I know the dashboard has no "push button" functionality out of the box. But as end switches are used you could use

  • radio buttons like they are used in the above mentioned examples
  • start buttons for setting (staring movement) and if even needed stop for resetting (stopping movement)
  • create your own JavaScript button reacting to "touchstart", "mousedown" and "touchend", "mouseup" events
    See example code:
    [{"id":"eac5d9eb.958798","type":"ui_template","z":"e659d6d440bf877d","group":"61e6d4c4.e7619c","name":"momentary button","order":7,"width":"0","height":"0","format":"<div id=\"momentary\">\n   <md-button style=\"min-width:36px;\n                    width: 100%; \n                    height: 100%; \n                    margin:0; \n                    padding: 0px; \n                    border-radius: 50%; \n                    background-color:green\">\n       \n      <i class=\"fa fa-hand-pointer-o\"></i>\n   </md-button>\n</div>\n<script>\n(function($scope) {\n    \n$('#momentary').on('touchstart mousedown', function(e) {\n    e.preventDefault(); //prevent default behavior\n    $scope.send({\"topic\":\"momentary\",\"payload\": true});\n});\n\n$('#momentary').on('touchend mouseup', function(e) {\n    e.preventDefault(); //prevent default behavior\n    $scope.send({\"topic\":\"momentary\",\"payload\": false});\n});\n    \n})(scope);\n</script>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","className":"","x":650,"y":2840,"wires":[["534f375d.fce978"]]},{"id":"534f375d.fce978","type":"debug","z":"e659d6d440bf877d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":820,"y":2840,"wires":[]},{"id":"61e6d4c4.e7619c","type":"ui_group","name":"TEST","tab":"d680797a.2f8b88","order":1,"disp":true,"width":"5","collapse":false,"className":""},{"id":"d680797a.2f8b88","type":"ui_tab","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]

 

View original
3 replies