Node-Red configuration
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Invert.js 655B

12345678910111213141516171819202122232425
  1. // Licensed under the MIT license, see LICENSE file.
  2. // Author: Per Malmberg (https://github.com/PerMalmberg)
  3. module.exports = function(RED) {
  4. function Invert(config) {
  5. RED.nodes.createNode(this,config);
  6. this.config = config;
  7. var node = this;
  8. var NodeHelper = require('./NodeHelper.js');
  9. var h = new NodeHelper( node );
  10. this.on('input', function(msg) {
  11. var topic = msg.topic;
  12. var payload = msg.payload;
  13. if( topic !== undefined && payload !== undefined ) {
  14. h.SetResult( !h.ToBoolean( payload ), topic );
  15. }
  16. });
  17. h.DisplayUnkownStatus();
  18. }
  19. RED.nodes.registerType("Invert",Invert);
  20. }