You are reading a single comment by @user90273 and its replies. Click here to read the full conversation.
  • I would like to trigger 2 IFTTT events with my Puck.js, the first IFTTT event, turns on a wifi plug and the second event turns off the wifi plug, all this done in node-red.
    I’m using the following code on the Puck.js, it send a different number each time the button is pressed, a 1 or an 11.

    var pressCount = 0;
    setWatch(function() {
      pressCount++;
      if ( pressCount == 1)
      {
        NRF.setAdvertising({
        0xFFFF : [pressCount]
       });
       pressCount = 10;
      }
      else
      {
         NRF.setAdvertising({
        0xFFFF : [pressCount]
       });
        pressCount = 0;
      }
    }, BTN, { edge:"rising", repeat:true, debounce:50 });
    
    

    in the node-red input mqtt node, I use the following as the Topic:
    /ble/advertise/ca:c2:42:7c:05:dc/ffff

    using a function node, I was trying to test for the 2 pressCount value I was sending each time I pressed the puck.js
    I could not figure how to test for the pressCount value so I ended up testing for the length.
    The following is the code I ended up using in the node fuction:

    var newMsg = { payload: msg.payload.length };
    if (newMsg.payload == 29) {
       return [  msg, null ];
    } else  {
        return [ null, msg ];
    }
    
    

    It worked out OK testing for the length, but if someone could show me how I could test for the pressCount value that would be appreciated.

    Thanks

About

Avatar for user90273 @user90273 started