# MQTT to InfluxDB function problem

**URL:** https://discourse.nodered.org/t/mqtt-to-influxdb-function-problem/52582
**Category:** General
**Created:** [22 October 2021 17:21 UTC](https://discourse.nodered.org/t/mqtt-to-influxdb-function-problem/52582 "2021-10-22T17:21:44Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![siado](https://avatars.discourse-cdn.com/v4/letter/s/b19c9b/32.png) [@siado](https://discourse.nodered.org/u/siado)
#### Post date: [22 October 2021 17:21 UTC](https://discourse.nodered.org/t/mqtt-to-influxdb-function-problem/52582/1 "2021-10-22T17:21:44Z")

</div>

Greetings all. I'm working on a piece of a flow to store existing MQTT data coming into a dashboard (working) and can not get the function to work to reformat for InfluxDB. All of the existing flow works (albeit cobbled and ugly) to display data on the dash.

Complete Flow. Working change node circled in green to drive a meter. Similar syntax used of the function node (circled in red) kicks out "generator", but not "CHP".

 ![Total Flow](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/6/568a6aad443d9bf5eb6fd2a38306e8c2be169423.jpeg)

Raw JSON coming out of the MQTT node:  
 ![Raw subscribe JSON](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/e/2e9637c330103a1585612525b0184482d845dcc1.jpeg)

Change node syntax that works  
 ![Change node for meter](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/6/a6c70fa5690ef15d30bed1b8b81abc50822ebe1d.jpeg)

Function node syntax that doesn't work  
 ![Non-working function node](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/5/556b161cacc936741c58da065d6e03ed87755a4e.jpeg)

Function node error  
 ![function node error](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/6/0681b409fef1e6465e5a69172324630cda4c0239.jpeg)

I've looked through every tutorial and reference I can find and don't understand it, so any assistance appreciated.

---

<div class="post-metadata">

### Author: ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)
#### Post date: [22 October 2021 17:27 UTC](https://discourse.nodered.org/t/mqtt-to-influxdb-function-problem/52582/2 "2021-10-22T17:27:00Z")

</div>

the `-`are not allowed in JS when using `.`notation  
you will need to use the [] notation  
`msg.payload["CHP-Generator-KW"]`

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [5 November 2021 17:27 UTC](https://discourse.nodered.org/t/mqtt-to-influxdb-function-problem/52582/3 "2021-11-05T17:27:05Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
