NodeRED for beginners: 6. Function node

แชร์
ฝัง
  • เผยแพร่เมื่อ 29 ธ.ค. 2024

ความคิดเห็น • 37

  • @MrAtarifreak
    @MrAtarifreak 6 ปีที่แล้ว +1

    Thanks for this tutorial. I like the way you explain it.

  • @alcidesmarcano
    @alcidesmarcano 6 ปีที่แล้ว

    Thanks for the tutorial series! very useful videos

  • @هبةمهديصالحالموسوي
    @هبةمهديصالحالموسوي 2 ปีที่แล้ว

    Hi.can you help me please how can l do machine classification for hart signals using nod red l already did the classification in R code

  • @dannydzware2023
    @dannydzware2023 5 ปีที่แล้ว

    Thank you very much. I am new to node red. Maybe you can help me: is there a chance that you can do a video about blinking LED and creating a running light like an Audi (car) blinking light. I have absolutely no idea how to do it. Thanks for your help.

    • @notenoughtech
      @notenoughtech  5 ปีที่แล้ว

      NodeRed can control the GPIO on raspberry pi. There it more than one way to resolve it. I believe Audi actually have it resolved by using hardware delay between the LEDs on the strip otherwise you would have to time each LED and that depends on how you going to connect the leds

  • @davidm.5968
    @davidm.5968 3 ปีที่แล้ว

    Hi thank you for your videos, one question , is possible in nodered with node fuction , add the payload of 2 sensors into one, exemple 223v sensor 1 200v sensor2: equal 1 sensor with value 423V ? thanks a lot

    • @notenoughtech
      @notenoughtech  3 ปีที่แล้ว

      Yes. You can store the value using context.set() when sensor A reports and add the value to sensor B just use separate msg.topic for each so you know which sensor is which.

    • @davidm.5968
      @davidm.5968 3 ปีที่แล้ว

      @@notenoughtech thanks a lot , it’s possible to write all the fuction, because I,m very noob with node red , and I don’t know how can I do it
      Thanks

    • @notenoughtech
      @notenoughtech  3 ปีที่แล้ว

      try this:
      [{"id":"4df53d45.2952d4","type":"function","z":"76cad92f.121798","name":"2 Sensors","func":"//please name your sensors \"sensorA\" & \"sensorB\" in msg.topic for each sensor,
      //the node will return only when both sensors submit values

      if(msg.topic === \"sensorA\"){
      var sensorA = msg.payload;
      context.set(\"sensorA\", sensorA);
      }
      if(msg.topic === \"sensorB\"){
      var sensorB = msg.payload;
      context.set(\"sensorB\", sensorB);
      }

      var A = context.get(\"sensorA\");
      var B = context.get(\"sensorB\");

      if(A !== null && B !== null){
      msg.payload = A+B;
      context.set(\"sensorB\", null);
      context.set(\"sensorA\", null);
      return msg;
      }



      ","outputs":1,"noerr":0,"initialize":"// Code added here will be run once
      // whenever the node is started.
      context.set(\"sensorB\", null);
      context.set(\"sensorA\", null);","finalize":"","libs":[],"x":230,"y":300,"wires":[[]]}]

    • @davidm.5968
      @davidm.5968 3 ปีที่แล้ว

      @@notenoughtech thanks a lot , this afternoon I try and comment the result

    • @davidm.5968
      @davidm.5968 3 ปีที่แล้ว

      I try , and works perfectly, thanks a lot for help. thank you very much

  • @bystander7325
    @bystander7325 5 ปีที่แล้ว

    Great English ! Congrats from Poland :P

    • @notenoughtech
      @notenoughtech  5 ปีที่แล้ว

      Dziekuje :) robie co moge!

    • @bystander7325
      @bystander7325 5 ปีที่แล้ว

      @@notenoughtech As I absolutely want you to keep this amazing channel international, let me reply in english :P
      Amazing work, Node-Red allows beginners to achieve breathtaking results with just some technical knowledge, and YOU make it possible. Thx again, respect !

  • @Y2KSailing
    @Y2KSailing 4 ปีที่แล้ว +1

    Thanks, very useful!

  • @mmanimator12
    @mmanimator12 4 ปีที่แล้ว

    I wonder if you know how to pass 3 different inputs to 3 outputs using function node? So, 1st input would pass to 1st output, 2nd input would pass to 2nd output and so forth

    • @notenoughtech
      @notenoughtech  4 ปีที่แล้ว

      return [msg1, msg2, msg3]
      each msg should have an object ie var msg1 = {payload: your_payload, ID: your_id}. Then on input
      Create if conditions for msg.ID

    • @mmanimator12
      @mmanimator12 4 ปีที่แล้ว

      @@notenoughtech
      Thank you for your response! I tried that but it didn't work, probably I didn't do it right but I ended up using join node and it worked.

    • @notenoughtech
      @notenoughtech  4 ปีที่แล้ว

      I'm actually writing about this as it's a good topic

    • @mmanimator12
      @mmanimator12 4 ปีที่แล้ว

      @@notenoughtech
      That would be really awesome 👌

    • @notenoughtech
      @notenoughtech  4 ปีที่แล้ว

      Follow me on one of social media as this one comes without video if you want a notification

  • @alijahangir3143
    @alijahangir3143 5 ปีที่แล้ว

    Amazing explanation. i m getting temperature value (msg.payload) from a function how do i turn something on or off connected to pi gpio based on temperature. stuck on this. help would be much appreciated.

    • @notenoughtech
      @notenoughtech  5 ปีที่แล้ว +1

      Nodered comes with gpio nodes. While I have no tutorials on that it shouldn't be more complicated than selecting the pin and pulling it LOW/HIGH as required

    • @alijahangir3143
      @alijahangir3143 5 ปีที่แล้ว

      @@notenoughtech i am new to this. i connected the function to rpi gpio node. dont know how put a condition in function. if payload value is above 40 gipo should turn high if less then 40 remain low.

  • @restuwahyusaputra7764
    @restuwahyusaputra7764 4 ปีที่แล้ว

    Great channel i like it

  • @annespacedroid
    @annespacedroid 6 ปีที่แล้ว

    Hi boss. I have a function node that sends a msg.payload as a notification through Google mini.
    I'm looking for a way to insert msg.emitVolume - 60, which plays the notification at 60% volume.
    Any idea how I pass that msg.emitVolume through with only some of the out putted messages I have?.
    I use the "Google home notify" with volume adjustment (msg.emitVolume = ?).
    If I type into the function:-
    msg.emitVolume = 60
    msg.payload = (whatever you choose)
    return msg;
    I get the notification at the correct volume, just unsure how to send msg.emitVolume with multiple messages.
    I've watched some of your other tuts & thank you for those.

    • @notenoughtech
      @notenoughtech  6 ปีที่แล้ว

      Currently, I'm using node-red-contrib-cast as the node google-notify stopped working for me some time ago. Anyway - if so, you can simply set msg.volume or msg.payload.volume to a number 0-100 to set the volume.
      so your object would look like this
      msg.payload = "Hey test message";
      msg.volume = 50;
      return msg;

    • @annespacedroid
      @annespacedroid 6 ปีที่แล้ว

      @@notenoughtech wow, what a speedy response.
      I'll try that when I get home.
      My nodered-contrib-cast stopped working as well, so I changed it for the new one, and it works again. Which has also volume adjustments via "msg.emitVolume =xx".
      Will let you know how it goes.
      Cheers

    • @notenoughtech
      @notenoughtech  6 ปีที่แล้ว

      Just make sure the node is updated - see the palette manager

    • @annespacedroid
      @annespacedroid 6 ปีที่แล้ว

      @@notenoughtech I'm actually using "node-red-contrib-google-home-notify-volume-adjustable", it's the latest update.
      This is what I have as a single msg, and works fine.
      msg.emitVolume = 50
      msg.payload = 'Anything you type'
      return msg;
      As stated, all works as expected with volume at 50%.
      I'm trying to create a function node with more than 2 messages & be able to change the volume for each msg.
      I need to output 5 messages & be able to set the volume on them individually.
      What I'm trying to do is:- (example)
      if msg.payload = 1, return "On" at 50% Volume
      if msg.payload = 2, return "Off" at 50% Volume
      if msg.payload = 3, return "Standby" at 75% Volume
      if msg.payload = 4, return "Sleeping" at 75% Volume.
      if msg.payload = 5, return "Overheat" at 100% Volume
      I have all the payload outputs for msg.payload set, just trying to change the volume, dependant upon the msg.
      Any help is greatly appreciated.

    • @notenoughtech
      @notenoughtech  6 ปีที่แล้ว

      There is an example of if statement in the function node tutorial you can use this and modify the outcomes.