您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

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