Send value from api to bacnet

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": "inject",
        "z": "3c0393f03dbda828",
        "name": "",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 100,
        "y": 240,
        "wires": [
            [
                "a1a79db0436d00ca"
            ]
        ]
    },
    {
        "id": "a1a79db0436d00ca",
        "type": "nordpool-api-plus",
        "z": "3c0393f03dbda828",
        "name": "",
        "area": "SE3",
        "currency": "SEK",
        "x": 300,
        "y": 240,
        "wires": [
            [
                "71c72db195b68260"
            ]
        ]
    },
    {
        "id": "71c72db195b68260",
        "type": "function",
        "z": "3c0393f03dbda828",
        "name": "chart data",
        "func": "var msg1 = {}\nfor (var i = 0; i<msg.payload.length;i++){\n    msg1 = {\n        topic:msg.payload[i].currency, \n        payload:msg.payload[i].price, \n        timestamp:msg.payload[i].timestamp,\n    }\n    node.send(msg1)\n}",
        "outputs": 1,
        "timeout": "",
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 500,
        "y": 240,
        "wires": [
            [
                "31826f5c856251e0",
                "85e1388914e4c5d9"
            ]
        ]
    },
    {
        "id": "8495e9b47b3be0f1",
        "type": "Bacnet-Gateway",
        "z": "3c0393f03dbda828",
        "name": "",
        "local_device_address": "192.168.68.151",
        "apduTimeout": 6000,
        "roundDecimal": 2,
        "local_device_port": 47808,
        "apduSize": "5",
        "maxSegments": "0x50",
        "retries": "5",
        "broadCastAddr": "255.255.255.255",
        "toLogIam": true,
        "discover_polling_schedule": "60",
        "discover_polling_schedule_value": "1",
        "discover_polling_schedule_options": "Minutes",
        "deviceId": "817001",
        "logErrorToConsole": false,
        "serverEnabled": false,
        "device_read_schedule": "60",
        "device_read_schedule_value": "1",
        "device_read_schedule_options": "Minutes",
        "deviceRangeRegisters": [],
        "portRangeRegisters": [],
        "cacheFileEnabled": false,
        "sanitise_device_schedule": "undefined",
        "sanitise_device_schedule_value": "",
        "x": 1180,
        "y": 80,
        "wires": [
            [
                "889e729a38804583"
            ]
        ]
    },
    {
        "id": "729a0561a8de8969",
        "type": "Bitpool-Inject",
        "z": "3c0393f03dbda828",
        "name": "Discover",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "doPoll": false,
        "doDiscover": true,
        "json": false,
        "mqtt": false,
        "pointJson": false,
        "object_property_simplePayload": false,
        "object_property_simpleWithStatus": false,
        "object_property_fullObject": false,
        "useDeviceName": false,
        "x": 1000,
        "y": 80,
        "wires": [
            [
                "8495e9b47b3be0f1"
            ]
        ]
    },
    {
        "id": "1926046efc180209",
        "type": "Bitpool-Inject",
        "z": "3c0393f03dbda828",
        "name": "Poll",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "1",
        "payloadType": "num",
        "doPoll": true,
        "doDiscover": false,
        "x": 750,
        "y": 120,
        "wires": [
            [
                "d11de816c82f7cbb"
            ]
        ]
    },
    {
        "id": "889e729a38804583",
        "type": "debug",
        "z": "3c0393f03dbda828",
        "name": "debug 4",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 1360,
        "y": 80,
        "wires": []
    },
    {
        "id": "d11de816c82f7cbb",
        "type": "Bacnet-Write",
        "z": "3c0393f03dbda828",
        "name": "",
        "applicationTag": "4",
        "priority": "16",
        "pointsToWrite": [
            {
                "meta": {
                    "objectId": {
                        "type": 2,
                        "instance": 1
                    },
                    "device": {
                        "address": "192.168.68.149",
                        "isMstp": false,
                        "deviceId": 3057254,
                        "vendorId": 10,
                        "deviceName": "AS-P_3057254 3057254"
                    }
                },
                "description": "",
                "objectName": "Time_00",
                "displayName": "Time_00",
                "objectType": 2,
                "presentValue": 311.5,
                "hasPriorityArray": true,
                "units": "no-units",
                "error": "none",
                "timestamp": 1734900612850,
                "status": "online",
                "deviceId": 3057254,
                "deviceAddress": "192.168.68.149",
                "key": "1-0-Time_00_AV_1"
            },
            {
                "meta": {
                    "objectId": {
                        "type": 2,
                        "instance": 2
                    },
                    "device": {
                        "address": "192.168.68.149",
                        "isMstp": false,
                        "deviceId": 3057254,
                        "vendorId": 10,
                        "deviceName": "AS-P_3057254 3057254"
                    }
                },
                "description": "",
                "objectName": "Time_01",
                "displayName": "Time_01",
                "objectType": 2,
                "presentValue": 10,
                "hasPriorityArray": true,
                "units": "no-units",
                "error": "none",
                "timestamp": 1734900612851,
                "status": "online",
                "deviceId": 3057254,
                "deviceAddress": "192.168.68.149",
                "key": "1-0-Time_01_AV_2"
            },
            {
                "meta": {
                    "objectId": {
                        "type": 2,
                        "instance": 3
                    },
                    "device": {
                        "address": "192.168.68.149",
                        "isMstp": false,
                        "deviceId": 3057254,
                        "vendorId": 10,
                        "deviceName": "AS-P_3057254 3057254"
                    }
                },
                "description": "",
                "objectName": "Time_03",
                "displayName": "Time_03",
                "objectType": 2,
                "presentValue": 252,
                "hasPriorityArray": true,
                "units": "no-units",
                "error": "none",
                "timestamp": 1734900612851,
                "status": "online",
                "deviceId": 3057254,
                "deviceAddress": "192.168.68.149",
                "key": "1-0-Time_03_AV_3"
            },
            {
                "meta": {
                    "objectId": {
                        "type": 2,
                        "instance": 4
                    },
                    "device": {
                        "address": "192.168.68.149",
                        "isMstp": false,
                        "deviceId": 3057254,
                        "vendorId": 10,
                        "deviceName": "AS-P_3057254 3057254"
                    }
                },
                "description": "",
                "objectName": "Time_04",
                "displayName": "Time_04",
                "objectType": 2,
                "presentValue": 25,
                "hasPriorityArray": true,
                "units": "no-units",
                "error": "none",
                "timestamp": 1734900612852,
                "status": "online",
                "deviceId": 3057254,
                "deviceAddress": "192.168.68.149",
                "key": "1-0-Time_04_AV_4"
            },
            {
                "meta": {
                    "objectId": {
                        "type": 2,
                        "instance": 5
                    },
                    "device": {
                        "address": "192.168.68.149",
                        "isMstp": false,
                        "deviceId": 3057254,
                        "vendorId": 10,
                        "deviceName": "AS-P_3057254 3057254"
                    }
                },
                "description": "",
                "objectName": "Time_05",
                "displayName": "Time_05",
                "objectType": 2,
                "presentValue": 8,
                "hasPriorityArray": true,
                "units": "no-units",
                "error": "none",
                "timestamp": 1734900612852,
                "status": "online",
                "deviceId": 3057254,
                "deviceAddress": "192.168.68.149",
                "key": "1-0-Time_05_AV_5"
            },
            {
                "meta": {
                    "objectId": {
                        "type": 2,
                        "instance": 6
                    }
                },
                "description": "",
                "objectName": "Time_02",
                "displayName": "Time_02",
                "objectType": 2,
                "presentValue": 0,
                "hasPriorityArray": true,
                "units": "no-units",
                "deviceId": 3057254,
                "deviceAddress": "192.168.68.149",
                "key": "1-0-Time_02_AV_6"
            }
        ],
        "writeDevices": [
            {
                "key": 1,
                "label": "AS-P_3057254 3057254",
                "data": "AS-P_3057254 3057254",
                "icon": "pi pi-server",
                "children": [
                    {
                        "key": "1-0-Time_00_AV_1",
                        "label": "Time_00",
                        "data": "Time_00",
                        "pointName": "Time_00_AV_1",
                        "icon": "pi writePointIcon",
                        "children": [
                            {
                                "label": "Name: Time_00",
                                "data": "Time_00",
                                "icon": "pi pi-cog",
                                "children": null
                            },
                            {
                                "label": "Object Type: 2",
                                "data": 2,
                                "icon": "pi pi-cog",
                                "children": null
                            },
                            {
                                "label": "Object Instance: 1",
                                "data": 1,
                                "icon": "pi pi-cog",
                                "children": null
                            },
                            {
                                "label": "Units: no-units",
                                "data": "no-units",
                                "icon": "pi pi-cog",
                                "children": null
                            },
                            {
                                "label": "Present Value: 311.5",
                                "data": 311.5,
                                "icon": "pi pi-cog",
                                "children": null
                            }
                        ],
                        "type": "point",
                        "parentDevice": "AS-P_3057254 3057254",
                        "parentDeviceId": 3057254,
                        "showAdded": true,
                        "bacnetType": 2,
                        "bacnetInstance": 1
                    },
                    {
                        "key": "1-0-Time_01_AV_2",
                        "label": "Time_01",
                        "data": "Time_01",
                        "pointName": "Time_01_AV_2",
                        "icon": "pi writePointIcon",
                        "children": [
                            {
                                "label": "Name: Time_01",
                                "data": "Time_01",
                                "icon": "pi pi-cog",
                                "children": null
                            },
                            {
                                "label": "Object Type: 2",
                                "data": 2,
                                "icon": "pi pi-cog",
                                "children": null
                            },
                            {
                                "label": "Object Instance: 2",
                                "data": 2,
                                "icon": "pi pi-cog",
                                "children": null
                            },
                            {
                                "label": "Units: no-units",
                                "data": "no-units",
                                "icon": "pi pi-cog",
                                "children": null
                            },
                            {
                                "label": "Present Value: 10",
                                "data": 10,
                                "icon": "pi pi-cog",
                                "children": null
                            }
                        ],
                        "type": "point",
                        "parentDevice": "AS-P_3057254 3057254",
                        "parentDeviceId": 3057254,
                        "showAdded": true,
                        "bacnetType": 2,
                        "bacnetInstance": 2
                    },
                    {
                        "key": "1-0-Time_03_AV_3",
                        "label": "Time_03",
                        "data": "Time_03",
                        "pointName": "Time_03_AV_3",
                        "icon": "pi writePointIcon",
                        "children": [
                            {
                                "label": "Name: Time_03",
                                "data": "Time_03",
                                "icon": "pi pi-cog",
                                "children": null
                            },
                            {
                                "label": "Object Type: 2",
                                "data": 2,
                                "icon": "pi pi-cog",
                                "children": null
                            },
                            {
                                "label": "Object Instance: 3",
                                "data": 3,
                                "icon": "pi pi-cog",
                                "children": null
                            },
                            {
                                "label": "Units: no-units",
                                "data": "no-units",
                                "icon": "pi pi-cog",
                                "children": null
                            },
                            {
                                "label": "Present Value: 252",
                                "data": 252,
                                "icon": "pi pi-cog",
                                "children": null
                            }
                        ],
                        "type": "point",
                        "parentDevice": "AS-P_3057254 3057254",
                        "parentDeviceId": 3057254,
                        "showAdded": true,
                        "bacnetType": 2,
                        "bacnetInstance": 3
                    },
                    {
                        "key": "1-0-Time_04_AV_4",
                        "label": "Time_04",
                        "data": "Time_04",
                        "pointName": "Time_04_AV_4",
                        "icon": "pi writePointIcon",
                        "children": [
                            {
                                "label": "Name: Time_04",
                                "data": "Time_04",
                                "icon": "pi pi-cog",
                                "children": null
                            },
                            {
                                "label": "Object Type: 2",
                                "data": 2,
                                "icon": "pi pi-cog",
                                "children": null
                            },
                            {
                                "label": "Object Instance: 4",
                                "data": 4,
                                "icon": "pi pi-cog",
                                "children": null
                            },
                            {
                                "label": "Units: no-units",
                                "data": "no-units",
                                "icon": "pi pi-cog",
                                "children": null
                            },
                            {
                                "label": "Present Value: 25",
                                "data": 25,
                                "icon": "pi pi-cog",
                                "children": null
                            }
                        ],
                        "type": "point",
                        "parentDevice": "AS-P_3057254 3057254",
                        "parentDeviceId": 3057254,
                        "showAdded": true,
                        "bacnetType": 2,
                        "bacnetInstance": 4
                    },
                    {
                        "key": "1-0-Time_05_AV_5",
                        "label": "Time_05",
                        "data": "Time_05",
                        "pointName": "Time_05_AV_5",
                        "icon": "pi writePointIcon",
                        "children": [
                            {
                                "label": "Name: Time_05",
                                "data": "Time_05",
                                "icon": "pi pi-cog",
                                "children": null
                            },
                            {
                                "label": "Object Type: 2",
                                "data": 2,
                                "icon": "pi pi-cog",
                                "children": null
                            },
                            {
                                "label": "Object Instance: 5",
                                "data": 5,
                                "icon": "pi pi-cog",
                                "children": null
                            },
                            {
                                "label": "Units: no-units",
                                "data": "no-units",
                                "icon": "pi pi-cog",
                                "children": null
                            },
                            {
                                "label": "Present Value: 8",
                                "data": 8,
                                "icon": "pi pi-cog",
                                "children": null
                            }
                        ],
                        "type": "point",
                        "parentDevice": "AS-P_3057254 3057254",
                        "parentDeviceId": 3057254,
                        "showAdded": true,
                        "bacnetType": 2,
                        "bacnetInstance": 5
                    },
                    {
                        "key": "1-0-Time_02_AV_6",
                        "label": "Time_02",
                        "data": "Time_02",
                        "pointName": "Time_02_AV_6",
                        "icon": "pi writePointIcon",
                        "children": [
                            {
                                "label": "Name: Time_02",
                                "data": "Time_02",
                                "icon": "pi pi-cog",
                                "children": null
                            },
                            {
                                "label": "Object Type: 2",
                                "data": 2,
                                "icon": "pi pi-cog",
                                "children": null
                            },
                            {
                                "label": "Object Instance: 6",
                                "data": 6,
                                "icon": "pi pi-cog",
                                "children": null
                            },
                            {
                                "label": "Units: no-units",
                                "data": "no-units",
                                "icon": "pi pi-cog",
                                "children": null
                            },
                            {
                                "label": "Present Value: 0",
                                "data": 0,
                                "icon": "pi pi-cog",
                                "children": null
                            }
                        ],
                        "type": "point",
                        "parentDevice": "AS-P_3057254 3057254",
                        "parentDeviceId": 3057254,
                        "showAdded": true,
                        "bacnetType": 2,
                        "bacnetInstance": 6
                    }
                ],
                "type": "device",
                "lastSeen": 1734900585739,
                "showAdded": false,
                "ipAddr": "192.168.68.149",
                "deviceId": 3057254,
                "isMstpDevice": false,
                "initialName": "AS-P_3057254 3057254"
            }
        ],
        "hiddenDeployToggle": false,
        "prevHiddenToggleState": false,
        "x": 1010,
        "y": 160,
        "wires": [
            [
                "8495e9b47b3be0f1"
            ]
        ]
    },
    {
        "id": "31826f5c856251e0",
        "type": "debug",
        "z": "3c0393f03dbda828",
        "name": "debug 5",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 500,
        "y": 180,
        "wires": []
    },
    {
        "id": "85e1388914e4c5d9",
        "type": "switch",
        "z": "3c0393f03dbda828",
        "name": "",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "index",
                "v": "",
                "vt": "num",
                "v2": "",
                "v2t": "num"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 770,
        "y": 300,
        "wires": [
            [
                "d11de816c82f7cbb"
            ]
        ]
    }
]

Hi There,

You have a switch node that has an index between rule with no values:

Seems a little strange to me, what is it meant to do?

I only gett the last value from API (551.77)

I don't know that's why I asked:

I still don't know.

Oh, I see from your new screenshot, you've removed the switch node and you are still just getting a single value.

Is the payload that is going into the function node really an array?

var msg1 = {}
for (var i = 0; i<msg.payload.length;i++){
    msg1 = {
        topic:msg.payload[i].currency, 
        payload:msg.payload[i].price, 
        timestamp:msg.payload[i].timestamp,
    }
    node.send(msg1)
}

that's what the function node is doing and the code assumes that payload is an array if not, it's probably just sending a single value (since payload.length is one). I have no idea what the nordpool-api-plus node returns but check the payload that comes from it.

Btw using forEach might be simpler:

msg.payload.forEach( val => {
    msg1 = {
        topic:val.currency, 
        payload:val.price, 
        timestamp:val.timestamp,
    }
    node.send(msg1)
})

forEach will fail if msg.payload isn't an array.

Solution
msg.payload = msg.payload[0].price
return msg
msg.payload = msg.payload[1].price
return msg
msg.payload = msg.payload[2].price
return msg
M.M