Gibbz
24 November 2025 02:48
1
I'm trying to output the node red logs into a table for easy debuging on my phone.... The problem is str needs to be a string of json, not the type [object Object] which it keeps giving me. Ive tried converting to string multiple ways with no luck.
I have the following function:
let logs = flow.get('logs') || []
var str = msg.payload.message
// prepare the row (keep other columns as-is)
let row = [
//msg.payload.time || '',
//msg.payload.type || '',
msg.payload.source,
str,
]
// debug: this needs to print a string! but it returns an object
node.error(str)
logs.push(row)
// cap at 20 rows
if (logs.length > 20) logs.shift()
flow.set('logs', logs)
msg.payload = logs
return msg
Pass the output of your function through a JSON node
Alternatively...
Gibbz:
msg.payload = logs
msg.payload = JSON.stringify(logs)
Gibbz
24 November 2025 03:08
3
Unfortunately for both, that converts the string to "[object Object]" instead of the contents of the object.
How are you trying to display it? Are you using UIBUILDER, Dashboard 2 or Dashboard 1?
Gibbz
24 November 2025 10:03
5
I'm using dashboard 2 with a table widget. Also output node.error displays the same format.
jbudd
24 November 2025 10:20
6
Where does msg.payload.message come from? How is it constructed?
Gibbz
24 November 2025 10:32
7
I'm using a catch node to catch errors. Passing them to this function. Then this function outputs to a table node.
Catch - function - table
Cheers
jbudd
24 November 2025 10:46
8
If you connect a debug node to the catch, showing the complete message object, what does it contain?
Gibbz
24 November 2025 20:50
9
It contains the following object:
{"battery":100,"device":{"applicationVersion":147,"dateCode":"22092025","friendlyName":"Front Motion","hardwareVersion":1,"ieeeAddr":"0xa4c1386709fdfac3","manufacturerID":4742,"manufacturerName":"_TZE200_rhgsbacq","model":"ZG-204ZV","networkAddress":43435,"powerSource":"Battery","softwareBuildID":"0122092025","stackVersion":2,"type":"EndDevice","zclVersion":3},"fading_time":30,"humidity":70,"humidity_calibration":0,"illuminance":745,"illuminance_interval":1,"indicator":"OFF","linkquality":51,"motion_detection_sensitivity":2,"presence":false,"temperature":17.8,"temperature_calibration":0,"temperature_unit":"celsius"}
jbudd
24 November 2025 21:42
10
That data does not include a msg.payload, so no msg.payload.message.
Indeed, it can't be that you only shared the payload: no msg.message either
Colin
24 November 2025 22:09
11
What contains that object? Did you set the debug node to Output Complete Message as requested?
Gibbz
24 November 2025 22:42
12
argh so silly! that was it.... msg.payload instead of msg.payload.message
Thanks guys
system
Closed
8 December 2025 22:42
13
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.