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.

25 satır
655B

  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. }