# \#function-node

**URL:** https://discourse.nodered.org/tag/function-node/20.md?page=3

[Latest](https://discourse.nodered.org/latest.md) · [Categories](https://discourse.nodered.org/categories.md) · [Tags](https://discourse.nodered.org/tags.md)

**Page:** 4

---

## [OPC Communication](https://discourse.nodered.org/t/opc-communication/95789)

<div class="topic-metadata">

**Author:** [@Mysmoo](https://discourse.nodered.org/u/Mysmoo)\
**Replies:** 22\
**Last updated:** [5 March 2025 11:36 UTC](https://discourse.nodered.org/t/opc-communication/95789 "2025-03-05T11:36:26Z")

</div>

Hey, I am new to Node-Red and trying to learn. What i am trying to do is read 6 signals from the OPC. I send then with a Join block and read them out in array. Code looks like this after the Join block: let msg1 = {}…

---

## [Problem with calendar input to Home assistant](https://discourse.nodered.org/t/problem-with-calendar-input-to-home-assistant/95766)

<div class="topic-metadata">

**Author:** [@bvndb](https://discourse.nodered.org/u/bvndb)\
**Replies:** 13\
**Last updated:** [3 March 2025 12:56 UTC](https://discourse.nodered.org/t/problem-with-calendar-input-to-home-assistant/95766 "2025-03-03T12:56:56Z")

</div>

When i create a flow and send the data as a msg to a create calendar event i got this error : InputError: Invalid JSON: {“\[object Object\]”} When i put the (captured data directly in the data field it works. What am i do…

---

## [Javascript function to parse complex json object](https://discourse.nodered.org/t/javascript-function-to-parse-complex-json-object/95700)

<div class="topic-metadata">

**Author:** [@Mick](https://discourse.nodered.org/u/Mick)\
**Replies:** 8\
**Last updated:** [28 February 2025 18:11 UTC](https://discourse.nodered.org/t/javascript-function-to-parse-complex-json-object/95700 "2025-02-28T18:11:44Z")

</div>

I am trying to parse a complex json object Here is the object. I am using the following flow to parse the data function getAllKeyValuePairs(obj, path = '') { const results = \[\]; for (const key in obj) { …

---

## [Node red dashboard using relays and authentication using badhe scans](https://discourse.nodered.org/t/node-red-dashboard-using-relays-and-authentication-using-badhe-scans/95643)

<div class="topic-metadata">

**Author:** [@qureshi](https://discourse.nodered.org/u/qureshi)\
**Replies:** 5\
**Last updated:** [25 February 2025 21:02 UTC](https://discourse.nodered.org/t/node-red-dashboard-using-relays-and-authentication-using-badhe-scans/95643 "2025-02-25T21:02:47Z")

</div>

Hey guys. This is probably going to be a really simple question for most of you and i would appreciate the help. So I'm trying to build a simple dashboard to automate a Vending machine. I initially want the user to sc…

---

## [Bar chart for dashboard 2.0](https://discourse.nodered.org/t/bar-chart-for-dashboard-2-0/95402)

<div class="topic-metadata">

**Author:** [@tsharma](https://discourse.nodered.org/u/tsharma)\
**Replies:** 2\
**Last updated:** [14 February 2025 15:55 UTC](https://discourse.nodered.org/t/bar-chart-for-dashboard-2-0/95402 "2025-02-14T15:55:21Z")

</div>

How to make 7 days bar-chart in node-red dashboard 2.0.

---

## [Energy daily consumption](https://discourse.nodered.org/t/energy-daily-consumption/95564)

<div class="topic-metadata">

**Author:** [@Asif128935](https://discourse.nodered.org/u/Asif128935)\
**Replies:** 2\
**Last updated:** [22 February 2025 13:21 UTC](https://discourse.nodered.org/t/energy-daily-consumption/95564 "2025-02-22T13:21:48Z")

</div>

Hello, our energy meter is connected to our scada via opc kepserver. The KWh from meter is cumulative. Not instantaneous. We need instantaneous value to calculate daily consumption. We apply some code to get daily. The r…

---

## [How to get Startdate and end date of a month for a given date](https://discourse.nodered.org/t/how-to-get-startdate-and-end-date-of-a-month-for-a-given-date/95457)

<div class="topic-metadata">

**Author:** [@smanjunath211](https://discourse.nodered.org/u/smanjunath211)\
**Replies:** 2\
**Last updated:** [17 February 2025 11:07 UTC](https://discourse.nodered.org/t/how-to-get-startdate-and-end-date-of-a-month-for-a-given-date/95457 "2025-02-17T11:07:17Z")

</div>

I need to get starting day of the month and ending day of the month for a given date. how do i write a simple function for the same. I tried from this link, but i am unable to get the start day. \`Calculate Last Date of…

---

## [Dynamically editing URL message content using a function](https://discourse.nodered.org/t/dynamically-editing-url-message-content-using-a-function/95370)

<div class="topic-metadata">

**Author:** [@shlomo](https://discourse.nodered.org/u/shlomo)\
**Replies:** 6\
**Last updated:** [13 February 2025 12:45 UTC](https://discourse.nodered.org/t/dynamically-editing-url-message-content-using-a-function/95370 "2025-02-13T12:45:15Z")

</div>

Hello everyone, I have a flow that is supposed to send me a WhatsApp message via "CallMeBot" when there is an inequality between two nodes But in practice I can't get it to work even though I checked the API KEY and it …

---

## [SQL-string with appendix](https://discourse.nodered.org/t/sql-string-with-appendix/95286)

<div class="topic-metadata">

**Author:** [@Owler](https://discourse.nodered.org/u/Owler)\
**Replies:** 4\
**Last updated:** [10 February 2025 19:16 UTC](https://discourse.nodered.org/t/sql-string-with-appendix/95286 "2025-02-10T19:16:15Z")

</div>

Hello, I try to save values from a smartmeter into a Mysql database. The smartmeter is a ISKRA eHZ-EDL . I can see the values at a dashboard so far so good. Now write the values into to the database did not work. I …

---

## [Dynamic column name for csv data logging](https://discourse.nodered.org/t/dynamic-column-name-for-csv-data-logging/95199)

<div class="topic-metadata">

**Author:** [@syed\_najam1](https://discourse.nodered.org/u/syed_najam1)\
**Replies:** 1\
**Last updated:** [7 February 2025 09:57 UTC](https://discourse.nodered.org/t/dynamic-column-name-for-csv-data-logging/95199 "2025-02-07T09:57:44Z")

</div>

I am logging data for 12 sensors in a CSV file, where each sensor corresponds to a specific column (e.g., Sensor1, Sensor2, Sensor3, etc.). I want to dynamically assign column names for each sensor through text input. Wh…

---

## [Basic Javascript Function concatenation \[SOLVED\]](https://discourse.nodered.org/t/basic-javascript-function-concatenation-solved/95090)

<div class="topic-metadata">

**Author:** [@vongomben](https://discourse.nodered.org/u/vongomben)\
**Replies:** 2\
**Last updated:** [3 February 2025 14:59 UTC](https://discourse.nodered.org/t/basic-javascript-function-concatenation-solved/95090 "2025-02-03T14:59:55Z")

</div>

Hi. I'm struggling in understand what's wrong in this concatenation. I'm failin in concatenate this object\[1\], using this function\[2\]. Nothing is coming out. Thanks in advance for your answer. This is the code \[1\] …

---

## [Nodered and SQLite Integration - Error](https://discourse.nodered.org/t/nodered-and-sqlite-integration-error/94529)

<div class="topic-metadata">

**Author:** [@ganeshiac](https://discourse.nodered.org/u/ganeshiac)\
**Replies:** 15\
**Last updated:** [3 February 2025 11:11 UTC](https://discourse.nodered.org/t/nodered-and-sqlite-integration-error/94529 "2025-02-03T11:11:48Z")

</div>

Good Afternoon!! Now, I currently developed nodered data send to SQLite DB. Here table is created but no data is stored in particular DB. Can you able to check my node flow. I updated below. I shared some details for you…

---

## [Read CPU-Load of Linux-Device where Node-Red is installed on](https://discourse.nodered.org/t/read-cpu-load-of-linux-device-where-node-red-is-installed-on/94922)

<div class="topic-metadata">

**Author:** [@Gawan](https://discourse.nodered.org/u/Gawan)\
**Replies:** 2\
**Last updated:** [26 January 2025 14:52 UTC](https://discourse.nodered.org/t/read-cpu-load-of-linux-device-where-node-red-is-installed-on/94922 "2025-01-26T14:52:41Z")

</div>

Hi all, I have some performance issues to I would like to read the node-red server CPU load in Node-Red and show it somewhere in a Maintenance-Tab. I am not a linux person, but I managed to get this line if I simply se…

---

## [Node Red TCP connection gives error (index a nil value) on MG400 Dobot](https://discourse.nodered.org/t/node-red-tcp-connection-gives-error-index-a-nil-value-on-mg400-dobot/94857)

<div class="topic-metadata">

**Author:** [@Palmhoej](https://discourse.nodered.org/u/Palmhoej)\
**Replies:** 7\
**Last updated:** [25 January 2025 13:14 UTC](https://discourse.nodered.org/t/node-red-tcp-connection-gives-error-index-a-nil-value-on-mg400-dobot/94857 "2025-01-25T13:14:40Z")

</div>

I have a dobot Mg400 with the following code: And then a simple flow in node red to inject strings using TCP connection (MG400 is the server): The code is executed as I would expect, robot does commands and I get…

---

## [Any idea how can i access these 2 values inside the array?](https://discourse.nodered.org/t/any-idea-how-can-i-access-these-2-values-inside-the-array/94863)

<div class="topic-metadata">

**Author:** [@zaid](https://discourse.nodered.org/u/zaid)\
**Replies:** 6\
**Last updated:** [25 January 2025 13:14 UTC](https://discourse.nodered.org/t/any-idea-how-can-i-access-these-2-values-inside-the-array/94863 "2025-01-25T13:14:05Z")

</div>

---

## [I need to perform an arithmetic operation between 2 variables of the same modbus device](https://discourse.nodered.org/t/i-need-to-perform-an-arithmetic-operation-between-2-variables-of-the-same-modbus-device/94258)

<div class="topic-metadata">

**Author:** [@Monobeto93](https://discourse.nodered.org/u/Monobeto93)\
**Replies:** 4\
**Last updated:** [21 January 2025 15:33 UTC](https://discourse.nodered.org/t/i-need-to-perform-an-arithmetic-operation-between-2-variables-of-the-same-modbus-device/94258 "2025-01-21T15:33:38Z")

</div>

I have converted MOT32 to float using a function, but when I take these two converted values ​​to another function to perform the arithmetic operation, there is a conflict between the payloads. I would really appreciate …

---

## [Help in Function Node - Dynamic Table properties (CSV to HTML)](https://discourse.nodered.org/t/help-in-function-node-dynamic-table-properties-csv-to-html/94751)

<div class="topic-metadata">

**Author:** [@smanjunath211](https://discourse.nodered.org/u/smanjunath211)\
**Replies:** 7\
**Last updated:** [20 January 2025 13:11 UTC](https://discourse.nodered.org/t/help-in-function-node-dynamic-table-properties-csv-to-html/94751 "2025-01-20T13:11:00Z")

</div>

I have a simple flow, where i convert the contents of a CSV file into an HTML table for sending it as email body. for few rows in the table i need to colspan 6 columns so that they appear in a single cell based on the c…

---

## [Function node and handling null as content of message output](https://discourse.nodered.org/t/function-node-and-handling-null-as-content-of-message-output/94732)

<div class="topic-metadata">

**Author:** [@hoekbrwr](https://discourse.nodered.org/u/hoekbrwr)\
**Replies:** 8\
**Last updated:** [19 January 2025 14:36 UTC](https://discourse.nodered.org/t/function-node-and-handling-null-as-content-of-message-output/94732 "2025-01-19T14:36:20Z")

</div>

I have a function that produces an array of 2 message objects, one or both can be null. If I read the documentation("If null is returned, either by itself or as an element of the array, no message is passed on")., there …

---

## [No Display in chart Node](https://discourse.nodered.org/t/no-display-in-chart-node/94571)

<div class="topic-metadata">

**Author:** [@firstfacility](https://discourse.nodered.org/u/firstfacility)\
**Replies:** 2\
**Last updated:** [13 January 2025 13:28 UTC](https://discourse.nodered.org/t/no-display-in-chart-node/94571 "2025-01-13T13:28:02Z")

</div>

\[ { "id": "545937a92027a29d", "type": "function", "z": "c7b6d33bb6abd6a9", "name": "function 23", "func": "// Testdaten erzeugen (Beispiel: Herzfrequenzdaten)\\nconst testData =…

---

## [A buffer as payload from function node](https://discourse.nodered.org/t/a-buffer-as-payload-from-function-node/94506)

<div class="topic-metadata">

**Author:** [@lbh00](https://discourse.nodered.org/u/lbh00)\
**Replies:** 4\
**Last updated:** [10 January 2025 16:07 UTC](https://discourse.nodered.org/t/a-buffer-as-payload-from-function-node/94506 "2025-01-10T16:07:29Z")

</div>

Hello, I have a flow in Node-red in which a function will have to send a binary message to the serial port node. I set up the function node with code similar to this blReply =\[217,181,0,75\]; for (i=0; i\< blReply.l…

---

## [Display line chart with data retrieved from mysql](https://discourse.nodered.org/t/display-line-chart-with-data-retrieved-from-mysql/94486)

<div class="topic-metadata">

**Author:** [@kaekzha](https://discourse.nodered.org/u/kaekzha)\
**Replies:** 6\
**Last updated:** [9 January 2025 18:10 UTC](https://discourse.nodered.org/t/display-line-chart-with-data-retrieved-from-mysql/94486 "2025-01-09T18:10:23Z")

</div>

can someone help me? im new with node-red. i want to display line chart for my data but seems like somethings wrong because the line won't appear. here is my flow \[ { "id": "965463562375cf7e", "type"…

---

## [Function with two Inputs to one Output](https://discourse.nodered.org/t/function-with-two-inputs-to-one-output/94368)

<div class="topic-metadata">

**Author:** [@tech152](https://discourse.nodered.org/u/tech152)\
**Replies:** 3\
**Last updated:** [5 January 2025 13:53 UTC](https://discourse.nodered.org/t/function-with-two-inputs-to-one-output/94368 "2025-01-05T13:53:22Z")

</div>

Hi, i have a flow and need help with a function. I have two msg.payload as Input. In this function should be converted to msg.payload.lat and the other to msg.payload.lon Can me help someone? Thanks \[ { …

---

## [Pdf file into database like postgres](https://discourse.nodered.org/t/pdf-file-into-database-like-postgres/94308)

<div class="topic-metadata">

**Author:** [@hemanthv1](https://discourse.nodered.org/u/hemanthv1)\
**Replies:** 1\
**Last updated:** [2 January 2025 06:24 UTC](https://discourse.nodered.org/t/pdf-file-into-database-like-postgres/94308 "2025-01-02T06:24:33Z")

</div>

Hi, I am trying to convert pdf files into base64 and log them in database. When using read file - "file-in" node and set output to output to base64 and include debug output. Base64 output is generated for the pdf file …

---

## [AEM1000 Multi Sensor ESP8266 with TFT (Co2, VOC, PM2.5, Temp, Humidity)](https://discourse.nodered.org/t/aem1000-multi-sensor-esp8266-with-tft-co2-voc-pm2-5-temp-humidity/94121)

<div class="topic-metadata">

**Author:** [@ajaybnl](https://discourse.nodered.org/u/ajaybnl)\
**Replies:** 2\
**Last updated:** [28 December 2024 13:20 UTC](https://discourse.nodered.org/t/aem1000-multi-sensor-esp8266-with-tft-co2-voc-pm2-5-temp-humidity/94121 "2024-12-28T13:20:41Z")

</div>

I have made a cheap multi Air sensors project using ESP8266 , 1.8" TFT. I have used Node-red to upload the sensor data to mysql db from Mqtt. The ASAIR AEM1000 is a cheap alternative. The data it provides is calibrated…

---

## [Send value from api to bacnet](https://discourse.nodered.org/t/send-value-from-api-to-bacnet/94112)

<div class="topic-metadata">

**Author:** [@Rippen85](https://discourse.nodered.org/u/Rippen85)\
**Replies:** 4\
**Last updated:** [26 December 2024 11:59 UTC](https://discourse.nodered.org/t/send-value-from-api-to-bacnet/94112 "2024-12-26T11:59:10Z")

</div>

I collect 24 points from Nordpool, then I want to send them to my bacnet unit. but it only takes the last value? How do I do between "chart data" and "write". \[ { "id": "3cb529667ade3110", "type": "i…

---

## [How to Modularize and Reuse Function Node Code in Node-RED?](https://discourse.nodered.org/t/how-to-modularize-and-reuse-function-node-code-in-node-red/94012)

<div class="topic-metadata">

**Author:** [@LoganathanSambath](https://discourse.nodered.org/u/LoganathanSambath)\
**Replies:** 14\
**Last updated:** [26 December 2024 07:07 UTC](https://discourse.nodered.org/t/how-to-modularize-and-reuse-function-node-code-in-node-red/94012 "2024-12-26T07:07:15Z")

</div>

I have a Node-RED flow where several function nodes contain more than 100 lines of JavaScript code each. Managing and writing unit tests for such large code blocks has become increasingly difficult. I’m looking for a wa…

---

## [Can't use message element with Function node](https://discourse.nodered.org/t/cant-use-message-element-with-function-node/94163)

<div class="topic-metadata">

**Author:** [@ralphjy](https://discourse.nodered.org/u/ralphjy)\
**Replies:** 4\
**Last updated:** [26 December 2024 05:30 UTC](https://discourse.nodered.org/t/cant-use-message-element-with-function-node/94163 "2024-12-26T05:30:55Z")

</div>

I'm having what I expect is a simple problem caused by my lack of understanding Node-Red. I have a JSON string received via MQTT. I set the MQTT input node to output a JSON object. This is data from object detection t…

---

## [Function to orient the payload (of an energy meter) according to a number](https://discourse.nodered.org/t/function-to-orient-the-payload-of-an-energy-meter-according-to-a-number/94135)

<div class="topic-metadata">

**Author:** [@Ives25](https://discourse.nodered.org/u/Ives25)\
**Replies:** 5\
**Last updated:** [24 December 2024 13:48 UTC](https://discourse.nodered.org/t/function-to-orient-the-payload-of-an-energy-meter-according-to-a-number/94135 "2024-12-24T13:48:47Z")

</div>

Hello, The first part of the energy counting from a meter containing the energy values ​​and the tariff works. I started the second part which consists of starting from a meter containing only the active energy value t…

---

## [Set and Get Variables & Time from Arduino Projects to Node-Red](https://discourse.nodered.org/t/set-and-get-variables-time-from-arduino-projects-to-node-red/94083)

<div class="topic-metadata">

**Author:** [@ajaybnl](https://discourse.nodered.org/u/ajaybnl)\
**Replies:** 3\
**Last updated:** [23 December 2024 04:38 UTC](https://discourse.nodered.org/t/set-and-get-variables-time-from-arduino-projects-to-node-red/94083 "2024-12-23T04:38:43Z")

</div>

You can save variables in Node-red Flow/Storage Data using Arduino based boards like ESP8266 , ESP32, and so on. Concept: Send message to node/variable to store publish to TOPIC + /$get to get stored data Example: T…

---

## [Node-red-contrib-nighttime. Need to provide GPS Day or Night node via JSON](https://discourse.nodered.org/t/node-red-contrib-nighttime-need-to-provide-gps-day-or-night-node-via-json/94078)

<div class="topic-metadata">

**Author:** [@pcborges](https://discourse.nodered.org/u/pcborges)\
**Replies:** 7\
**Last updated:** [21 December 2024 21:11 UTC](https://discourse.nodered.org/t/node-red-contrib-nighttime-need-to-provide-gps-day-or-night-node-via-json/94078 "2024-12-21T21:11:15Z")

</div>

I am using node-red-contrib-nighttime and currently I am typing LAT & LONG manualy. I need to make it autonomous so I am getting coordinates from on line service. Day\_or\_Night node says it can get LAT/LONG data from lo…

[Previous page](https://discourse.nodered.org/tag/function-node/20.md?match_all_tags=true&page=2&tags%5B%5D=function-node)

[Next page](https://discourse.nodered.org/tag/function-node/20.md?match_all_tags=true&page=4&tags%5B%5D=function-node)
