I have an mqtt output of this type {“ts”: “2025-01-31T16:24:29Z”, “humidity”:56} and I am unable to convert it to number to make it readable in influxdb or grafana which is my ultimate goal. Any help on this?
The output comes from meraki sensors. With this topic meraki/v1/mt/L_3698581193978019842/ble/C4:8B:A3:FC:63:36/humidity
The output is a JSON , if you set the mqtt node to auto detect object, then the output would be a Javascript object. Then msg.payload.humidity would be a number. If you require the ts as a millisecond timestamp (epoch) then you can use a function node and the date() constructor and getTime() method
msg.payload.timestamp = Date(msg.payload.ts).getTime();
return msg;
You can then format your payload for influxDb
p.s. Welcome to the forum.