Flow.set - One set string - One set "[object Object]"

I have a inject node injecting a string into a function node - The function node sets a flow.set to the string -- Happy days.

All of a sudden with no changes this flow now set the flow.set to "[object Object]" -- Un happy days.

Copy the nodes and past it in the same flow - the one set the flow.set to the string the other to "[object Object]" --- And yet the one is a copy of the other. -- The only reasons I copied the node were to try and establish what went wrong.

image

From the bottom flow
image

From the top flow
image

[
    {
        "id": "6ab02e2eb769cd16",
        "type": "inject",
        "z": "6151ad3d1b9f5d2b",
        "name": "",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": true,
        "onceDelay": "2",
        "topic": "",
        "payload": "soiot",
        "payloadType": "str",
        "x": 150,
        "y": 180,
        "wires": [
            [
                "360dec737c1e3dea",
                "9e59528565c07e48"
            ]
        ]
    },
    {
        "id": "360dec737c1e3dea",
        "type": "function",
        "z": "6151ad3d1b9f5d2b",
        "name": "",
        "func": "flow.set('db', msg.payload)\n\n\nmsg1 = {topic : \"CREATE TABLE IF NOT EXISTS `nodemap` ( `application` int DEFAULT NULL, `device` int DEFAULT NULL, `dlat` decimal(10,7) DEFAULT NULL, `dlon` decimal(10,7) DEFAULT NULL, `rssi` decimal(3,0) DEFAULT NULL, `snr` decimal(4,2) DEFAULT NULL, `sf` decimal(2,0) DEFAULT NULL, `frequency` decimal(9,0) DEFAULT NULL, `bandwidth` decimal(6,0) DEFAULT NULL, `airtime` decimal(7,6) DEFAULT NULL, `ttngateway` int DEFAULT NULL, `glat` decimal(10,7) DEFAULT NULL, `glon` decimal(10,7) DEFAULT NULL, `altitude` decimal(3,0) DEFAULT NULL, `time` timestamp NULL DEFAULT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;\"}\n\nmsg2 = {topic :\"CREATE TABLE IF NOT EXISTS `tapplication` (`idA` int NOT NULL AUTO_INCREMENT, `application` varchar(45) NOT NULL, PRIMARY KEY (`idA`), UNIQUE KEY `idA_UNIQUE` (`idA`), UNIQUE KEY `application_UNIQUE` (`application`)) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;\"}\n\nmsg3 = {topic :\"CREATE TABLE IF NOT EXISTS `tdevice` (`idd` int NOT NULL AUTO_INCREMENT, `device` varchar(45) NOT NULL, PRIMARY KEY (`device`), UNIQUE KEY `idd_UNIQUE` (`idd`), UNIQUE KEY `device_UNIQUE` (`device`)) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;\"}\n\nmsg4 = {topic : \"CREATE TABLE IF NOT EXISTS `ttngateway` (`idg` int NOT NULL AUTO_INCREMENT, `ttngateway` varchar(45) NOT NULL, PRIMARY KEY (`ttngateway`), UNIQUE KEY `idg_UNIQUE` (`idg`), UNIQUE KEY `ttngateway_UNIQUE` (`ttngateway`)) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;\"}\n\nreturn [msg1, msg2, msg3, msg4];",
        "outputs": 4,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 330,
        "y": 180,
        "wires": [
            [
                "b34c256cf4114036",
                "9e59528565c07e48"
            ],
            [
                "b34c256cf4114036",
                "9e59528565c07e48"
            ],
            [
                "b34c256cf4114036",
                "9e59528565c07e48"
            ],
            [
                "b34c256cf4114036",
                "9e59528565c07e48"
            ]
        ]
    },
    {
        "id": "9e59528565c07e48",
        "type": "debug",
        "z": "6151ad3d1b9f5d2b",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": "true",
        "targetType": "full",
        "statusVal": "payload",
        "statusType": "auto",
        "x": 470,
        "y": 240,
        "wires": []
    },
    {
        "id": "0e90111719f94e4b",
        "type": "inject",
        "z": "6151ad3d1b9f5d2b",
        "name": "",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": true,
        "onceDelay": "2",
        "topic": "",
        "payload": "soiot",
        "payloadType": "str",
        "x": 110,
        "y": 60,
        "wires": [
            [
                "378e037f9769a0e9",
                "207ba41389dab50f"
            ]
        ]
    },
    {
        "id": "378e037f9769a0e9",
        "type": "function",
        "z": "6151ad3d1b9f5d2b",
        "name": "",
        "func": "flow.set('db', msg.payload)\n\n\nmsg1 = {topic : \"CREATE TABLE IF NOT EXISTS `nodemap` ( `application` int DEFAULT NULL, `device` int DEFAULT NULL, `dlat` decimal(10,7) DEFAULT NULL, `dlon` decimal(10,7) DEFAULT NULL, `rssi` decimal(3,0) DEFAULT NULL, `snr` decimal(4,2) DEFAULT NULL, `sf` decimal(2,0) DEFAULT NULL, `frequency` decimal(9,0) DEFAULT NULL, `bandwidth` decimal(6,0) DEFAULT NULL, `airtime` decimal(7,6) DEFAULT NULL, `ttngateway` int DEFAULT NULL, `glat` decimal(10,7) DEFAULT NULL, `glon` decimal(10,7) DEFAULT NULL, `altitude` decimal(3,0) DEFAULT NULL, `time` timestamp NULL DEFAULT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;\"}\n\nmsg2 = {topic :\"CREATE TABLE IF NOT EXISTS `tapplication` (`idA` int NOT NULL AUTO_INCREMENT, `application` varchar(45) NOT NULL, PRIMARY KEY (`idA`), UNIQUE KEY `idA_UNIQUE` (`idA`), UNIQUE KEY `application_UNIQUE` (`application`)) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;\"}\n\nmsg3 = {topic :\"CREATE TABLE IF NOT EXISTS `tdevice` (`idd` int NOT NULL AUTO_INCREMENT, `device` varchar(45) NOT NULL, PRIMARY KEY (`device`), UNIQUE KEY `idd_UNIQUE` (`idd`), UNIQUE KEY `device_UNIQUE` (`device`)) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;\"}\n\nmsg4 = {topic : \"CREATE TABLE IF NOT EXISTS `ttngateway` (`idg` int NOT NULL AUTO_INCREMENT, `ttngateway` varchar(45) NOT NULL, PRIMARY KEY (`ttngateway`), UNIQUE KEY `idg_UNIQUE` (`idg`), UNIQUE KEY `ttngateway_UNIQUE` (`ttngateway`)) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;\"}\n\nreturn [msg1, msg2, msg3, msg4];",
        "outputs": 4,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 350,
        "y": 60,
        "wires": [
            [
                "207ba41389dab50f"
            ],
            [
                "207ba41389dab50f"
            ],
            [
                "207ba41389dab50f"
            ],
            [
                "207ba41389dab50f"
            ]
        ]
    },
    {
        "id": "207ba41389dab50f",
        "type": "debug",
        "z": "6151ad3d1b9f5d2b",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": "true",
        "targetType": "full",
        "statusVal": "payload",
        "statusType": "auto",
        "x": 490,
        "y": 120,
        "wires": []
    }
]
23 Nov 19:08:49 - [info] Node-RED version: v2.0.6
23 Nov 19:08:49 - [info] Node.js  version: v12.22.7
23 Nov 19:08:49 - [info] Linux 5.11.0-1021-aws x64 LE
23 Nov 19:08:49 - [info] Loading palette nodes
23 Nov 19:08:51 - [info] Worldmap version 2.19.0
23 Nov 19:08:51 - [info] Dashboard version 3.1.2 started at /ui

I changed the flow.set("dbc.xxx) and now it works - stores the correct value

1 Like

Looks like you got it sorted - somewhere, an object started moving through your flow where you were expecting a string.